babylon.d.txt 3.0 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * A class serves as a medium between the observable and its observers
  52. */
  53. export class EventState {
  54. /**
  55. * Create a new EventState
  56. * @param mask defines the mask associated with this state
  57. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  58. * @param target defines the original target of the state
  59. * @param currentTarget defines the current target of the state
  60. */
  61. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62. /**
  63. * Initialize the current event state
  64. * @param mask defines the mask associated with this state
  65. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66. * @param target defines the original target of the state
  67. * @param currentTarget defines the current target of the state
  68. * @returns the current event state
  69. */
  70. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  71. /**
  72. * An Observer can set this property to true to prevent subsequent observers of being notified
  73. */
  74. skipNextObservers: boolean;
  75. /**
  76. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77. */
  78. mask: number;
  79. /**
  80. * The object that originally notified the event
  81. */
  82. target?: any;
  83. /**
  84. * The current object in the bubbling phase
  85. */
  86. currentTarget?: any;
  87. /**
  88. * This will be populated with the return value of the last function that was executed.
  89. * If it is the first function in the callback chain it will be the event data.
  90. */
  91. lastReturnValue?: any;
  92. }
  93. /**
  94. * Represent an Observer registered to a given Observable object.
  95. */
  96. export class Observer<T> {
  97. /**
  98. * Defines the callback to call when the observer is notified
  99. */
  100. callback: (eventData: T, eventState: EventState) => void;
  101. /**
  102. * Defines the mask of the observer (used to filter notifications)
  103. */
  104. mask: number;
  105. /**
  106. * Defines the current scope used to restore the JS context
  107. */
  108. scope: any;
  109. /** @hidden */ private _willBeUnregistered: boolean;
  110. /**
  111. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  112. */
  113. unregisterOnNextCall: boolean;
  114. /**
  115. * Creates a new observer
  116. * @param callback defines the callback to call when the observer is notified
  117. * @param mask defines the mask of the observer (used to filter notifications)
  118. * @param scope defines the current scope used to restore the JS context
  119. */
  120. constructor(
  121. /**
  122. * Defines the callback to call when the observer is notified
  123. */
  124. callback: (eventData: T, eventState: EventState) => void,
  125. /**
  126. * Defines the mask of the observer (used to filter notifications)
  127. */
  128. mask: number,
  129. /**
  130. * Defines the current scope used to restore the JS context
  131. */
  132. scope?: any);
  133. }
  134. /**
  135. * Represent a list of observers registered to multiple Observables object.
  136. */
  137. export class MultiObserver<T> {
  138. private _observers;
  139. private _observables;
  140. /**
  141. * Release associated resources
  142. */
  143. dispose(): void;
  144. /**
  145. * Raise a callback when one of the observable will notify
  146. * @param observables defines a list of observables to watch
  147. * @param callback defines the callback to call on notification
  148. * @param mask defines the mask used to filter notifications
  149. * @param scope defines the current scope used to restore the JS context
  150. * @returns the new MultiObserver
  151. */
  152. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  153. }
  154. /**
  155. * The Observable class is a simple implementation of the Observable pattern.
  156. *
  157. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  158. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  159. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  160. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  161. */
  162. export class Observable<T> {
  163. private _observers;
  164. private _eventState;
  165. private _onObserverAdded;
  166. /**
  167. * Gets the list of observers
  168. */
  169. readonly observers: Array<Observer<T>>;
  170. /**
  171. * Creates a new observable
  172. * @param onObserverAdded defines a callback to call when a new observer is added
  173. */
  174. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  175. /**
  176. * Create a new Observer with the specified callback
  177. * @param callback the callback that will be executed for that Observer
  178. * @param mask the mask used to filter observers
  179. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  180. * @param scope optional scope for the callback to be called from
  181. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  182. * @returns the new observer created for the callback
  183. */
  184. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  185. /**
  186. * Create a new Observer with the specified callback and unregisters after the next notification
  187. * @param callback the callback that will be executed for that Observer
  188. * @returns the new observer created for the callback
  189. */
  190. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  191. /**
  192. * Remove an Observer from the Observable object
  193. * @param observer the instance of the Observer to remove
  194. * @returns false if it doesn't belong to this Observable
  195. */
  196. remove(observer: Nullable<Observer<T>>): boolean;
  197. /**
  198. * Remove a callback from the Observable object
  199. * @param callback the callback to remove
  200. * @param scope optional scope. If used only the callbacks with this scope will be removed
  201. * @returns false if it doesn't belong to this Observable
  202. */
  203. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  204. private _deferUnregister;
  205. private _remove;
  206. /**
  207. * Moves the observable to the top of the observer list making it get called first when notified
  208. * @param observer the observer to move
  209. */
  210. makeObserverTopPriority(observer: Observer<T>): void;
  211. /**
  212. * Moves the observable to the bottom of the observer list making it get called last when notified
  213. * @param observer the observer to move
  214. */
  215. makeObserverBottomPriority(observer: Observer<T>): void;
  216. /**
  217. * Notify all Observers by calling their respective callback with the given data
  218. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  219. * @param eventData defines the data to send to all observers
  220. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  221. * @param target defines the original target of the state
  222. * @param currentTarget defines the current target of the state
  223. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  224. */
  225. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  226. /**
  227. * Calling this will execute each callback, expecting it to be a promise or return a value.
  228. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  229. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  230. * and it is crucial that all callbacks will be executed.
  231. * The order of the callbacks is kept, callbacks are not executed parallel.
  232. *
  233. * @param eventData The data to be sent to each callback
  234. * @param mask is used to filter observers defaults to -1
  235. * @param target defines the callback target (see EventState)
  236. * @param currentTarget defines he current object in the bubbling phase
  237. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  238. */
  239. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  240. /**
  241. * Notify a specific observer
  242. * @param observer defines the observer to notify
  243. * @param eventData defines the data to be sent to each callback
  244. * @param mask is used to filter observers defaults to -1
  245. */
  246. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  247. /**
  248. * Gets a boolean indicating if the observable has at least one observer
  249. * @returns true is the Observable has at least one Observer registered
  250. */
  251. hasObservers(): boolean;
  252. /**
  253. * Clear the list of observers
  254. */
  255. clear(): void;
  256. /**
  257. * Clone the current observable
  258. * @returns a new observable
  259. */
  260. clone(): Observable<T>;
  261. /**
  262. * Does this observable handles observer registered with a given mask
  263. * @param mask defines the mask to be tested
  264. * @return whether or not one observer registered with the given mask is handeled
  265. **/
  266. hasSpecificMask(mask?: number): boolean;
  267. }
  268. }
  269. declare module BABYLON {
  270. /**
  271. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  272. * Babylon.js
  273. */
  274. export class DomManagement {
  275. /**
  276. * Checks if the window object exists
  277. * @returns true if the window object exists
  278. */
  279. static IsWindowObjectExist(): boolean;
  280. /**
  281. * Checks if the navigator object exists
  282. * @returns true if the navigator object exists
  283. */
  284. static IsNavigatorAvailable(): boolean;
  285. /**
  286. * Extracts text content from a DOM element hierarchy
  287. * @param element defines the root element
  288. * @returns a string
  289. */
  290. static GetDOMTextContent(element: HTMLElement): string;
  291. }
  292. }
  293. declare module BABYLON {
  294. /**
  295. * Logger used througouht the application to allow configuration of
  296. * the log level required for the messages.
  297. */
  298. export class Logger {
  299. /**
  300. * No log
  301. */
  302. static readonly NoneLogLevel: number;
  303. /**
  304. * Only message logs
  305. */
  306. static readonly MessageLogLevel: number;
  307. /**
  308. * Only warning logs
  309. */
  310. static readonly WarningLogLevel: number;
  311. /**
  312. * Only error logs
  313. */
  314. static readonly ErrorLogLevel: number;
  315. /**
  316. * All logs
  317. */
  318. static readonly AllLogLevel: number;
  319. private static _LogCache;
  320. /**
  321. * Gets a value indicating the number of loading errors
  322. * @ignorenaming
  323. */
  324. static errorsCount: number;
  325. /**
  326. * Callback called when a new log is added
  327. */
  328. static OnNewCacheEntry: (entry: string) => void;
  329. private static _AddLogEntry;
  330. private static _FormatMessage;
  331. private static _LogDisabled;
  332. private static _LogEnabled;
  333. private static _WarnDisabled;
  334. private static _WarnEnabled;
  335. private static _ErrorDisabled;
  336. private static _ErrorEnabled;
  337. /**
  338. * Log a message to the console
  339. */
  340. static Log: (message: string) => void;
  341. /**
  342. * Write a warning message to the console
  343. */
  344. static Warn: (message: string) => void;
  345. /**
  346. * Write an error message to the console
  347. */
  348. static Error: (message: string) => void;
  349. /**
  350. * Gets current log cache (list of logs)
  351. */
  352. static readonly LogCache: string;
  353. /**
  354. * Clears the log cache
  355. */
  356. static ClearLogCache(): void;
  357. /**
  358. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  359. */
  360. static LogLevels: number;
  361. }
  362. }
  363. declare module BABYLON {
  364. /** @hidden */
  365. export class _TypeStore {
  366. /** @hidden */
  367. static RegisteredTypes: {
  368. [key: string]: Object;
  369. };
  370. /** @hidden */
  371. static GetClass(fqdn: string): any;
  372. }
  373. }
  374. declare module BABYLON {
  375. /**
  376. * Class containing a set of static utilities functions for deep copy.
  377. */
  378. export class DeepCopier {
  379. /**
  380. * Tries to copy an object by duplicating every property
  381. * @param source defines the source object
  382. * @param destination defines the target object
  383. * @param doNotCopyList defines a list of properties to avoid
  384. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  385. */
  386. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  387. }
  388. }
  389. declare module BABYLON {
  390. /**
  391. * Class containing a set of static utilities functions for precision date
  392. */
  393. export class PrecisionDate {
  394. /**
  395. * Gets either window.performance.now() if supported or Date.now() else
  396. */
  397. static readonly Now: number;
  398. }
  399. }
  400. declare module BABYLON {
  401. /** @hidden */
  402. export class _DevTools {
  403. static WarnImport(name: string): string;
  404. }
  405. }
  406. declare module BABYLON {
  407. /**
  408. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  409. */
  410. export class WebRequest {
  411. private _xhr;
  412. /**
  413. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  414. * i.e. when loading files, where the server/service expects an Authorization header
  415. */
  416. static CustomRequestHeaders: {
  417. [key: string]: string;
  418. };
  419. /**
  420. * Add callback functions in this array to update all the requests before they get sent to the network
  421. */
  422. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  423. private _injectCustomRequestHeaders;
  424. /**
  425. * Gets or sets a function to be called when loading progress changes
  426. */
  427. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  428. /**
  429. * Returns client's state
  430. */
  431. readonly readyState: number;
  432. /**
  433. * Returns client's status
  434. */
  435. readonly status: number;
  436. /**
  437. * Returns client's status as a text
  438. */
  439. readonly statusText: string;
  440. /**
  441. * Returns client's response
  442. */
  443. readonly response: any;
  444. /**
  445. * Returns client's response url
  446. */
  447. readonly responseURL: string;
  448. /**
  449. * Returns client's response as text
  450. */
  451. readonly responseText: string;
  452. /**
  453. * Gets or sets the expected response type
  454. */
  455. responseType: XMLHttpRequestResponseType;
  456. /** @hidden */
  457. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  458. /** @hidden */
  459. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  460. /**
  461. * Cancels any network activity
  462. */
  463. abort(): void;
  464. /**
  465. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  466. * @param body defines an optional request body
  467. */
  468. send(body?: Document | BodyInit | null): void;
  469. /**
  470. * Sets the request method, request URL
  471. * @param method defines the method to use (GET, POST, etc..)
  472. * @param url defines the url to connect with
  473. */
  474. open(method: string, url: string): void;
  475. }
  476. }
  477. declare module BABYLON {
  478. /**
  479. * File request interface
  480. */
  481. export interface IFileRequest {
  482. /**
  483. * Raised when the request is complete (success or error).
  484. */
  485. onCompleteObservable: Observable<IFileRequest>;
  486. /**
  487. * Aborts the request for a file.
  488. */
  489. abort: () => void;
  490. }
  491. }
  492. declare module BABYLON {
  493. /**
  494. * Scalar computation library
  495. */
  496. export class Scalar {
  497. /**
  498. * Two pi constants convenient for computation.
  499. */
  500. static TwoPi: number;
  501. /**
  502. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  503. * @param a number
  504. * @param b number
  505. * @param epsilon (default = 1.401298E-45)
  506. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  507. */
  508. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  509. /**
  510. * Returns a string : the upper case translation of the number i to hexadecimal.
  511. * @param i number
  512. * @returns the upper case translation of the number i to hexadecimal.
  513. */
  514. static ToHex(i: number): string;
  515. /**
  516. * Returns -1 if value is negative and +1 is value is positive.
  517. * @param value the value
  518. * @returns the value itself if it's equal to zero.
  519. */
  520. static Sign(value: number): number;
  521. /**
  522. * Returns the value itself if it's between min and max.
  523. * Returns min if the value is lower than min.
  524. * Returns max if the value is greater than max.
  525. * @param value the value to clmap
  526. * @param min the min value to clamp to (default: 0)
  527. * @param max the max value to clamp to (default: 1)
  528. * @returns the clamped value
  529. */
  530. static Clamp(value: number, min?: number, max?: number): number;
  531. /**
  532. * the log2 of value.
  533. * @param value the value to compute log2 of
  534. * @returns the log2 of value.
  535. */
  536. static Log2(value: number): number;
  537. /**
  538. * Loops the value, so that it is never larger than length and never smaller than 0.
  539. *
  540. * This is similar to the modulo operator but it works with floating point numbers.
  541. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  542. * With t = 5 and length = 2.5, the result would be 0.0.
  543. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  544. * @param value the value
  545. * @param length the length
  546. * @returns the looped value
  547. */
  548. static Repeat(value: number, length: number): number;
  549. /**
  550. * Normalize the value between 0.0 and 1.0 using min and max values
  551. * @param value value to normalize
  552. * @param min max to normalize between
  553. * @param max min to normalize between
  554. * @returns the normalized value
  555. */
  556. static Normalize(value: number, min: number, max: number): number;
  557. /**
  558. * Denormalize the value from 0.0 and 1.0 using min and max values
  559. * @param normalized value to denormalize
  560. * @param min max to denormalize between
  561. * @param max min to denormalize between
  562. * @returns the denormalized value
  563. */
  564. static Denormalize(normalized: number, min: number, max: number): number;
  565. /**
  566. * Calculates the shortest difference between two given angles given in degrees.
  567. * @param current current angle in degrees
  568. * @param target target angle in degrees
  569. * @returns the delta
  570. */
  571. static DeltaAngle(current: number, target: number): number;
  572. /**
  573. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  574. * @param tx value
  575. * @param length length
  576. * @returns The returned value will move back and forth between 0 and length
  577. */
  578. static PingPong(tx: number, length: number): number;
  579. /**
  580. * Interpolates between min and max with smoothing at the limits.
  581. *
  582. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  583. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  584. * @param from from
  585. * @param to to
  586. * @param tx value
  587. * @returns the smooth stepped value
  588. */
  589. static SmoothStep(from: number, to: number, tx: number): number;
  590. /**
  591. * Moves a value current towards target.
  592. *
  593. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  594. * Negative values of maxDelta pushes the value away from target.
  595. * @param current current value
  596. * @param target target value
  597. * @param maxDelta max distance to move
  598. * @returns resulting value
  599. */
  600. static MoveTowards(current: number, target: number, maxDelta: number): number;
  601. /**
  602. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  603. *
  604. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  605. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  606. * @param current current value
  607. * @param target target value
  608. * @param maxDelta max distance to move
  609. * @returns resulting angle
  610. */
  611. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  612. /**
  613. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  614. * @param start start value
  615. * @param end target value
  616. * @param amount amount to lerp between
  617. * @returns the lerped value
  618. */
  619. static Lerp(start: number, end: number, amount: number): number;
  620. /**
  621. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  622. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  623. * @param start start value
  624. * @param end target value
  625. * @param amount amount to lerp between
  626. * @returns the lerped value
  627. */
  628. static LerpAngle(start: number, end: number, amount: number): number;
  629. /**
  630. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  631. * @param a start value
  632. * @param b target value
  633. * @param value value between a and b
  634. * @returns the inverseLerp value
  635. */
  636. static InverseLerp(a: number, b: number, value: number): number;
  637. /**
  638. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  639. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  640. * @param value1 spline value
  641. * @param tangent1 spline value
  642. * @param value2 spline value
  643. * @param tangent2 spline value
  644. * @param amount input value
  645. * @returns hermite result
  646. */
  647. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  648. /**
  649. * Returns a random float number between and min and max values
  650. * @param min min value of random
  651. * @param max max value of random
  652. * @returns random value
  653. */
  654. static RandomRange(min: number, max: number): number;
  655. /**
  656. * This function returns percentage of a number in a given range.
  657. *
  658. * RangeToPercent(40,20,60) will return 0.5 (50%)
  659. * RangeToPercent(34,0,100) will return 0.34 (34%)
  660. * @param number to convert to percentage
  661. * @param min min range
  662. * @param max max range
  663. * @returns the percentage
  664. */
  665. static RangeToPercent(number: number, min: number, max: number): number;
  666. /**
  667. * This function returns number that corresponds to the percentage in a given range.
  668. *
  669. * PercentToRange(0.34,0,100) will return 34.
  670. * @param percent to convert to number
  671. * @param min min range
  672. * @param max max range
  673. * @returns the number
  674. */
  675. static PercentToRange(percent: number, min: number, max: number): number;
  676. /**
  677. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  678. * @param angle The angle to normalize in radian.
  679. * @return The converted angle.
  680. */
  681. static NormalizeRadians(angle: number): number;
  682. }
  683. }
  684. declare module BABYLON {
  685. /**
  686. * Constant used to convert a value to gamma space
  687. * @ignorenaming
  688. */
  689. export const ToGammaSpace: number;
  690. /**
  691. * Constant used to convert a value to linear space
  692. * @ignorenaming
  693. */
  694. export const ToLinearSpace = 2.2;
  695. /**
  696. * Constant used to define the minimal number value in Babylon.js
  697. * @ignorenaming
  698. */
  699. let Epsilon: number;
  700. }
  701. declare module BABYLON {
  702. /**
  703. * Class used to represent a viewport on screen
  704. */
  705. export class Viewport {
  706. /** viewport left coordinate */
  707. x: number;
  708. /** viewport top coordinate */
  709. y: number;
  710. /**viewport width */
  711. width: number;
  712. /** viewport height */
  713. height: number;
  714. /**
  715. * Creates a Viewport object located at (x, y) and sized (width, height)
  716. * @param x defines viewport left coordinate
  717. * @param y defines viewport top coordinate
  718. * @param width defines the viewport width
  719. * @param height defines the viewport height
  720. */
  721. constructor(
  722. /** viewport left coordinate */
  723. x: number,
  724. /** viewport top coordinate */
  725. y: number,
  726. /**viewport width */
  727. width: number,
  728. /** viewport height */
  729. height: number);
  730. /**
  731. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  732. * @param renderWidth defines the rendering width
  733. * @param renderHeight defines the rendering height
  734. * @returns a new Viewport
  735. */
  736. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  737. /**
  738. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  739. * @param renderWidth defines the rendering width
  740. * @param renderHeight defines the rendering height
  741. * @param ref defines the target viewport
  742. * @returns the current viewport
  743. */
  744. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  745. /**
  746. * Returns a new Viewport copied from the current one
  747. * @returns a new Viewport
  748. */
  749. clone(): Viewport;
  750. }
  751. }
  752. declare module BABYLON {
  753. /**
  754. * Class containing a set of static utilities functions for arrays.
  755. */
  756. export class ArrayTools {
  757. /**
  758. * Returns an array of the given size filled with element built from the given constructor and the paramters
  759. * @param size the number of element to construct and put in the array
  760. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  761. * @returns a new array filled with new objects
  762. */
  763. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  764. }
  765. }
  766. declare module BABYLON {
  767. /**
  768. * @hidden
  769. */
  770. export interface IColor4Like {
  771. r: float;
  772. g: float;
  773. b: float;
  774. a: float;
  775. }
  776. /**
  777. * @hidden
  778. */
  779. export interface IColor3Like {
  780. r: float;
  781. g: float;
  782. b: float;
  783. }
  784. /**
  785. * @hidden
  786. */
  787. export interface IVector4Like {
  788. x: float;
  789. y: float;
  790. z: float;
  791. w: float;
  792. }
  793. /**
  794. * @hidden
  795. */
  796. export interface IVector3Like {
  797. x: float;
  798. y: float;
  799. z: float;
  800. }
  801. /**
  802. * @hidden
  803. */
  804. export interface IVector2Like {
  805. x: float;
  806. y: float;
  807. }
  808. /**
  809. * @hidden
  810. */
  811. export interface IMatrixLike {
  812. toArray(): DeepImmutable<Float32Array>;
  813. updateFlag: int;
  814. }
  815. /**
  816. * @hidden
  817. */
  818. export interface IViewportLike {
  819. x: float;
  820. y: float;
  821. width: float;
  822. height: float;
  823. }
  824. /**
  825. * @hidden
  826. */
  827. export interface IPlaneLike {
  828. normal: IVector3Like;
  829. d: float;
  830. normalize(): void;
  831. }
  832. }
  833. declare module BABYLON {
  834. /**
  835. * Class representing a vector containing 2 coordinates
  836. */
  837. export class Vector2 {
  838. /** defines the first coordinate */
  839. x: number;
  840. /** defines the second coordinate */
  841. y: number;
  842. /**
  843. * Creates a new Vector2 from the given x and y coordinates
  844. * @param x defines the first coordinate
  845. * @param y defines the second coordinate
  846. */
  847. constructor(
  848. /** defines the first coordinate */
  849. x?: number,
  850. /** defines the second coordinate */
  851. y?: number);
  852. /**
  853. * Gets a string with the Vector2 coordinates
  854. * @returns a string with the Vector2 coordinates
  855. */
  856. toString(): string;
  857. /**
  858. * Gets class name
  859. * @returns the string "Vector2"
  860. */
  861. getClassName(): string;
  862. /**
  863. * Gets current vector hash code
  864. * @returns the Vector2 hash code as a number
  865. */
  866. getHashCode(): number;
  867. /**
  868. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  869. * @param array defines the source array
  870. * @param index defines the offset in source array
  871. * @returns the current Vector2
  872. */
  873. toArray(array: FloatArray, index?: number): Vector2;
  874. /**
  875. * Copy the current vector to an array
  876. * @returns a new array with 2 elements: the Vector2 coordinates.
  877. */
  878. asArray(): number[];
  879. /**
  880. * Sets the Vector2 coordinates with the given Vector2 coordinates
  881. * @param source defines the source Vector2
  882. * @returns the current updated Vector2
  883. */
  884. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  885. /**
  886. * Sets the Vector2 coordinates with the given floats
  887. * @param x defines the first coordinate
  888. * @param y defines the second coordinate
  889. * @returns the current updated Vector2
  890. */
  891. copyFromFloats(x: number, y: number): Vector2;
  892. /**
  893. * Sets the Vector2 coordinates with the given floats
  894. * @param x defines the first coordinate
  895. * @param y defines the second coordinate
  896. * @returns the current updated Vector2
  897. */
  898. set(x: number, y: number): Vector2;
  899. /**
  900. * Add another vector with the current one
  901. * @param otherVector defines the other vector
  902. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  903. */
  904. add(otherVector: DeepImmutable<Vector2>): Vector2;
  905. /**
  906. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  907. * @param otherVector defines the other vector
  908. * @param result defines the target vector
  909. * @returns the unmodified current Vector2
  910. */
  911. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  912. /**
  913. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  914. * @param otherVector defines the other vector
  915. * @returns the current updated Vector2
  916. */
  917. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  918. /**
  919. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  920. * @param otherVector defines the other vector
  921. * @returns a new Vector2
  922. */
  923. addVector3(otherVector: Vector3): Vector2;
  924. /**
  925. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  926. * @param otherVector defines the other vector
  927. * @returns a new Vector2
  928. */
  929. subtract(otherVector: Vector2): Vector2;
  930. /**
  931. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  932. * @param otherVector defines the other vector
  933. * @param result defines the target vector
  934. * @returns the unmodified current Vector2
  935. */
  936. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  937. /**
  938. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  939. * @param otherVector defines the other vector
  940. * @returns the current updated Vector2
  941. */
  942. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  943. /**
  944. * Multiplies in place the current Vector2 coordinates by the given ones
  945. * @param otherVector defines the other vector
  946. * @returns the current updated Vector2
  947. */
  948. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  949. /**
  950. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  951. * @param otherVector defines the other vector
  952. * @returns a new Vector2
  953. */
  954. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  955. /**
  956. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  957. * @param otherVector defines the other vector
  958. * @param result defines the target vector
  959. * @returns the unmodified current Vector2
  960. */
  961. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  962. /**
  963. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  964. * @param x defines the first coordinate
  965. * @param y defines the second coordinate
  966. * @returns a new Vector2
  967. */
  968. multiplyByFloats(x: number, y: number): Vector2;
  969. /**
  970. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  971. * @param otherVector defines the other vector
  972. * @returns a new Vector2
  973. */
  974. divide(otherVector: Vector2): Vector2;
  975. /**
  976. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  977. * @param otherVector defines the other vector
  978. * @param result defines the target vector
  979. * @returns the unmodified current Vector2
  980. */
  981. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  982. /**
  983. * Divides the current Vector2 coordinates by the given ones
  984. * @param otherVector defines the other vector
  985. * @returns the current updated Vector2
  986. */
  987. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  988. /**
  989. * Gets a new Vector2 with current Vector2 negated coordinates
  990. * @returns a new Vector2
  991. */
  992. negate(): Vector2;
  993. /**
  994. * Multiply the Vector2 coordinates by scale
  995. * @param scale defines the scaling factor
  996. * @returns the current updated Vector2
  997. */
  998. scaleInPlace(scale: number): Vector2;
  999. /**
  1000. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1001. * @param scale defines the scaling factor
  1002. * @returns a new Vector2
  1003. */
  1004. scale(scale: number): Vector2;
  1005. /**
  1006. * Scale the current Vector2 values by a factor to a given Vector2
  1007. * @param scale defines the scale factor
  1008. * @param result defines the Vector2 object where to store the result
  1009. * @returns the unmodified current Vector2
  1010. */
  1011. scaleToRef(scale: number, result: Vector2): Vector2;
  1012. /**
  1013. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1014. * @param scale defines the scale factor
  1015. * @param result defines the Vector2 object where to store the result
  1016. * @returns the unmodified current Vector2
  1017. */
  1018. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1019. /**
  1020. * Gets a boolean if two vectors are equals
  1021. * @param otherVector defines the other vector
  1022. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1023. */
  1024. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1025. /**
  1026. * Gets a boolean if two vectors are equals (using an epsilon value)
  1027. * @param otherVector defines the other vector
  1028. * @param epsilon defines the minimal distance to consider equality
  1029. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1030. */
  1031. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1032. /**
  1033. * Gets a new Vector2 from current Vector2 floored values
  1034. * @returns a new Vector2
  1035. */
  1036. floor(): Vector2;
  1037. /**
  1038. * Gets a new Vector2 from current Vector2 floored values
  1039. * @returns a new Vector2
  1040. */
  1041. fract(): Vector2;
  1042. /**
  1043. * Gets the length of the vector
  1044. * @returns the vector length (float)
  1045. */
  1046. length(): number;
  1047. /**
  1048. * Gets the vector squared length
  1049. * @returns the vector squared length (float)
  1050. */
  1051. lengthSquared(): number;
  1052. /**
  1053. * Normalize the vector
  1054. * @returns the current updated Vector2
  1055. */
  1056. normalize(): Vector2;
  1057. /**
  1058. * Gets a new Vector2 copied from the Vector2
  1059. * @returns a new Vector2
  1060. */
  1061. clone(): Vector2;
  1062. /**
  1063. * Gets a new Vector2(0, 0)
  1064. * @returns a new Vector2
  1065. */
  1066. static Zero(): Vector2;
  1067. /**
  1068. * Gets a new Vector2(1, 1)
  1069. * @returns a new Vector2
  1070. */
  1071. static One(): Vector2;
  1072. /**
  1073. * Gets a new Vector2 set from the given index element of the given array
  1074. * @param array defines the data source
  1075. * @param offset defines the offset in the data source
  1076. * @returns a new Vector2
  1077. */
  1078. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1079. /**
  1080. * Sets "result" from the given index element of the given array
  1081. * @param array defines the data source
  1082. * @param offset defines the offset in the data source
  1083. * @param result defines the target vector
  1084. */
  1085. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1086. /**
  1087. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1088. * @param value1 defines 1st point of control
  1089. * @param value2 defines 2nd point of control
  1090. * @param value3 defines 3rd point of control
  1091. * @param value4 defines 4th point of control
  1092. * @param amount defines the interpolation factor
  1093. * @returns a new Vector2
  1094. */
  1095. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1096. /**
  1097. * 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".
  1098. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1099. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1100. * @param value defines the value to clamp
  1101. * @param min defines the lower limit
  1102. * @param max defines the upper limit
  1103. * @returns a new Vector2
  1104. */
  1105. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1106. /**
  1107. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1108. * @param value1 defines the 1st control point
  1109. * @param tangent1 defines the outgoing tangent
  1110. * @param value2 defines the 2nd control point
  1111. * @param tangent2 defines the incoming tangent
  1112. * @param amount defines the interpolation factor
  1113. * @returns a new Vector2
  1114. */
  1115. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1116. /**
  1117. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1118. * @param start defines the start vector
  1119. * @param end defines the end vector
  1120. * @param amount defines the interpolation factor
  1121. * @returns a new Vector2
  1122. */
  1123. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1124. /**
  1125. * Gets the dot product of the vector "left" and the vector "right"
  1126. * @param left defines first vector
  1127. * @param right defines second vector
  1128. * @returns the dot product (float)
  1129. */
  1130. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1131. /**
  1132. * Returns a new Vector2 equal to the normalized given vector
  1133. * @param vector defines the vector to normalize
  1134. * @returns a new Vector2
  1135. */
  1136. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1137. /**
  1138. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1139. * @param left defines 1st vector
  1140. * @param right defines 2nd vector
  1141. * @returns a new Vector2
  1142. */
  1143. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1144. /**
  1145. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1146. * @param left defines 1st vector
  1147. * @param right defines 2nd vector
  1148. * @returns a new Vector2
  1149. */
  1150. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1151. /**
  1152. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1153. * @param vector defines the vector to transform
  1154. * @param transformation defines the matrix to apply
  1155. * @returns a new Vector2
  1156. */
  1157. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1158. /**
  1159. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1160. * @param vector defines the vector to transform
  1161. * @param transformation defines the matrix to apply
  1162. * @param result defines the target vector
  1163. */
  1164. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1165. /**
  1166. * Determines if a given vector is included in a triangle
  1167. * @param p defines the vector to test
  1168. * @param p0 defines 1st triangle point
  1169. * @param p1 defines 2nd triangle point
  1170. * @param p2 defines 3rd triangle point
  1171. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1172. */
  1173. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1174. /**
  1175. * Gets the distance between the vectors "value1" and "value2"
  1176. * @param value1 defines first vector
  1177. * @param value2 defines second vector
  1178. * @returns the distance between vectors
  1179. */
  1180. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1181. /**
  1182. * Returns the squared distance between the vectors "value1" and "value2"
  1183. * @param value1 defines first vector
  1184. * @param value2 defines second vector
  1185. * @returns the squared distance between vectors
  1186. */
  1187. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1188. /**
  1189. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1190. * @param value1 defines first vector
  1191. * @param value2 defines second vector
  1192. * @returns a new Vector2
  1193. */
  1194. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1195. /**
  1196. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1197. * @param p defines the middle point
  1198. * @param segA defines one point of the segment
  1199. * @param segB defines the other point of the segment
  1200. * @returns the shortest distance
  1201. */
  1202. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1203. }
  1204. /**
  1205. * Classed used to store (x,y,z) vector representation
  1206. * A Vector3 is the main object used in 3D geometry
  1207. * It can represent etiher the coordinates of a point the space, either a direction
  1208. * Reminder: js uses a left handed forward facing system
  1209. */
  1210. export class Vector3 {
  1211. /**
  1212. * Defines the first coordinates (on X axis)
  1213. */
  1214. x: number;
  1215. /**
  1216. * Defines the second coordinates (on Y axis)
  1217. */
  1218. y: number;
  1219. /**
  1220. * Defines the third coordinates (on Z axis)
  1221. */
  1222. z: number;
  1223. private static _UpReadOnly;
  1224. private static _ZeroReadOnly;
  1225. /**
  1226. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1227. * @param x defines the first coordinates (on X axis)
  1228. * @param y defines the second coordinates (on Y axis)
  1229. * @param z defines the third coordinates (on Z axis)
  1230. */
  1231. constructor(
  1232. /**
  1233. * Defines the first coordinates (on X axis)
  1234. */
  1235. x?: number,
  1236. /**
  1237. * Defines the second coordinates (on Y axis)
  1238. */
  1239. y?: number,
  1240. /**
  1241. * Defines the third coordinates (on Z axis)
  1242. */
  1243. z?: number);
  1244. /**
  1245. * Creates a string representation of the Vector3
  1246. * @returns a string with the Vector3 coordinates.
  1247. */
  1248. toString(): string;
  1249. /**
  1250. * Gets the class name
  1251. * @returns the string "Vector3"
  1252. */
  1253. getClassName(): string;
  1254. /**
  1255. * Creates the Vector3 hash code
  1256. * @returns a number which tends to be unique between Vector3 instances
  1257. */
  1258. getHashCode(): number;
  1259. /**
  1260. * Creates an array containing three elements : the coordinates of the Vector3
  1261. * @returns a new array of numbers
  1262. */
  1263. asArray(): number[];
  1264. /**
  1265. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1266. * @param array defines the destination array
  1267. * @param index defines the offset in the destination array
  1268. * @returns the current Vector3
  1269. */
  1270. toArray(array: FloatArray, index?: number): Vector3;
  1271. /**
  1272. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1273. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1274. */
  1275. toQuaternion(): Quaternion;
  1276. /**
  1277. * Adds the given vector to the current Vector3
  1278. * @param otherVector defines the second operand
  1279. * @returns the current updated Vector3
  1280. */
  1281. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1282. /**
  1283. * Adds the given coordinates to the current Vector3
  1284. * @param x defines the x coordinate of the operand
  1285. * @param y defines the y coordinate of the operand
  1286. * @param z defines the z coordinate of the operand
  1287. * @returns the current updated Vector3
  1288. */
  1289. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1290. /**
  1291. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1292. * @param otherVector defines the second operand
  1293. * @returns the resulting Vector3
  1294. */
  1295. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1296. /**
  1297. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1298. * @param otherVector defines the second operand
  1299. * @param result defines the Vector3 object where to store the result
  1300. * @returns the current Vector3
  1301. */
  1302. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1303. /**
  1304. * Subtract the given vector from the current Vector3
  1305. * @param otherVector defines the second operand
  1306. * @returns the current updated Vector3
  1307. */
  1308. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1309. /**
  1310. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1311. * @param otherVector defines the second operand
  1312. * @returns the resulting Vector3
  1313. */
  1314. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1315. /**
  1316. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1317. * @param otherVector defines the second operand
  1318. * @param result defines the Vector3 object where to store the result
  1319. * @returns the current Vector3
  1320. */
  1321. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1322. /**
  1323. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1324. * @param x defines the x coordinate of the operand
  1325. * @param y defines the y coordinate of the operand
  1326. * @param z defines the z coordinate of the operand
  1327. * @returns the resulting Vector3
  1328. */
  1329. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1330. /**
  1331. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1332. * @param x defines the x coordinate of the operand
  1333. * @param y defines the y coordinate of the operand
  1334. * @param z defines the z coordinate of the operand
  1335. * @param result defines the Vector3 object where to store the result
  1336. * @returns the current Vector3
  1337. */
  1338. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1339. /**
  1340. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1341. * @returns a new Vector3
  1342. */
  1343. negate(): Vector3;
  1344. /**
  1345. * Multiplies the Vector3 coordinates by the float "scale"
  1346. * @param scale defines the multiplier factor
  1347. * @returns the current updated Vector3
  1348. */
  1349. scaleInPlace(scale: number): Vector3;
  1350. /**
  1351. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1352. * @param scale defines the multiplier factor
  1353. * @returns a new Vector3
  1354. */
  1355. scale(scale: number): Vector3;
  1356. /**
  1357. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1358. * @param scale defines the multiplier factor
  1359. * @param result defines the Vector3 object where to store the result
  1360. * @returns the current Vector3
  1361. */
  1362. scaleToRef(scale: number, result: Vector3): Vector3;
  1363. /**
  1364. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1365. * @param scale defines the scale factor
  1366. * @param result defines the Vector3 object where to store the result
  1367. * @returns the unmodified current Vector3
  1368. */
  1369. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1370. /**
  1371. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1372. * @param otherVector defines the second operand
  1373. * @returns true if both vectors are equals
  1374. */
  1375. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1376. /**
  1377. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1378. * @param otherVector defines the second operand
  1379. * @param epsilon defines the minimal distance to define values as equals
  1380. * @returns true if both vectors are distant less than epsilon
  1381. */
  1382. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1383. /**
  1384. * Returns true if the current Vector3 coordinates equals the given floats
  1385. * @param x defines the x coordinate of the operand
  1386. * @param y defines the y coordinate of the operand
  1387. * @param z defines the z coordinate of the operand
  1388. * @returns true if both vectors are equals
  1389. */
  1390. equalsToFloats(x: number, y: number, z: number): boolean;
  1391. /**
  1392. * Multiplies the current Vector3 coordinates by the given ones
  1393. * @param otherVector defines the second operand
  1394. * @returns the current updated Vector3
  1395. */
  1396. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1397. /**
  1398. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1399. * @param otherVector defines the second operand
  1400. * @returns the new Vector3
  1401. */
  1402. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1403. /**
  1404. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1405. * @param otherVector defines the second operand
  1406. * @param result defines the Vector3 object where to store the result
  1407. * @returns the current Vector3
  1408. */
  1409. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1410. /**
  1411. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1412. * @param x defines the x coordinate of the operand
  1413. * @param y defines the y coordinate of the operand
  1414. * @param z defines the z coordinate of the operand
  1415. * @returns the new Vector3
  1416. */
  1417. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1418. /**
  1419. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1420. * @param otherVector defines the second operand
  1421. * @returns the new Vector3
  1422. */
  1423. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1424. /**
  1425. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1426. * @param otherVector defines the second operand
  1427. * @param result defines the Vector3 object where to store the result
  1428. * @returns the current Vector3
  1429. */
  1430. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1431. /**
  1432. * Divides the current Vector3 coordinates by the given ones.
  1433. * @param otherVector defines the second operand
  1434. * @returns the current updated Vector3
  1435. */
  1436. divideInPlace(otherVector: Vector3): Vector3;
  1437. /**
  1438. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1439. * @param other defines the second operand
  1440. * @returns the current updated Vector3
  1441. */
  1442. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1443. /**
  1444. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1445. * @param other defines the second operand
  1446. * @returns the current updated Vector3
  1447. */
  1448. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1449. /**
  1450. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1451. * @param x defines the x coordinate of the operand
  1452. * @param y defines the y coordinate of the operand
  1453. * @param z defines the z coordinate of the operand
  1454. * @returns the current updated Vector3
  1455. */
  1456. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1457. /**
  1458. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1459. * @param x defines the x coordinate of the operand
  1460. * @param y defines the y coordinate of the operand
  1461. * @param z defines the z coordinate of the operand
  1462. * @returns the current updated Vector3
  1463. */
  1464. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1465. /**
  1466. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1467. * Check if is non uniform within a certain amount of decimal places to account for this
  1468. * @param epsilon the amount the values can differ
  1469. * @returns if the the vector is non uniform to a certain number of decimal places
  1470. */
  1471. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1472. /**
  1473. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1474. */
  1475. readonly isNonUniform: boolean;
  1476. /**
  1477. * Gets a new Vector3 from current Vector3 floored values
  1478. * @returns a new Vector3
  1479. */
  1480. floor(): Vector3;
  1481. /**
  1482. * Gets a new Vector3 from current Vector3 floored values
  1483. * @returns a new Vector3
  1484. */
  1485. fract(): Vector3;
  1486. /**
  1487. * Gets the length of the Vector3
  1488. * @returns the length of the Vector3
  1489. */
  1490. length(): number;
  1491. /**
  1492. * Gets the squared length of the Vector3
  1493. * @returns squared length of the Vector3
  1494. */
  1495. lengthSquared(): number;
  1496. /**
  1497. * Normalize the current Vector3.
  1498. * Please note that this is an in place operation.
  1499. * @returns the current updated Vector3
  1500. */
  1501. normalize(): Vector3;
  1502. /**
  1503. * Reorders the x y z properties of the vector in place
  1504. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1505. * @returns the current updated vector
  1506. */
  1507. reorderInPlace(order: string): this;
  1508. /**
  1509. * Rotates the vector around 0,0,0 by a quaternion
  1510. * @param quaternion the rotation quaternion
  1511. * @param result vector to store the result
  1512. * @returns the resulting vector
  1513. */
  1514. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1515. /**
  1516. * Rotates a vector around a given point
  1517. * @param quaternion the rotation quaternion
  1518. * @param point the point to rotate around
  1519. * @param result vector to store the result
  1520. * @returns the resulting vector
  1521. */
  1522. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1523. /**
  1524. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  1525. * The cross product is then orthogonal to both current and "other"
  1526. * @param other defines the right operand
  1527. * @returns the cross product
  1528. */
  1529. cross(other: Vector3): Vector3;
  1530. /**
  1531. * Normalize the current Vector3 with the given input length.
  1532. * Please note that this is an in place operation.
  1533. * @param len the length of the vector
  1534. * @returns the current updated Vector3
  1535. */
  1536. normalizeFromLength(len: number): Vector3;
  1537. /**
  1538. * Normalize the current Vector3 to a new vector
  1539. * @returns the new Vector3
  1540. */
  1541. normalizeToNew(): Vector3;
  1542. /**
  1543. * Normalize the current Vector3 to the reference
  1544. * @param reference define the Vector3 to update
  1545. * @returns the updated Vector3
  1546. */
  1547. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1548. /**
  1549. * Creates a new Vector3 copied from the current Vector3
  1550. * @returns the new Vector3
  1551. */
  1552. clone(): Vector3;
  1553. /**
  1554. * Copies the given vector coordinates to the current Vector3 ones
  1555. * @param source defines the source Vector3
  1556. * @returns the current updated Vector3
  1557. */
  1558. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1559. /**
  1560. * Copies the given floats to the current Vector3 coordinates
  1561. * @param x defines the x coordinate of the operand
  1562. * @param y defines the y coordinate of the operand
  1563. * @param z defines the z coordinate of the operand
  1564. * @returns the current updated Vector3
  1565. */
  1566. copyFromFloats(x: number, y: number, z: number): Vector3;
  1567. /**
  1568. * Copies the given floats to the current Vector3 coordinates
  1569. * @param x defines the x coordinate of the operand
  1570. * @param y defines the y coordinate of the operand
  1571. * @param z defines the z coordinate of the operand
  1572. * @returns the current updated Vector3
  1573. */
  1574. set(x: number, y: number, z: number): Vector3;
  1575. /**
  1576. * Copies the given float to the current Vector3 coordinates
  1577. * @param v defines the x, y and z coordinates of the operand
  1578. * @returns the current updated Vector3
  1579. */
  1580. setAll(v: number): Vector3;
  1581. /**
  1582. * Get the clip factor between two vectors
  1583. * @param vector0 defines the first operand
  1584. * @param vector1 defines the second operand
  1585. * @param axis defines the axis to use
  1586. * @param size defines the size along the axis
  1587. * @returns the clip factor
  1588. */
  1589. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1590. /**
  1591. * Get angle between two vectors
  1592. * @param vector0 angle between vector0 and vector1
  1593. * @param vector1 angle between vector0 and vector1
  1594. * @param normal direction of the normal
  1595. * @return the angle between vector0 and vector1
  1596. */
  1597. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1598. /**
  1599. * Returns a new Vector3 set from the index "offset" of the given array
  1600. * @param array defines the source array
  1601. * @param offset defines the offset in the source array
  1602. * @returns the new Vector3
  1603. */
  1604. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1605. /**
  1606. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1607. * This function is deprecated. Use FromArray instead
  1608. * @param array defines the source array
  1609. * @param offset defines the offset in the source array
  1610. * @returns the new Vector3
  1611. */
  1612. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1613. /**
  1614. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1615. * @param array defines the source array
  1616. * @param offset defines the offset in the source array
  1617. * @param result defines the Vector3 where to store the result
  1618. */
  1619. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1620. /**
  1621. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1622. * This function is deprecated. Use FromArrayToRef instead.
  1623. * @param array defines the source array
  1624. * @param offset defines the offset in the source array
  1625. * @param result defines the Vector3 where to store the result
  1626. */
  1627. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1628. /**
  1629. * Sets the given vector "result" with the given floats.
  1630. * @param x defines the x coordinate of the source
  1631. * @param y defines the y coordinate of the source
  1632. * @param z defines the z coordinate of the source
  1633. * @param result defines the Vector3 where to store the result
  1634. */
  1635. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1636. /**
  1637. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1638. * @returns a new empty Vector3
  1639. */
  1640. static Zero(): Vector3;
  1641. /**
  1642. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1643. * @returns a new unit Vector3
  1644. */
  1645. static One(): Vector3;
  1646. /**
  1647. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1648. * @returns a new up Vector3
  1649. */
  1650. static Up(): Vector3;
  1651. /**
  1652. * Gets a up Vector3 that must not be updated
  1653. */
  1654. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1655. /**
  1656. * Gets a zero Vector3 that must not be updated
  1657. */
  1658. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1659. /**
  1660. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1661. * @returns a new down Vector3
  1662. */
  1663. static Down(): Vector3;
  1664. /**
  1665. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1666. * @returns a new forward Vector3
  1667. */
  1668. static Forward(): Vector3;
  1669. /**
  1670. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1671. * @returns a new forward Vector3
  1672. */
  1673. static Backward(): Vector3;
  1674. /**
  1675. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1676. * @returns a new right Vector3
  1677. */
  1678. static Right(): Vector3;
  1679. /**
  1680. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1681. * @returns a new left Vector3
  1682. */
  1683. static Left(): Vector3;
  1684. /**
  1685. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1686. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1687. * @param vector defines the Vector3 to transform
  1688. * @param transformation defines the transformation matrix
  1689. * @returns the transformed Vector3
  1690. */
  1691. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1692. /**
  1693. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1694. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1695. * @param vector defines the Vector3 to transform
  1696. * @param transformation defines the transformation matrix
  1697. * @param result defines the Vector3 where to store the result
  1698. */
  1699. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1700. /**
  1701. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1702. * This method computes tranformed coordinates only, not transformed direction vectors
  1703. * @param x define the x coordinate of the source vector
  1704. * @param y define the y coordinate of the source vector
  1705. * @param z define the z coordinate of the source vector
  1706. * @param transformation defines the transformation matrix
  1707. * @param result defines the Vector3 where to store the result
  1708. */
  1709. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1710. /**
  1711. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1712. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1713. * @param vector defines the Vector3 to transform
  1714. * @param transformation defines the transformation matrix
  1715. * @returns the new Vector3
  1716. */
  1717. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1718. /**
  1719. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1720. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1721. * @param vector defines the Vector3 to transform
  1722. * @param transformation defines the transformation matrix
  1723. * @param result defines the Vector3 where to store the result
  1724. */
  1725. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1726. /**
  1727. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1728. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1729. * @param x define the x coordinate of the source vector
  1730. * @param y define the y coordinate of the source vector
  1731. * @param z define the z coordinate of the source vector
  1732. * @param transformation defines the transformation matrix
  1733. * @param result defines the Vector3 where to store the result
  1734. */
  1735. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1736. /**
  1737. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1738. * @param value1 defines the first control point
  1739. * @param value2 defines the second control point
  1740. * @param value3 defines the third control point
  1741. * @param value4 defines the fourth control point
  1742. * @param amount defines the amount on the spline to use
  1743. * @returns the new Vector3
  1744. */
  1745. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1746. /**
  1747. * 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"
  1748. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1749. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1750. * @param value defines the current value
  1751. * @param min defines the lower range value
  1752. * @param max defines the upper range value
  1753. * @returns the new Vector3
  1754. */
  1755. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1756. /**
  1757. * 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"
  1758. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1759. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1760. * @param value defines the current value
  1761. * @param min defines the lower range value
  1762. * @param max defines the upper range value
  1763. * @param result defines the Vector3 where to store the result
  1764. */
  1765. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1766. /**
  1767. * Checks if a given vector is inside a specific range
  1768. * @param v defines the vector to test
  1769. * @param min defines the minimum range
  1770. * @param max defines the maximum range
  1771. */
  1772. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  1773. /**
  1774. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1775. * @param value1 defines the first control point
  1776. * @param tangent1 defines the first tangent vector
  1777. * @param value2 defines the second control point
  1778. * @param tangent2 defines the second tangent vector
  1779. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1780. * @returns the new Vector3
  1781. */
  1782. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1783. /**
  1784. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1785. * @param start defines the start value
  1786. * @param end defines the end value
  1787. * @param amount max defines amount between both (between 0 and 1)
  1788. * @returns the new Vector3
  1789. */
  1790. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1793. * @param start defines the start value
  1794. * @param end defines the end value
  1795. * @param amount max defines amount between both (between 0 and 1)
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1799. /**
  1800. * Returns the dot product (float) between the vectors "left" and "right"
  1801. * @param left defines the left operand
  1802. * @param right defines the right operand
  1803. * @returns the dot product
  1804. */
  1805. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1806. /**
  1807. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1808. * The cross product is then orthogonal to both "left" and "right"
  1809. * @param left defines the left operand
  1810. * @param right defines the right operand
  1811. * @returns the cross product
  1812. */
  1813. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1814. /**
  1815. * Sets the given vector "result" with the cross product of "left" and "right"
  1816. * The cross product is then orthogonal to both "left" and "right"
  1817. * @param left defines the left operand
  1818. * @param right defines the right operand
  1819. * @param result defines the Vector3 where to store the result
  1820. */
  1821. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1822. /**
  1823. * Returns a new Vector3 as the normalization of the given vector
  1824. * @param vector defines the Vector3 to normalize
  1825. * @returns the new Vector3
  1826. */
  1827. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1828. /**
  1829. * Sets the given vector "result" with the normalization of the given first vector
  1830. * @param vector defines the Vector3 to normalize
  1831. * @param result defines the Vector3 where to store the result
  1832. */
  1833. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1834. /**
  1835. * Project a Vector3 onto screen space
  1836. * @param vector defines the Vector3 to project
  1837. * @param world defines the world matrix to use
  1838. * @param transform defines the transform (view x projection) matrix to use
  1839. * @param viewport defines the screen viewport to use
  1840. * @returns the new Vector3
  1841. */
  1842. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1843. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1844. /**
  1845. * Unproject from screen space to object space
  1846. * @param source defines the screen space Vector3 to use
  1847. * @param viewportWidth defines the current width of the viewport
  1848. * @param viewportHeight defines the current height of the viewport
  1849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1850. * @param transform defines the transform (view x projection) matrix to use
  1851. * @returns the new Vector3
  1852. */
  1853. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1854. /**
  1855. * Unproject from screen space to object space
  1856. * @param source defines the screen space Vector3 to use
  1857. * @param viewportWidth defines the current width of the viewport
  1858. * @param viewportHeight defines the current height of the viewport
  1859. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1860. * @param view defines the view matrix to use
  1861. * @param projection defines the projection matrix to use
  1862. * @returns the new Vector3
  1863. */
  1864. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1865. /**
  1866. * Unproject from screen space to object space
  1867. * @param source defines the screen space Vector3 to use
  1868. * @param viewportWidth defines the current width of the viewport
  1869. * @param viewportHeight defines the current height of the viewport
  1870. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1871. * @param view defines the view matrix to use
  1872. * @param projection defines the projection matrix to use
  1873. * @param result defines the Vector3 where to store the result
  1874. */
  1875. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1876. /**
  1877. * Unproject from screen space to object space
  1878. * @param sourceX defines the screen space x coordinate to use
  1879. * @param sourceY defines the screen space y coordinate to use
  1880. * @param sourceZ defines the screen space z coordinate to use
  1881. * @param viewportWidth defines the current width of the viewport
  1882. * @param viewportHeight defines the current height of the viewport
  1883. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1884. * @param view defines the view matrix to use
  1885. * @param projection defines the projection matrix to use
  1886. * @param result defines the Vector3 where to store the result
  1887. */
  1888. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1889. /**
  1890. * Gets the minimal coordinate values between two Vector3
  1891. * @param left defines the first operand
  1892. * @param right defines the second operand
  1893. * @returns the new Vector3
  1894. */
  1895. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1896. /**
  1897. * Gets the maximal coordinate values between two Vector3
  1898. * @param left defines the first operand
  1899. * @param right defines the second operand
  1900. * @returns the new Vector3
  1901. */
  1902. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1903. /**
  1904. * Returns the distance between the vectors "value1" and "value2"
  1905. * @param value1 defines the first operand
  1906. * @param value2 defines the second operand
  1907. * @returns the distance
  1908. */
  1909. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1910. /**
  1911. * Returns the squared distance between the vectors "value1" and "value2"
  1912. * @param value1 defines the first operand
  1913. * @param value2 defines the second operand
  1914. * @returns the squared distance
  1915. */
  1916. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1917. /**
  1918. * Returns a new Vector3 located at the center between "value1" and "value2"
  1919. * @param value1 defines the first operand
  1920. * @param value2 defines the second operand
  1921. * @returns the new Vector3
  1922. */
  1923. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1924. /**
  1925. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1926. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1927. * to something in order to rotate it from its local system to the given target system
  1928. * Note: axis1, axis2 and axis3 are normalized during this operation
  1929. * @param axis1 defines the first axis
  1930. * @param axis2 defines the second axis
  1931. * @param axis3 defines the third axis
  1932. * @returns a new Vector3
  1933. */
  1934. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1935. /**
  1936. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1937. * @param axis1 defines the first axis
  1938. * @param axis2 defines the second axis
  1939. * @param axis3 defines the third axis
  1940. * @param ref defines the Vector3 where to store the result
  1941. */
  1942. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1943. }
  1944. /**
  1945. * Vector4 class created for EulerAngle class conversion to Quaternion
  1946. */
  1947. export class Vector4 {
  1948. /** x value of the vector */
  1949. x: number;
  1950. /** y value of the vector */
  1951. y: number;
  1952. /** z value of the vector */
  1953. z: number;
  1954. /** w value of the vector */
  1955. w: number;
  1956. /**
  1957. * Creates a Vector4 object from the given floats.
  1958. * @param x x value of the vector
  1959. * @param y y value of the vector
  1960. * @param z z value of the vector
  1961. * @param w w value of the vector
  1962. */
  1963. constructor(
  1964. /** x value of the vector */
  1965. x: number,
  1966. /** y value of the vector */
  1967. y: number,
  1968. /** z value of the vector */
  1969. z: number,
  1970. /** w value of the vector */
  1971. w: number);
  1972. /**
  1973. * Returns the string with the Vector4 coordinates.
  1974. * @returns a string containing all the vector values
  1975. */
  1976. toString(): string;
  1977. /**
  1978. * Returns the string "Vector4".
  1979. * @returns "Vector4"
  1980. */
  1981. getClassName(): string;
  1982. /**
  1983. * Returns the Vector4 hash code.
  1984. * @returns a unique hash code
  1985. */
  1986. getHashCode(): number;
  1987. /**
  1988. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1989. * @returns the resulting array
  1990. */
  1991. asArray(): number[];
  1992. /**
  1993. * Populates the given array from the given index with the Vector4 coordinates.
  1994. * @param array array to populate
  1995. * @param index index of the array to start at (default: 0)
  1996. * @returns the Vector4.
  1997. */
  1998. toArray(array: FloatArray, index?: number): Vector4;
  1999. /**
  2000. * Adds the given vector to the current Vector4.
  2001. * @param otherVector the vector to add
  2002. * @returns the updated Vector4.
  2003. */
  2004. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2005. /**
  2006. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2007. * @param otherVector the vector to add
  2008. * @returns the resulting vector
  2009. */
  2010. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2011. /**
  2012. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2013. * @param otherVector the vector to add
  2014. * @param result the vector to store the result
  2015. * @returns the current Vector4.
  2016. */
  2017. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2018. /**
  2019. * Subtract in place the given vector from the current Vector4.
  2020. * @param otherVector the vector to subtract
  2021. * @returns the updated Vector4.
  2022. */
  2023. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2024. /**
  2025. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2026. * @param otherVector the vector to add
  2027. * @returns the new vector with the result
  2028. */
  2029. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2030. /**
  2031. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2032. * @param otherVector the vector to subtract
  2033. * @param result the vector to store the result
  2034. * @returns the current Vector4.
  2035. */
  2036. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2037. /**
  2038. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2039. */
  2040. /**
  2041. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2042. * @param x value to subtract
  2043. * @param y value to subtract
  2044. * @param z value to subtract
  2045. * @param w value to subtract
  2046. * @returns new vector containing the result
  2047. */
  2048. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2049. /**
  2050. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2051. * @param x value to subtract
  2052. * @param y value to subtract
  2053. * @param z value to subtract
  2054. * @param w value to subtract
  2055. * @param result the vector to store the result in
  2056. * @returns the current Vector4.
  2057. */
  2058. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2059. /**
  2060. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2061. * @returns a new vector with the negated values
  2062. */
  2063. negate(): Vector4;
  2064. /**
  2065. * Multiplies the current Vector4 coordinates by scale (float).
  2066. * @param scale the number to scale with
  2067. * @returns the updated Vector4.
  2068. */
  2069. scaleInPlace(scale: number): Vector4;
  2070. /**
  2071. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2072. * @param scale the number to scale with
  2073. * @returns a new vector with the result
  2074. */
  2075. scale(scale: number): Vector4;
  2076. /**
  2077. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2078. * @param scale the number to scale with
  2079. * @param result a vector to store the result in
  2080. * @returns the current Vector4.
  2081. */
  2082. scaleToRef(scale: number, result: Vector4): Vector4;
  2083. /**
  2084. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2085. * @param scale defines the scale factor
  2086. * @param result defines the Vector4 object where to store the result
  2087. * @returns the unmodified current Vector4
  2088. */
  2089. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2090. /**
  2091. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2092. * @param otherVector the vector to compare against
  2093. * @returns true if they are equal
  2094. */
  2095. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2096. /**
  2097. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2098. * @param otherVector vector to compare against
  2099. * @param epsilon (Default: very small number)
  2100. * @returns true if they are equal
  2101. */
  2102. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2103. /**
  2104. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2105. * @param x x value to compare against
  2106. * @param y y value to compare against
  2107. * @param z z value to compare against
  2108. * @param w w value to compare against
  2109. * @returns true if equal
  2110. */
  2111. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2112. /**
  2113. * Multiplies in place the current Vector4 by the given one.
  2114. * @param otherVector vector to multiple with
  2115. * @returns the updated Vector4.
  2116. */
  2117. multiplyInPlace(otherVector: Vector4): Vector4;
  2118. /**
  2119. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2120. * @param otherVector vector to multiple with
  2121. * @returns resulting new vector
  2122. */
  2123. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2124. /**
  2125. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2126. * @param otherVector vector to multiple with
  2127. * @param result vector to store the result
  2128. * @returns the current Vector4.
  2129. */
  2130. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2131. /**
  2132. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2133. * @param x x value multiply with
  2134. * @param y y value multiply with
  2135. * @param z z value multiply with
  2136. * @param w w value multiply with
  2137. * @returns resulting new vector
  2138. */
  2139. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2140. /**
  2141. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2142. * @param otherVector vector to devide with
  2143. * @returns resulting new vector
  2144. */
  2145. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2146. /**
  2147. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2148. * @param otherVector vector to devide with
  2149. * @param result vector to store the result
  2150. * @returns the current Vector4.
  2151. */
  2152. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2153. /**
  2154. * Divides the current Vector3 coordinates by the given ones.
  2155. * @param otherVector vector to devide with
  2156. * @returns the updated Vector3.
  2157. */
  2158. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2159. /**
  2160. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2161. * @param other defines the second operand
  2162. * @returns the current updated Vector4
  2163. */
  2164. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2165. /**
  2166. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2167. * @param other defines the second operand
  2168. * @returns the current updated Vector4
  2169. */
  2170. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2171. /**
  2172. * Gets a new Vector4 from current Vector4 floored values
  2173. * @returns a new Vector4
  2174. */
  2175. floor(): Vector4;
  2176. /**
  2177. * Gets a new Vector4 from current Vector3 floored values
  2178. * @returns a new Vector4
  2179. */
  2180. fract(): Vector4;
  2181. /**
  2182. * Returns the Vector4 length (float).
  2183. * @returns the length
  2184. */
  2185. length(): number;
  2186. /**
  2187. * Returns the Vector4 squared length (float).
  2188. * @returns the length squared
  2189. */
  2190. lengthSquared(): number;
  2191. /**
  2192. * Normalizes in place the Vector4.
  2193. * @returns the updated Vector4.
  2194. */
  2195. normalize(): Vector4;
  2196. /**
  2197. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2198. * @returns this converted to a new vector3
  2199. */
  2200. toVector3(): Vector3;
  2201. /**
  2202. * Returns a new Vector4 copied from the current one.
  2203. * @returns the new cloned vector
  2204. */
  2205. clone(): Vector4;
  2206. /**
  2207. * Updates the current Vector4 with the given one coordinates.
  2208. * @param source the source vector to copy from
  2209. * @returns the updated Vector4.
  2210. */
  2211. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2212. /**
  2213. * Updates the current Vector4 coordinates with the given floats.
  2214. * @param x float to copy from
  2215. * @param y float to copy from
  2216. * @param z float to copy from
  2217. * @param w float to copy from
  2218. * @returns the updated Vector4.
  2219. */
  2220. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2221. /**
  2222. * Updates the current Vector4 coordinates with the given floats.
  2223. * @param x float to set from
  2224. * @param y float to set from
  2225. * @param z float to set from
  2226. * @param w float to set from
  2227. * @returns the updated Vector4.
  2228. */
  2229. set(x: number, y: number, z: number, w: number): Vector4;
  2230. /**
  2231. * Copies the given float to the current Vector3 coordinates
  2232. * @param v defines the x, y, z and w coordinates of the operand
  2233. * @returns the current updated Vector3
  2234. */
  2235. setAll(v: number): Vector4;
  2236. /**
  2237. * Returns a new Vector4 set from the starting index of the given array.
  2238. * @param array the array to pull values from
  2239. * @param offset the offset into the array to start at
  2240. * @returns the new vector
  2241. */
  2242. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2243. /**
  2244. * Updates the given vector "result" from the starting index of the given array.
  2245. * @param array the array to pull values from
  2246. * @param offset the offset into the array to start at
  2247. * @param result the vector to store the result in
  2248. */
  2249. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2250. /**
  2251. * Updates the given vector "result" from the starting index of the given Float32Array.
  2252. * @param array the array to pull values from
  2253. * @param offset the offset into the array to start at
  2254. * @param result the vector to store the result in
  2255. */
  2256. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2257. /**
  2258. * Updates the given vector "result" coordinates from the given floats.
  2259. * @param x float to set from
  2260. * @param y float to set from
  2261. * @param z float to set from
  2262. * @param w float to set from
  2263. * @param result the vector to the floats in
  2264. */
  2265. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2266. /**
  2267. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2268. * @returns the new vector
  2269. */
  2270. static Zero(): Vector4;
  2271. /**
  2272. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2273. * @returns the new vector
  2274. */
  2275. static One(): Vector4;
  2276. /**
  2277. * Returns a new normalized Vector4 from the given one.
  2278. * @param vector the vector to normalize
  2279. * @returns the vector
  2280. */
  2281. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2282. /**
  2283. * Updates the given vector "result" from the normalization of the given one.
  2284. * @param vector the vector to normalize
  2285. * @param result the vector to store the result in
  2286. */
  2287. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2288. /**
  2289. * Returns a vector with the minimum values from the left and right vectors
  2290. * @param left left vector to minimize
  2291. * @param right right vector to minimize
  2292. * @returns a new vector with the minimum of the left and right vector values
  2293. */
  2294. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2295. /**
  2296. * Returns a vector with the maximum values from the left and right vectors
  2297. * @param left left vector to maximize
  2298. * @param right right vector to maximize
  2299. * @returns a new vector with the maximum of the left and right vector values
  2300. */
  2301. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Returns the distance (float) between the vectors "value1" and "value2".
  2304. * @param value1 value to calulate the distance between
  2305. * @param value2 value to calulate the distance between
  2306. * @return the distance between the two vectors
  2307. */
  2308. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2309. /**
  2310. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2311. * @param value1 value to calulate the distance between
  2312. * @param value2 value to calulate the distance between
  2313. * @return the distance between the two vectors squared
  2314. */
  2315. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2316. /**
  2317. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2318. * @param value1 value to calulate the center between
  2319. * @param value2 value to calulate the center between
  2320. * @return the center between the two vectors
  2321. */
  2322. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2323. /**
  2324. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2325. * This methods computes transformed normalized direction vectors only.
  2326. * @param vector the vector to transform
  2327. * @param transformation the transformation matrix to apply
  2328. * @returns the new vector
  2329. */
  2330. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2331. /**
  2332. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2333. * This methods computes transformed normalized direction vectors only.
  2334. * @param vector the vector to transform
  2335. * @param transformation the transformation matrix to apply
  2336. * @param result the vector to store the result in
  2337. */
  2338. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2339. /**
  2340. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2341. * This methods computes transformed normalized direction vectors only.
  2342. * @param x value to transform
  2343. * @param y value to transform
  2344. * @param z value to transform
  2345. * @param w value to transform
  2346. * @param transformation the transformation matrix to apply
  2347. * @param result the vector to store the results in
  2348. */
  2349. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2350. /**
  2351. * Creates a new Vector4 from a Vector3
  2352. * @param source defines the source data
  2353. * @param w defines the 4th component (default is 0)
  2354. * @returns a new Vector4
  2355. */
  2356. static FromVector3(source: Vector3, w?: number): Vector4;
  2357. }
  2358. /**
  2359. * Class used to store quaternion data
  2360. * @see https://en.wikipedia.org/wiki/Quaternion
  2361. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2362. */
  2363. export class Quaternion {
  2364. /** defines the first component (0 by default) */
  2365. x: number;
  2366. /** defines the second component (0 by default) */
  2367. y: number;
  2368. /** defines the third component (0 by default) */
  2369. z: number;
  2370. /** defines the fourth component (1.0 by default) */
  2371. w: number;
  2372. /**
  2373. * Creates a new Quaternion from the given floats
  2374. * @param x defines the first component (0 by default)
  2375. * @param y defines the second component (0 by default)
  2376. * @param z defines the third component (0 by default)
  2377. * @param w defines the fourth component (1.0 by default)
  2378. */
  2379. constructor(
  2380. /** defines the first component (0 by default) */
  2381. x?: number,
  2382. /** defines the second component (0 by default) */
  2383. y?: number,
  2384. /** defines the third component (0 by default) */
  2385. z?: number,
  2386. /** defines the fourth component (1.0 by default) */
  2387. w?: number);
  2388. /**
  2389. * Gets a string representation for the current quaternion
  2390. * @returns a string with the Quaternion coordinates
  2391. */
  2392. toString(): string;
  2393. /**
  2394. * Gets the class name of the quaternion
  2395. * @returns the string "Quaternion"
  2396. */
  2397. getClassName(): string;
  2398. /**
  2399. * Gets a hash code for this quaternion
  2400. * @returns the quaternion hash code
  2401. */
  2402. getHashCode(): number;
  2403. /**
  2404. * Copy the quaternion to an array
  2405. * @returns a new array populated with 4 elements from the quaternion coordinates
  2406. */
  2407. asArray(): number[];
  2408. /**
  2409. * Check if two quaternions are equals
  2410. * @param otherQuaternion defines the second operand
  2411. * @return true if the current quaternion and the given one coordinates are strictly equals
  2412. */
  2413. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2414. /**
  2415. * Clone the current quaternion
  2416. * @returns a new quaternion copied from the current one
  2417. */
  2418. clone(): Quaternion;
  2419. /**
  2420. * Copy a quaternion to the current one
  2421. * @param other defines the other quaternion
  2422. * @returns the updated current quaternion
  2423. */
  2424. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2425. /**
  2426. * Updates the current quaternion with the given float coordinates
  2427. * @param x defines the x coordinate
  2428. * @param y defines the y coordinate
  2429. * @param z defines the z coordinate
  2430. * @param w defines the w coordinate
  2431. * @returns the updated current quaternion
  2432. */
  2433. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2434. /**
  2435. * Updates the current quaternion from the given float coordinates
  2436. * @param x defines the x coordinate
  2437. * @param y defines the y coordinate
  2438. * @param z defines the z coordinate
  2439. * @param w defines the w coordinate
  2440. * @returns the updated current quaternion
  2441. */
  2442. set(x: number, y: number, z: number, w: number): Quaternion;
  2443. /**
  2444. * Adds two quaternions
  2445. * @param other defines the second operand
  2446. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2447. */
  2448. add(other: DeepImmutable<Quaternion>): Quaternion;
  2449. /**
  2450. * Add a quaternion to the current one
  2451. * @param other defines the quaternion to add
  2452. * @returns the current quaternion
  2453. */
  2454. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2455. /**
  2456. * Subtract two quaternions
  2457. * @param other defines the second operand
  2458. * @returns a new quaternion as the subtraction result of the given one from the current one
  2459. */
  2460. subtract(other: Quaternion): Quaternion;
  2461. /**
  2462. * Multiplies the current quaternion by a scale factor
  2463. * @param value defines the scale factor
  2464. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2465. */
  2466. scale(value: number): Quaternion;
  2467. /**
  2468. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2469. * @param scale defines the scale factor
  2470. * @param result defines the Quaternion object where to store the result
  2471. * @returns the unmodified current quaternion
  2472. */
  2473. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2474. /**
  2475. * Multiplies in place the current quaternion by a scale factor
  2476. * @param value defines the scale factor
  2477. * @returns the current modified quaternion
  2478. */
  2479. scaleInPlace(value: number): Quaternion;
  2480. /**
  2481. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2482. * @param scale defines the scale factor
  2483. * @param result defines the Quaternion object where to store the result
  2484. * @returns the unmodified current quaternion
  2485. */
  2486. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2487. /**
  2488. * Multiplies two quaternions
  2489. * @param q1 defines the second operand
  2490. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2491. */
  2492. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2493. /**
  2494. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2495. * @param q1 defines the second operand
  2496. * @param result defines the target quaternion
  2497. * @returns the current quaternion
  2498. */
  2499. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2500. /**
  2501. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2502. * @param q1 defines the second operand
  2503. * @returns the currentupdated quaternion
  2504. */
  2505. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2506. /**
  2507. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2508. * @param ref defines the target quaternion
  2509. * @returns the current quaternion
  2510. */
  2511. conjugateToRef(ref: Quaternion): Quaternion;
  2512. /**
  2513. * Conjugates in place (1-q) the current quaternion
  2514. * @returns the current updated quaternion
  2515. */
  2516. conjugateInPlace(): Quaternion;
  2517. /**
  2518. * Conjugates in place (1-q) the current quaternion
  2519. * @returns a new quaternion
  2520. */
  2521. conjugate(): Quaternion;
  2522. /**
  2523. * Gets length of current quaternion
  2524. * @returns the quaternion length (float)
  2525. */
  2526. length(): number;
  2527. /**
  2528. * Normalize in place the current quaternion
  2529. * @returns the current updated quaternion
  2530. */
  2531. normalize(): Quaternion;
  2532. /**
  2533. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2534. * @param order is a reserved parameter and is ignore for now
  2535. * @returns a new Vector3 containing the Euler angles
  2536. */
  2537. toEulerAngles(order?: string): Vector3;
  2538. /**
  2539. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2540. * @param result defines the vector which will be filled with the Euler angles
  2541. * @param order is a reserved parameter and is ignore for now
  2542. * @returns the current unchanged quaternion
  2543. */
  2544. toEulerAnglesToRef(result: Vector3): Quaternion;
  2545. /**
  2546. * Updates the given rotation matrix with the current quaternion values
  2547. * @param result defines the target matrix
  2548. * @returns the current unchanged quaternion
  2549. */
  2550. toRotationMatrix(result: Matrix): Quaternion;
  2551. /**
  2552. * Updates the current quaternion from the given rotation matrix values
  2553. * @param matrix defines the source matrix
  2554. * @returns the current updated quaternion
  2555. */
  2556. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2557. /**
  2558. * Creates a new quaternion from a rotation matrix
  2559. * @param matrix defines the source matrix
  2560. * @returns a new quaternion created from the given rotation matrix values
  2561. */
  2562. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2563. /**
  2564. * Updates the given quaternion with the given rotation matrix values
  2565. * @param matrix defines the source matrix
  2566. * @param result defines the target quaternion
  2567. */
  2568. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2569. /**
  2570. * Returns the dot product (float) between the quaternions "left" and "right"
  2571. * @param left defines the left operand
  2572. * @param right defines the right operand
  2573. * @returns the dot product
  2574. */
  2575. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2576. /**
  2577. * Checks if the two quaternions are close to each other
  2578. * @param quat0 defines the first quaternion to check
  2579. * @param quat1 defines the second quaternion to check
  2580. * @returns true if the two quaternions are close to each other
  2581. */
  2582. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2583. /**
  2584. * Creates an empty quaternion
  2585. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2586. */
  2587. static Zero(): Quaternion;
  2588. /**
  2589. * Inverse a given quaternion
  2590. * @param q defines the source quaternion
  2591. * @returns a new quaternion as the inverted current quaternion
  2592. */
  2593. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2594. /**
  2595. * Inverse a given quaternion
  2596. * @param q defines the source quaternion
  2597. * @param result the quaternion the result will be stored in
  2598. * @returns the result quaternion
  2599. */
  2600. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2601. /**
  2602. * Creates an identity quaternion
  2603. * @returns the identity quaternion
  2604. */
  2605. static Identity(): Quaternion;
  2606. /**
  2607. * Gets a boolean indicating if the given quaternion is identity
  2608. * @param quaternion defines the quaternion to check
  2609. * @returns true if the quaternion is identity
  2610. */
  2611. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2612. /**
  2613. * Creates a quaternion from a rotation around an axis
  2614. * @param axis defines the axis to use
  2615. * @param angle defines the angle to use
  2616. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2617. */
  2618. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2619. /**
  2620. * Creates a rotation around an axis and stores it into the given quaternion
  2621. * @param axis defines the axis to use
  2622. * @param angle defines the angle to use
  2623. * @param result defines the target quaternion
  2624. * @returns the target quaternion
  2625. */
  2626. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2627. /**
  2628. * Creates a new quaternion from data stored into an array
  2629. * @param array defines the data source
  2630. * @param offset defines the offset in the source array where the data starts
  2631. * @returns a new quaternion
  2632. */
  2633. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2634. /**
  2635. * Create a quaternion from Euler rotation angles
  2636. * @param x Pitch
  2637. * @param y Yaw
  2638. * @param z Roll
  2639. * @returns the new Quaternion
  2640. */
  2641. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2642. /**
  2643. * Updates a quaternion from Euler rotation angles
  2644. * @param x Pitch
  2645. * @param y Yaw
  2646. * @param z Roll
  2647. * @param result the quaternion to store the result
  2648. * @returns the updated quaternion
  2649. */
  2650. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2651. /**
  2652. * Create a quaternion from Euler rotation vector
  2653. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2654. * @returns the new Quaternion
  2655. */
  2656. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2657. /**
  2658. * Updates a quaternion from Euler rotation vector
  2659. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2660. * @param result the quaternion to store the result
  2661. * @returns the updated quaternion
  2662. */
  2663. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2664. /**
  2665. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2666. * @param yaw defines the rotation around Y axis
  2667. * @param pitch defines the rotation around X axis
  2668. * @param roll defines the rotation around Z axis
  2669. * @returns the new quaternion
  2670. */
  2671. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2672. /**
  2673. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2674. * @param yaw defines the rotation around Y axis
  2675. * @param pitch defines the rotation around X axis
  2676. * @param roll defines the rotation around Z axis
  2677. * @param result defines the target quaternion
  2678. */
  2679. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2680. /**
  2681. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2682. * @param alpha defines the rotation around first axis
  2683. * @param beta defines the rotation around second axis
  2684. * @param gamma defines the rotation around third axis
  2685. * @returns the new quaternion
  2686. */
  2687. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2688. /**
  2689. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2690. * @param alpha defines the rotation around first axis
  2691. * @param beta defines the rotation around second axis
  2692. * @param gamma defines the rotation around third axis
  2693. * @param result defines the target quaternion
  2694. */
  2695. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2696. /**
  2697. * 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)
  2698. * @param axis1 defines the first axis
  2699. * @param axis2 defines the second axis
  2700. * @param axis3 defines the third axis
  2701. * @returns the new quaternion
  2702. */
  2703. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2704. /**
  2705. * 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
  2706. * @param axis1 defines the first axis
  2707. * @param axis2 defines the second axis
  2708. * @param axis3 defines the third axis
  2709. * @param ref defines the target quaternion
  2710. */
  2711. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2712. /**
  2713. * Interpolates between two quaternions
  2714. * @param left defines first quaternion
  2715. * @param right defines second quaternion
  2716. * @param amount defines the gradient to use
  2717. * @returns the new interpolated quaternion
  2718. */
  2719. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2720. /**
  2721. * Interpolates between two quaternions and stores it into a target quaternion
  2722. * @param left defines first quaternion
  2723. * @param right defines second quaternion
  2724. * @param amount defines the gradient to use
  2725. * @param result defines the target quaternion
  2726. */
  2727. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2728. /**
  2729. * Interpolate between two quaternions using Hermite interpolation
  2730. * @param value1 defines first quaternion
  2731. * @param tangent1 defines the incoming tangent
  2732. * @param value2 defines second quaternion
  2733. * @param tangent2 defines the outgoing tangent
  2734. * @param amount defines the target quaternion
  2735. * @returns the new interpolated quaternion
  2736. */
  2737. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2738. }
  2739. /**
  2740. * Class used to store matrix data (4x4)
  2741. */
  2742. export class Matrix {
  2743. private static _updateFlagSeed;
  2744. private static _identityReadOnly;
  2745. private _isIdentity;
  2746. private _isIdentityDirty;
  2747. private _isIdentity3x2;
  2748. private _isIdentity3x2Dirty;
  2749. /**
  2750. * Gets the update flag of the matrix which is an unique number for the matrix.
  2751. * It will be incremented every time the matrix data change.
  2752. * You can use it to speed the comparison between two versions of the same matrix.
  2753. */
  2754. updateFlag: number;
  2755. private readonly _m;
  2756. /**
  2757. * Gets the internal data of the matrix
  2758. */
  2759. readonly m: DeepImmutable<Float32Array>;
  2760. /** @hidden */ private _markAsUpdated(): void;
  2761. /** @hidden */
  2762. private _updateIdentityStatus;
  2763. /**
  2764. * Creates an empty matrix (filled with zeros)
  2765. */
  2766. constructor();
  2767. /**
  2768. * Check if the current matrix is identity
  2769. * @returns true is the matrix is the identity matrix
  2770. */
  2771. isIdentity(): boolean;
  2772. /**
  2773. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2774. * @returns true is the matrix is the identity matrix
  2775. */
  2776. isIdentityAs3x2(): boolean;
  2777. /**
  2778. * Gets the determinant of the matrix
  2779. * @returns the matrix determinant
  2780. */
  2781. determinant(): number;
  2782. /**
  2783. * Returns the matrix as a Float32Array
  2784. * @returns the matrix underlying array
  2785. */
  2786. toArray(): DeepImmutable<Float32Array>;
  2787. /**
  2788. * Returns the matrix as a Float32Array
  2789. * @returns the matrix underlying array.
  2790. */
  2791. asArray(): DeepImmutable<Float32Array>;
  2792. /**
  2793. * Inverts the current matrix in place
  2794. * @returns the current inverted matrix
  2795. */
  2796. invert(): Matrix;
  2797. /**
  2798. * Sets all the matrix elements to zero
  2799. * @returns the current matrix
  2800. */
  2801. reset(): Matrix;
  2802. /**
  2803. * Adds the current matrix with a second one
  2804. * @param other defines the matrix to add
  2805. * @returns a new matrix as the addition of the current matrix and the given one
  2806. */
  2807. add(other: DeepImmutable<Matrix>): Matrix;
  2808. /**
  2809. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2810. * @param other defines the matrix to add
  2811. * @param result defines the target matrix
  2812. * @returns the current matrix
  2813. */
  2814. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2815. /**
  2816. * Adds in place the given matrix to the current matrix
  2817. * @param other defines the second operand
  2818. * @returns the current updated matrix
  2819. */
  2820. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2821. /**
  2822. * Sets the given matrix to the current inverted Matrix
  2823. * @param other defines the target matrix
  2824. * @returns the unmodified current matrix
  2825. */
  2826. invertToRef(other: Matrix): Matrix;
  2827. /**
  2828. * add a value at the specified position in the current Matrix
  2829. * @param index the index of the value within the matrix. between 0 and 15.
  2830. * @param value the value to be added
  2831. * @returns the current updated matrix
  2832. */
  2833. addAtIndex(index: number, value: number): Matrix;
  2834. /**
  2835. * mutiply the specified position in the current Matrix by a value
  2836. * @param index the index of the value within the matrix. between 0 and 15.
  2837. * @param value the value to be added
  2838. * @returns the current updated matrix
  2839. */
  2840. multiplyAtIndex(index: number, value: number): Matrix;
  2841. /**
  2842. * Inserts the translation vector (using 3 floats) in the current matrix
  2843. * @param x defines the 1st component of the translation
  2844. * @param y defines the 2nd component of the translation
  2845. * @param z defines the 3rd component of the translation
  2846. * @returns the current updated matrix
  2847. */
  2848. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2849. /**
  2850. * Adds the translation vector (using 3 floats) in the current matrix
  2851. * @param x defines the 1st component of the translation
  2852. * @param y defines the 2nd component of the translation
  2853. * @param z defines the 3rd component of the translation
  2854. * @returns the current updated matrix
  2855. */
  2856. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2857. /**
  2858. * Inserts the translation vector in the current matrix
  2859. * @param vector3 defines the translation to insert
  2860. * @returns the current updated matrix
  2861. */
  2862. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2863. /**
  2864. * Gets the translation value of the current matrix
  2865. * @returns a new Vector3 as the extracted translation from the matrix
  2866. */
  2867. getTranslation(): Vector3;
  2868. /**
  2869. * Fill a Vector3 with the extracted translation from the matrix
  2870. * @param result defines the Vector3 where to store the translation
  2871. * @returns the current matrix
  2872. */
  2873. getTranslationToRef(result: Vector3): Matrix;
  2874. /**
  2875. * Remove rotation and scaling part from the matrix
  2876. * @returns the updated matrix
  2877. */
  2878. removeRotationAndScaling(): Matrix;
  2879. /**
  2880. * Multiply two matrices
  2881. * @param other defines the second operand
  2882. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2883. */
  2884. multiply(other: DeepImmutable<Matrix>): Matrix;
  2885. /**
  2886. * Copy the current matrix from the given one
  2887. * @param other defines the source matrix
  2888. * @returns the current updated matrix
  2889. */
  2890. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2891. /**
  2892. * Populates the given array from the starting index with the current matrix values
  2893. * @param array defines the target array
  2894. * @param offset defines the offset in the target array where to start storing values
  2895. * @returns the current matrix
  2896. */
  2897. copyToArray(array: Float32Array, offset?: number): Matrix;
  2898. /**
  2899. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2900. * @param other defines the second operand
  2901. * @param result defines the matrix where to store the multiplication
  2902. * @returns the current matrix
  2903. */
  2904. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2905. /**
  2906. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2907. * @param other defines the second operand
  2908. * @param result defines the array where to store the multiplication
  2909. * @param offset defines the offset in the target array where to start storing values
  2910. * @returns the current matrix
  2911. */
  2912. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2913. /**
  2914. * Check equality between this matrix and a second one
  2915. * @param value defines the second matrix to compare
  2916. * @returns true is the current matrix and the given one values are strictly equal
  2917. */
  2918. equals(value: DeepImmutable<Matrix>): boolean;
  2919. /**
  2920. * Clone the current matrix
  2921. * @returns a new matrix from the current matrix
  2922. */
  2923. clone(): Matrix;
  2924. /**
  2925. * Returns the name of the current matrix class
  2926. * @returns the string "Matrix"
  2927. */
  2928. getClassName(): string;
  2929. /**
  2930. * Gets the hash code of the current matrix
  2931. * @returns the hash code
  2932. */
  2933. getHashCode(): number;
  2934. /**
  2935. * Decomposes the current Matrix into a translation, rotation and scaling components
  2936. * @param scale defines the scale vector3 given as a reference to update
  2937. * @param rotation defines the rotation quaternion given as a reference to update
  2938. * @param translation defines the translation vector3 given as a reference to update
  2939. * @returns true if operation was successful
  2940. */
  2941. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  2942. /**
  2943. * Gets specific row of the matrix
  2944. * @param index defines the number of the row to get
  2945. * @returns the index-th row of the current matrix as a new Vector4
  2946. */
  2947. getRow(index: number): Nullable<Vector4>;
  2948. /**
  2949. * Sets the index-th row of the current matrix to the vector4 values
  2950. * @param index defines the number of the row to set
  2951. * @param row defines the target vector4
  2952. * @returns the updated current matrix
  2953. */
  2954. setRow(index: number, row: Vector4): Matrix;
  2955. /**
  2956. * Compute the transpose of the matrix
  2957. * @returns the new transposed matrix
  2958. */
  2959. transpose(): Matrix;
  2960. /**
  2961. * Compute the transpose of the matrix and store it in a given matrix
  2962. * @param result defines the target matrix
  2963. * @returns the current matrix
  2964. */
  2965. transposeToRef(result: Matrix): Matrix;
  2966. /**
  2967. * Sets the index-th row of the current matrix with the given 4 x float values
  2968. * @param index defines the row index
  2969. * @param x defines the x component to set
  2970. * @param y defines the y component to set
  2971. * @param z defines the z component to set
  2972. * @param w defines the w component to set
  2973. * @returns the updated current matrix
  2974. */
  2975. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  2976. /**
  2977. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  2978. * @param scale defines the scale factor
  2979. * @returns a new matrix
  2980. */
  2981. scale(scale: number): Matrix;
  2982. /**
  2983. * Scale the current matrix values by a factor to a given result matrix
  2984. * @param scale defines the scale factor
  2985. * @param result defines the matrix to store the result
  2986. * @returns the current matrix
  2987. */
  2988. scaleToRef(scale: number, result: Matrix): Matrix;
  2989. /**
  2990. * Scale the current matrix values by a factor and add the result to a given matrix
  2991. * @param scale defines the scale factor
  2992. * @param result defines the Matrix to store the result
  2993. * @returns the current matrix
  2994. */
  2995. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  2996. /**
  2997. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  2998. * @param ref matrix to store the result
  2999. */
  3000. toNormalMatrix(ref: Matrix): void;
  3001. /**
  3002. * Gets only rotation part of the current matrix
  3003. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3004. */
  3005. getRotationMatrix(): Matrix;
  3006. /**
  3007. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3008. * @param result defines the target matrix to store data to
  3009. * @returns the current matrix
  3010. */
  3011. getRotationMatrixToRef(result: Matrix): Matrix;
  3012. /**
  3013. * Toggles model matrix from being right handed to left handed in place and vice versa
  3014. */
  3015. toggleModelMatrixHandInPlace(): void;
  3016. /**
  3017. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3018. */
  3019. toggleProjectionMatrixHandInPlace(): void;
  3020. /**
  3021. * Creates a matrix from an array
  3022. * @param array defines the source array
  3023. * @param offset defines an offset in the source array
  3024. * @returns a new Matrix set from the starting index of the given array
  3025. */
  3026. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3027. /**
  3028. * Copy the content of an array into a given matrix
  3029. * @param array defines the source array
  3030. * @param offset defines an offset in the source array
  3031. * @param result defines the target matrix
  3032. */
  3033. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3034. /**
  3035. * Stores an array into a matrix after having multiplied each component by a given factor
  3036. * @param array defines the source array
  3037. * @param offset defines the offset in the source array
  3038. * @param scale defines the scaling factor
  3039. * @param result defines the target matrix
  3040. */
  3041. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3042. /**
  3043. * Gets an identity matrix that must not be updated
  3044. */
  3045. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3046. /**
  3047. * Stores a list of values (16) inside a given matrix
  3048. * @param initialM11 defines 1st value of 1st row
  3049. * @param initialM12 defines 2nd value of 1st row
  3050. * @param initialM13 defines 3rd value of 1st row
  3051. * @param initialM14 defines 4th value of 1st row
  3052. * @param initialM21 defines 1st value of 2nd row
  3053. * @param initialM22 defines 2nd value of 2nd row
  3054. * @param initialM23 defines 3rd value of 2nd row
  3055. * @param initialM24 defines 4th value of 2nd row
  3056. * @param initialM31 defines 1st value of 3rd row
  3057. * @param initialM32 defines 2nd value of 3rd row
  3058. * @param initialM33 defines 3rd value of 3rd row
  3059. * @param initialM34 defines 4th value of 3rd row
  3060. * @param initialM41 defines 1st value of 4th row
  3061. * @param initialM42 defines 2nd value of 4th row
  3062. * @param initialM43 defines 3rd value of 4th row
  3063. * @param initialM44 defines 4th value of 4th row
  3064. * @param result defines the target matrix
  3065. */
  3066. 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;
  3067. /**
  3068. * Creates new matrix from a list of values (16)
  3069. * @param initialM11 defines 1st value of 1st row
  3070. * @param initialM12 defines 2nd value of 1st row
  3071. * @param initialM13 defines 3rd value of 1st row
  3072. * @param initialM14 defines 4th value of 1st row
  3073. * @param initialM21 defines 1st value of 2nd row
  3074. * @param initialM22 defines 2nd value of 2nd row
  3075. * @param initialM23 defines 3rd value of 2nd row
  3076. * @param initialM24 defines 4th value of 2nd row
  3077. * @param initialM31 defines 1st value of 3rd row
  3078. * @param initialM32 defines 2nd value of 3rd row
  3079. * @param initialM33 defines 3rd value of 3rd row
  3080. * @param initialM34 defines 4th value of 3rd row
  3081. * @param initialM41 defines 1st value of 4th row
  3082. * @param initialM42 defines 2nd value of 4th row
  3083. * @param initialM43 defines 3rd value of 4th row
  3084. * @param initialM44 defines 4th value of 4th row
  3085. * @returns the new matrix
  3086. */
  3087. 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;
  3088. /**
  3089. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3090. * @param scale defines the scale vector3
  3091. * @param rotation defines the rotation quaternion
  3092. * @param translation defines the translation vector3
  3093. * @returns a new matrix
  3094. */
  3095. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3096. /**
  3097. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3098. * @param scale defines the scale vector3
  3099. * @param rotation defines the rotation quaternion
  3100. * @param translation defines the translation vector3
  3101. * @param result defines the target matrix
  3102. */
  3103. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3104. /**
  3105. * Creates a new identity matrix
  3106. * @returns a new identity matrix
  3107. */
  3108. static Identity(): Matrix;
  3109. /**
  3110. * Creates a new identity matrix and stores the result in a given matrix
  3111. * @param result defines the target matrix
  3112. */
  3113. static IdentityToRef(result: Matrix): void;
  3114. /**
  3115. * Creates a new zero matrix
  3116. * @returns a new zero matrix
  3117. */
  3118. static Zero(): Matrix;
  3119. /**
  3120. * Creates a new rotation matrix for "angle" radians around the X axis
  3121. * @param angle defines the angle (in radians) to use
  3122. * @return the new matrix
  3123. */
  3124. static RotationX(angle: number): Matrix;
  3125. /**
  3126. * Creates a new matrix as the invert of a given matrix
  3127. * @param source defines the source matrix
  3128. * @returns the new matrix
  3129. */
  3130. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3131. /**
  3132. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3133. * @param angle defines the angle (in radians) to use
  3134. * @param result defines the target matrix
  3135. */
  3136. static RotationXToRef(angle: number, result: Matrix): void;
  3137. /**
  3138. * Creates a new rotation matrix for "angle" radians around the Y axis
  3139. * @param angle defines the angle (in radians) to use
  3140. * @return the new matrix
  3141. */
  3142. static RotationY(angle: number): Matrix;
  3143. /**
  3144. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3145. * @param angle defines the angle (in radians) to use
  3146. * @param result defines the target matrix
  3147. */
  3148. static RotationYToRef(angle: number, result: Matrix): void;
  3149. /**
  3150. * Creates a new rotation matrix for "angle" radians around the Z axis
  3151. * @param angle defines the angle (in radians) to use
  3152. * @return the new matrix
  3153. */
  3154. static RotationZ(angle: number): Matrix;
  3155. /**
  3156. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3157. * @param angle defines the angle (in radians) to use
  3158. * @param result defines the target matrix
  3159. */
  3160. static RotationZToRef(angle: number, result: Matrix): void;
  3161. /**
  3162. * Creates a new rotation matrix for "angle" radians around the given axis
  3163. * @param axis defines the axis to use
  3164. * @param angle defines the angle (in radians) to use
  3165. * @return the new matrix
  3166. */
  3167. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3168. /**
  3169. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3170. * @param axis defines the axis to use
  3171. * @param angle defines the angle (in radians) to use
  3172. * @param result defines the target matrix
  3173. */
  3174. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3175. /**
  3176. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3177. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3178. * @param from defines the vector to align
  3179. * @param to defines the vector to align to
  3180. * @param result defines the target matrix
  3181. */
  3182. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3183. /**
  3184. * Creates a rotation matrix
  3185. * @param yaw defines the yaw angle in radians (Y axis)
  3186. * @param pitch defines the pitch angle in radians (X axis)
  3187. * @param roll defines the roll angle in radians (X axis)
  3188. * @returns the new rotation matrix
  3189. */
  3190. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3191. /**
  3192. * Creates a rotation matrix and stores it in a given matrix
  3193. * @param yaw defines the yaw angle in radians (Y axis)
  3194. * @param pitch defines the pitch angle in radians (X axis)
  3195. * @param roll defines the roll angle in radians (X axis)
  3196. * @param result defines the target matrix
  3197. */
  3198. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3199. /**
  3200. * Creates a scaling matrix
  3201. * @param x defines the scale factor on X axis
  3202. * @param y defines the scale factor on Y axis
  3203. * @param z defines the scale factor on Z axis
  3204. * @returns the new matrix
  3205. */
  3206. static Scaling(x: number, y: number, z: number): Matrix;
  3207. /**
  3208. * Creates a scaling matrix and stores it in a given matrix
  3209. * @param x defines the scale factor on X axis
  3210. * @param y defines the scale factor on Y axis
  3211. * @param z defines the scale factor on Z axis
  3212. * @param result defines the target matrix
  3213. */
  3214. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3215. /**
  3216. * Creates a translation matrix
  3217. * @param x defines the translation on X axis
  3218. * @param y defines the translation on Y axis
  3219. * @param z defines the translationon Z axis
  3220. * @returns the new matrix
  3221. */
  3222. static Translation(x: number, y: number, z: number): Matrix;
  3223. /**
  3224. * Creates a translation matrix and stores it in a given matrix
  3225. * @param x defines the translation on X axis
  3226. * @param y defines the translation on Y axis
  3227. * @param z defines the translationon Z axis
  3228. * @param result defines the target matrix
  3229. */
  3230. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3231. /**
  3232. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3233. * @param startValue defines the start value
  3234. * @param endValue defines the end value
  3235. * @param gradient defines the gradient factor
  3236. * @returns the new matrix
  3237. */
  3238. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3239. /**
  3240. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3241. * @param startValue defines the start value
  3242. * @param endValue defines the end value
  3243. * @param gradient defines the gradient factor
  3244. * @param result defines the Matrix object where to store data
  3245. */
  3246. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3247. /**
  3248. * Builds a new matrix whose values are computed by:
  3249. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3250. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3251. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3252. * @param startValue defines the first matrix
  3253. * @param endValue defines the second matrix
  3254. * @param gradient defines the gradient between the two matrices
  3255. * @returns the new matrix
  3256. */
  3257. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3258. /**
  3259. * Update a matrix to values which are computed by:
  3260. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3261. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3262. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3263. * @param startValue defines the first matrix
  3264. * @param endValue defines the second matrix
  3265. * @param gradient defines the gradient between the two matrices
  3266. * @param result defines the target matrix
  3267. */
  3268. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3269. /**
  3270. * 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"
  3271. * This function works in left handed mode
  3272. * @param eye defines the final position of the entity
  3273. * @param target defines where the entity should look at
  3274. * @param up defines the up vector for the entity
  3275. * @returns the new matrix
  3276. */
  3277. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3278. /**
  3279. * 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".
  3280. * This function works in left handed mode
  3281. * @param eye defines the final position of the entity
  3282. * @param target defines where the entity should look at
  3283. * @param up defines the up vector for the entity
  3284. * @param result defines the target matrix
  3285. */
  3286. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3287. /**
  3288. * 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"
  3289. * This function works in right handed mode
  3290. * @param eye defines the final position of the entity
  3291. * @param target defines where the entity should look at
  3292. * @param up defines the up vector for the entity
  3293. * @returns the new matrix
  3294. */
  3295. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3296. /**
  3297. * 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".
  3298. * This function works in right handed mode
  3299. * @param eye defines the final position of the entity
  3300. * @param target defines where the entity should look at
  3301. * @param up defines the up vector for the entity
  3302. * @param result defines the target matrix
  3303. */
  3304. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3305. /**
  3306. * Create a left-handed orthographic projection matrix
  3307. * @param width defines the viewport width
  3308. * @param height defines the viewport height
  3309. * @param znear defines the near clip plane
  3310. * @param zfar defines the far clip plane
  3311. * @returns a new matrix as a left-handed orthographic projection matrix
  3312. */
  3313. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3314. /**
  3315. * Store a left-handed orthographic projection to a given matrix
  3316. * @param width defines the viewport width
  3317. * @param height defines the viewport height
  3318. * @param znear defines the near clip plane
  3319. * @param zfar defines the far clip plane
  3320. * @param result defines the target matrix
  3321. */
  3322. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3323. /**
  3324. * Create a left-handed orthographic projection matrix
  3325. * @param left defines the viewport left coordinate
  3326. * @param right defines the viewport right coordinate
  3327. * @param bottom defines the viewport bottom coordinate
  3328. * @param top defines the viewport top coordinate
  3329. * @param znear defines the near clip plane
  3330. * @param zfar defines the far clip plane
  3331. * @returns a new matrix as a left-handed orthographic projection matrix
  3332. */
  3333. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3334. /**
  3335. * Stores a left-handed orthographic projection into a given matrix
  3336. * @param left defines the viewport left coordinate
  3337. * @param right defines the viewport right coordinate
  3338. * @param bottom defines the viewport bottom coordinate
  3339. * @param top defines the viewport top coordinate
  3340. * @param znear defines the near clip plane
  3341. * @param zfar defines the far clip plane
  3342. * @param result defines the target matrix
  3343. */
  3344. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3345. /**
  3346. * Creates a right-handed orthographic projection matrix
  3347. * @param left defines the viewport left coordinate
  3348. * @param right defines the viewport right coordinate
  3349. * @param bottom defines the viewport bottom coordinate
  3350. * @param top defines the viewport top coordinate
  3351. * @param znear defines the near clip plane
  3352. * @param zfar defines the far clip plane
  3353. * @returns a new matrix as a right-handed orthographic projection matrix
  3354. */
  3355. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3356. /**
  3357. * Stores a right-handed orthographic projection into a given matrix
  3358. * @param left defines the viewport left coordinate
  3359. * @param right defines the viewport right coordinate
  3360. * @param bottom defines the viewport bottom coordinate
  3361. * @param top defines the viewport top coordinate
  3362. * @param znear defines the near clip plane
  3363. * @param zfar defines the far clip plane
  3364. * @param result defines the target matrix
  3365. */
  3366. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3367. /**
  3368. * Creates a left-handed perspective projection matrix
  3369. * @param width defines the viewport width
  3370. * @param height defines the viewport height
  3371. * @param znear defines the near clip plane
  3372. * @param zfar defines the far clip plane
  3373. * @returns a new matrix as a left-handed perspective projection matrix
  3374. */
  3375. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3376. /**
  3377. * Creates a left-handed perspective projection matrix
  3378. * @param fov defines the horizontal field of view
  3379. * @param aspect defines the aspect ratio
  3380. * @param znear defines the near clip plane
  3381. * @param zfar defines the far clip plane
  3382. * @returns a new matrix as a left-handed perspective projection matrix
  3383. */
  3384. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3385. /**
  3386. * Stores a left-handed perspective projection into a given matrix
  3387. * @param fov defines the horizontal field of view
  3388. * @param aspect defines the aspect ratio
  3389. * @param znear defines the near clip plane
  3390. * @param zfar defines the far clip plane
  3391. * @param result defines the target matrix
  3392. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3393. */
  3394. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3395. /**
  3396. * Creates a right-handed perspective projection matrix
  3397. * @param fov defines the horizontal field of view
  3398. * @param aspect defines the aspect ratio
  3399. * @param znear defines the near clip plane
  3400. * @param zfar defines the far clip plane
  3401. * @returns a new matrix as a right-handed perspective projection matrix
  3402. */
  3403. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3404. /**
  3405. * Stores a right-handed perspective projection into a given matrix
  3406. * @param fov defines the horizontal field of view
  3407. * @param aspect defines the aspect ratio
  3408. * @param znear defines the near clip plane
  3409. * @param zfar defines the far clip plane
  3410. * @param result defines the target matrix
  3411. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3412. */
  3413. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3414. /**
  3415. * Stores a perspective projection for WebVR info a given matrix
  3416. * @param fov defines the field of view
  3417. * @param znear defines the near clip plane
  3418. * @param zfar defines the far clip plane
  3419. * @param result defines the target matrix
  3420. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3421. */
  3422. static PerspectiveFovWebVRToRef(fov: {
  3423. upDegrees: number;
  3424. downDegrees: number;
  3425. leftDegrees: number;
  3426. rightDegrees: number;
  3427. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3428. /**
  3429. * Computes a complete transformation matrix
  3430. * @param viewport defines the viewport to use
  3431. * @param world defines the world matrix
  3432. * @param view defines the view matrix
  3433. * @param projection defines the projection matrix
  3434. * @param zmin defines the near clip plane
  3435. * @param zmax defines the far clip plane
  3436. * @returns the transformation matrix
  3437. */
  3438. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3439. /**
  3440. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3441. * @param matrix defines the matrix to use
  3442. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3443. */
  3444. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3445. /**
  3446. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3447. * @param matrix defines the matrix to use
  3448. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3449. */
  3450. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3451. /**
  3452. * Compute the transpose of a given matrix
  3453. * @param matrix defines the matrix to transpose
  3454. * @returns the new matrix
  3455. */
  3456. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3457. /**
  3458. * Compute the transpose of a matrix and store it in a target matrix
  3459. * @param matrix defines the matrix to transpose
  3460. * @param result defines the target matrix
  3461. */
  3462. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3463. /**
  3464. * Computes a reflection matrix from a plane
  3465. * @param plane defines the reflection plane
  3466. * @returns a new matrix
  3467. */
  3468. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  3469. /**
  3470. * Computes a reflection matrix from a plane
  3471. * @param plane defines the reflection plane
  3472. * @param result defines the target matrix
  3473. */
  3474. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  3475. /**
  3476. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3477. * @param xaxis defines the value of the 1st axis
  3478. * @param yaxis defines the value of the 2nd axis
  3479. * @param zaxis defines the value of the 3rd axis
  3480. * @param result defines the target matrix
  3481. */
  3482. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3483. /**
  3484. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3485. * @param quat defines the quaternion to use
  3486. * @param result defines the target matrix
  3487. */
  3488. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3489. }
  3490. /**
  3491. * @hidden
  3492. */
  3493. export class TmpVectors {
  3494. static Vector2: Vector2[];
  3495. static Vector3: Vector3[];
  3496. static Vector4: Vector4[];
  3497. static Quaternion: Quaternion[];
  3498. static Matrix: Matrix[];
  3499. }
  3500. }
  3501. declare module BABYLON {
  3502. /**
  3503. * Class used to hold a RBG color
  3504. */
  3505. export class Color3 {
  3506. /**
  3507. * Defines the red component (between 0 and 1, default is 0)
  3508. */
  3509. r: number;
  3510. /**
  3511. * Defines the green component (between 0 and 1, default is 0)
  3512. */
  3513. g: number;
  3514. /**
  3515. * Defines the blue component (between 0 and 1, default is 0)
  3516. */
  3517. b: number;
  3518. /**
  3519. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  3520. * @param r defines the red component (between 0 and 1, default is 0)
  3521. * @param g defines the green component (between 0 and 1, default is 0)
  3522. * @param b defines the blue component (between 0 and 1, default is 0)
  3523. */
  3524. constructor(
  3525. /**
  3526. * Defines the red component (between 0 and 1, default is 0)
  3527. */
  3528. r?: number,
  3529. /**
  3530. * Defines the green component (between 0 and 1, default is 0)
  3531. */
  3532. g?: number,
  3533. /**
  3534. * Defines the blue component (between 0 and 1, default is 0)
  3535. */
  3536. b?: number);
  3537. /**
  3538. * Creates a string with the Color3 current values
  3539. * @returns the string representation of the Color3 object
  3540. */
  3541. toString(): string;
  3542. /**
  3543. * Returns the string "Color3"
  3544. * @returns "Color3"
  3545. */
  3546. getClassName(): string;
  3547. /**
  3548. * Compute the Color3 hash code
  3549. * @returns an unique number that can be used to hash Color3 objects
  3550. */
  3551. getHashCode(): number;
  3552. /**
  3553. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  3554. * @param array defines the array where to store the r,g,b components
  3555. * @param index defines an optional index in the target array to define where to start storing values
  3556. * @returns the current Color3 object
  3557. */
  3558. toArray(array: FloatArray, index?: number): Color3;
  3559. /**
  3560. * Returns a new Color4 object from the current Color3 and the given alpha
  3561. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  3562. * @returns a new Color4 object
  3563. */
  3564. toColor4(alpha?: number): Color4;
  3565. /**
  3566. * Returns a new array populated with 3 numeric elements : red, green and blue values
  3567. * @returns the new array
  3568. */
  3569. asArray(): number[];
  3570. /**
  3571. * Returns the luminance value
  3572. * @returns a float value
  3573. */
  3574. toLuminance(): number;
  3575. /**
  3576. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  3577. * @param otherColor defines the second operand
  3578. * @returns the new Color3 object
  3579. */
  3580. multiply(otherColor: DeepImmutable<Color3>): Color3;
  3581. /**
  3582. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  3583. * @param otherColor defines the second operand
  3584. * @param result defines the Color3 object where to store the result
  3585. * @returns the current Color3
  3586. */
  3587. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3588. /**
  3589. * Determines equality between Color3 objects
  3590. * @param otherColor defines the second operand
  3591. * @returns true if the rgb values are equal to the given ones
  3592. */
  3593. equals(otherColor: DeepImmutable<Color3>): boolean;
  3594. /**
  3595. * Determines equality between the current Color3 object and a set of r,b,g values
  3596. * @param r defines the red component to check
  3597. * @param g defines the green component to check
  3598. * @param b defines the blue component to check
  3599. * @returns true if the rgb values are equal to the given ones
  3600. */
  3601. equalsFloats(r: number, g: number, b: number): boolean;
  3602. /**
  3603. * Multiplies in place each rgb value by scale
  3604. * @param scale defines the scaling factor
  3605. * @returns the updated Color3
  3606. */
  3607. scale(scale: number): Color3;
  3608. /**
  3609. * Multiplies the rgb values by scale and stores the result into "result"
  3610. * @param scale defines the scaling factor
  3611. * @param result defines the Color3 object where to store the result
  3612. * @returns the unmodified current Color3
  3613. */
  3614. scaleToRef(scale: number, result: Color3): Color3;
  3615. /**
  3616. * Scale the current Color3 values by a factor and add the result to a given Color3
  3617. * @param scale defines the scale factor
  3618. * @param result defines color to store the result into
  3619. * @returns the unmodified current Color3
  3620. */
  3621. scaleAndAddToRef(scale: number, result: Color3): Color3;
  3622. /**
  3623. * Clamps the rgb values by the min and max values and stores the result into "result"
  3624. * @param min defines minimum clamping value (default is 0)
  3625. * @param max defines maximum clamping value (default is 1)
  3626. * @param result defines color to store the result into
  3627. * @returns the original Color3
  3628. */
  3629. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  3630. /**
  3631. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  3632. * @param otherColor defines the second operand
  3633. * @returns the new Color3
  3634. */
  3635. add(otherColor: DeepImmutable<Color3>): Color3;
  3636. /**
  3637. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  3638. * @param otherColor defines the second operand
  3639. * @param result defines Color3 object to store the result into
  3640. * @returns the unmodified current Color3
  3641. */
  3642. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3643. /**
  3644. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  3645. * @param otherColor defines the second operand
  3646. * @returns the new Color3
  3647. */
  3648. subtract(otherColor: DeepImmutable<Color3>): Color3;
  3649. /**
  3650. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  3651. * @param otherColor defines the second operand
  3652. * @param result defines Color3 object to store the result into
  3653. * @returns the unmodified current Color3
  3654. */
  3655. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3656. /**
  3657. * Copy the current object
  3658. * @returns a new Color3 copied the current one
  3659. */
  3660. clone(): Color3;
  3661. /**
  3662. * Copies the rgb values from the source in the current Color3
  3663. * @param source defines the source Color3 object
  3664. * @returns the updated Color3 object
  3665. */
  3666. copyFrom(source: DeepImmutable<Color3>): Color3;
  3667. /**
  3668. * Updates the Color3 rgb values from the given floats
  3669. * @param r defines the red component to read from
  3670. * @param g defines the green component to read from
  3671. * @param b defines the blue component to read from
  3672. * @returns the current Color3 object
  3673. */
  3674. copyFromFloats(r: number, g: number, b: number): Color3;
  3675. /**
  3676. * Updates the Color3 rgb values from the given floats
  3677. * @param r defines the red component to read from
  3678. * @param g defines the green component to read from
  3679. * @param b defines the blue component to read from
  3680. * @returns the current Color3 object
  3681. */
  3682. set(r: number, g: number, b: number): Color3;
  3683. /**
  3684. * Compute the Color3 hexadecimal code as a string
  3685. * @returns a string containing the hexadecimal representation of the Color3 object
  3686. */
  3687. toHexString(): string;
  3688. /**
  3689. * Computes a new Color3 converted from the current one to linear space
  3690. * @returns a new Color3 object
  3691. */
  3692. toLinearSpace(): Color3;
  3693. /**
  3694. * Converts current color in rgb space to HSV values
  3695. * @returns a new color3 representing the HSV values
  3696. */
  3697. toHSV(): Color3;
  3698. /**
  3699. * Converts current color in rgb space to HSV values
  3700. * @param result defines the Color3 where to store the HSV values
  3701. */
  3702. toHSVToRef(result: Color3): void;
  3703. /**
  3704. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  3705. * @param convertedColor defines the Color3 object where to store the linear space version
  3706. * @returns the unmodified Color3
  3707. */
  3708. toLinearSpaceToRef(convertedColor: Color3): Color3;
  3709. /**
  3710. * Computes a new Color3 converted from the current one to gamma space
  3711. * @returns a new Color3 object
  3712. */
  3713. toGammaSpace(): Color3;
  3714. /**
  3715. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  3716. * @param convertedColor defines the Color3 object where to store the gamma space version
  3717. * @returns the unmodified Color3
  3718. */
  3719. toGammaSpaceToRef(convertedColor: Color3): Color3;
  3720. private static _BlackReadOnly;
  3721. /**
  3722. * Convert Hue, saturation and value to a Color3 (RGB)
  3723. * @param hue defines the hue
  3724. * @param saturation defines the saturation
  3725. * @param value defines the value
  3726. * @param result defines the Color3 where to store the RGB values
  3727. */
  3728. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  3729. /**
  3730. * Creates a new Color3 from the string containing valid hexadecimal values
  3731. * @param hex defines a string containing valid hexadecimal values
  3732. * @returns a new Color3 object
  3733. */
  3734. static FromHexString(hex: string): Color3;
  3735. /**
  3736. * Creates a new Color3 from the starting index of the given array
  3737. * @param array defines the source array
  3738. * @param offset defines an offset in the source array
  3739. * @returns a new Color3 object
  3740. */
  3741. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  3742. /**
  3743. * Creates a new Color3 from integer values (< 256)
  3744. * @param r defines the red component to read from (value between 0 and 255)
  3745. * @param g defines the green component to read from (value between 0 and 255)
  3746. * @param b defines the blue component to read from (value between 0 and 255)
  3747. * @returns a new Color3 object
  3748. */
  3749. static FromInts(r: number, g: number, b: number): Color3;
  3750. /**
  3751. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3752. * @param start defines the start Color3 value
  3753. * @param end defines the end Color3 value
  3754. * @param amount defines the gradient value between start and end
  3755. * @returns a new Color3 object
  3756. */
  3757. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  3758. /**
  3759. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3760. * @param left defines the start value
  3761. * @param right defines the end value
  3762. * @param amount defines the gradient factor
  3763. * @param result defines the Color3 object where to store the result
  3764. */
  3765. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  3766. /**
  3767. * Returns a Color3 value containing a red color
  3768. * @returns a new Color3 object
  3769. */
  3770. static Red(): Color3;
  3771. /**
  3772. * Returns a Color3 value containing a green color
  3773. * @returns a new Color3 object
  3774. */
  3775. static Green(): Color3;
  3776. /**
  3777. * Returns a Color3 value containing a blue color
  3778. * @returns a new Color3 object
  3779. */
  3780. static Blue(): Color3;
  3781. /**
  3782. * Returns a Color3 value containing a black color
  3783. * @returns a new Color3 object
  3784. */
  3785. static Black(): Color3;
  3786. /**
  3787. * Gets a Color3 value containing a black color that must not be updated
  3788. */
  3789. static readonly BlackReadOnly: DeepImmutable<Color3>;
  3790. /**
  3791. * Returns a Color3 value containing a white color
  3792. * @returns a new Color3 object
  3793. */
  3794. static White(): Color3;
  3795. /**
  3796. * Returns a Color3 value containing a purple color
  3797. * @returns a new Color3 object
  3798. */
  3799. static Purple(): Color3;
  3800. /**
  3801. * Returns a Color3 value containing a magenta color
  3802. * @returns a new Color3 object
  3803. */
  3804. static Magenta(): Color3;
  3805. /**
  3806. * Returns a Color3 value containing a yellow color
  3807. * @returns a new Color3 object
  3808. */
  3809. static Yellow(): Color3;
  3810. /**
  3811. * Returns a Color3 value containing a gray color
  3812. * @returns a new Color3 object
  3813. */
  3814. static Gray(): Color3;
  3815. /**
  3816. * Returns a Color3 value containing a teal color
  3817. * @returns a new Color3 object
  3818. */
  3819. static Teal(): Color3;
  3820. /**
  3821. * Returns a Color3 value containing a random color
  3822. * @returns a new Color3 object
  3823. */
  3824. static Random(): Color3;
  3825. }
  3826. /**
  3827. * Class used to hold a RBGA color
  3828. */
  3829. export class Color4 {
  3830. /**
  3831. * Defines the red component (between 0 and 1, default is 0)
  3832. */
  3833. r: number;
  3834. /**
  3835. * Defines the green component (between 0 and 1, default is 0)
  3836. */
  3837. g: number;
  3838. /**
  3839. * Defines the blue component (between 0 and 1, default is 0)
  3840. */
  3841. b: number;
  3842. /**
  3843. * Defines the alpha component (between 0 and 1, default is 1)
  3844. */
  3845. a: number;
  3846. /**
  3847. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  3848. * @param r defines the red component (between 0 and 1, default is 0)
  3849. * @param g defines the green component (between 0 and 1, default is 0)
  3850. * @param b defines the blue component (between 0 and 1, default is 0)
  3851. * @param a defines the alpha component (between 0 and 1, default is 1)
  3852. */
  3853. constructor(
  3854. /**
  3855. * Defines the red component (between 0 and 1, default is 0)
  3856. */
  3857. r?: number,
  3858. /**
  3859. * Defines the green component (between 0 and 1, default is 0)
  3860. */
  3861. g?: number,
  3862. /**
  3863. * Defines the blue component (between 0 and 1, default is 0)
  3864. */
  3865. b?: number,
  3866. /**
  3867. * Defines the alpha component (between 0 and 1, default is 1)
  3868. */
  3869. a?: number);
  3870. /**
  3871. * Adds in place the given Color4 values to the current Color4 object
  3872. * @param right defines the second operand
  3873. * @returns the current updated Color4 object
  3874. */
  3875. addInPlace(right: DeepImmutable<Color4>): Color4;
  3876. /**
  3877. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  3878. * @returns the new array
  3879. */
  3880. asArray(): number[];
  3881. /**
  3882. * Stores from the starting index in the given array the Color4 successive values
  3883. * @param array defines the array where to store the r,g,b components
  3884. * @param index defines an optional index in the target array to define where to start storing values
  3885. * @returns the current Color4 object
  3886. */
  3887. toArray(array: number[], index?: number): Color4;
  3888. /**
  3889. * Determines equality between Color4 objects
  3890. * @param otherColor defines the second operand
  3891. * @returns true if the rgba values are equal to the given ones
  3892. */
  3893. equals(otherColor: DeepImmutable<Color4>): boolean;
  3894. /**
  3895. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  3896. * @param right defines the second operand
  3897. * @returns a new Color4 object
  3898. */
  3899. add(right: DeepImmutable<Color4>): Color4;
  3900. /**
  3901. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  3902. * @param right defines the second operand
  3903. * @returns a new Color4 object
  3904. */
  3905. subtract(right: DeepImmutable<Color4>): Color4;
  3906. /**
  3907. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  3908. * @param right defines the second operand
  3909. * @param result defines the Color4 object where to store the result
  3910. * @returns the current Color4 object
  3911. */
  3912. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  3913. /**
  3914. * Creates a new Color4 with the current Color4 values multiplied by scale
  3915. * @param scale defines the scaling factor to apply
  3916. * @returns a new Color4 object
  3917. */
  3918. scale(scale: number): Color4;
  3919. /**
  3920. * Multiplies the current Color4 values by scale and stores the result in "result"
  3921. * @param scale defines the scaling factor to apply
  3922. * @param result defines the Color4 object where to store the result
  3923. * @returns the current unmodified Color4
  3924. */
  3925. scaleToRef(scale: number, result: Color4): Color4;
  3926. /**
  3927. * Scale the current Color4 values by a factor and add the result to a given Color4
  3928. * @param scale defines the scale factor
  3929. * @param result defines the Color4 object where to store the result
  3930. * @returns the unmodified current Color4
  3931. */
  3932. scaleAndAddToRef(scale: number, result: Color4): Color4;
  3933. /**
  3934. * Clamps the rgb values by the min and max values and stores the result into "result"
  3935. * @param min defines minimum clamping value (default is 0)
  3936. * @param max defines maximum clamping value (default is 1)
  3937. * @param result defines color to store the result into.
  3938. * @returns the cuurent Color4
  3939. */
  3940. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  3941. /**
  3942. * Multipy an Color4 value by another and return a new Color4 object
  3943. * @param color defines the Color4 value to multiply by
  3944. * @returns a new Color4 object
  3945. */
  3946. multiply(color: Color4): Color4;
  3947. /**
  3948. * Multipy a Color4 value by another and push the result in a reference value
  3949. * @param color defines the Color4 value to multiply by
  3950. * @param result defines the Color4 to fill the result in
  3951. * @returns the result Color4
  3952. */
  3953. multiplyToRef(color: Color4, result: Color4): Color4;
  3954. /**
  3955. * Creates a string with the Color4 current values
  3956. * @returns the string representation of the Color4 object
  3957. */
  3958. toString(): string;
  3959. /**
  3960. * Returns the string "Color4"
  3961. * @returns "Color4"
  3962. */
  3963. getClassName(): string;
  3964. /**
  3965. * Compute the Color4 hash code
  3966. * @returns an unique number that can be used to hash Color4 objects
  3967. */
  3968. getHashCode(): number;
  3969. /**
  3970. * Creates a new Color4 copied from the current one
  3971. * @returns a new Color4 object
  3972. */
  3973. clone(): Color4;
  3974. /**
  3975. * Copies the given Color4 values into the current one
  3976. * @param source defines the source Color4 object
  3977. * @returns the current updated Color4 object
  3978. */
  3979. copyFrom(source: Color4): Color4;
  3980. /**
  3981. * Copies the given float values into the current one
  3982. * @param r defines the red component to read from
  3983. * @param g defines the green component to read from
  3984. * @param b defines the blue component to read from
  3985. * @param a defines the alpha component to read from
  3986. * @returns the current updated Color4 object
  3987. */
  3988. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  3989. /**
  3990. * Copies the given float values into the current one
  3991. * @param r defines the red component to read from
  3992. * @param g defines the green component to read from
  3993. * @param b defines the blue component to read from
  3994. * @param a defines the alpha component to read from
  3995. * @returns the current updated Color4 object
  3996. */
  3997. set(r: number, g: number, b: number, a: number): Color4;
  3998. /**
  3999. * Compute the Color4 hexadecimal code as a string
  4000. * @returns a string containing the hexadecimal representation of the Color4 object
  4001. */
  4002. toHexString(): string;
  4003. /**
  4004. * Computes a new Color4 converted from the current one to linear space
  4005. * @returns a new Color4 object
  4006. */
  4007. toLinearSpace(): Color4;
  4008. /**
  4009. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  4010. * @param convertedColor defines the Color4 object where to store the linear space version
  4011. * @returns the unmodified Color4
  4012. */
  4013. toLinearSpaceToRef(convertedColor: Color4): Color4;
  4014. /**
  4015. * Computes a new Color4 converted from the current one to gamma space
  4016. * @returns a new Color4 object
  4017. */
  4018. toGammaSpace(): Color4;
  4019. /**
  4020. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  4021. * @param convertedColor defines the Color4 object where to store the gamma space version
  4022. * @returns the unmodified Color4
  4023. */
  4024. toGammaSpaceToRef(convertedColor: Color4): Color4;
  4025. /**
  4026. * Creates a new Color4 from the string containing valid hexadecimal values
  4027. * @param hex defines a string containing valid hexadecimal values
  4028. * @returns a new Color4 object
  4029. */
  4030. static FromHexString(hex: string): Color4;
  4031. /**
  4032. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4033. * @param left defines the start value
  4034. * @param right defines the end value
  4035. * @param amount defines the gradient factor
  4036. * @returns a new Color4 object
  4037. */
  4038. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  4039. /**
  4040. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4041. * @param left defines the start value
  4042. * @param right defines the end value
  4043. * @param amount defines the gradient factor
  4044. * @param result defines the Color4 object where to store data
  4045. */
  4046. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  4047. /**
  4048. * Creates a new Color4 from a Color3 and an alpha value
  4049. * @param color3 defines the source Color3 to read from
  4050. * @param alpha defines the alpha component (1.0 by default)
  4051. * @returns a new Color4 object
  4052. */
  4053. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  4054. /**
  4055. * Creates a new Color4 from the starting index element of the given array
  4056. * @param array defines the source array to read from
  4057. * @param offset defines the offset in the source array
  4058. * @returns a new Color4 object
  4059. */
  4060. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  4061. /**
  4062. * Creates a new Color3 from integer values (< 256)
  4063. * @param r defines the red component to read from (value between 0 and 255)
  4064. * @param g defines the green component to read from (value between 0 and 255)
  4065. * @param b defines the blue component to read from (value between 0 and 255)
  4066. * @param a defines the alpha component to read from (value between 0 and 255)
  4067. * @returns a new Color3 object
  4068. */
  4069. static FromInts(r: number, g: number, b: number, a: number): Color4;
  4070. /**
  4071. * Check the content of a given array and convert it to an array containing RGBA data
  4072. * If the original array was already containing count * 4 values then it is returned directly
  4073. * @param colors defines the array to check
  4074. * @param count defines the number of RGBA data to expect
  4075. * @returns an array containing count * 4 values (RGBA)
  4076. */
  4077. static CheckColors4(colors: number[], count: number): number[];
  4078. }
  4079. /**
  4080. * @hidden
  4081. */
  4082. export class TmpColors {
  4083. static Color3: Color3[];
  4084. static Color4: Color4[];
  4085. }
  4086. }
  4087. declare module BABYLON {
  4088. /**
  4089. * Class representing spherical harmonics coefficients to the 3rd degree
  4090. */
  4091. export class SphericalHarmonics {
  4092. /**
  4093. * Defines whether or not the harmonics have been prescaled for rendering.
  4094. */
  4095. preScaled: boolean;
  4096. /**
  4097. * The l0,0 coefficients of the spherical harmonics
  4098. */
  4099. l00: Vector3;
  4100. /**
  4101. * The l1,-1 coefficients of the spherical harmonics
  4102. */
  4103. l1_1: Vector3;
  4104. /**
  4105. * The l1,0 coefficients of the spherical harmonics
  4106. */
  4107. l10: Vector3;
  4108. /**
  4109. * The l1,1 coefficients of the spherical harmonics
  4110. */
  4111. l11: Vector3;
  4112. /**
  4113. * The l2,-2 coefficients of the spherical harmonics
  4114. */
  4115. l2_2: Vector3;
  4116. /**
  4117. * The l2,-1 coefficients of the spherical harmonics
  4118. */
  4119. l2_1: Vector3;
  4120. /**
  4121. * The l2,0 coefficients of the spherical harmonics
  4122. */
  4123. l20: Vector3;
  4124. /**
  4125. * The l2,1 coefficients of the spherical harmonics
  4126. */
  4127. l21: Vector3;
  4128. /**
  4129. * The l2,2 coefficients of the spherical harmonics
  4130. */
  4131. l22: Vector3;
  4132. /**
  4133. * Adds a light to the spherical harmonics
  4134. * @param direction the direction of the light
  4135. * @param color the color of the light
  4136. * @param deltaSolidAngle the delta solid angle of the light
  4137. */
  4138. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  4139. /**
  4140. * Scales the spherical harmonics by the given amount
  4141. * @param scale the amount to scale
  4142. */
  4143. scaleInPlace(scale: number): void;
  4144. /**
  4145. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  4146. *
  4147. * ```
  4148. * E_lm = A_l * L_lm
  4149. * ```
  4150. *
  4151. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  4152. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  4153. * the scaling factors are given in equation 9.
  4154. */
  4155. convertIncidentRadianceToIrradiance(): void;
  4156. /**
  4157. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  4158. *
  4159. * ```
  4160. * L = (1/pi) * E * rho
  4161. * ```
  4162. *
  4163. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  4164. */
  4165. convertIrradianceToLambertianRadiance(): void;
  4166. /**
  4167. * Integrates the reconstruction coefficients directly in to the SH preventing further
  4168. * required operations at run time.
  4169. *
  4170. * This is simply done by scaling back the SH with Ylm constants parameter.
  4171. * The trigonometric part being applied by the shader at run time.
  4172. */
  4173. preScaleForRendering(): void;
  4174. /**
  4175. * Constructs a spherical harmonics from an array.
  4176. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  4177. * @returns the spherical harmonics
  4178. */
  4179. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  4180. /**
  4181. * Gets the spherical harmonics from polynomial
  4182. * @param polynomial the spherical polynomial
  4183. * @returns the spherical harmonics
  4184. */
  4185. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  4186. }
  4187. /**
  4188. * Class representing spherical polynomial coefficients to the 3rd degree
  4189. */
  4190. export class SphericalPolynomial {
  4191. private _harmonics;
  4192. /**
  4193. * The spherical harmonics used to create the polynomials.
  4194. */
  4195. readonly preScaledHarmonics: SphericalHarmonics;
  4196. /**
  4197. * The x coefficients of the spherical polynomial
  4198. */
  4199. x: Vector3;
  4200. /**
  4201. * The y coefficients of the spherical polynomial
  4202. */
  4203. y: Vector3;
  4204. /**
  4205. * The z coefficients of the spherical polynomial
  4206. */
  4207. z: Vector3;
  4208. /**
  4209. * The xx coefficients of the spherical polynomial
  4210. */
  4211. xx: Vector3;
  4212. /**
  4213. * The yy coefficients of the spherical polynomial
  4214. */
  4215. yy: Vector3;
  4216. /**
  4217. * The zz coefficients of the spherical polynomial
  4218. */
  4219. zz: Vector3;
  4220. /**
  4221. * The xy coefficients of the spherical polynomial
  4222. */
  4223. xy: Vector3;
  4224. /**
  4225. * The yz coefficients of the spherical polynomial
  4226. */
  4227. yz: Vector3;
  4228. /**
  4229. * The zx coefficients of the spherical polynomial
  4230. */
  4231. zx: Vector3;
  4232. /**
  4233. * Adds an ambient color to the spherical polynomial
  4234. * @param color the color to add
  4235. */
  4236. addAmbient(color: Color3): void;
  4237. /**
  4238. * Scales the spherical polynomial by the given amount
  4239. * @param scale the amount to scale
  4240. */
  4241. scaleInPlace(scale: number): void;
  4242. /**
  4243. * Gets the spherical polynomial from harmonics
  4244. * @param harmonics the spherical harmonics
  4245. * @returns the spherical polynomial
  4246. */
  4247. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  4248. /**
  4249. * Constructs a spherical polynomial from an array.
  4250. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  4251. * @returns the spherical polynomial
  4252. */
  4253. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  4254. }
  4255. }
  4256. declare module BABYLON {
  4257. /**
  4258. * Define options used to create a render target texture
  4259. */
  4260. export class RenderTargetCreationOptions {
  4261. /**
  4262. * Specifies is mipmaps must be generated
  4263. */
  4264. generateMipMaps?: boolean;
  4265. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  4266. generateDepthBuffer?: boolean;
  4267. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  4268. generateStencilBuffer?: boolean;
  4269. /** Defines texture type (int by default) */
  4270. type?: number;
  4271. /** Defines sampling mode (trilinear by default) */
  4272. samplingMode?: number;
  4273. /** Defines format (RGBA by default) */
  4274. format?: number;
  4275. }
  4276. }
  4277. declare module BABYLON {
  4278. /**
  4279. * @hidden
  4280. **/
  4281. export class _AlphaState {
  4282. private _isAlphaBlendDirty;
  4283. private _isBlendFunctionParametersDirty;
  4284. private _isBlendEquationParametersDirty;
  4285. private _isBlendConstantsDirty;
  4286. private _alphaBlend;
  4287. private _blendFunctionParameters;
  4288. private _blendEquationParameters;
  4289. private _blendConstants;
  4290. /**
  4291. * Initializes the state.
  4292. */
  4293. constructor();
  4294. readonly isDirty: boolean;
  4295. alphaBlend: boolean;
  4296. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  4297. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  4298. setAlphaEquationParameters(rgb: number, alpha: number): void;
  4299. reset(): void;
  4300. apply(gl: WebGLRenderingContext): void;
  4301. }
  4302. }
  4303. declare module BABYLON {
  4304. /**
  4305. * @hidden
  4306. **/
  4307. export class _DepthCullingState {
  4308. private _isDepthTestDirty;
  4309. private _isDepthMaskDirty;
  4310. private _isDepthFuncDirty;
  4311. private _isCullFaceDirty;
  4312. private _isCullDirty;
  4313. private _isZOffsetDirty;
  4314. private _isFrontFaceDirty;
  4315. private _depthTest;
  4316. private _depthMask;
  4317. private _depthFunc;
  4318. private _cull;
  4319. private _cullFace;
  4320. private _zOffset;
  4321. private _frontFace;
  4322. /**
  4323. * Initializes the state.
  4324. */
  4325. constructor();
  4326. readonly isDirty: boolean;
  4327. zOffset: number;
  4328. cullFace: Nullable<number>;
  4329. cull: Nullable<boolean>;
  4330. depthFunc: Nullable<number>;
  4331. depthMask: boolean;
  4332. depthTest: boolean;
  4333. frontFace: Nullable<number>;
  4334. reset(): void;
  4335. apply(gl: WebGLRenderingContext): void;
  4336. }
  4337. }
  4338. declare module BABYLON {
  4339. /** Defines the cross module used constants to avoid circular dependncies */
  4340. export class Constants {
  4341. /** Defines that alpha blending is disabled */
  4342. static readonly ALPHA_DISABLE: number;
  4343. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4344. static readonly ALPHA_ADD: number;
  4345. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4346. static readonly ALPHA_COMBINE: number;
  4347. /** Defines that alpha blending to DEST - SRC * DEST */
  4348. static readonly ALPHA_SUBTRACT: number;
  4349. /** Defines that alpha blending to SRC * DEST */
  4350. static readonly ALPHA_MULTIPLY: number;
  4351. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4352. static readonly ALPHA_MAXIMIZED: number;
  4353. /** Defines that alpha blending to SRC + DEST */
  4354. static readonly ALPHA_ONEONE: number;
  4355. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4356. static readonly ALPHA_PREMULTIPLIED: number;
  4357. /**
  4358. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4359. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4360. */
  4361. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4362. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4363. static readonly ALPHA_INTERPOLATE: number;
  4364. /**
  4365. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4366. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4367. */
  4368. static readonly ALPHA_SCREENMODE: number;
  4369. /**
  4370. * Defines that alpha blending to SRC + DST
  4371. * Alpha will be set to SRC ALPHA + DST ALPHA
  4372. */
  4373. static readonly ALPHA_ONEONE_ONEONE: number;
  4374. /**
  4375. * Defines that alpha blending to SRC * DST ALPHA + DST
  4376. * Alpha will be set to 0
  4377. */
  4378. static readonly ALPHA_ALPHATOCOLOR: number;
  4379. /**
  4380. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  4381. */
  4382. static readonly ALPHA_REVERSEONEMINUS: number;
  4383. /**
  4384. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  4385. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  4386. */
  4387. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  4388. /**
  4389. * Defines that alpha blending to SRC + DST
  4390. * Alpha will be set to SRC ALPHA
  4391. */
  4392. static readonly ALPHA_ONEONE_ONEZERO: number;
  4393. /** Defines that alpha blending equation a SUM */
  4394. static readonly ALPHA_EQUATION_ADD: number;
  4395. /** Defines that alpha blending equation a SUBSTRACTION */
  4396. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  4397. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  4398. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  4399. /** Defines that alpha blending equation a MAX operation */
  4400. static readonly ALPHA_EQUATION_MAX: number;
  4401. /** Defines that alpha blending equation a MIN operation */
  4402. static readonly ALPHA_EQUATION_MIN: number;
  4403. /**
  4404. * Defines that alpha blending equation a DARKEN operation:
  4405. * It takes the min of the src and sums the alpha channels.
  4406. */
  4407. static readonly ALPHA_EQUATION_DARKEN: number;
  4408. /** Defines that the ressource is not delayed*/
  4409. static readonly DELAYLOADSTATE_NONE: number;
  4410. /** Defines that the ressource was successfully delay loaded */
  4411. static readonly DELAYLOADSTATE_LOADED: number;
  4412. /** Defines that the ressource is currently delay loading */
  4413. static readonly DELAYLOADSTATE_LOADING: number;
  4414. /** Defines that the ressource is delayed and has not started loading */
  4415. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4416. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4417. static readonly NEVER: number;
  4418. /** 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 */
  4419. static readonly ALWAYS: number;
  4420. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4421. static readonly LESS: number;
  4422. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4423. static readonly EQUAL: number;
  4424. /** 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 */
  4425. static readonly LEQUAL: number;
  4426. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4427. static readonly GREATER: number;
  4428. /** 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 */
  4429. static readonly GEQUAL: number;
  4430. /** 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 */
  4431. static readonly NOTEQUAL: number;
  4432. /** Passed to stencilOperation to specify that stencil value must be kept */
  4433. static readonly KEEP: number;
  4434. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4435. static readonly REPLACE: number;
  4436. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4437. static readonly INCR: number;
  4438. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4439. static readonly DECR: number;
  4440. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4441. static readonly INVERT: number;
  4442. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4443. static readonly INCR_WRAP: number;
  4444. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4445. static readonly DECR_WRAP: number;
  4446. /** Texture is not repeating outside of 0..1 UVs */
  4447. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4448. /** Texture is repeating outside of 0..1 UVs */
  4449. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4450. /** Texture is repeating and mirrored */
  4451. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4452. /** ALPHA */
  4453. static readonly TEXTUREFORMAT_ALPHA: number;
  4454. /** LUMINANCE */
  4455. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4456. /** LUMINANCE_ALPHA */
  4457. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4458. /** RGB */
  4459. static readonly TEXTUREFORMAT_RGB: number;
  4460. /** RGBA */
  4461. static readonly TEXTUREFORMAT_RGBA: number;
  4462. /** RED */
  4463. static readonly TEXTUREFORMAT_RED: number;
  4464. /** RED (2nd reference) */
  4465. static readonly TEXTUREFORMAT_R: number;
  4466. /** RG */
  4467. static readonly TEXTUREFORMAT_RG: number;
  4468. /** RED_INTEGER */
  4469. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4470. /** RED_INTEGER (2nd reference) */
  4471. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4472. /** RG_INTEGER */
  4473. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4474. /** RGB_INTEGER */
  4475. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4476. /** RGBA_INTEGER */
  4477. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4478. /** UNSIGNED_BYTE */
  4479. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4480. /** UNSIGNED_BYTE (2nd reference) */
  4481. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4482. /** FLOAT */
  4483. static readonly TEXTURETYPE_FLOAT: number;
  4484. /** HALF_FLOAT */
  4485. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4486. /** BYTE */
  4487. static readonly TEXTURETYPE_BYTE: number;
  4488. /** SHORT */
  4489. static readonly TEXTURETYPE_SHORT: number;
  4490. /** UNSIGNED_SHORT */
  4491. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4492. /** INT */
  4493. static readonly TEXTURETYPE_INT: number;
  4494. /** UNSIGNED_INT */
  4495. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4496. /** UNSIGNED_SHORT_4_4_4_4 */
  4497. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4498. /** UNSIGNED_SHORT_5_5_5_1 */
  4499. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4500. /** UNSIGNED_SHORT_5_6_5 */
  4501. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4502. /** UNSIGNED_INT_2_10_10_10_REV */
  4503. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4504. /** UNSIGNED_INT_24_8 */
  4505. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4506. /** UNSIGNED_INT_10F_11F_11F_REV */
  4507. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4508. /** UNSIGNED_INT_5_9_9_9_REV */
  4509. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4510. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4511. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4512. /** nearest is mag = nearest and min = nearest and mip = linear */
  4513. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4514. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4515. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4516. /** Trilinear is mag = linear and min = linear and mip = linear */
  4517. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4518. /** nearest is mag = nearest and min = nearest and mip = linear */
  4519. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4520. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4521. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4522. /** Trilinear is mag = linear and min = linear and mip = linear */
  4523. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4524. /** mag = nearest and min = nearest and mip = nearest */
  4525. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4526. /** mag = nearest and min = linear and mip = nearest */
  4527. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4528. /** mag = nearest and min = linear and mip = linear */
  4529. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4530. /** mag = nearest and min = linear and mip = none */
  4531. static readonly TEXTURE_NEAREST_LINEAR: number;
  4532. /** mag = nearest and min = nearest and mip = none */
  4533. static readonly TEXTURE_NEAREST_NEAREST: number;
  4534. /** mag = linear and min = nearest and mip = nearest */
  4535. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4536. /** mag = linear and min = nearest and mip = linear */
  4537. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4538. /** mag = linear and min = linear and mip = none */
  4539. static readonly TEXTURE_LINEAR_LINEAR: number;
  4540. /** mag = linear and min = nearest and mip = none */
  4541. static readonly TEXTURE_LINEAR_NEAREST: number;
  4542. /** Explicit coordinates mode */
  4543. static readonly TEXTURE_EXPLICIT_MODE: number;
  4544. /** Spherical coordinates mode */
  4545. static readonly TEXTURE_SPHERICAL_MODE: number;
  4546. /** Planar coordinates mode */
  4547. static readonly TEXTURE_PLANAR_MODE: number;
  4548. /** Cubic coordinates mode */
  4549. static readonly TEXTURE_CUBIC_MODE: number;
  4550. /** Projection coordinates mode */
  4551. static readonly TEXTURE_PROJECTION_MODE: number;
  4552. /** Skybox coordinates mode */
  4553. static readonly TEXTURE_SKYBOX_MODE: number;
  4554. /** Inverse Cubic coordinates mode */
  4555. static readonly TEXTURE_INVCUBIC_MODE: number;
  4556. /** Equirectangular coordinates mode */
  4557. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4558. /** Equirectangular Fixed coordinates mode */
  4559. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4560. /** Equirectangular Fixed Mirrored coordinates mode */
  4561. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4562. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4563. static readonly SCALEMODE_FLOOR: number;
  4564. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4565. static readonly SCALEMODE_NEAREST: number;
  4566. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4567. static readonly SCALEMODE_CEILING: number;
  4568. /**
  4569. * The dirty texture flag value
  4570. */
  4571. static readonly MATERIAL_TextureDirtyFlag: number;
  4572. /**
  4573. * The dirty light flag value
  4574. */
  4575. static readonly MATERIAL_LightDirtyFlag: number;
  4576. /**
  4577. * The dirty fresnel flag value
  4578. */
  4579. static readonly MATERIAL_FresnelDirtyFlag: number;
  4580. /**
  4581. * The dirty attribute flag value
  4582. */
  4583. static readonly MATERIAL_AttributesDirtyFlag: number;
  4584. /**
  4585. * The dirty misc flag value
  4586. */
  4587. static readonly MATERIAL_MiscDirtyFlag: number;
  4588. /**
  4589. * The all dirty flag value
  4590. */
  4591. static readonly MATERIAL_AllDirtyFlag: number;
  4592. /**
  4593. * Returns the triangle fill mode
  4594. */
  4595. static readonly MATERIAL_TriangleFillMode: number;
  4596. /**
  4597. * Returns the wireframe mode
  4598. */
  4599. static readonly MATERIAL_WireFrameFillMode: number;
  4600. /**
  4601. * Returns the point fill mode
  4602. */
  4603. static readonly MATERIAL_PointFillMode: number;
  4604. /**
  4605. * Returns the point list draw mode
  4606. */
  4607. static readonly MATERIAL_PointListDrawMode: number;
  4608. /**
  4609. * Returns the line list draw mode
  4610. */
  4611. static readonly MATERIAL_LineListDrawMode: number;
  4612. /**
  4613. * Returns the line loop draw mode
  4614. */
  4615. static readonly MATERIAL_LineLoopDrawMode: number;
  4616. /**
  4617. * Returns the line strip draw mode
  4618. */
  4619. static readonly MATERIAL_LineStripDrawMode: number;
  4620. /**
  4621. * Returns the triangle strip draw mode
  4622. */
  4623. static readonly MATERIAL_TriangleStripDrawMode: number;
  4624. /**
  4625. * Returns the triangle fan draw mode
  4626. */
  4627. static readonly MATERIAL_TriangleFanDrawMode: number;
  4628. /**
  4629. * Stores the clock-wise side orientation
  4630. */
  4631. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4632. /**
  4633. * Stores the counter clock-wise side orientation
  4634. */
  4635. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4636. /**
  4637. * Nothing
  4638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4639. */
  4640. static readonly ACTION_NothingTrigger: number;
  4641. /**
  4642. * On pick
  4643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4644. */
  4645. static readonly ACTION_OnPickTrigger: number;
  4646. /**
  4647. * On left pick
  4648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4649. */
  4650. static readonly ACTION_OnLeftPickTrigger: number;
  4651. /**
  4652. * On right pick
  4653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4654. */
  4655. static readonly ACTION_OnRightPickTrigger: number;
  4656. /**
  4657. * On center pick
  4658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4659. */
  4660. static readonly ACTION_OnCenterPickTrigger: number;
  4661. /**
  4662. * On pick down
  4663. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4664. */
  4665. static readonly ACTION_OnPickDownTrigger: number;
  4666. /**
  4667. * On double pick
  4668. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4669. */
  4670. static readonly ACTION_OnDoublePickTrigger: number;
  4671. /**
  4672. * On pick up
  4673. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4674. */
  4675. static readonly ACTION_OnPickUpTrigger: number;
  4676. /**
  4677. * On pick out.
  4678. * This trigger will only be raised if you also declared a OnPickDown
  4679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4680. */
  4681. static readonly ACTION_OnPickOutTrigger: number;
  4682. /**
  4683. * On long press
  4684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4685. */
  4686. static readonly ACTION_OnLongPressTrigger: number;
  4687. /**
  4688. * On pointer over
  4689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4690. */
  4691. static readonly ACTION_OnPointerOverTrigger: number;
  4692. /**
  4693. * On pointer out
  4694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4695. */
  4696. static readonly ACTION_OnPointerOutTrigger: number;
  4697. /**
  4698. * On every frame
  4699. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4700. */
  4701. static readonly ACTION_OnEveryFrameTrigger: number;
  4702. /**
  4703. * On intersection enter
  4704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4705. */
  4706. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4707. /**
  4708. * On intersection exit
  4709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4710. */
  4711. static readonly ACTION_OnIntersectionExitTrigger: number;
  4712. /**
  4713. * On key down
  4714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4715. */
  4716. static readonly ACTION_OnKeyDownTrigger: number;
  4717. /**
  4718. * On key up
  4719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4720. */
  4721. static readonly ACTION_OnKeyUpTrigger: number;
  4722. /**
  4723. * Billboard mode will only apply to Y axis
  4724. */
  4725. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4726. /**
  4727. * Billboard mode will apply to all axes
  4728. */
  4729. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4730. /**
  4731. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4732. */
  4733. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4734. /**
  4735. * Gets or sets base Assets URL
  4736. */
  4737. static PARTICLES_BaseAssetsUrl: string;
  4738. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4739. * Test order :
  4740. * Is the bounding sphere outside the frustum ?
  4741. * If not, are the bounding box vertices outside the frustum ?
  4742. * It not, then the cullable object is in the frustum.
  4743. */
  4744. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4745. /** Culling strategy : Bounding Sphere Only.
  4746. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4747. * It's also less accurate than the standard because some not visible objects can still be selected.
  4748. * Test : is the bounding sphere outside the frustum ?
  4749. * If not, then the cullable object is in the frustum.
  4750. */
  4751. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4752. /** Culling strategy : Optimistic Inclusion.
  4753. * This in an inclusion test first, then the standard exclusion test.
  4754. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4755. * 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.
  4756. * Anyway, it's as accurate as the standard strategy.
  4757. * Test :
  4758. * Is the cullable object bounding sphere center in the frustum ?
  4759. * If not, apply the default culling strategy.
  4760. */
  4761. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4762. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4763. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4764. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4765. * 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.
  4766. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4767. * Test :
  4768. * Is the cullable object bounding sphere center in the frustum ?
  4769. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4770. */
  4771. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4772. /**
  4773. * No logging while loading
  4774. */
  4775. static readonly SCENELOADER_NO_LOGGING: number;
  4776. /**
  4777. * Minimal logging while loading
  4778. */
  4779. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4780. /**
  4781. * Summary logging while loading
  4782. */
  4783. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4784. /**
  4785. * Detailled logging while loading
  4786. */
  4787. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4788. }
  4789. }
  4790. declare module BABYLON {
  4791. /**
  4792. * @hidden
  4793. **/
  4794. export class _StencilState {
  4795. /** 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 */
  4796. static readonly ALWAYS: number;
  4797. /** Passed to stencilOperation to specify that stencil value must be kept */
  4798. static readonly KEEP: number;
  4799. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4800. static readonly REPLACE: number;
  4801. private _isStencilTestDirty;
  4802. private _isStencilMaskDirty;
  4803. private _isStencilFuncDirty;
  4804. private _isStencilOpDirty;
  4805. private _stencilTest;
  4806. private _stencilMask;
  4807. private _stencilFunc;
  4808. private _stencilFuncRef;
  4809. private _stencilFuncMask;
  4810. private _stencilOpStencilFail;
  4811. private _stencilOpDepthFail;
  4812. private _stencilOpStencilDepthPass;
  4813. readonly isDirty: boolean;
  4814. stencilFunc: number;
  4815. stencilFuncRef: number;
  4816. stencilFuncMask: number;
  4817. stencilOpStencilFail: number;
  4818. stencilOpDepthFail: number;
  4819. stencilOpStencilDepthPass: number;
  4820. stencilMask: number;
  4821. stencilTest: boolean;
  4822. constructor();
  4823. reset(): void;
  4824. apply(gl: WebGLRenderingContext): void;
  4825. }
  4826. }
  4827. declare module BABYLON {
  4828. /**
  4829. * @hidden
  4830. **/
  4831. export class _TimeToken { private _startTimeQuery: Nullable<WebGLQuery>; private _endTimeQuery: Nullable<WebGLQuery>; private _timeElapsedQuery: Nullable<WebGLQuery>; private _timeElapsedQueryEnded: boolean;
  4832. }
  4833. }
  4834. declare module BABYLON {
  4835. /**
  4836. * This represents the required contract to create a new type of texture loader.
  4837. */
  4838. export interface IInternalTextureLoader {
  4839. /**
  4840. * Defines wether the loader supports cascade loading the different faces.
  4841. */
  4842. supportCascades: boolean;
  4843. /**
  4844. * This returns if the loader support the current file information.
  4845. * @param extension defines the file extension of the file being loaded
  4846. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4847. * @param fallback defines the fallback internal texture if any
  4848. * @param isBase64 defines whether the texture is encoded as a base64
  4849. * @param isBuffer defines whether the texture data are stored as a buffer
  4850. * @returns true if the loader can load the specified file
  4851. */
  4852. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  4853. /**
  4854. * Transform the url before loading if required.
  4855. * @param rootUrl the url of the texture
  4856. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4857. * @returns the transformed texture
  4858. */
  4859. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  4860. /**
  4861. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  4862. * @param rootUrl the url of the texture
  4863. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4864. * @returns the fallback texture
  4865. */
  4866. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  4867. /**
  4868. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  4869. * @param data contains the texture data
  4870. * @param texture defines the BabylonJS internal texture
  4871. * @param createPolynomials will be true if polynomials have been requested
  4872. * @param onLoad defines the callback to trigger once the texture is ready
  4873. * @param onError defines the callback to trigger in case of error
  4874. */
  4875. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  4876. /**
  4877. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  4878. * @param data contains the texture data
  4879. * @param texture defines the BabylonJS internal texture
  4880. * @param callback defines the method to call once ready to upload
  4881. */
  4882. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  4883. }
  4884. }
  4885. declare module BABYLON {
  4886. /**
  4887. * Class used to store and describe the pipeline context associated with an effect
  4888. */
  4889. export interface IPipelineContext {
  4890. /**
  4891. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4892. */
  4893. isAsync: boolean;
  4894. /**
  4895. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4896. */
  4897. isReady: boolean;
  4898. /** @hidden */ private _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4899. }
  4900. }
  4901. declare module BABYLON {
  4902. /**
  4903. * Class used to store gfx data (like WebGLBuffer)
  4904. */
  4905. export class DataBuffer {
  4906. /**
  4907. * Gets or sets the number of objects referencing this buffer
  4908. */
  4909. references: number;
  4910. /** Gets or sets the size of the underlying buffer */
  4911. capacity: number;
  4912. /**
  4913. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  4914. */
  4915. is32Bits: boolean;
  4916. /**
  4917. * Gets the underlying buffer
  4918. */
  4919. readonly underlyingResource: any;
  4920. }
  4921. }
  4922. declare module BABYLON {
  4923. /** @hidden */
  4924. export interface IShaderProcessor {
  4925. attributeProcessor?: (attribute: string) => string;
  4926. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4927. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4928. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4929. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4930. lineProcessor?: (line: string, isFragment: boolean) => string;
  4931. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4932. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4933. }
  4934. }
  4935. declare module BABYLON {
  4936. /** @hidden */
  4937. export interface ProcessingOptions {
  4938. defines: string[];
  4939. indexParameters: any;
  4940. isFragment: boolean;
  4941. shouldUseHighPrecisionShader: boolean;
  4942. supportsUniformBuffers: boolean;
  4943. shadersRepository: string;
  4944. includesShadersStore: {
  4945. [key: string]: string;
  4946. };
  4947. processor?: IShaderProcessor;
  4948. version: string;
  4949. platformName: string;
  4950. lookForClosingBracketForUniformBuffer?: boolean;
  4951. }
  4952. }
  4953. declare module BABYLON {
  4954. /**
  4955. * Helper to manipulate strings
  4956. */
  4957. export class StringTools {
  4958. /**
  4959. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4960. * @param str Source string
  4961. * @param suffix Suffix to search for in the source string
  4962. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4963. */
  4964. static EndsWith(str: string, suffix: string): boolean;
  4965. /**
  4966. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4967. * @param str Source string
  4968. * @param suffix Suffix to search for in the source string
  4969. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4970. */
  4971. static StartsWith(str: string, suffix: string): boolean;
  4972. }
  4973. }
  4974. declare module BABYLON {
  4975. /** @hidden */
  4976. export class ShaderCodeNode {
  4977. line: string;
  4978. children: ShaderCodeNode[];
  4979. additionalDefineKey?: string;
  4980. additionalDefineValue?: string;
  4981. isValid(preprocessors: {
  4982. [key: string]: string;
  4983. }): boolean;
  4984. process(preprocessors: {
  4985. [key: string]: string;
  4986. }, options: ProcessingOptions): string;
  4987. }
  4988. }
  4989. declare module BABYLON {
  4990. /** @hidden */
  4991. export class ShaderCodeCursor {
  4992. private _lines;
  4993. lineIndex: number;
  4994. readonly currentLine: string;
  4995. readonly canRead: boolean;
  4996. lines: string[];
  4997. }
  4998. }
  4999. declare module BABYLON {
  5000. /** @hidden */
  5001. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5002. process(preprocessors: {
  5003. [key: string]: string;
  5004. }, options: ProcessingOptions): string;
  5005. }
  5006. }
  5007. declare module BABYLON {
  5008. /** @hidden */
  5009. export class ShaderDefineExpression {
  5010. isTrue(preprocessors: {
  5011. [key: string]: string;
  5012. }): boolean;
  5013. }
  5014. }
  5015. declare module BABYLON {
  5016. /** @hidden */
  5017. export class ShaderCodeTestNode extends ShaderCodeNode {
  5018. testExpression: ShaderDefineExpression;
  5019. isValid(preprocessors: {
  5020. [key: string]: string;
  5021. }): boolean;
  5022. }
  5023. }
  5024. declare module BABYLON {
  5025. /** @hidden */
  5026. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5027. define: string;
  5028. not: boolean;
  5029. constructor(define: string, not?: boolean);
  5030. isTrue(preprocessors: {
  5031. [key: string]: string;
  5032. }): boolean;
  5033. }
  5034. }
  5035. declare module BABYLON {
  5036. /** @hidden */
  5037. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5038. leftOperand: ShaderDefineExpression;
  5039. rightOperand: ShaderDefineExpression;
  5040. isTrue(preprocessors: {
  5041. [key: string]: string;
  5042. }): boolean;
  5043. }
  5044. }
  5045. declare module BABYLON {
  5046. /** @hidden */
  5047. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5048. leftOperand: ShaderDefineExpression;
  5049. rightOperand: ShaderDefineExpression;
  5050. isTrue(preprocessors: {
  5051. [key: string]: string;
  5052. }): boolean;
  5053. }
  5054. }
  5055. declare module BABYLON {
  5056. /** @hidden */
  5057. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5058. define: string;
  5059. operand: string;
  5060. testValue: string;
  5061. constructor(define: string, operand: string, testValue: string);
  5062. isTrue(preprocessors: {
  5063. [key: string]: string;
  5064. }): boolean;
  5065. }
  5066. }
  5067. declare module BABYLON {
  5068. /**
  5069. * @ignore
  5070. * Application error to support additional information when loading a file
  5071. */
  5072. export class LoadFileError extends Error {
  5073. /** defines the optional web request */
  5074. request?: WebRequest | undefined;
  5075. private static _setPrototypeOf;
  5076. /**
  5077. * Creates a new LoadFileError
  5078. * @param message defines the message of the error
  5079. * @param request defines the optional web request
  5080. */
  5081. constructor(message: string,
  5082. /** defines the optional web request */
  5083. request?: WebRequest | undefined);
  5084. }
  5085. }
  5086. declare module BABYLON {
  5087. /**
  5088. * Class used to enable access to offline support
  5089. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  5090. */
  5091. export interface IOfflineProvider {
  5092. /**
  5093. * Gets a boolean indicating if scene must be saved in the database
  5094. */
  5095. enableSceneOffline: boolean;
  5096. /**
  5097. * Gets a boolean indicating if textures must be saved in the database
  5098. */
  5099. enableTexturesOffline: boolean;
  5100. /**
  5101. * Open the offline support and make it available
  5102. * @param successCallback defines the callback to call on success
  5103. * @param errorCallback defines the callback to call on error
  5104. */
  5105. open(successCallback: () => void, errorCallback: () => void): void;
  5106. /**
  5107. * Loads an image from the offline support
  5108. * @param url defines the url to load from
  5109. * @param image defines the target DOM image
  5110. */
  5111. loadImage(url: string, image: HTMLImageElement): void;
  5112. /**
  5113. * Loads a file from offline support
  5114. * @param url defines the URL to load from
  5115. * @param sceneLoaded defines a callback to call on success
  5116. * @param progressCallBack defines a callback to call when progress changed
  5117. * @param errorCallback defines a callback to call on error
  5118. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  5119. */
  5120. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  5121. }
  5122. }
  5123. declare module BABYLON {
  5124. /**
  5125. * Class used to help managing file picking and drag'n'drop
  5126. * File Storage
  5127. */
  5128. export class FilesInputStore {
  5129. /**
  5130. * List of files ready to be loaded
  5131. */
  5132. static FilesToLoad: {
  5133. [key: string]: File;
  5134. };
  5135. }
  5136. }
  5137. declare module BABYLON {
  5138. /**
  5139. * Class used to define a retry strategy when error happens while loading assets
  5140. */
  5141. export class RetryStrategy {
  5142. /**
  5143. * Function used to defines an exponential back off strategy
  5144. * @param maxRetries defines the maximum number of retries (3 by default)
  5145. * @param baseInterval defines the interval between retries
  5146. * @returns the strategy function to use
  5147. */
  5148. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  5149. }
  5150. }
  5151. declare module BABYLON {
  5152. /**
  5153. * @hidden
  5154. */
  5155. export class FileTools {
  5156. /**
  5157. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  5158. */
  5159. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  5160. /**
  5161. * Gets or sets the base URL to use to load assets
  5162. */
  5163. static BaseUrl: string;
  5164. /**
  5165. * Default behaviour for cors in the application.
  5166. * It can be a string if the expected behavior is identical in the entire app.
  5167. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  5168. */
  5169. static CorsBehavior: string | ((url: string | string[]) => string);
  5170. /**
  5171. * Gets or sets a function used to pre-process url before using them to load assets
  5172. */
  5173. static PreprocessUrl: (url: string) => string;
  5174. /**
  5175. * Removes unwanted characters from an url
  5176. * @param url defines the url to clean
  5177. * @returns the cleaned url
  5178. */
  5179. private static _CleanUrl;
  5180. /**
  5181. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  5182. * @param url define the url we are trying
  5183. * @param element define the dom element where to configure the cors policy
  5184. */
  5185. static SetCorsBehavior(url: string | string[], element: {
  5186. crossOrigin: string | null;
  5187. }): void;
  5188. /**
  5189. * Loads an image as an HTMLImageElement.
  5190. * @param input url string, ArrayBuffer, or Blob to load
  5191. * @param onLoad callback called when the image successfully loads
  5192. * @param onError callback called when the image fails to load
  5193. * @param offlineProvider offline provider for caching
  5194. * @returns the HTMLImageElement of the loaded image
  5195. */
  5196. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  5197. /**
  5198. * Loads a file
  5199. * @param fileToLoad defines the file to load
  5200. * @param callback defines the callback to call when data is loaded
  5201. * @param progressCallBack defines the callback to call during loading process
  5202. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  5203. * @returns a file request object
  5204. */
  5205. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  5206. /**
  5207. * Loads a file
  5208. * @param url url string, ArrayBuffer, or Blob to load
  5209. * @param onSuccess callback called when the file successfully loads
  5210. * @param onProgress callback called while file is loading (if the server supports this mode)
  5211. * @param offlineProvider defines the offline provider for caching
  5212. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  5213. * @param onError callback called when the file fails to load
  5214. * @returns a file request object
  5215. */
  5216. 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;
  5217. /**
  5218. * Checks if the loaded document was accessed via `file:`-Protocol.
  5219. * @returns boolean
  5220. */
  5221. static IsFileURL(): boolean;
  5222. }
  5223. }
  5224. declare module BABYLON {
  5225. /** @hidden */
  5226. export class ShaderProcessor {
  5227. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5228. private static _ProcessPrecision;
  5229. private static _ExtractOperation;
  5230. private static _BuildSubExpression;
  5231. private static _BuildExpression;
  5232. private static _MoveCursorWithinIf;
  5233. private static _MoveCursor;
  5234. private static _EvaluatePreProcessors;
  5235. private static _PreparePreProcessors;
  5236. private static _ProcessShaderConversion;
  5237. private static _ProcessIncludes;
  5238. }
  5239. }
  5240. declare module BABYLON {
  5241. /**
  5242. * Class used to evalaute queries containing `and` and `or` operators
  5243. */
  5244. export class AndOrNotEvaluator {
  5245. /**
  5246. * Evaluate a query
  5247. * @param query defines the query to evaluate
  5248. * @param evaluateCallback defines the callback used to filter result
  5249. * @returns true if the query matches
  5250. */
  5251. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5252. private static _HandleParenthesisContent;
  5253. private static _SimplifyNegation;
  5254. }
  5255. }
  5256. declare module BABYLON {
  5257. /**
  5258. * Class used to store custom tags
  5259. */
  5260. export class Tags {
  5261. /**
  5262. * Adds support for tags on the given object
  5263. * @param obj defines the object to use
  5264. */
  5265. static EnableFor(obj: any): void;
  5266. /**
  5267. * Removes tags support
  5268. * @param obj defines the object to use
  5269. */
  5270. static DisableFor(obj: any): void;
  5271. /**
  5272. * Gets a boolean indicating if the given object has tags
  5273. * @param obj defines the object to use
  5274. * @returns a boolean
  5275. */
  5276. static HasTags(obj: any): boolean;
  5277. /**
  5278. * Gets the tags available on a given object
  5279. * @param obj defines the object to use
  5280. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5281. * @returns the tags
  5282. */
  5283. static GetTags(obj: any, asString?: boolean): any;
  5284. /**
  5285. * Adds tags to an object
  5286. * @param obj defines the object to use
  5287. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5288. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5289. */
  5290. static AddTagsTo(obj: any, tagsString: string): void;
  5291. /**
  5292. * @hidden
  5293. */ private static _AddTagTo(obj: any, tag: string): void;
  5294. /**
  5295. * Removes specific tags from a specific object
  5296. * @param obj defines the object to use
  5297. * @param tagsString defines the tags to remove
  5298. */
  5299. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5300. /**
  5301. * @hidden
  5302. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5303. /**
  5304. * Defines if tags hosted on an object match a given query
  5305. * @param obj defines the object to use
  5306. * @param tagsQuery defines the tag query
  5307. * @returns a boolean
  5308. */
  5309. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5310. }
  5311. }
  5312. declare module BABYLON {
  5313. /**
  5314. * Defines potential orientation for back face culling
  5315. */
  5316. export enum Orientation {
  5317. /**
  5318. * Clockwise
  5319. */
  5320. CW = 0,
  5321. /** Counter clockwise */
  5322. CCW = 1
  5323. }
  5324. /** Class used to represent a Bezier curve */
  5325. export class BezierCurve {
  5326. /**
  5327. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5328. * @param t defines the time
  5329. * @param x1 defines the left coordinate on X axis
  5330. * @param y1 defines the left coordinate on Y axis
  5331. * @param x2 defines the right coordinate on X axis
  5332. * @param y2 defines the right coordinate on Y axis
  5333. * @returns the interpolated value
  5334. */
  5335. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5336. }
  5337. /**
  5338. * Defines angle representation
  5339. */
  5340. export class Angle {
  5341. private _radians;
  5342. /**
  5343. * Creates an Angle object of "radians" radians (float).
  5344. * @param radians the angle in radians
  5345. */
  5346. constructor(radians: number);
  5347. /**
  5348. * Get value in degrees
  5349. * @returns the Angle value in degrees (float)
  5350. */
  5351. degrees(): number;
  5352. /**
  5353. * Get value in radians
  5354. * @returns the Angle value in radians (float)
  5355. */
  5356. radians(): number;
  5357. /**
  5358. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5359. * @param a defines first vector
  5360. * @param b defines second vector
  5361. * @returns a new Angle
  5362. */
  5363. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5364. /**
  5365. * Gets a new Angle object from the given float in radians
  5366. * @param radians defines the angle value in radians
  5367. * @returns a new Angle
  5368. */
  5369. static FromRadians(radians: number): Angle;
  5370. /**
  5371. * Gets a new Angle object from the given float in degrees
  5372. * @param degrees defines the angle value in degrees
  5373. * @returns a new Angle
  5374. */
  5375. static FromDegrees(degrees: number): Angle;
  5376. }
  5377. /**
  5378. * This represents an arc in a 2d space.
  5379. */
  5380. export class Arc2 {
  5381. /** Defines the start point of the arc */
  5382. startPoint: Vector2;
  5383. /** Defines the mid point of the arc */
  5384. midPoint: Vector2;
  5385. /** Defines the end point of the arc */
  5386. endPoint: Vector2;
  5387. /**
  5388. * Defines the center point of the arc.
  5389. */
  5390. centerPoint: Vector2;
  5391. /**
  5392. * Defines the radius of the arc.
  5393. */
  5394. radius: number;
  5395. /**
  5396. * Defines the angle of the arc (from mid point to end point).
  5397. */
  5398. angle: Angle;
  5399. /**
  5400. * Defines the start angle of the arc (from start point to middle point).
  5401. */
  5402. startAngle: Angle;
  5403. /**
  5404. * Defines the orientation of the arc (clock wise/counter clock wise).
  5405. */
  5406. orientation: Orientation;
  5407. /**
  5408. * Creates an Arc object from the three given points : start, middle and end.
  5409. * @param startPoint Defines the start point of the arc
  5410. * @param midPoint Defines the midlle point of the arc
  5411. * @param endPoint Defines the end point of the arc
  5412. */
  5413. constructor(
  5414. /** Defines the start point of the arc */
  5415. startPoint: Vector2,
  5416. /** Defines the mid point of the arc */
  5417. midPoint: Vector2,
  5418. /** Defines the end point of the arc */
  5419. endPoint: Vector2);
  5420. }
  5421. /**
  5422. * Represents a 2D path made up of multiple 2D points
  5423. */
  5424. export class Path2 {
  5425. private _points;
  5426. private _length;
  5427. /**
  5428. * If the path start and end point are the same
  5429. */
  5430. closed: boolean;
  5431. /**
  5432. * Creates a Path2 object from the starting 2D coordinates x and y.
  5433. * @param x the starting points x value
  5434. * @param y the starting points y value
  5435. */
  5436. constructor(x: number, y: number);
  5437. /**
  5438. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5439. * @param x the added points x value
  5440. * @param y the added points y value
  5441. * @returns the updated Path2.
  5442. */
  5443. addLineTo(x: number, y: number): Path2;
  5444. /**
  5445. * 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.
  5446. * @param midX middle point x value
  5447. * @param midY middle point y value
  5448. * @param endX end point x value
  5449. * @param endY end point y value
  5450. * @param numberOfSegments (default: 36)
  5451. * @returns the updated Path2.
  5452. */
  5453. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5454. /**
  5455. * Closes the Path2.
  5456. * @returns the Path2.
  5457. */
  5458. close(): Path2;
  5459. /**
  5460. * Gets the sum of the distance between each sequential point in the path
  5461. * @returns the Path2 total length (float).
  5462. */
  5463. length(): number;
  5464. /**
  5465. * Gets the points which construct the path
  5466. * @returns the Path2 internal array of points.
  5467. */
  5468. getPoints(): Vector2[];
  5469. /**
  5470. * Retreives the point at the distance aways from the starting point
  5471. * @param normalizedLengthPosition the length along the path to retreive the point from
  5472. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5473. */
  5474. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5475. /**
  5476. * Creates a new path starting from an x and y position
  5477. * @param x starting x value
  5478. * @param y starting y value
  5479. * @returns a new Path2 starting at the coordinates (x, y).
  5480. */
  5481. static StartingAt(x: number, y: number): Path2;
  5482. }
  5483. /**
  5484. * Represents a 3D path made up of multiple 3D points
  5485. */
  5486. export class Path3D {
  5487. /**
  5488. * an array of Vector3, the curve axis of the Path3D
  5489. */
  5490. path: Vector3[];
  5491. private _curve;
  5492. private _distances;
  5493. private _tangents;
  5494. private _normals;
  5495. private _binormals;
  5496. private _raw;
  5497. /**
  5498. * new Path3D(path, normal, raw)
  5499. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5500. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5501. * @param path an array of Vector3, the curve axis of the Path3D
  5502. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5503. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5504. */
  5505. constructor(
  5506. /**
  5507. * an array of Vector3, the curve axis of the Path3D
  5508. */
  5509. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5510. /**
  5511. * Returns the Path3D array of successive Vector3 designing its curve.
  5512. * @returns the Path3D array of successive Vector3 designing its curve.
  5513. */
  5514. getCurve(): Vector3[];
  5515. /**
  5516. * Returns an array populated with tangent vectors on each Path3D curve point.
  5517. * @returns an array populated with tangent vectors on each Path3D curve point.
  5518. */
  5519. getTangents(): Vector3[];
  5520. /**
  5521. * Returns an array populated with normal vectors on each Path3D curve point.
  5522. * @returns an array populated with normal vectors on each Path3D curve point.
  5523. */
  5524. getNormals(): Vector3[];
  5525. /**
  5526. * Returns an array populated with binormal vectors on each Path3D curve point.
  5527. * @returns an array populated with binormal vectors on each Path3D curve point.
  5528. */
  5529. getBinormals(): Vector3[];
  5530. /**
  5531. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5532. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5533. */
  5534. getDistances(): number[];
  5535. /**
  5536. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5537. * @param path path which all values are copied into the curves points
  5538. * @param firstNormal which should be projected onto the curve
  5539. * @returns the same object updated.
  5540. */
  5541. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5542. private _compute;
  5543. private _getFirstNonNullVector;
  5544. private _getLastNonNullVector;
  5545. private _normalVector;
  5546. }
  5547. /**
  5548. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5549. * A Curve3 is designed from a series of successive Vector3.
  5550. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5551. */
  5552. export class Curve3 {
  5553. private _points;
  5554. private _length;
  5555. /**
  5556. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5557. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5558. * @param v1 (Vector3) the control point
  5559. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5560. * @param nbPoints (integer) the wanted number of points in the curve
  5561. * @returns the created Curve3
  5562. */
  5563. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5564. /**
  5565. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5566. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5567. * @param v1 (Vector3) the first control point
  5568. * @param v2 (Vector3) the second control point
  5569. * @param v3 (Vector3) the end point of the Cubic Bezier
  5570. * @param nbPoints (integer) the wanted number of points in the curve
  5571. * @returns the created Curve3
  5572. */
  5573. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5574. /**
  5575. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5576. * @param p1 (Vector3) the origin point of the Hermite Spline
  5577. * @param t1 (Vector3) the tangent vector at the origin point
  5578. * @param p2 (Vector3) the end point of the Hermite Spline
  5579. * @param t2 (Vector3) the tangent vector at the end point
  5580. * @param nbPoints (integer) the wanted number of points in the curve
  5581. * @returns the created Curve3
  5582. */
  5583. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5584. /**
  5585. * Returns a Curve3 object along a CatmullRom Spline curve :
  5586. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5587. * @param nbPoints (integer) the wanted number of points between each curve control points
  5588. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5589. * @returns the created Curve3
  5590. */
  5591. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5592. /**
  5593. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5594. * A Curve3 is designed from a series of successive Vector3.
  5595. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5596. * @param points points which make up the curve
  5597. */
  5598. constructor(points: Vector3[]);
  5599. /**
  5600. * @returns the Curve3 stored array of successive Vector3
  5601. */
  5602. getPoints(): Vector3[];
  5603. /**
  5604. * @returns the computed length (float) of the curve.
  5605. */
  5606. length(): number;
  5607. /**
  5608. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5609. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5610. * curveA and curveB keep unchanged.
  5611. * @param curve the curve to continue from this curve
  5612. * @returns the newly constructed curve
  5613. */
  5614. continue(curve: DeepImmutable<Curve3>): Curve3;
  5615. private _computeLength;
  5616. }
  5617. }
  5618. declare module BABYLON {
  5619. /**
  5620. * This represents the main contract an easing function should follow.
  5621. * Easing functions are used throughout the animation system.
  5622. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5623. */
  5624. export interface IEasingFunction {
  5625. /**
  5626. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5627. * of the easing function.
  5628. * The link below provides some of the most common examples of easing functions.
  5629. * @see https://easings.net/
  5630. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5631. * @returns the corresponding value on the curve defined by the easing function
  5632. */
  5633. ease(gradient: number): number;
  5634. }
  5635. /**
  5636. * Base class used for every default easing function.
  5637. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5638. */
  5639. export class EasingFunction implements IEasingFunction {
  5640. /**
  5641. * Interpolation follows the mathematical formula associated with the easing function.
  5642. */
  5643. static readonly EASINGMODE_EASEIN: number;
  5644. /**
  5645. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5646. */
  5647. static readonly EASINGMODE_EASEOUT: number;
  5648. /**
  5649. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5650. */
  5651. static readonly EASINGMODE_EASEINOUT: number;
  5652. private _easingMode;
  5653. /**
  5654. * Sets the easing mode of the current function.
  5655. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5656. */
  5657. setEasingMode(easingMode: number): void;
  5658. /**
  5659. * Gets the current easing mode.
  5660. * @returns the easing mode
  5661. */
  5662. getEasingMode(): number;
  5663. /**
  5664. * @hidden
  5665. */
  5666. easeInCore(gradient: number): number;
  5667. /**
  5668. * Given an input gradient between 0 and 1, this returns the corresponding value
  5669. * of the easing function.
  5670. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5671. * @returns the corresponding value on the curve defined by the easing function
  5672. */
  5673. ease(gradient: number): number;
  5674. }
  5675. /**
  5676. * Easing function with a circle shape (see link below).
  5677. * @see https://easings.net/#easeInCirc
  5678. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5679. */
  5680. export class CircleEase extends EasingFunction implements IEasingFunction {
  5681. /** @hidden */
  5682. easeInCore(gradient: number): number;
  5683. }
  5684. /**
  5685. * Easing function with a ease back shape (see link below).
  5686. * @see https://easings.net/#easeInBack
  5687. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5688. */
  5689. export class BackEase extends EasingFunction implements IEasingFunction {
  5690. /** Defines the amplitude of the function */
  5691. amplitude: number;
  5692. /**
  5693. * Instantiates a back ease easing
  5694. * @see https://easings.net/#easeInBack
  5695. * @param amplitude Defines the amplitude of the function
  5696. */
  5697. constructor(
  5698. /** Defines the amplitude of the function */
  5699. amplitude?: number);
  5700. /** @hidden */
  5701. easeInCore(gradient: number): number;
  5702. }
  5703. /**
  5704. * Easing function with a bouncing shape (see link below).
  5705. * @see https://easings.net/#easeInBounce
  5706. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5707. */
  5708. export class BounceEase extends EasingFunction implements IEasingFunction {
  5709. /** Defines the number of bounces */
  5710. bounces: number;
  5711. /** Defines the amplitude of the bounce */
  5712. bounciness: number;
  5713. /**
  5714. * Instantiates a bounce easing
  5715. * @see https://easings.net/#easeInBounce
  5716. * @param bounces Defines the number of bounces
  5717. * @param bounciness Defines the amplitude of the bounce
  5718. */
  5719. constructor(
  5720. /** Defines the number of bounces */
  5721. bounces?: number,
  5722. /** Defines the amplitude of the bounce */
  5723. bounciness?: number);
  5724. /** @hidden */
  5725. easeInCore(gradient: number): number;
  5726. }
  5727. /**
  5728. * Easing function with a power of 3 shape (see link below).
  5729. * @see https://easings.net/#easeInCubic
  5730. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5731. */
  5732. export class CubicEase extends EasingFunction implements IEasingFunction {
  5733. /** @hidden */
  5734. easeInCore(gradient: number): number;
  5735. }
  5736. /**
  5737. * Easing function with an elastic shape (see link below).
  5738. * @see https://easings.net/#easeInElastic
  5739. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5740. */
  5741. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5742. /** Defines the number of oscillations*/
  5743. oscillations: number;
  5744. /** Defines the amplitude of the oscillations*/
  5745. springiness: number;
  5746. /**
  5747. * Instantiates an elastic easing function
  5748. * @see https://easings.net/#easeInElastic
  5749. * @param oscillations Defines the number of oscillations
  5750. * @param springiness Defines the amplitude of the oscillations
  5751. */
  5752. constructor(
  5753. /** Defines the number of oscillations*/
  5754. oscillations?: number,
  5755. /** Defines the amplitude of the oscillations*/
  5756. springiness?: number);
  5757. /** @hidden */
  5758. easeInCore(gradient: number): number;
  5759. }
  5760. /**
  5761. * Easing function with an exponential shape (see link below).
  5762. * @see https://easings.net/#easeInExpo
  5763. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5764. */
  5765. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5766. /** Defines the exponent of the function */
  5767. exponent: number;
  5768. /**
  5769. * Instantiates an exponential easing function
  5770. * @see https://easings.net/#easeInExpo
  5771. * @param exponent Defines the exponent of the function
  5772. */
  5773. constructor(
  5774. /** Defines the exponent of the function */
  5775. exponent?: number);
  5776. /** @hidden */
  5777. easeInCore(gradient: number): number;
  5778. }
  5779. /**
  5780. * Easing function with a power shape (see link below).
  5781. * @see https://easings.net/#easeInQuad
  5782. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5783. */
  5784. export class PowerEase extends EasingFunction implements IEasingFunction {
  5785. /** Defines the power of the function */
  5786. power: number;
  5787. /**
  5788. * Instantiates an power base easing function
  5789. * @see https://easings.net/#easeInQuad
  5790. * @param power Defines the power of the function
  5791. */
  5792. constructor(
  5793. /** Defines the power of the function */
  5794. power?: number);
  5795. /** @hidden */
  5796. easeInCore(gradient: number): number;
  5797. }
  5798. /**
  5799. * Easing function with a power of 2 shape (see link below).
  5800. * @see https://easings.net/#easeInQuad
  5801. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5802. */
  5803. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5804. /** @hidden */
  5805. easeInCore(gradient: number): number;
  5806. }
  5807. /**
  5808. * Easing function with a power of 4 shape (see link below).
  5809. * @see https://easings.net/#easeInQuart
  5810. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5811. */
  5812. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5813. /** @hidden */
  5814. easeInCore(gradient: number): number;
  5815. }
  5816. /**
  5817. * Easing function with a power of 5 shape (see link below).
  5818. * @see https://easings.net/#easeInQuint
  5819. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5820. */
  5821. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5822. /** @hidden */
  5823. easeInCore(gradient: number): number;
  5824. }
  5825. /**
  5826. * Easing function with a sin shape (see link below).
  5827. * @see https://easings.net/#easeInSine
  5828. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5829. */
  5830. export class SineEase extends EasingFunction implements IEasingFunction {
  5831. /** @hidden */
  5832. easeInCore(gradient: number): number;
  5833. }
  5834. /**
  5835. * Easing function with a bezier shape (see link below).
  5836. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5837. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5838. */
  5839. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5840. /** Defines the x component of the start tangent in the bezier curve */
  5841. x1: number;
  5842. /** Defines the y component of the start tangent in the bezier curve */
  5843. y1: number;
  5844. /** Defines the x component of the end tangent in the bezier curve */
  5845. x2: number;
  5846. /** Defines the y component of the end tangent in the bezier curve */
  5847. y2: number;
  5848. /**
  5849. * Instantiates a bezier function
  5850. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5851. * @param x1 Defines the x component of the start tangent in the bezier curve
  5852. * @param y1 Defines the y component of the start tangent in the bezier curve
  5853. * @param x2 Defines the x component of the end tangent in the bezier curve
  5854. * @param y2 Defines the y component of the end tangent in the bezier curve
  5855. */
  5856. constructor(
  5857. /** Defines the x component of the start tangent in the bezier curve */
  5858. x1?: number,
  5859. /** Defines the y component of the start tangent in the bezier curve */
  5860. y1?: number,
  5861. /** Defines the x component of the end tangent in the bezier curve */
  5862. x2?: number,
  5863. /** Defines the y component of the end tangent in the bezier curve */
  5864. y2?: number);
  5865. /** @hidden */
  5866. easeInCore(gradient: number): number;
  5867. }
  5868. }
  5869. declare module BABYLON {
  5870. /**
  5871. * Defines an interface which represents an animation key frame
  5872. */
  5873. export interface IAnimationKey {
  5874. /**
  5875. * Frame of the key frame
  5876. */
  5877. frame: number;
  5878. /**
  5879. * Value at the specifies key frame
  5880. */
  5881. value: any;
  5882. /**
  5883. * The input tangent for the cubic hermite spline
  5884. */
  5885. inTangent?: any;
  5886. /**
  5887. * The output tangent for the cubic hermite spline
  5888. */
  5889. outTangent?: any;
  5890. /**
  5891. * The animation interpolation type
  5892. */
  5893. interpolation?: AnimationKeyInterpolation;
  5894. }
  5895. /**
  5896. * Enum for the animation key frame interpolation type
  5897. */
  5898. export enum AnimationKeyInterpolation {
  5899. /**
  5900. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5901. */
  5902. STEP = 1
  5903. }
  5904. }
  5905. declare module BABYLON {
  5906. /**
  5907. * Represents the range of an animation
  5908. */
  5909. export class AnimationRange {
  5910. /**The name of the animation range**/
  5911. name: string;
  5912. /**The starting frame of the animation */
  5913. from: number;
  5914. /**The ending frame of the animation*/
  5915. to: number;
  5916. /**
  5917. * Initializes the range of an animation
  5918. * @param name The name of the animation range
  5919. * @param from The starting frame of the animation
  5920. * @param to The ending frame of the animation
  5921. */
  5922. constructor(
  5923. /**The name of the animation range**/
  5924. name: string,
  5925. /**The starting frame of the animation */
  5926. from: number,
  5927. /**The ending frame of the animation*/
  5928. to: number);
  5929. /**
  5930. * Makes a copy of the animation range
  5931. * @returns A copy of the animation range
  5932. */
  5933. clone(): AnimationRange;
  5934. }
  5935. }
  5936. declare module BABYLON {
  5937. /**
  5938. * Composed of a frame, and an action function
  5939. */
  5940. export class AnimationEvent {
  5941. /** The frame for which the event is triggered **/
  5942. frame: number;
  5943. /** The event to perform when triggered **/
  5944. action: (currentFrame: number) => void;
  5945. /** Specifies if the event should be triggered only once**/
  5946. onlyOnce?: boolean | undefined;
  5947. /**
  5948. * Specifies if the animation event is done
  5949. */
  5950. isDone: boolean;
  5951. /**
  5952. * Initializes the animation event
  5953. * @param frame The frame for which the event is triggered
  5954. * @param action The event to perform when triggered
  5955. * @param onlyOnce Specifies if the event should be triggered only once
  5956. */
  5957. constructor(
  5958. /** The frame for which the event is triggered **/
  5959. frame: number,
  5960. /** The event to perform when triggered **/
  5961. action: (currentFrame: number) => void,
  5962. /** Specifies if the event should be triggered only once**/
  5963. onlyOnce?: boolean | undefined);
  5964. /** @hidden */ private _clone(): AnimationEvent;
  5965. }
  5966. }
  5967. declare module BABYLON {
  5968. /**
  5969. * Interface used to define a behavior
  5970. */
  5971. export interface Behavior<T> {
  5972. /** gets or sets behavior's name */
  5973. name: string;
  5974. /**
  5975. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5976. */
  5977. init(): void;
  5978. /**
  5979. * Called when the behavior is attached to a target
  5980. * @param target defines the target where the behavior is attached to
  5981. */
  5982. attach(target: T): void;
  5983. /**
  5984. * Called when the behavior is detached from its target
  5985. */
  5986. detach(): void;
  5987. }
  5988. /**
  5989. * Interface implemented by classes supporting behaviors
  5990. */
  5991. export interface IBehaviorAware<T> {
  5992. /**
  5993. * Attach a behavior
  5994. * @param behavior defines the behavior to attach
  5995. * @returns the current host
  5996. */
  5997. addBehavior(behavior: Behavior<T>): T;
  5998. /**
  5999. * Remove a behavior from the current object
  6000. * @param behavior defines the behavior to detach
  6001. * @returns the current host
  6002. */
  6003. removeBehavior(behavior: Behavior<T>): T;
  6004. /**
  6005. * Gets a behavior using its name to search
  6006. * @param name defines the name to search
  6007. * @returns the behavior or null if not found
  6008. */
  6009. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6010. }
  6011. }
  6012. declare module BABYLON {
  6013. /**
  6014. * Defines an array and its length.
  6015. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6016. */
  6017. export interface ISmartArrayLike<T> {
  6018. /**
  6019. * The data of the array.
  6020. */
  6021. data: Array<T>;
  6022. /**
  6023. * The active length of the array.
  6024. */
  6025. length: number;
  6026. }
  6027. /**
  6028. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6029. */
  6030. export class SmartArray<T> implements ISmartArrayLike<T> {
  6031. /**
  6032. * The full set of data from the array.
  6033. */
  6034. data: Array<T>;
  6035. /**
  6036. * The active length of the array.
  6037. */
  6038. length: number;
  6039. protected _id: number;
  6040. /**
  6041. * Instantiates a Smart Array.
  6042. * @param capacity defines the default capacity of the array.
  6043. */
  6044. constructor(capacity: number);
  6045. /**
  6046. * Pushes a value at the end of the active data.
  6047. * @param value defines the object to push in the array.
  6048. */
  6049. push(value: T): void;
  6050. /**
  6051. * Iterates over the active data and apply the lambda to them.
  6052. * @param func defines the action to apply on each value.
  6053. */
  6054. forEach(func: (content: T) => void): void;
  6055. /**
  6056. * Sorts the full sets of data.
  6057. * @param compareFn defines the comparison function to apply.
  6058. */
  6059. sort(compareFn: (a: T, b: T) => number): void;
  6060. /**
  6061. * Resets the active data to an empty array.
  6062. */
  6063. reset(): void;
  6064. /**
  6065. * Releases all the data from the array as well as the array.
  6066. */
  6067. dispose(): void;
  6068. /**
  6069. * Concats the active data with a given array.
  6070. * @param array defines the data to concatenate with.
  6071. */
  6072. concat(array: any): void;
  6073. /**
  6074. * Returns the position of a value in the active data.
  6075. * @param value defines the value to find the index for
  6076. * @returns the index if found in the active data otherwise -1
  6077. */
  6078. indexOf(value: T): number;
  6079. /**
  6080. * Returns whether an element is part of the active data.
  6081. * @param value defines the value to look for
  6082. * @returns true if found in the active data otherwise false
  6083. */
  6084. contains(value: T): boolean;
  6085. private static _GlobalId;
  6086. }
  6087. /**
  6088. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6089. * The data in this array can only be present once
  6090. */
  6091. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6092. private _duplicateId;
  6093. /**
  6094. * Pushes a value at the end of the active data.
  6095. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6096. * @param value defines the object to push in the array.
  6097. */
  6098. push(value: T): void;
  6099. /**
  6100. * Pushes a value at the end of the active data.
  6101. * If the data is already present, it won t be added again
  6102. * @param value defines the object to push in the array.
  6103. * @returns true if added false if it was already present
  6104. */
  6105. pushNoDuplicate(value: T): boolean;
  6106. /**
  6107. * Resets the active data to an empty array.
  6108. */
  6109. reset(): void;
  6110. /**
  6111. * Concats the active data with a given array.
  6112. * This ensures no dupplicate will be present in the result.
  6113. * @param array defines the data to concatenate with.
  6114. */
  6115. concatWithNoDuplicate(array: any): void;
  6116. }
  6117. }
  6118. declare module BABYLON {
  6119. /**
  6120. * @ignore
  6121. * This is a list of all the different input types that are available in the application.
  6122. * Fo instance: ArcRotateCameraGamepadInput...
  6123. */
  6124. export var CameraInputTypes: {};
  6125. /**
  6126. * This is the contract to implement in order to create a new input class.
  6127. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6128. */
  6129. export interface ICameraInput<TCamera extends Camera> {
  6130. /**
  6131. * Defines the camera the input is attached to.
  6132. */
  6133. camera: Nullable<TCamera>;
  6134. /**
  6135. * Gets the class name of the current intput.
  6136. * @returns the class name
  6137. */
  6138. getClassName(): string;
  6139. /**
  6140. * Get the friendly name associated with the input class.
  6141. * @returns the input friendly name
  6142. */
  6143. getSimpleName(): string;
  6144. /**
  6145. * Attach the input controls to a specific dom element to get the input from.
  6146. * @param element Defines the element the controls should be listened from
  6147. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6148. */
  6149. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6150. /**
  6151. * Detach the current controls from the specified dom element.
  6152. * @param element Defines the element to stop listening the inputs from
  6153. */
  6154. detachControl(element: Nullable<HTMLElement>): void;
  6155. /**
  6156. * Update the current camera state depending on the inputs that have been used this frame.
  6157. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6158. */
  6159. checkInputs?: () => void;
  6160. }
  6161. /**
  6162. * Represents a map of input types to input instance or input index to input instance.
  6163. */
  6164. export interface CameraInputsMap<TCamera extends Camera> {
  6165. /**
  6166. * Accessor to the input by input type.
  6167. */
  6168. [name: string]: ICameraInput<TCamera>;
  6169. /**
  6170. * Accessor to the input by input index.
  6171. */
  6172. [idx: number]: ICameraInput<TCamera>;
  6173. }
  6174. /**
  6175. * This represents the input manager used within a camera.
  6176. * It helps dealing with all the different kind of input attached to a camera.
  6177. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6178. */
  6179. export class CameraInputsManager<TCamera extends Camera> {
  6180. /**
  6181. * Defines the list of inputs attahed to the camera.
  6182. */
  6183. attached: CameraInputsMap<TCamera>;
  6184. /**
  6185. * Defines the dom element the camera is collecting inputs from.
  6186. * This is null if the controls have not been attached.
  6187. */
  6188. attachedElement: Nullable<HTMLElement>;
  6189. /**
  6190. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6191. */
  6192. noPreventDefault: boolean;
  6193. /**
  6194. * Defined the camera the input manager belongs to.
  6195. */
  6196. camera: TCamera;
  6197. /**
  6198. * Update the current camera state depending on the inputs that have been used this frame.
  6199. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6200. */
  6201. checkInputs: () => void;
  6202. /**
  6203. * Instantiate a new Camera Input Manager.
  6204. * @param camera Defines the camera the input manager blongs to
  6205. */
  6206. constructor(camera: TCamera);
  6207. /**
  6208. * Add an input method to a camera
  6209. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6210. * @param input camera input method
  6211. */
  6212. add(input: ICameraInput<TCamera>): void;
  6213. /**
  6214. * Remove a specific input method from a camera
  6215. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6216. * @param inputToRemove camera input method
  6217. */
  6218. remove(inputToRemove: ICameraInput<TCamera>): void;
  6219. /**
  6220. * Remove a specific input type from a camera
  6221. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6222. * @param inputType the type of the input to remove
  6223. */
  6224. removeByType(inputType: string): void;
  6225. private _addCheckInputs;
  6226. /**
  6227. * Attach the input controls to the currently attached dom element to listen the events from.
  6228. * @param input Defines the input to attach
  6229. */
  6230. attachInput(input: ICameraInput<TCamera>): void;
  6231. /**
  6232. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6233. * @param element Defines the dom element to collect the events from
  6234. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6235. */
  6236. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6237. /**
  6238. * Detach the current manager inputs controls from a specific dom element.
  6239. * @param element Defines the dom element to collect the events from
  6240. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6241. */
  6242. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6243. /**
  6244. * Rebuild the dynamic inputCheck function from the current list of
  6245. * defined inputs in the manager.
  6246. */
  6247. rebuildInputCheck(): void;
  6248. /**
  6249. * Remove all attached input methods from a camera
  6250. */
  6251. clear(): void;
  6252. /**
  6253. * Serialize the current input manager attached to a camera.
  6254. * This ensures than once parsed,
  6255. * the input associated to the camera will be identical to the current ones
  6256. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6257. */
  6258. serialize(serializedCamera: any): void;
  6259. /**
  6260. * Parses an input manager serialized JSON to restore the previous list of inputs
  6261. * and states associated to a camera.
  6262. * @param parsedCamera Defines the JSON to parse
  6263. */
  6264. parse(parsedCamera: any): void;
  6265. }
  6266. }
  6267. declare module BABYLON {
  6268. /**
  6269. * Class used to store data that will be store in GPU memory
  6270. */
  6271. export class Buffer {
  6272. private _engine;
  6273. private _buffer;
  6274. /** @hidden */ private _data: Nullable<DataArray>;
  6275. private _updatable;
  6276. private _instanced;
  6277. /**
  6278. * Gets the byte stride.
  6279. */
  6280. readonly byteStride: number;
  6281. /**
  6282. * Constructor
  6283. * @param engine the engine
  6284. * @param data the data to use for this buffer
  6285. * @param updatable whether the data is updatable
  6286. * @param stride the stride (optional)
  6287. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6288. * @param instanced whether the buffer is instanced (optional)
  6289. * @param useBytes set to true if the stride in in bytes (optional)
  6290. */
  6291. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6292. /**
  6293. * Create a new VertexBuffer based on the current buffer
  6294. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6295. * @param offset defines offset in the buffer (0 by default)
  6296. * @param size defines the size in floats of attributes (position is 3 for instance)
  6297. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6298. * @param instanced defines if the vertex buffer contains indexed data
  6299. * @param useBytes defines if the offset and stride are in bytes
  6300. * @returns the new vertex buffer
  6301. */
  6302. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6303. /**
  6304. * Gets a boolean indicating if the Buffer is updatable?
  6305. * @returns true if the buffer is updatable
  6306. */
  6307. isUpdatable(): boolean;
  6308. /**
  6309. * Gets current buffer's data
  6310. * @returns a DataArray or null
  6311. */
  6312. getData(): Nullable<DataArray>;
  6313. /**
  6314. * Gets underlying native buffer
  6315. * @returns underlying native buffer
  6316. */
  6317. getBuffer(): Nullable<DataBuffer>;
  6318. /**
  6319. * Gets the stride in float32 units (i.e. byte stride / 4).
  6320. * May not be an integer if the byte stride is not divisible by 4.
  6321. * DEPRECATED. Use byteStride instead.
  6322. * @returns the stride in float32 units
  6323. */
  6324. getStrideSize(): number;
  6325. /**
  6326. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6327. * @param data defines the data to store
  6328. */
  6329. create(data?: Nullable<DataArray>): void;
  6330. /** @hidden */ private _rebuild(): void;
  6331. /**
  6332. * Update current buffer data
  6333. * @param data defines the data to store
  6334. */
  6335. update(data: DataArray): void;
  6336. /**
  6337. * Updates the data directly.
  6338. * @param data the new data
  6339. * @param offset the new offset
  6340. * @param vertexCount the vertex count (optional)
  6341. * @param useBytes set to true if the offset is in bytes
  6342. */
  6343. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6344. /**
  6345. * Release all resources
  6346. */
  6347. dispose(): void;
  6348. }
  6349. /**
  6350. * Specialized buffer used to store vertex data
  6351. */
  6352. export class VertexBuffer {
  6353. /** @hidden */ private _buffer: Buffer;
  6354. private _kind;
  6355. private _size;
  6356. private _ownsBuffer;
  6357. private _instanced;
  6358. private _instanceDivisor;
  6359. /**
  6360. * The byte type.
  6361. */
  6362. static readonly BYTE: number;
  6363. /**
  6364. * The unsigned byte type.
  6365. */
  6366. static readonly UNSIGNED_BYTE: number;
  6367. /**
  6368. * The short type.
  6369. */
  6370. static readonly SHORT: number;
  6371. /**
  6372. * The unsigned short type.
  6373. */
  6374. static readonly UNSIGNED_SHORT: number;
  6375. /**
  6376. * The integer type.
  6377. */
  6378. static readonly INT: number;
  6379. /**
  6380. * The unsigned integer type.
  6381. */
  6382. static readonly UNSIGNED_INT: number;
  6383. /**
  6384. * The float type.
  6385. */
  6386. static readonly FLOAT: number;
  6387. /**
  6388. * Gets or sets the instance divisor when in instanced mode
  6389. */
  6390. instanceDivisor: number;
  6391. /**
  6392. * Gets the byte stride.
  6393. */
  6394. readonly byteStride: number;
  6395. /**
  6396. * Gets the byte offset.
  6397. */
  6398. readonly byteOffset: number;
  6399. /**
  6400. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6401. */
  6402. readonly normalized: boolean;
  6403. /**
  6404. * Gets the data type of each component in the array.
  6405. */
  6406. readonly type: number;
  6407. /**
  6408. * Constructor
  6409. * @param engine the engine
  6410. * @param data the data to use for this vertex buffer
  6411. * @param kind the vertex buffer kind
  6412. * @param updatable whether the data is updatable
  6413. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6414. * @param stride the stride (optional)
  6415. * @param instanced whether the buffer is instanced (optional)
  6416. * @param offset the offset of the data (optional)
  6417. * @param size the number of components (optional)
  6418. * @param type the type of the component (optional)
  6419. * @param normalized whether the data contains normalized data (optional)
  6420. * @param useBytes set to true if stride and offset are in bytes (optional)
  6421. */
  6422. 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);
  6423. /** @hidden */ private _rebuild(): void;
  6424. /**
  6425. * Returns the kind of the VertexBuffer (string)
  6426. * @returns a string
  6427. */
  6428. getKind(): string;
  6429. /**
  6430. * Gets a boolean indicating if the VertexBuffer is updatable?
  6431. * @returns true if the buffer is updatable
  6432. */
  6433. isUpdatable(): boolean;
  6434. /**
  6435. * Gets current buffer's data
  6436. * @returns a DataArray or null
  6437. */
  6438. getData(): Nullable<DataArray>;
  6439. /**
  6440. * Gets underlying native buffer
  6441. * @returns underlying native buffer
  6442. */
  6443. getBuffer(): Nullable<DataBuffer>;
  6444. /**
  6445. * Gets the stride in float32 units (i.e. byte stride / 4).
  6446. * May not be an integer if the byte stride is not divisible by 4.
  6447. * DEPRECATED. Use byteStride instead.
  6448. * @returns the stride in float32 units
  6449. */
  6450. getStrideSize(): number;
  6451. /**
  6452. * Returns the offset as a multiple of the type byte length.
  6453. * DEPRECATED. Use byteOffset instead.
  6454. * @returns the offset in bytes
  6455. */
  6456. getOffset(): number;
  6457. /**
  6458. * Returns the number of components per vertex attribute (integer)
  6459. * @returns the size in float
  6460. */
  6461. getSize(): number;
  6462. /**
  6463. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6464. * @returns true if this buffer is instanced
  6465. */
  6466. getIsInstanced(): boolean;
  6467. /**
  6468. * Returns the instancing divisor, zero for non-instanced (integer).
  6469. * @returns a number
  6470. */
  6471. getInstanceDivisor(): number;
  6472. /**
  6473. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6474. * @param data defines the data to store
  6475. */
  6476. create(data?: DataArray): void;
  6477. /**
  6478. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6479. * This function will create a new buffer if the current one is not updatable
  6480. * @param data defines the data to store
  6481. */
  6482. update(data: DataArray): void;
  6483. /**
  6484. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6485. * Returns the directly updated WebGLBuffer.
  6486. * @param data the new data
  6487. * @param offset the new offset
  6488. * @param useBytes set to true if the offset is in bytes
  6489. */
  6490. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6491. /**
  6492. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6493. */
  6494. dispose(): void;
  6495. /**
  6496. * Enumerates each value of this vertex buffer as numbers.
  6497. * @param count the number of values to enumerate
  6498. * @param callback the callback function called for each value
  6499. */
  6500. forEach(count: number, callback: (value: number, index: number) => void): void;
  6501. /**
  6502. * Positions
  6503. */
  6504. static readonly PositionKind: string;
  6505. /**
  6506. * Normals
  6507. */
  6508. static readonly NormalKind: string;
  6509. /**
  6510. * Tangents
  6511. */
  6512. static readonly TangentKind: string;
  6513. /**
  6514. * Texture coordinates
  6515. */
  6516. static readonly UVKind: string;
  6517. /**
  6518. * Texture coordinates 2
  6519. */
  6520. static readonly UV2Kind: string;
  6521. /**
  6522. * Texture coordinates 3
  6523. */
  6524. static readonly UV3Kind: string;
  6525. /**
  6526. * Texture coordinates 4
  6527. */
  6528. static readonly UV4Kind: string;
  6529. /**
  6530. * Texture coordinates 5
  6531. */
  6532. static readonly UV5Kind: string;
  6533. /**
  6534. * Texture coordinates 6
  6535. */
  6536. static readonly UV6Kind: string;
  6537. /**
  6538. * Colors
  6539. */
  6540. static readonly ColorKind: string;
  6541. /**
  6542. * Matrix indices (for bones)
  6543. */
  6544. static readonly MatricesIndicesKind: string;
  6545. /**
  6546. * Matrix weights (for bones)
  6547. */
  6548. static readonly MatricesWeightsKind: string;
  6549. /**
  6550. * Additional matrix indices (for bones)
  6551. */
  6552. static readonly MatricesIndicesExtraKind: string;
  6553. /**
  6554. * Additional matrix weights (for bones)
  6555. */
  6556. static readonly MatricesWeightsExtraKind: string;
  6557. /**
  6558. * Deduces the stride given a kind.
  6559. * @param kind The kind string to deduce
  6560. * @returns The deduced stride
  6561. */
  6562. static DeduceStride(kind: string): number;
  6563. /**
  6564. * Gets the byte length of the given type.
  6565. * @param type the type
  6566. * @returns the number of bytes
  6567. */
  6568. static GetTypeByteLength(type: number): number;
  6569. /**
  6570. * Enumerates each value of the given parameters as numbers.
  6571. * @param data the data to enumerate
  6572. * @param byteOffset the byte offset of the data
  6573. * @param byteStride the byte stride of the data
  6574. * @param componentCount the number of components per element
  6575. * @param componentType the type of the component
  6576. * @param count the number of values to enumerate
  6577. * @param normalized whether the data is normalized
  6578. * @param callback the callback function called for each value
  6579. */
  6580. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6581. private static _GetFloatValue;
  6582. }
  6583. }
  6584. declare module BABYLON {
  6585. /**
  6586. * @hidden
  6587. */
  6588. export class IntersectionInfo {
  6589. bu: Nullable<number>;
  6590. bv: Nullable<number>;
  6591. distance: number;
  6592. faceId: number;
  6593. subMeshId: number;
  6594. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6595. }
  6596. }
  6597. declare module BABYLON {
  6598. /**
  6599. * Represens a plane by the equation ax + by + cz + d = 0
  6600. */
  6601. export class Plane {
  6602. private static _TmpMatrix;
  6603. /**
  6604. * Normal of the plane (a,b,c)
  6605. */
  6606. normal: Vector3;
  6607. /**
  6608. * d component of the plane
  6609. */
  6610. d: number;
  6611. /**
  6612. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6613. * @param a a component of the plane
  6614. * @param b b component of the plane
  6615. * @param c c component of the plane
  6616. * @param d d component of the plane
  6617. */
  6618. constructor(a: number, b: number, c: number, d: number);
  6619. /**
  6620. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6621. */
  6622. asArray(): number[];
  6623. /**
  6624. * @returns a new plane copied from the current Plane.
  6625. */
  6626. clone(): Plane;
  6627. /**
  6628. * @returns the string "Plane".
  6629. */
  6630. getClassName(): string;
  6631. /**
  6632. * @returns the Plane hash code.
  6633. */
  6634. getHashCode(): number;
  6635. /**
  6636. * Normalize the current Plane in place.
  6637. * @returns the updated Plane.
  6638. */
  6639. normalize(): Plane;
  6640. /**
  6641. * Applies a transformation the plane and returns the result
  6642. * @param transformation the transformation matrix to be applied to the plane
  6643. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6644. */
  6645. transform(transformation: DeepImmutable<Matrix>): Plane;
  6646. /**
  6647. * Calcualtte the dot product between the point and the plane normal
  6648. * @param point point to calculate the dot product with
  6649. * @returns the dot product (float) of the point coordinates and the plane normal.
  6650. */
  6651. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6652. /**
  6653. * Updates the current Plane from the plane defined by the three given points.
  6654. * @param point1 one of the points used to contruct the plane
  6655. * @param point2 one of the points used to contruct the plane
  6656. * @param point3 one of the points used to contruct the plane
  6657. * @returns the updated Plane.
  6658. */
  6659. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6660. /**
  6661. * Checks if the plane is facing a given direction
  6662. * @param direction the direction to check if the plane is facing
  6663. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6664. * @returns True is the vector "direction" is the same side than the plane normal.
  6665. */
  6666. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6667. /**
  6668. * Calculates the distance to a point
  6669. * @param point point to calculate distance to
  6670. * @returns the signed distance (float) from the given point to the Plane.
  6671. */
  6672. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6673. /**
  6674. * Creates a plane from an array
  6675. * @param array the array to create a plane from
  6676. * @returns a new Plane from the given array.
  6677. */
  6678. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6679. /**
  6680. * Creates a plane from three points
  6681. * @param point1 point used to create the plane
  6682. * @param point2 point used to create the plane
  6683. * @param point3 point used to create the plane
  6684. * @returns a new Plane defined by the three given points.
  6685. */
  6686. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6687. /**
  6688. * Creates a plane from an origin point and a normal
  6689. * @param origin origin of the plane to be constructed
  6690. * @param normal normal of the plane to be constructed
  6691. * @returns a new Plane the normal vector to this plane at the given origin point.
  6692. * Note : the vector "normal" is updated because normalized.
  6693. */
  6694. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6695. /**
  6696. * Calculates the distance from a plane and a point
  6697. * @param origin origin of the plane to be constructed
  6698. * @param normal normal of the plane to be constructed
  6699. * @param point point to calculate distance to
  6700. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6701. */
  6702. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6703. }
  6704. }
  6705. declare module BABYLON {
  6706. /**
  6707. * Class used to store bounding sphere information
  6708. */
  6709. export class BoundingSphere {
  6710. /**
  6711. * Gets the center of the bounding sphere in local space
  6712. */
  6713. readonly center: Vector3;
  6714. /**
  6715. * Radius of the bounding sphere in local space
  6716. */
  6717. radius: number;
  6718. /**
  6719. * Gets the center of the bounding sphere in world space
  6720. */
  6721. readonly centerWorld: Vector3;
  6722. /**
  6723. * Radius of the bounding sphere in world space
  6724. */
  6725. radiusWorld: number;
  6726. /**
  6727. * Gets the minimum vector in local space
  6728. */
  6729. readonly minimum: Vector3;
  6730. /**
  6731. * Gets the maximum vector in local space
  6732. */
  6733. readonly maximum: Vector3;
  6734. private _worldMatrix;
  6735. private static readonly TmpVector3;
  6736. /**
  6737. * Creates a new bounding sphere
  6738. * @param min defines the minimum vector (in local space)
  6739. * @param max defines the maximum vector (in local space)
  6740. * @param worldMatrix defines the new world matrix
  6741. */
  6742. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6743. /**
  6744. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6745. * @param min defines the new minimum vector (in local space)
  6746. * @param max defines the new maximum vector (in local space)
  6747. * @param worldMatrix defines the new world matrix
  6748. */
  6749. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6750. /**
  6751. * Scale the current bounding sphere by applying a scale factor
  6752. * @param factor defines the scale factor to apply
  6753. * @returns the current bounding box
  6754. */
  6755. scale(factor: number): BoundingSphere;
  6756. /**
  6757. * Gets the world matrix of the bounding box
  6758. * @returns a matrix
  6759. */
  6760. getWorldMatrix(): DeepImmutable<Matrix>;
  6761. /** @hidden */ private _update(worldMatrix: DeepImmutable<Matrix>): void;
  6762. /**
  6763. * Tests if the bounding sphere is intersecting the frustum planes
  6764. * @param frustumPlanes defines the frustum planes to test
  6765. * @returns true if there is an intersection
  6766. */
  6767. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6768. /**
  6769. * Tests if the bounding sphere center is in between the frustum planes.
  6770. * Used for optimistic fast inclusion.
  6771. * @param frustumPlanes defines the frustum planes to test
  6772. * @returns true if the sphere center is in between the frustum planes
  6773. */
  6774. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6775. /**
  6776. * Tests if a point is inside the bounding sphere
  6777. * @param point defines the point to test
  6778. * @returns true if the point is inside the bounding sphere
  6779. */
  6780. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6781. /**
  6782. * Checks if two sphere intersct
  6783. * @param sphere0 sphere 0
  6784. * @param sphere1 sphere 1
  6785. * @returns true if the speres intersect
  6786. */
  6787. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6788. }
  6789. }
  6790. declare module BABYLON {
  6791. /**
  6792. * Class used to store bounding box information
  6793. */
  6794. export class BoundingBox implements ICullable {
  6795. /**
  6796. * Gets the 8 vectors representing the bounding box in local space
  6797. */
  6798. readonly vectors: Vector3[];
  6799. /**
  6800. * Gets the center of the bounding box in local space
  6801. */
  6802. readonly center: Vector3;
  6803. /**
  6804. * Gets the center of the bounding box in world space
  6805. */
  6806. readonly centerWorld: Vector3;
  6807. /**
  6808. * Gets the extend size in local space
  6809. */
  6810. readonly extendSize: Vector3;
  6811. /**
  6812. * Gets the extend size in world space
  6813. */
  6814. readonly extendSizeWorld: Vector3;
  6815. /**
  6816. * Gets the OBB (object bounding box) directions
  6817. */
  6818. readonly directions: Vector3[];
  6819. /**
  6820. * Gets the 8 vectors representing the bounding box in world space
  6821. */
  6822. readonly vectorsWorld: Vector3[];
  6823. /**
  6824. * Gets the minimum vector in world space
  6825. */
  6826. readonly minimumWorld: Vector3;
  6827. /**
  6828. * Gets the maximum vector in world space
  6829. */
  6830. readonly maximumWorld: Vector3;
  6831. /**
  6832. * Gets the minimum vector in local space
  6833. */
  6834. readonly minimum: Vector3;
  6835. /**
  6836. * Gets the maximum vector in local space
  6837. */
  6838. readonly maximum: Vector3;
  6839. private _worldMatrix;
  6840. private static readonly TmpVector3;
  6841. /**
  6842. * @hidden
  6843. */ private _tag: number;
  6844. /**
  6845. * Creates a new bounding box
  6846. * @param min defines the minimum vector (in local space)
  6847. * @param max defines the maximum vector (in local space)
  6848. * @param worldMatrix defines the new world matrix
  6849. */
  6850. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6851. /**
  6852. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6853. * @param min defines the new minimum vector (in local space)
  6854. * @param max defines the new maximum vector (in local space)
  6855. * @param worldMatrix defines the new world matrix
  6856. */
  6857. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6858. /**
  6859. * Scale the current bounding box by applying a scale factor
  6860. * @param factor defines the scale factor to apply
  6861. * @returns the current bounding box
  6862. */
  6863. scale(factor: number): BoundingBox;
  6864. /**
  6865. * Gets the world matrix of the bounding box
  6866. * @returns a matrix
  6867. */
  6868. getWorldMatrix(): DeepImmutable<Matrix>;
  6869. /** @hidden */ private _update(world: DeepImmutable<Matrix>): void;
  6870. /**
  6871. * Tests if the bounding box is intersecting the frustum planes
  6872. * @param frustumPlanes defines the frustum planes to test
  6873. * @returns true if there is an intersection
  6874. */
  6875. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6876. /**
  6877. * Tests if the bounding box is entirely inside the frustum planes
  6878. * @param frustumPlanes defines the frustum planes to test
  6879. * @returns true if there is an inclusion
  6880. */
  6881. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6882. /**
  6883. * Tests if a point is inside the bounding box
  6884. * @param point defines the point to test
  6885. * @returns true if the point is inside the bounding box
  6886. */
  6887. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6888. /**
  6889. * Tests if the bounding box intersects with a bounding sphere
  6890. * @param sphere defines the sphere to test
  6891. * @returns true if there is an intersection
  6892. */
  6893. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6894. /**
  6895. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6896. * @param min defines the min vector to use
  6897. * @param max defines the max vector to use
  6898. * @returns true if there is an intersection
  6899. */
  6900. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6901. /**
  6902. * Tests if two bounding boxes are intersections
  6903. * @param box0 defines the first box to test
  6904. * @param box1 defines the second box to test
  6905. * @returns true if there is an intersection
  6906. */
  6907. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6908. /**
  6909. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6910. * @param minPoint defines the minimum vector of the bounding box
  6911. * @param maxPoint defines the maximum vector of the bounding box
  6912. * @param sphereCenter defines the sphere center
  6913. * @param sphereRadius defines the sphere radius
  6914. * @returns true if there is an intersection
  6915. */
  6916. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6917. /**
  6918. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6919. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6920. * @param frustumPlanes defines the frustum planes to test
  6921. * @return true if there is an inclusion
  6922. */
  6923. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6924. /**
  6925. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6926. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6927. * @param frustumPlanes defines the frustum planes to test
  6928. * @return true if there is an intersection
  6929. */
  6930. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6931. }
  6932. }
  6933. declare module BABYLON {
  6934. /** @hidden */
  6935. export class Collider {
  6936. /** Define if a collision was found */
  6937. collisionFound: boolean;
  6938. /**
  6939. * Define last intersection point in local space
  6940. */
  6941. intersectionPoint: Vector3;
  6942. /**
  6943. * Define last collided mesh
  6944. */
  6945. collidedMesh: Nullable<AbstractMesh>;
  6946. private _collisionPoint;
  6947. private _planeIntersectionPoint;
  6948. private _tempVector;
  6949. private _tempVector2;
  6950. private _tempVector3;
  6951. private _tempVector4;
  6952. private _edge;
  6953. private _baseToVertex;
  6954. private _destinationPoint;
  6955. private _slidePlaneNormal;
  6956. private _displacementVector;
  6957. /** @hidden */ private _radius: Vector3;
  6958. /** @hidden */ private _retry: number;
  6959. private _velocity;
  6960. private _basePoint;
  6961. private _epsilon;
  6962. /** @hidden */ private _velocityWorldLength: number;
  6963. /** @hidden */ private _basePointWorld: Vector3;
  6964. private _velocityWorld;
  6965. private _normalizedVelocity;
  6966. /** @hidden */ private _initialVelocity: Vector3;
  6967. /** @hidden */ private _initialPosition: Vector3;
  6968. private _nearestDistance;
  6969. private _collisionMask;
  6970. collisionMask: number;
  6971. /**
  6972. * Gets the plane normal used to compute the sliding response (in local space)
  6973. */
  6974. readonly slidePlaneNormal: Vector3;
  6975. /** @hidden */ private _initialize(source: Vector3, dir: Vector3, e: number): void;
  6976. /** @hidden */ private _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6977. /** @hidden */ private _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6978. /** @hidden */ private _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6979. /** @hidden */ private _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6980. /** @hidden */ private _getResponse(pos: Vector3, vel: Vector3): void;
  6981. }
  6982. }
  6983. declare module BABYLON {
  6984. /**
  6985. * Interface for cullable objects
  6986. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6987. */
  6988. export interface ICullable {
  6989. /**
  6990. * Checks if the object or part of the object is in the frustum
  6991. * @param frustumPlanes Camera near/planes
  6992. * @returns true if the object is in frustum otherwise false
  6993. */
  6994. isInFrustum(frustumPlanes: Plane[]): boolean;
  6995. /**
  6996. * Checks if a cullable object (mesh...) is in the camera frustum
  6997. * Unlike isInFrustum this cheks the full bounding box
  6998. * @param frustumPlanes Camera near/planes
  6999. * @returns true if the object is in frustum otherwise false
  7000. */
  7001. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7002. }
  7003. /**
  7004. * Info for a bounding data of a mesh
  7005. */
  7006. export class BoundingInfo implements ICullable {
  7007. /**
  7008. * Bounding box for the mesh
  7009. */
  7010. readonly boundingBox: BoundingBox;
  7011. /**
  7012. * Bounding sphere for the mesh
  7013. */
  7014. readonly boundingSphere: BoundingSphere;
  7015. private _isLocked;
  7016. private static readonly TmpVector3;
  7017. /**
  7018. * Constructs bounding info
  7019. * @param minimum min vector of the bounding box/sphere
  7020. * @param maximum max vector of the bounding box/sphere
  7021. * @param worldMatrix defines the new world matrix
  7022. */
  7023. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7024. /**
  7025. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7026. * @param min defines the new minimum vector (in local space)
  7027. * @param max defines the new maximum vector (in local space)
  7028. * @param worldMatrix defines the new world matrix
  7029. */
  7030. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7031. /**
  7032. * min vector of the bounding box/sphere
  7033. */
  7034. readonly minimum: Vector3;
  7035. /**
  7036. * max vector of the bounding box/sphere
  7037. */
  7038. readonly maximum: Vector3;
  7039. /**
  7040. * If the info is locked and won't be updated to avoid perf overhead
  7041. */
  7042. isLocked: boolean;
  7043. /**
  7044. * Updates the bounding sphere and box
  7045. * @param world world matrix to be used to update
  7046. */
  7047. update(world: DeepImmutable<Matrix>): void;
  7048. /**
  7049. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7050. * @param center New center of the bounding info
  7051. * @param extend New extend of the bounding info
  7052. * @returns the current bounding info
  7053. */
  7054. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7055. /**
  7056. * Scale the current bounding info by applying a scale factor
  7057. * @param factor defines the scale factor to apply
  7058. * @returns the current bounding info
  7059. */
  7060. scale(factor: number): BoundingInfo;
  7061. /**
  7062. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7063. * @param frustumPlanes defines the frustum to test
  7064. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7065. * @returns true if the bounding info is in the frustum planes
  7066. */
  7067. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7068. /**
  7069. * Gets the world distance between the min and max points of the bounding box
  7070. */
  7071. readonly diagonalLength: number;
  7072. /**
  7073. * Checks if a cullable object (mesh...) is in the camera frustum
  7074. * Unlike isInFrustum this cheks the full bounding box
  7075. * @param frustumPlanes Camera near/planes
  7076. * @returns true if the object is in frustum otherwise false
  7077. */
  7078. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7079. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  7080. /**
  7081. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7082. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7083. * @param point the point to check intersection with
  7084. * @returns if the point intersects
  7085. */
  7086. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7087. /**
  7088. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7089. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7090. * @param boundingInfo the bounding info to check intersection with
  7091. * @param precise if the intersection should be done using OBB
  7092. * @returns if the bounding info intersects
  7093. */
  7094. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7095. }
  7096. }
  7097. declare module BABYLON {
  7098. /**
  7099. * Extracts minimum and maximum values from a list of indexed positions
  7100. * @param positions defines the positions to use
  7101. * @param indices defines the indices to the positions
  7102. * @param indexStart defines the start index
  7103. * @param indexCount defines the end index
  7104. * @param bias defines bias value to add to the result
  7105. * @return minimum and maximum values
  7106. */
  7107. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7108. minimum: Vector3;
  7109. maximum: Vector3;
  7110. };
  7111. /**
  7112. * Extracts minimum and maximum values from a list of positions
  7113. * @param positions defines the positions to use
  7114. * @param start defines the start index in the positions array
  7115. * @param count defines the number of positions to handle
  7116. * @param bias defines bias value to add to the result
  7117. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7118. * @return minimum and maximum values
  7119. */
  7120. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7121. minimum: Vector3;
  7122. maximum: Vector3;
  7123. };
  7124. }
  7125. declare module BABYLON {
  7126. /**
  7127. * Uniform buffer objects.
  7128. *
  7129. * Handles blocks of uniform on the GPU.
  7130. *
  7131. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7132. *
  7133. * For more information, please refer to :
  7134. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7135. */
  7136. export class UniformBuffer {
  7137. private _engine;
  7138. private _buffer;
  7139. private _data;
  7140. private _bufferData;
  7141. private _dynamic?;
  7142. private _uniformLocations;
  7143. private _uniformSizes;
  7144. private _uniformLocationPointer;
  7145. private _needSync;
  7146. private _noUBO;
  7147. private _currentEffect;
  7148. private static _MAX_UNIFORM_SIZE;
  7149. private static _tempBuffer;
  7150. /**
  7151. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7152. * This is dynamic to allow compat with webgl 1 and 2.
  7153. * You will need to pass the name of the uniform as well as the value.
  7154. */
  7155. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7156. /**
  7157. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7158. * This is dynamic to allow compat with webgl 1 and 2.
  7159. * You will need to pass the name of the uniform as well as the value.
  7160. */
  7161. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7162. /**
  7163. * Lambda to Update a single float in a uniform buffer.
  7164. * This is dynamic to allow compat with webgl 1 and 2.
  7165. * You will need to pass the name of the uniform as well as the value.
  7166. */
  7167. updateFloat: (name: string, x: number) => void;
  7168. /**
  7169. * Lambda to Update a vec2 of float in a uniform buffer.
  7170. * This is dynamic to allow compat with webgl 1 and 2.
  7171. * You will need to pass the name of the uniform as well as the value.
  7172. */
  7173. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7174. /**
  7175. * Lambda to Update a vec3 of float in a uniform buffer.
  7176. * This is dynamic to allow compat with webgl 1 and 2.
  7177. * You will need to pass the name of the uniform as well as the value.
  7178. */
  7179. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7180. /**
  7181. * Lambda to Update a vec4 of float in a uniform buffer.
  7182. * This is dynamic to allow compat with webgl 1 and 2.
  7183. * You will need to pass the name of the uniform as well as the value.
  7184. */
  7185. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7186. /**
  7187. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7188. * This is dynamic to allow compat with webgl 1 and 2.
  7189. * You will need to pass the name of the uniform as well as the value.
  7190. */
  7191. updateMatrix: (name: string, mat: Matrix) => void;
  7192. /**
  7193. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7194. * This is dynamic to allow compat with webgl 1 and 2.
  7195. * You will need to pass the name of the uniform as well as the value.
  7196. */
  7197. updateVector3: (name: string, vector: Vector3) => void;
  7198. /**
  7199. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7200. * This is dynamic to allow compat with webgl 1 and 2.
  7201. * You will need to pass the name of the uniform as well as the value.
  7202. */
  7203. updateVector4: (name: string, vector: Vector4) => void;
  7204. /**
  7205. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7206. * This is dynamic to allow compat with webgl 1 and 2.
  7207. * You will need to pass the name of the uniform as well as the value.
  7208. */
  7209. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7210. /**
  7211. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7212. * This is dynamic to allow compat with webgl 1 and 2.
  7213. * You will need to pass the name of the uniform as well as the value.
  7214. */
  7215. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7216. /**
  7217. * Instantiates a new Uniform buffer objects.
  7218. *
  7219. * Handles blocks of uniform on the GPU.
  7220. *
  7221. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7222. *
  7223. * For more information, please refer to :
  7224. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7225. * @param engine Define the engine the buffer is associated with
  7226. * @param data Define the data contained in the buffer
  7227. * @param dynamic Define if the buffer is updatable
  7228. */
  7229. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7230. /**
  7231. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7232. * or just falling back on setUniformXXX calls.
  7233. */
  7234. readonly useUbo: boolean;
  7235. /**
  7236. * Indicates if the WebGL underlying uniform buffer is in sync
  7237. * with the javascript cache data.
  7238. */
  7239. readonly isSync: boolean;
  7240. /**
  7241. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7242. * Also, a dynamic UniformBuffer will disable cache verification and always
  7243. * update the underlying WebGL uniform buffer to the GPU.
  7244. * @returns if Dynamic, otherwise false
  7245. */
  7246. isDynamic(): boolean;
  7247. /**
  7248. * The data cache on JS side.
  7249. * @returns the underlying data as a float array
  7250. */
  7251. getData(): Float32Array;
  7252. /**
  7253. * The underlying WebGL Uniform buffer.
  7254. * @returns the webgl buffer
  7255. */
  7256. getBuffer(): Nullable<DataBuffer>;
  7257. /**
  7258. * std140 layout specifies how to align data within an UBO structure.
  7259. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7260. * for specs.
  7261. */
  7262. private _fillAlignment;
  7263. /**
  7264. * Adds an uniform in the buffer.
  7265. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7266. * for the layout to be correct !
  7267. * @param name Name of the uniform, as used in the uniform block in the shader.
  7268. * @param size Data size, or data directly.
  7269. */
  7270. addUniform(name: string, size: number | number[]): void;
  7271. /**
  7272. * Adds a Matrix 4x4 to the uniform buffer.
  7273. * @param name Name of the uniform, as used in the uniform block in the shader.
  7274. * @param mat A 4x4 matrix.
  7275. */
  7276. addMatrix(name: string, mat: Matrix): void;
  7277. /**
  7278. * Adds a vec2 to the uniform buffer.
  7279. * @param name Name of the uniform, as used in the uniform block in the shader.
  7280. * @param x Define the x component value of the vec2
  7281. * @param y Define the y component value of the vec2
  7282. */
  7283. addFloat2(name: string, x: number, y: number): void;
  7284. /**
  7285. * Adds a vec3 to the uniform buffer.
  7286. * @param name Name of the uniform, as used in the uniform block in the shader.
  7287. * @param x Define the x component value of the vec3
  7288. * @param y Define the y component value of the vec3
  7289. * @param z Define the z component value of the vec3
  7290. */
  7291. addFloat3(name: string, x: number, y: number, z: number): void;
  7292. /**
  7293. * Adds a vec3 to the uniform buffer.
  7294. * @param name Name of the uniform, as used in the uniform block in the shader.
  7295. * @param color Define the vec3 from a Color
  7296. */
  7297. addColor3(name: string, color: Color3): void;
  7298. /**
  7299. * Adds a vec4 to the uniform buffer.
  7300. * @param name Name of the uniform, as used in the uniform block in the shader.
  7301. * @param color Define the rgb components from a Color
  7302. * @param alpha Define the a component of the vec4
  7303. */
  7304. addColor4(name: string, color: Color3, alpha: number): void;
  7305. /**
  7306. * Adds a vec3 to the uniform buffer.
  7307. * @param name Name of the uniform, as used in the uniform block in the shader.
  7308. * @param vector Define the vec3 components from a Vector
  7309. */
  7310. addVector3(name: string, vector: Vector3): void;
  7311. /**
  7312. * Adds a Matrix 3x3 to the uniform buffer.
  7313. * @param name Name of the uniform, as used in the uniform block in the shader.
  7314. */
  7315. addMatrix3x3(name: string): void;
  7316. /**
  7317. * Adds a Matrix 2x2 to the uniform buffer.
  7318. * @param name Name of the uniform, as used in the uniform block in the shader.
  7319. */
  7320. addMatrix2x2(name: string): void;
  7321. /**
  7322. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7323. */
  7324. create(): void;
  7325. /** @hidden */ private _rebuild(): void;
  7326. /**
  7327. * Updates the WebGL Uniform Buffer on the GPU.
  7328. * If the `dynamic` flag is set to true, no cache comparison is done.
  7329. * Otherwise, the buffer will be updated only if the cache differs.
  7330. */
  7331. update(): void;
  7332. /**
  7333. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7334. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7335. * @param data Define the flattened data
  7336. * @param size Define the size of the data.
  7337. */
  7338. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7339. private _valueCache;
  7340. private _cacheMatrix;
  7341. private _updateMatrix3x3ForUniform;
  7342. private _updateMatrix3x3ForEffect;
  7343. private _updateMatrix2x2ForEffect;
  7344. private _updateMatrix2x2ForUniform;
  7345. private _updateFloatForEffect;
  7346. private _updateFloatForUniform;
  7347. private _updateFloat2ForEffect;
  7348. private _updateFloat2ForUniform;
  7349. private _updateFloat3ForEffect;
  7350. private _updateFloat3ForUniform;
  7351. private _updateFloat4ForEffect;
  7352. private _updateFloat4ForUniform;
  7353. private _updateMatrixForEffect;
  7354. private _updateMatrixForUniform;
  7355. private _updateVector3ForEffect;
  7356. private _updateVector3ForUniform;
  7357. private _updateVector4ForEffect;
  7358. private _updateVector4ForUniform;
  7359. private _updateColor3ForEffect;
  7360. private _updateColor3ForUniform;
  7361. private _updateColor4ForEffect;
  7362. private _updateColor4ForUniform;
  7363. /**
  7364. * Sets a sampler uniform on the effect.
  7365. * @param name Define the name of the sampler.
  7366. * @param texture Define the texture to set in the sampler
  7367. */
  7368. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7369. /**
  7370. * Directly updates the value of the uniform in the cache AND on the GPU.
  7371. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7372. * @param data Define the flattened data
  7373. */
  7374. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7375. /**
  7376. * Binds this uniform buffer to an effect.
  7377. * @param effect Define the effect to bind the buffer to
  7378. * @param name Name of the uniform block in the shader.
  7379. */
  7380. bindToEffect(effect: Effect, name: string): void;
  7381. /**
  7382. * Disposes the uniform buffer.
  7383. */
  7384. dispose(): void;
  7385. }
  7386. }
  7387. declare module BABYLON {
  7388. /**
  7389. * Enum that determines the text-wrapping mode to use.
  7390. */
  7391. export enum InspectableType {
  7392. /**
  7393. * Checkbox for booleans
  7394. */
  7395. Checkbox = 0,
  7396. /**
  7397. * Sliders for numbers
  7398. */
  7399. Slider = 1,
  7400. /**
  7401. * Vector3
  7402. */
  7403. Vector3 = 2,
  7404. /**
  7405. * Quaternions
  7406. */
  7407. Quaternion = 3,
  7408. /**
  7409. * Color3
  7410. */
  7411. Color3 = 4,
  7412. /**
  7413. * String
  7414. */
  7415. String = 5
  7416. }
  7417. /**
  7418. * Interface used to define custom inspectable properties.
  7419. * This interface is used by the inspector to display custom property grids
  7420. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7421. */
  7422. export interface IInspectable {
  7423. /**
  7424. * Gets the label to display
  7425. */
  7426. label: string;
  7427. /**
  7428. * Gets the name of the property to edit
  7429. */
  7430. propertyName: string;
  7431. /**
  7432. * Gets the type of the editor to use
  7433. */
  7434. type: InspectableType;
  7435. /**
  7436. * Gets the minimum value of the property when using in "slider" mode
  7437. */
  7438. min?: number;
  7439. /**
  7440. * Gets the maximum value of the property when using in "slider" mode
  7441. */
  7442. max?: number;
  7443. /**
  7444. * Gets the setp to use when using in "slider" mode
  7445. */
  7446. step?: number;
  7447. }
  7448. }
  7449. declare module BABYLON {
  7450. /**
  7451. * Class used to provide helper for timing
  7452. */
  7453. export class TimingTools {
  7454. /**
  7455. * Polyfill for setImmediate
  7456. * @param action defines the action to execute after the current execution block
  7457. */
  7458. static SetImmediate(action: () => void): void;
  7459. }
  7460. }
  7461. declare module BABYLON {
  7462. /**
  7463. * Class used to enable instatition of objects by class name
  7464. */
  7465. export class InstantiationTools {
  7466. /**
  7467. * Use this object to register external classes like custom textures or material
  7468. * to allow the laoders to instantiate them
  7469. */
  7470. static RegisteredExternalClasses: {
  7471. [key: string]: Object;
  7472. };
  7473. /**
  7474. * Tries to instantiate a new object from a given class name
  7475. * @param className defines the class name to instantiate
  7476. * @returns the new object or null if the system was not able to do the instantiation
  7477. */
  7478. static Instantiate(className: string): any;
  7479. }
  7480. }
  7481. declare module BABYLON {
  7482. /**
  7483. * Define options used to create a depth texture
  7484. */
  7485. export class DepthTextureCreationOptions {
  7486. /** Specifies whether or not a stencil should be allocated in the texture */
  7487. generateStencil?: boolean;
  7488. /** Specifies whether or not bilinear filtering is enable on the texture */
  7489. bilinearFiltering?: boolean;
  7490. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7491. comparisonFunction?: number;
  7492. /** Specifies if the created texture is a cube texture */
  7493. isCube?: boolean;
  7494. }
  7495. }
  7496. declare module BABYLON {
  7497. interface BaseEngine {
  7498. /**
  7499. * Creates a depth stencil cube texture.
  7500. * This is only available in WebGL 2.
  7501. * @param size The size of face edge in the cube texture.
  7502. * @param options The options defining the cube texture.
  7503. * @returns The cube texture
  7504. */ private _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7505. /**
  7506. * Creates a cube texture
  7507. * @param rootUrl defines the url where the files to load is located
  7508. * @param scene defines the current scene
  7509. * @param files defines the list of files to load (1 per face)
  7510. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7511. * @param onLoad defines an optional callback raised when the texture is loaded
  7512. * @param onError defines an optional callback raised if there is an issue to load the texture
  7513. * @param format defines the format of the data
  7514. * @param forcedExtension defines the extension to use to pick the right loader
  7515. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7516. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7517. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7518. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7519. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7520. * @returns the cube texture as an InternalTexture
  7521. */
  7522. 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;
  7523. /**
  7524. * Creates a cube texture
  7525. * @param rootUrl defines the url where the files to load is located
  7526. * @param scene defines the current scene
  7527. * @param files defines the list of files to load (1 per face)
  7528. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7529. * @param onLoad defines an optional callback raised when the texture is loaded
  7530. * @param onError defines an optional callback raised if there is an issue to load the texture
  7531. * @param format defines the format of the data
  7532. * @param forcedExtension defines the extension to use to pick the right loader
  7533. * @returns the cube texture as an InternalTexture
  7534. */
  7535. 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;
  7536. /**
  7537. * Creates a cube texture
  7538. * @param rootUrl defines the url where the files to load is located
  7539. * @param scene defines the current scene
  7540. * @param files defines the list of files to load (1 per face)
  7541. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7542. * @param onLoad defines an optional callback raised when the texture is loaded
  7543. * @param onError defines an optional callback raised if there is an issue to load the texture
  7544. * @param format defines the format of the data
  7545. * @param forcedExtension defines the extension to use to pick the right loader
  7546. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7547. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7548. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7549. * @returns the cube texture as an InternalTexture
  7550. */
  7551. 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;
  7552. /** @hidden */ private _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7553. /** @hidden */ private _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7554. /** @hidden */ private _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7555. /** @hidden */ private _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7556. }
  7557. }
  7558. declare module BABYLON {
  7559. /**
  7560. * Class for creating a cube texture
  7561. */
  7562. export class CubeTexture extends BaseTexture {
  7563. private _delayedOnLoad;
  7564. /**
  7565. * The url of the texture
  7566. */
  7567. url: string;
  7568. /**
  7569. * Gets or sets the center of the bounding box associated with the cube texture.
  7570. * It must define where the camera used to render the texture was set
  7571. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7572. */
  7573. boundingBoxPosition: Vector3;
  7574. private _boundingBoxSize;
  7575. /**
  7576. * Gets or sets the size of the bounding box associated with the cube texture
  7577. * When defined, the cubemap will switch to local mode
  7578. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7579. * @example https://www.babylonjs-playground.com/#RNASML
  7580. */
  7581. /**
  7582. * Returns the bounding box size
  7583. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7584. */
  7585. boundingBoxSize: Vector3;
  7586. protected _rotationY: number;
  7587. /**
  7588. * Sets texture matrix rotation angle around Y axis in radians.
  7589. */
  7590. /**
  7591. * Gets texture matrix rotation angle around Y axis radians.
  7592. */
  7593. rotationY: number;
  7594. /**
  7595. * Are mip maps generated for this texture or not.
  7596. */
  7597. readonly noMipmap: boolean;
  7598. private _noMipmap;
  7599. private _files;
  7600. private _extensions;
  7601. private _textureMatrix;
  7602. private _format;
  7603. private _createPolynomials;
  7604. /** @hidden */ private _prefiltered: boolean;
  7605. /**
  7606. * Creates a cube texture from an array of image urls
  7607. * @param files defines an array of image urls
  7608. * @param scene defines the hosting scene
  7609. * @param noMipmap specifies if mip maps are not used
  7610. * @returns a cube texture
  7611. */
  7612. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7613. /**
  7614. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7615. * @param url defines the url of the prefiltered texture
  7616. * @param scene defines the scene the texture is attached to
  7617. * @param forcedExtension defines the extension of the file if different from the url
  7618. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7619. * @return the prefiltered texture
  7620. */
  7621. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7622. /**
  7623. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7624. * as prefiltered data.
  7625. * @param rootUrl defines the url of the texture or the root name of the six images
  7626. * @param scene defines the scene the texture is attached to
  7627. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7628. * @param noMipmap defines if mipmaps should be created or not
  7629. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7630. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7631. * @param onError defines a callback triggered in case of error during load
  7632. * @param format defines the internal format to use for the texture once loaded
  7633. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7634. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7635. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7636. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7637. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7638. * @return the cube texture
  7639. */
  7640. 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);
  7641. /**
  7642. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7643. */
  7644. readonly isPrefiltered: boolean;
  7645. /**
  7646. * Get the current class name of the texture useful for serialization or dynamic coding.
  7647. * @returns "CubeTexture"
  7648. */
  7649. getClassName(): string;
  7650. /**
  7651. * Update the url (and optional buffer) of this texture if url was null during construction.
  7652. * @param url the url of the texture
  7653. * @param forcedExtension defines the extension to use
  7654. * @param onLoad callback called when the texture is loaded (defaults to null)
  7655. */
  7656. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7657. /**
  7658. * Delays loading of the cube texture
  7659. * @param forcedExtension defines the extension to use
  7660. */
  7661. delayLoad(forcedExtension?: string): void;
  7662. /**
  7663. * Returns the reflection texture matrix
  7664. * @returns the reflection texture matrix
  7665. */
  7666. getReflectionTextureMatrix(): Matrix;
  7667. /**
  7668. * Sets the reflection texture matrix
  7669. * @param value Reflection texture matrix
  7670. */
  7671. setReflectionTextureMatrix(value: Matrix): void;
  7672. /**
  7673. * Parses text to create a cube texture
  7674. * @param parsedTexture define the serialized text to read from
  7675. * @param scene defines the hosting scene
  7676. * @param rootUrl defines the root url of the cube texture
  7677. * @returns a cube texture
  7678. */
  7679. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7680. /**
  7681. * Makes a clone, or deep copy, of the cube texture
  7682. * @returns a new cube texture
  7683. */
  7684. clone(): CubeTexture;
  7685. }
  7686. }
  7687. declare module BABYLON {
  7688. /**
  7689. * Manages the defines for the Material
  7690. */
  7691. export class MaterialDefines {
  7692. /** @hidden */
  7693. protected _keys: string[];
  7694. private _isDirty;
  7695. /** @hidden */ private _renderId: number;
  7696. /** @hidden */ private _areLightsDirty: boolean;
  7697. /** @hidden */ private _areLightsDisposed: boolean;
  7698. /** @hidden */ private _areAttributesDirty: boolean;
  7699. /** @hidden */ private _areTexturesDirty: boolean;
  7700. /** @hidden */ private _areFresnelDirty: boolean;
  7701. /** @hidden */ private _areMiscDirty: boolean;
  7702. /** @hidden */ private _areImageProcessingDirty: boolean;
  7703. /** @hidden */ private _normals: boolean;
  7704. /** @hidden */ private _uvs: boolean;
  7705. /** @hidden */ private _needNormals: boolean;
  7706. /** @hidden */ private _needUVs: boolean;
  7707. [id: string]: any;
  7708. /**
  7709. * Specifies if the material needs to be re-calculated
  7710. */
  7711. readonly isDirty: boolean;
  7712. /**
  7713. * Marks the material to indicate that it has been re-calculated
  7714. */
  7715. markAsProcessed(): void;
  7716. /**
  7717. * Marks the material to indicate that it needs to be re-calculated
  7718. */
  7719. markAsUnprocessed(): void;
  7720. /**
  7721. * Marks the material to indicate all of its defines need to be re-calculated
  7722. */
  7723. markAllAsDirty(): void;
  7724. /**
  7725. * Marks the material to indicate that image processing needs to be re-calculated
  7726. */
  7727. markAsImageProcessingDirty(): void;
  7728. /**
  7729. * Marks the material to indicate the lights need to be re-calculated
  7730. * @param disposed Defines whether the light is dirty due to dispose or not
  7731. */
  7732. markAsLightDirty(disposed?: boolean): void;
  7733. /**
  7734. * Marks the attribute state as changed
  7735. */
  7736. markAsAttributesDirty(): void;
  7737. /**
  7738. * Marks the texture state as changed
  7739. */
  7740. markAsTexturesDirty(): void;
  7741. /**
  7742. * Marks the fresnel state as changed
  7743. */
  7744. markAsFresnelDirty(): void;
  7745. /**
  7746. * Marks the misc state as changed
  7747. */
  7748. markAsMiscDirty(): void;
  7749. /**
  7750. * Rebuilds the material defines
  7751. */
  7752. rebuild(): void;
  7753. /**
  7754. * Specifies if two material defines are equal
  7755. * @param other - A material define instance to compare to
  7756. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7757. */
  7758. isEqual(other: MaterialDefines): boolean;
  7759. /**
  7760. * Clones this instance's defines to another instance
  7761. * @param other - material defines to clone values to
  7762. */
  7763. cloneTo(other: MaterialDefines): void;
  7764. /**
  7765. * Resets the material define values
  7766. */
  7767. reset(): void;
  7768. /**
  7769. * Converts the material define values to a string
  7770. * @returns - String of material define information
  7771. */
  7772. toString(): string;
  7773. }
  7774. }
  7775. declare module BABYLON {
  7776. /**
  7777. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7778. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7779. * 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;
  7780. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7781. */
  7782. export class ColorCurves {
  7783. private _dirty;
  7784. private _tempColor;
  7785. private _globalCurve;
  7786. private _highlightsCurve;
  7787. private _midtonesCurve;
  7788. private _shadowsCurve;
  7789. private _positiveCurve;
  7790. private _negativeCurve;
  7791. private _globalHue;
  7792. private _globalDensity;
  7793. private _globalSaturation;
  7794. private _globalExposure;
  7795. /**
  7796. * Gets the global Hue value.
  7797. * 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).
  7798. */
  7799. /**
  7800. * Sets the global Hue value.
  7801. * 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).
  7802. */
  7803. globalHue: number;
  7804. /**
  7805. * Gets the global Density value.
  7806. * 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.
  7807. * Values less than zero provide a filter of opposite hue.
  7808. */
  7809. /**
  7810. * Sets the global Density value.
  7811. * 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.
  7812. * Values less than zero provide a filter of opposite hue.
  7813. */
  7814. globalDensity: number;
  7815. /**
  7816. * Gets the global Saturation 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 saturation and negative values decrease saturation.
  7818. */
  7819. /**
  7820. * Sets the global Saturation 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 saturation and negative values decrease saturation.
  7822. */
  7823. globalSaturation: number;
  7824. /**
  7825. * Gets the global Exposure value.
  7826. * 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.
  7827. */
  7828. /**
  7829. * Sets the global Exposure value.
  7830. * 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.
  7831. */
  7832. globalExposure: number;
  7833. private _highlightsHue;
  7834. private _highlightsDensity;
  7835. private _highlightsSaturation;
  7836. private _highlightsExposure;
  7837. /**
  7838. * Gets the highlights Hue value.
  7839. * 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).
  7840. */
  7841. /**
  7842. * Sets the highlights Hue value.
  7843. * 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).
  7844. */
  7845. highlightsHue: number;
  7846. /**
  7847. * Gets the highlights Density value.
  7848. * 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.
  7849. * Values less than zero provide a filter of opposite hue.
  7850. */
  7851. /**
  7852. * Sets the highlights Density value.
  7853. * 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.
  7854. * Values less than zero provide a filter of opposite hue.
  7855. */
  7856. highlightsDensity: number;
  7857. /**
  7858. * Gets the highlights Saturation 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 saturation and negative values decrease saturation.
  7860. */
  7861. /**
  7862. * Sets the highlights Saturation 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 saturation and negative values decrease saturation.
  7864. */
  7865. highlightsSaturation: number;
  7866. /**
  7867. * Gets the highlights Exposure value.
  7868. * 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.
  7869. */
  7870. /**
  7871. * Sets the highlights Exposure value.
  7872. * 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.
  7873. */
  7874. highlightsExposure: number;
  7875. private _midtonesHue;
  7876. private _midtonesDensity;
  7877. private _midtonesSaturation;
  7878. private _midtonesExposure;
  7879. /**
  7880. * Gets the midtones Hue value.
  7881. * 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).
  7882. */
  7883. /**
  7884. * Sets the midtones Hue value.
  7885. * 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).
  7886. */
  7887. midtonesHue: number;
  7888. /**
  7889. * Gets the midtones Density value.
  7890. * 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.
  7891. * Values less than zero provide a filter of opposite hue.
  7892. */
  7893. /**
  7894. * Sets the midtones Density value.
  7895. * 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.
  7896. * Values less than zero provide a filter of opposite hue.
  7897. */
  7898. midtonesDensity: number;
  7899. /**
  7900. * Gets the midtones Saturation value.
  7901. * 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.
  7902. */
  7903. /**
  7904. * Sets the midtones Saturation value.
  7905. * 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.
  7906. */
  7907. midtonesSaturation: number;
  7908. /**
  7909. * Gets the midtones Exposure value.
  7910. * 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.
  7911. */
  7912. /**
  7913. * Sets the midtones Exposure value.
  7914. * 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.
  7915. */
  7916. midtonesExposure: number;
  7917. private _shadowsHue;
  7918. private _shadowsDensity;
  7919. private _shadowsSaturation;
  7920. private _shadowsExposure;
  7921. /**
  7922. * Gets the shadows Hue value.
  7923. * 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).
  7924. */
  7925. /**
  7926. * Sets the shadows Hue value.
  7927. * 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).
  7928. */
  7929. shadowsHue: number;
  7930. /**
  7931. * Gets the shadows Density value.
  7932. * 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.
  7933. * Values less than zero provide a filter of opposite hue.
  7934. */
  7935. /**
  7936. * Sets the shadows Density value.
  7937. * 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.
  7938. * Values less than zero provide a filter of opposite hue.
  7939. */
  7940. shadowsDensity: number;
  7941. /**
  7942. * Gets the shadows Saturation value.
  7943. * 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.
  7944. */
  7945. /**
  7946. * Sets the shadows Saturation value.
  7947. * 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.
  7948. */
  7949. shadowsSaturation: number;
  7950. /**
  7951. * Gets the shadows Exposure value.
  7952. * 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.
  7953. */
  7954. /**
  7955. * Sets the shadows Exposure value.
  7956. * 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.
  7957. */
  7958. shadowsExposure: number;
  7959. /**
  7960. * Returns the class name
  7961. * @returns The class name
  7962. */
  7963. getClassName(): string;
  7964. /**
  7965. * Binds the color curves to the shader.
  7966. * @param colorCurves The color curve to bind
  7967. * @param effect The effect to bind to
  7968. * @param positiveUniform The positive uniform shader parameter
  7969. * @param neutralUniform The neutral uniform shader parameter
  7970. * @param negativeUniform The negative uniform shader parameter
  7971. */
  7972. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7973. /**
  7974. * Prepare the list of uniforms associated with the ColorCurves effects.
  7975. * @param uniformsList The list of uniforms used in the effect
  7976. */
  7977. static PrepareUniforms(uniformsList: string[]): void;
  7978. /**
  7979. * Returns color grading data based on a hue, density, saturation and exposure value.
  7980. * @param filterHue The hue of the color filter.
  7981. * @param filterDensity The density of the color filter.
  7982. * @param saturation The saturation.
  7983. * @param exposure The exposure.
  7984. * @param result The result data container.
  7985. */
  7986. private getColorGradingDataToRef;
  7987. /**
  7988. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7989. * @param value The input slider value in range [-100,100].
  7990. * @returns Adjusted value.
  7991. */
  7992. private static applyColorGradingSliderNonlinear;
  7993. /**
  7994. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7995. * @param hue The hue (H) input.
  7996. * @param saturation The saturation (S) input.
  7997. * @param brightness The brightness (B) input.
  7998. * @result An RGBA color represented as Vector4.
  7999. */
  8000. private static fromHSBToRef;
  8001. /**
  8002. * Returns a value clamped between min and max
  8003. * @param value The value to clamp
  8004. * @param min The minimum of value
  8005. * @param max The maximum of value
  8006. * @returns The clamped value.
  8007. */
  8008. private static clamp;
  8009. /**
  8010. * Clones the current color curve instance.
  8011. * @return The cloned curves
  8012. */
  8013. clone(): ColorCurves;
  8014. /**
  8015. * Serializes the current color curve instance to a json representation.
  8016. * @return a JSON representation
  8017. */
  8018. serialize(): any;
  8019. /**
  8020. * Parses the color curve from a json representation.
  8021. * @param source the JSON source to parse
  8022. * @return The parsed curves
  8023. */
  8024. static Parse(source: any): ColorCurves;
  8025. }
  8026. }
  8027. declare module BABYLON {
  8028. /**
  8029. * Interface to follow in your material defines to integrate easily the
  8030. * Image proccessing functions.
  8031. * @hidden
  8032. */
  8033. export interface IImageProcessingConfigurationDefines {
  8034. IMAGEPROCESSING: boolean;
  8035. VIGNETTE: boolean;
  8036. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8037. VIGNETTEBLENDMODEOPAQUE: boolean;
  8038. TONEMAPPING: boolean;
  8039. TONEMAPPING_ACES: boolean;
  8040. CONTRAST: boolean;
  8041. EXPOSURE: boolean;
  8042. COLORCURVES: boolean;
  8043. COLORGRADING: boolean;
  8044. COLORGRADING3D: boolean;
  8045. SAMPLER3DGREENDEPTH: boolean;
  8046. SAMPLER3DBGRMAP: boolean;
  8047. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8048. }
  8049. /**
  8050. * @hidden
  8051. */
  8052. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8053. IMAGEPROCESSING: boolean;
  8054. VIGNETTE: boolean;
  8055. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8056. VIGNETTEBLENDMODEOPAQUE: boolean;
  8057. TONEMAPPING: boolean;
  8058. TONEMAPPING_ACES: boolean;
  8059. CONTRAST: boolean;
  8060. COLORCURVES: boolean;
  8061. COLORGRADING: boolean;
  8062. COLORGRADING3D: boolean;
  8063. SAMPLER3DGREENDEPTH: boolean;
  8064. SAMPLER3DBGRMAP: boolean;
  8065. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8066. EXPOSURE: boolean;
  8067. constructor();
  8068. }
  8069. /**
  8070. * This groups together the common properties used for image processing either in direct forward pass
  8071. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8072. * or not.
  8073. */
  8074. export class ImageProcessingConfiguration {
  8075. /**
  8076. * Default tone mapping applied in BabylonJS.
  8077. */
  8078. static readonly TONEMAPPING_STANDARD: number;
  8079. /**
  8080. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8081. * to other engines rendering to increase portability.
  8082. */
  8083. static readonly TONEMAPPING_ACES: number;
  8084. /**
  8085. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8086. */
  8087. colorCurves: Nullable<ColorCurves>;
  8088. private _colorCurvesEnabled;
  8089. /**
  8090. * Gets wether the color curves effect is enabled.
  8091. */
  8092. /**
  8093. * Sets wether the color curves effect is enabled.
  8094. */
  8095. colorCurvesEnabled: boolean;
  8096. private _colorGradingTexture;
  8097. /**
  8098. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8099. */
  8100. /**
  8101. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8102. */
  8103. colorGradingTexture: Nullable<BaseTexture>;
  8104. private _colorGradingEnabled;
  8105. /**
  8106. * Gets wether the color grading effect is enabled.
  8107. */
  8108. /**
  8109. * Sets wether the color grading effect is enabled.
  8110. */
  8111. colorGradingEnabled: boolean;
  8112. private _colorGradingWithGreenDepth;
  8113. /**
  8114. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8115. */
  8116. /**
  8117. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8118. */
  8119. colorGradingWithGreenDepth: boolean;
  8120. private _colorGradingBGR;
  8121. /**
  8122. * Gets wether the color grading texture contains BGR values.
  8123. */
  8124. /**
  8125. * Sets wether the color grading texture contains BGR values.
  8126. */
  8127. colorGradingBGR: boolean;
  8128. /** @hidden */ private _exposure: number;
  8129. /**
  8130. * Gets the Exposure used in the effect.
  8131. */
  8132. /**
  8133. * Sets the Exposure used in the effect.
  8134. */
  8135. exposure: number;
  8136. private _toneMappingEnabled;
  8137. /**
  8138. * Gets wether the tone mapping effect is enabled.
  8139. */
  8140. /**
  8141. * Sets wether the tone mapping effect is enabled.
  8142. */
  8143. toneMappingEnabled: boolean;
  8144. private _toneMappingType;
  8145. /**
  8146. * Gets the type of tone mapping effect.
  8147. */
  8148. /**
  8149. * Sets the type of tone mapping effect used in BabylonJS.
  8150. */
  8151. toneMappingType: number;
  8152. protected _contrast: number;
  8153. /**
  8154. * Gets the contrast used in the effect.
  8155. */
  8156. /**
  8157. * Sets the contrast used in the effect.
  8158. */
  8159. contrast: number;
  8160. /**
  8161. * Vignette stretch size.
  8162. */
  8163. vignetteStretch: number;
  8164. /**
  8165. * Vignette centre X Offset.
  8166. */
  8167. vignetteCentreX: number;
  8168. /**
  8169. * Vignette centre Y Offset.
  8170. */
  8171. vignetteCentreY: number;
  8172. /**
  8173. * Vignette weight or intensity of the vignette effect.
  8174. */
  8175. vignetteWeight: number;
  8176. /**
  8177. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8178. * if vignetteEnabled is set to true.
  8179. */
  8180. vignetteColor: Color4;
  8181. /**
  8182. * Camera field of view used by the Vignette effect.
  8183. */
  8184. vignetteCameraFov: number;
  8185. private _vignetteBlendMode;
  8186. /**
  8187. * Gets the vignette blend mode allowing different kind of effect.
  8188. */
  8189. /**
  8190. * Sets the vignette blend mode allowing different kind of effect.
  8191. */
  8192. vignetteBlendMode: number;
  8193. private _vignetteEnabled;
  8194. /**
  8195. * Gets wether the vignette effect is enabled.
  8196. */
  8197. /**
  8198. * Sets wether the vignette effect is enabled.
  8199. */
  8200. vignetteEnabled: boolean;
  8201. private _applyByPostProcess;
  8202. /**
  8203. * Gets wether the image processing is applied through a post process or not.
  8204. */
  8205. /**
  8206. * Sets wether the image processing is applied through a post process or not.
  8207. */
  8208. applyByPostProcess: boolean;
  8209. private _isEnabled;
  8210. /**
  8211. * Gets wether the image processing is enabled or not.
  8212. */
  8213. /**
  8214. * Sets wether the image processing is enabled or not.
  8215. */
  8216. isEnabled: boolean;
  8217. /**
  8218. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8219. */
  8220. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8221. /**
  8222. * Method called each time the image processing information changes requires to recompile the effect.
  8223. */
  8224. protected _updateParameters(): void;
  8225. /**
  8226. * Gets the current class name.
  8227. * @return "ImageProcessingConfiguration"
  8228. */
  8229. getClassName(): string;
  8230. /**
  8231. * Prepare the list of uniforms associated with the Image Processing effects.
  8232. * @param uniforms The list of uniforms used in the effect
  8233. * @param defines the list of defines currently in use
  8234. */
  8235. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8236. /**
  8237. * Prepare the list of samplers associated with the Image Processing effects.
  8238. * @param samplersList The list of uniforms used in the effect
  8239. * @param defines the list of defines currently in use
  8240. */
  8241. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8242. /**
  8243. * Prepare the list of defines associated to the shader.
  8244. * @param defines the list of defines to complete
  8245. * @param forPostProcess Define if we are currently in post process mode or not
  8246. */
  8247. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8248. /**
  8249. * Returns true if all the image processing information are ready.
  8250. * @returns True if ready, otherwise, false
  8251. */
  8252. isReady(): boolean;
  8253. /**
  8254. * Binds the image processing to the shader.
  8255. * @param effect The effect to bind to
  8256. * @param aspectRatio Define the current aspect ratio of the effect
  8257. */
  8258. bind(effect: Effect, aspectRatio?: number): void;
  8259. /**
  8260. * Clones the current image processing instance.
  8261. * @return The cloned image processing
  8262. */
  8263. clone(): ImageProcessingConfiguration;
  8264. /**
  8265. * Serializes the current image processing instance to a json representation.
  8266. * @return a JSON representation
  8267. */
  8268. serialize(): any;
  8269. /**
  8270. * Parses the image processing from a json representation.
  8271. * @param source the JSON source to parse
  8272. * @return The parsed image processing
  8273. */
  8274. static Parse(source: any): ImageProcessingConfiguration;
  8275. private static _VIGNETTEMODE_MULTIPLY;
  8276. private static _VIGNETTEMODE_OPAQUE;
  8277. /**
  8278. * Used to apply the vignette as a mix with the pixel color.
  8279. */
  8280. static readonly VIGNETTEMODE_MULTIPLY: number;
  8281. /**
  8282. * Used to apply the vignette as a replacement of the pixel color.
  8283. */
  8284. static readonly VIGNETTEMODE_OPAQUE: number;
  8285. }
  8286. }
  8287. declare module BABYLON {
  8288. /** @hidden */
  8289. export var postprocessVertexShader: {
  8290. name: string;
  8291. shader: string;
  8292. };
  8293. }
  8294. declare module BABYLON {
  8295. /** Defines supported spaces */
  8296. export enum Space {
  8297. /** Local (object) space */
  8298. LOCAL = 0,
  8299. /** World space */
  8300. WORLD = 1,
  8301. /** Bone space */
  8302. BONE = 2
  8303. }
  8304. /** Defines the 3 main axes */
  8305. export class Axis {
  8306. /** X axis */
  8307. static X: Vector3;
  8308. /** Y axis */
  8309. static Y: Vector3;
  8310. /** Z axis */
  8311. static Z: Vector3;
  8312. }
  8313. }
  8314. declare module BABYLON {
  8315. /**
  8316. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8317. * This is the base of the follow, arc rotate cameras and Free camera
  8318. * @see http://doc.babylonjs.com/features/cameras
  8319. */
  8320. export class TargetCamera extends Camera {
  8321. private static _RigCamTransformMatrix;
  8322. private static _TargetTransformMatrix;
  8323. private static _TargetFocalPoint;
  8324. /**
  8325. * Define the current direction the camera is moving to
  8326. */
  8327. cameraDirection: Vector3;
  8328. /**
  8329. * Define the current rotation the camera is rotating to
  8330. */
  8331. cameraRotation: Vector2;
  8332. /**
  8333. * When set, the up vector of the camera will be updated by the rotation of the camera
  8334. */
  8335. updateUpVectorFromRotation: boolean;
  8336. private _tmpQuaternion;
  8337. /**
  8338. * Define the current rotation of the camera
  8339. */
  8340. rotation: Vector3;
  8341. /**
  8342. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8343. */
  8344. rotationQuaternion: Quaternion;
  8345. /**
  8346. * Define the current speed of the camera
  8347. */
  8348. speed: number;
  8349. /**
  8350. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8351. * around all axis.
  8352. */
  8353. noRotationConstraint: boolean;
  8354. /**
  8355. * Define the current target of the camera as an object or a position.
  8356. */
  8357. lockedTarget: any;
  8358. /** @hidden */ private _currentTarget: Vector3;
  8359. /** @hidden */ private _initialFocalDistance: number;
  8360. /** @hidden */ private _viewMatrix: Matrix;
  8361. /** @hidden */ private _camMatrix: Matrix;
  8362. /** @hidden */ private _cameraTransformMatrix: Matrix;
  8363. /** @hidden */ private _cameraRotationMatrix: Matrix;
  8364. /** @hidden */ private _referencePoint: Vector3;
  8365. /** @hidden */ private _transformedReferencePoint: Vector3;
  8366. protected _globalCurrentTarget: Vector3;
  8367. protected _globalCurrentUpVector: Vector3;
  8368. /** @hidden */ private _reset: () => void;
  8369. private _defaultUp;
  8370. /**
  8371. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8372. * This is the base of the follow, arc rotate cameras and Free camera
  8373. * @see http://doc.babylonjs.com/features/cameras
  8374. * @param name Defines the name of the camera in the scene
  8375. * @param position Defines the start position of the camera in the scene
  8376. * @param scene Defines the scene the camera belongs to
  8377. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8378. */
  8379. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8380. /**
  8381. * Gets the position in front of the camera at a given distance.
  8382. * @param distance The distance from the camera we want the position to be
  8383. * @returns the position
  8384. */
  8385. getFrontPosition(distance: number): Vector3;
  8386. /** @hidden */ private _getLockedTargetPosition(): Nullable<Vector3>;
  8387. private _storedPosition;
  8388. private _storedRotation;
  8389. private _storedRotationQuaternion;
  8390. /**
  8391. * Store current camera state of the camera (fov, position, rotation, etc..)
  8392. * @returns the camera
  8393. */
  8394. storeState(): Camera;
  8395. /**
  8396. * Restored camera state. You must call storeState() first
  8397. * @returns whether it was successful or not
  8398. * @hidden
  8399. */ private _restoreStateValues(): boolean;
  8400. /** @hidden */ private _initCache(): void;
  8401. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  8402. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  8403. /** @hidden */ private _computeLocalCameraSpeed(): number;
  8404. /**
  8405. * Defines the target the camera should look at.
  8406. * @param target Defines the new target as a Vector or a mesh
  8407. */
  8408. setTarget(target: Vector3): void;
  8409. /**
  8410. * Return the current target position of the camera. This value is expressed in local space.
  8411. * @returns the target position
  8412. */
  8413. getTarget(): Vector3;
  8414. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  8415. /** @hidden */ private _updatePosition(): void;
  8416. /** @hidden */ private _checkInputs(): void;
  8417. protected _updateCameraRotationMatrix(): void;
  8418. /**
  8419. * 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)
  8420. * @returns the current camera
  8421. */
  8422. private _rotateUpVectorWithCameraRotationMatrix;
  8423. private _cachedRotationZ;
  8424. private _cachedQuaternionRotationZ;
  8425. /** @hidden */ private _getViewMatrix(): Matrix;
  8426. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8427. /**
  8428. * @hidden
  8429. */
  8430. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8431. /**
  8432. * @hidden
  8433. */ private _updateRigCameras(): void;
  8434. private _getRigCamPositionAndTarget;
  8435. /**
  8436. * Gets the current object class name.
  8437. * @return the class name
  8438. */
  8439. getClassName(): string;
  8440. }
  8441. }
  8442. declare module BABYLON {
  8443. /**
  8444. * Gather the list of keyboard event types as constants.
  8445. */
  8446. export class KeyboardEventTypes {
  8447. /**
  8448. * The keydown event is fired when a key becomes active (pressed).
  8449. */
  8450. static readonly KEYDOWN: number;
  8451. /**
  8452. * The keyup event is fired when a key has been released.
  8453. */
  8454. static readonly KEYUP: number;
  8455. }
  8456. /**
  8457. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8458. */
  8459. export class KeyboardInfo {
  8460. /**
  8461. * Defines the type of event (KeyboardEventTypes)
  8462. */
  8463. type: number;
  8464. /**
  8465. * Defines the related dom event
  8466. */
  8467. event: KeyboardEvent;
  8468. /**
  8469. * Instantiates a new keyboard info.
  8470. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8471. * @param type Defines the type of event (KeyboardEventTypes)
  8472. * @param event Defines the related dom event
  8473. */
  8474. constructor(
  8475. /**
  8476. * Defines the type of event (KeyboardEventTypes)
  8477. */
  8478. type: number,
  8479. /**
  8480. * Defines the related dom event
  8481. */
  8482. event: KeyboardEvent);
  8483. }
  8484. /**
  8485. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8486. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8487. */
  8488. export class KeyboardInfoPre extends KeyboardInfo {
  8489. /**
  8490. * Defines the type of event (KeyboardEventTypes)
  8491. */
  8492. type: number;
  8493. /**
  8494. * Defines the related dom event
  8495. */
  8496. event: KeyboardEvent;
  8497. /**
  8498. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8499. */
  8500. skipOnPointerObservable: boolean;
  8501. /**
  8502. * Instantiates a new keyboard pre info.
  8503. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8504. * @param type Defines the type of event (KeyboardEventTypes)
  8505. * @param event Defines the related dom event
  8506. */
  8507. constructor(
  8508. /**
  8509. * Defines the type of event (KeyboardEventTypes)
  8510. */
  8511. type: number,
  8512. /**
  8513. * Defines the related dom event
  8514. */
  8515. event: KeyboardEvent);
  8516. }
  8517. }
  8518. declare module BABYLON {
  8519. /**
  8520. * Manage the keyboard inputs to control the movement of a free camera.
  8521. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8522. */
  8523. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8524. /**
  8525. * Defines the camera the input is attached to.
  8526. */
  8527. camera: FreeCamera;
  8528. /**
  8529. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8530. */
  8531. keysUp: number[];
  8532. /**
  8533. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8534. */
  8535. keysDown: number[];
  8536. /**
  8537. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8538. */
  8539. keysLeft: number[];
  8540. /**
  8541. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8542. */
  8543. keysRight: number[];
  8544. private _keys;
  8545. private _onCanvasBlurObserver;
  8546. private _onKeyboardObserver;
  8547. private _engine;
  8548. private _scene;
  8549. /**
  8550. * Attach the input controls to a specific dom element to get the input from.
  8551. * @param element Defines the element the controls should be listened from
  8552. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8553. */
  8554. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8555. /**
  8556. * Detach the current controls from the specified dom element.
  8557. * @param element Defines the element to stop listening the inputs from
  8558. */
  8559. detachControl(element: Nullable<HTMLElement>): void;
  8560. /**
  8561. * Update the current camera state depending on the inputs that have been used this frame.
  8562. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8563. */
  8564. checkInputs(): void;
  8565. /**
  8566. * Gets the class name of the current intput.
  8567. * @returns the class name
  8568. */
  8569. getClassName(): string;
  8570. /** @hidden */ private _onLostFocus(): void;
  8571. /**
  8572. * Get the friendly name associated with the input class.
  8573. * @returns the input friendly name
  8574. */
  8575. getSimpleName(): string;
  8576. }
  8577. }
  8578. declare module BABYLON {
  8579. /**
  8580. * Interface describing all the common properties and methods a shadow light needs to implement.
  8581. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8582. * as well as binding the different shadow properties to the effects.
  8583. */
  8584. export interface IShadowLight extends Light {
  8585. /**
  8586. * The light id in the scene (used in scene.findLighById for instance)
  8587. */
  8588. id: string;
  8589. /**
  8590. * The position the shdow will be casted from.
  8591. */
  8592. position: Vector3;
  8593. /**
  8594. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8595. */
  8596. direction: Vector3;
  8597. /**
  8598. * The transformed position. Position of the light in world space taking parenting in account.
  8599. */
  8600. transformedPosition: Vector3;
  8601. /**
  8602. * The transformed direction. Direction of the light in world space taking parenting in account.
  8603. */
  8604. transformedDirection: Vector3;
  8605. /**
  8606. * The friendly name of the light in the scene.
  8607. */
  8608. name: string;
  8609. /**
  8610. * Defines the shadow projection clipping minimum z value.
  8611. */
  8612. shadowMinZ: number;
  8613. /**
  8614. * Defines the shadow projection clipping maximum z value.
  8615. */
  8616. shadowMaxZ: number;
  8617. /**
  8618. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8619. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8620. */
  8621. computeTransformedInformation(): boolean;
  8622. /**
  8623. * Gets the scene the light belongs to.
  8624. * @returns The scene
  8625. */
  8626. getScene(): Scene;
  8627. /**
  8628. * Callback defining a custom Projection Matrix Builder.
  8629. * This can be used to override the default projection matrix computation.
  8630. */
  8631. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8632. /**
  8633. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8634. * @param matrix The materix to updated with the projection information
  8635. * @param viewMatrix The transform matrix of the light
  8636. * @param renderList The list of mesh to render in the map
  8637. * @returns The current light
  8638. */
  8639. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8640. /**
  8641. * Gets the current depth scale used in ESM.
  8642. * @returns The scale
  8643. */
  8644. getDepthScale(): number;
  8645. /**
  8646. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8647. * @returns true if a cube texture needs to be use
  8648. */
  8649. needCube(): boolean;
  8650. /**
  8651. * Detects if the projection matrix requires to be recomputed this frame.
  8652. * @returns true if it requires to be recomputed otherwise, false.
  8653. */
  8654. needProjectionMatrixCompute(): boolean;
  8655. /**
  8656. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8657. */
  8658. forceProjectionMatrixCompute(): void;
  8659. /**
  8660. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8661. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8662. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8663. */
  8664. getShadowDirection(faceIndex?: number): Vector3;
  8665. /**
  8666. * Gets the minZ used for shadow according to both the scene and the light.
  8667. * @param activeCamera The camera we are returning the min for
  8668. * @returns the depth min z
  8669. */
  8670. getDepthMinZ(activeCamera: Camera): number;
  8671. /**
  8672. * Gets the maxZ used for shadow according to both the scene and the light.
  8673. * @param activeCamera The camera we are returning the max for
  8674. * @returns the depth max z
  8675. */
  8676. getDepthMaxZ(activeCamera: Camera): number;
  8677. }
  8678. /**
  8679. * Base implementation IShadowLight
  8680. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8681. */
  8682. export abstract class ShadowLight extends Light implements IShadowLight {
  8683. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8684. protected _position: Vector3;
  8685. protected _setPosition(value: Vector3): void;
  8686. /**
  8687. * Sets the position the shadow will be casted from. Also use as the light position for both
  8688. * point and spot lights.
  8689. */
  8690. /**
  8691. * Sets the position the shadow will be casted from. Also use as the light position for both
  8692. * point and spot lights.
  8693. */
  8694. position: Vector3;
  8695. protected _direction: Vector3;
  8696. protected _setDirection(value: Vector3): void;
  8697. /**
  8698. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8699. * Also use as the light direction on spot and directional lights.
  8700. */
  8701. /**
  8702. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8703. * Also use as the light direction on spot and directional lights.
  8704. */
  8705. direction: Vector3;
  8706. private _shadowMinZ;
  8707. /**
  8708. * Gets the shadow projection clipping minimum z value.
  8709. */
  8710. /**
  8711. * Sets the shadow projection clipping minimum z value.
  8712. */
  8713. shadowMinZ: number;
  8714. private _shadowMaxZ;
  8715. /**
  8716. * Sets the shadow projection clipping maximum z value.
  8717. */
  8718. /**
  8719. * Gets the shadow projection clipping maximum z value.
  8720. */
  8721. shadowMaxZ: number;
  8722. /**
  8723. * Callback defining a custom Projection Matrix Builder.
  8724. * This can be used to override the default projection matrix computation.
  8725. */
  8726. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8727. /**
  8728. * The transformed position. Position of the light in world space taking parenting in account.
  8729. */
  8730. transformedPosition: Vector3;
  8731. /**
  8732. * The transformed direction. Direction of the light in world space taking parenting in account.
  8733. */
  8734. transformedDirection: Vector3;
  8735. private _needProjectionMatrixCompute;
  8736. /**
  8737. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8738. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8739. */
  8740. computeTransformedInformation(): boolean;
  8741. /**
  8742. * Return the depth scale used for the shadow map.
  8743. * @returns the depth scale.
  8744. */
  8745. getDepthScale(): number;
  8746. /**
  8747. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8748. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8749. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8750. */
  8751. getShadowDirection(faceIndex?: number): Vector3;
  8752. /**
  8753. * Returns the ShadowLight absolute position in the World.
  8754. * @returns the position vector in world space
  8755. */
  8756. getAbsolutePosition(): Vector3;
  8757. /**
  8758. * Sets the ShadowLight direction toward the passed target.
  8759. * @param target The point to target in local space
  8760. * @returns the updated ShadowLight direction
  8761. */
  8762. setDirectionToTarget(target: Vector3): Vector3;
  8763. /**
  8764. * Returns the light rotation in euler definition.
  8765. * @returns the x y z rotation in local space.
  8766. */
  8767. getRotation(): Vector3;
  8768. /**
  8769. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8770. * @returns true if a cube texture needs to be use
  8771. */
  8772. needCube(): boolean;
  8773. /**
  8774. * Detects if the projection matrix requires to be recomputed this frame.
  8775. * @returns true if it requires to be recomputed otherwise, false.
  8776. */
  8777. needProjectionMatrixCompute(): boolean;
  8778. /**
  8779. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8780. */
  8781. forceProjectionMatrixCompute(): void;
  8782. /** @hidden */ private _initCache(): void;
  8783. /** @hidden */ private _isSynchronized(): boolean;
  8784. /**
  8785. * Computes the world matrix of the node
  8786. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8787. * @returns the world matrix
  8788. */
  8789. computeWorldMatrix(force?: boolean): Matrix;
  8790. /**
  8791. * Gets the minZ used for shadow according to both the scene and the light.
  8792. * @param activeCamera The camera we are returning the min for
  8793. * @returns the depth min z
  8794. */
  8795. getDepthMinZ(activeCamera: Camera): number;
  8796. /**
  8797. * Gets the maxZ used for shadow according to both the scene and the light.
  8798. * @param activeCamera The camera we are returning the max for
  8799. * @returns the depth max z
  8800. */
  8801. getDepthMaxZ(activeCamera: Camera): number;
  8802. /**
  8803. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8804. * @param matrix The materix to updated with the projection information
  8805. * @param viewMatrix The transform matrix of the light
  8806. * @param renderList The list of mesh to render in the map
  8807. * @returns The current light
  8808. */
  8809. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8810. }
  8811. }
  8812. declare module BABYLON {
  8813. /**
  8814. * "Static Class" containing the most commonly used helper while dealing with material for
  8815. * rendering purpose.
  8816. *
  8817. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8818. *
  8819. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8820. */
  8821. export class MaterialHelper {
  8822. /**
  8823. * Bind the current view position to an effect.
  8824. * @param effect The effect to be bound
  8825. * @param scene The scene the eyes position is used from
  8826. */
  8827. static BindEyePosition(effect: Effect, scene: Scene): void;
  8828. /**
  8829. * Helps preparing the defines values about the UVs in used in the effect.
  8830. * UVs are shared as much as we can accross channels in the shaders.
  8831. * @param texture The texture we are preparing the UVs for
  8832. * @param defines The defines to update
  8833. * @param key The channel key "diffuse", "specular"... used in the shader
  8834. */
  8835. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8836. /**
  8837. * Binds a texture matrix value to its corrsponding uniform
  8838. * @param texture The texture to bind the matrix for
  8839. * @param uniformBuffer The uniform buffer receivin the data
  8840. * @param key The channel key "diffuse", "specular"... used in the shader
  8841. */
  8842. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8843. /**
  8844. * Gets the current status of the fog (should it be enabled?)
  8845. * @param mesh defines the mesh to evaluate for fog support
  8846. * @param scene defines the hosting scene
  8847. * @returns true if fog must be enabled
  8848. */
  8849. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8850. /**
  8851. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8852. * @param mesh defines the current mesh
  8853. * @param scene defines the current scene
  8854. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8855. * @param pointsCloud defines if point cloud rendering has to be turned on
  8856. * @param fogEnabled defines if fog has to be turned on
  8857. * @param alphaTest defines if alpha testing has to be turned on
  8858. * @param defines defines the current list of defines
  8859. */
  8860. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8861. /**
  8862. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8863. * @param scene defines the current scene
  8864. * @param engine defines the current engine
  8865. * @param defines specifies the list of active defines
  8866. * @param useInstances defines if instances have to be turned on
  8867. * @param useClipPlane defines if clip plane have to be turned on
  8868. */
  8869. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8870. /**
  8871. * Prepares the defines for bones
  8872. * @param mesh The mesh containing the geometry data we will draw
  8873. * @param defines The defines to update
  8874. */
  8875. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8876. /**
  8877. * Prepares the defines for morph targets
  8878. * @param mesh The mesh containing the geometry data we will draw
  8879. * @param defines The defines to update
  8880. */
  8881. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8882. /**
  8883. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8884. * @param mesh The mesh containing the geometry data we will draw
  8885. * @param defines The defines to update
  8886. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8887. * @param useBones Precise whether bones should be used or not (override mesh info)
  8888. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8889. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8890. * @returns false if defines are considered not dirty and have not been checked
  8891. */
  8892. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8893. /**
  8894. * Prepares the defines related to multiview
  8895. * @param scene The scene we are intending to draw
  8896. * @param defines The defines to update
  8897. */
  8898. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8899. /**
  8900. * Prepares the defines related to the light information passed in parameter
  8901. * @param scene The scene we are intending to draw
  8902. * @param mesh The mesh the effect is compiling for
  8903. * @param light The light the effect is compiling for
  8904. * @param lightIndex The index of the light
  8905. * @param defines The defines to update
  8906. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8907. * @param state Defines the current state regarding what is needed (normals, etc...)
  8908. */
  8909. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8910. needNormals: boolean;
  8911. needRebuild: boolean;
  8912. shadowEnabled: boolean;
  8913. specularEnabled: boolean;
  8914. lightmapMode: boolean;
  8915. }): void;
  8916. /**
  8917. * Prepares the defines related to the light information passed in parameter
  8918. * @param scene The scene we are intending to draw
  8919. * @param mesh The mesh the effect is compiling for
  8920. * @param defines The defines to update
  8921. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8922. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8923. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8924. * @returns true if normals will be required for the rest of the effect
  8925. */
  8926. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8927. /**
  8928. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8929. * @param lightIndex defines the light index
  8930. * @param uniformsList The uniform list
  8931. * @param samplersList The sampler list
  8932. * @param projectedLightTexture defines if projected texture must be used
  8933. * @param uniformBuffersList defines an optional list of uniform buffers
  8934. */
  8935. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8936. /**
  8937. * Prepares the uniforms and samplers list to be used in the effect
  8938. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8939. * @param samplersList The sampler list
  8940. * @param defines The defines helping in the list generation
  8941. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8942. */
  8943. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8944. /**
  8945. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8946. * @param defines The defines to update while falling back
  8947. * @param fallbacks The authorized effect fallbacks
  8948. * @param maxSimultaneousLights The maximum number of lights allowed
  8949. * @param rank the current rank of the Effect
  8950. * @returns The newly affected rank
  8951. */
  8952. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8953. private static _TmpMorphInfluencers;
  8954. /**
  8955. * Prepares the list of attributes required for morph targets according to the effect defines.
  8956. * @param attribs The current list of supported attribs
  8957. * @param mesh The mesh to prepare the morph targets attributes for
  8958. * @param influencers The number of influencers
  8959. */
  8960. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8961. /**
  8962. * Prepares the list of attributes required for morph targets according to the effect defines.
  8963. * @param attribs The current list of supported attribs
  8964. * @param mesh The mesh to prepare the morph targets attributes for
  8965. * @param defines The current Defines of the effect
  8966. */
  8967. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8968. /**
  8969. * Prepares the list of attributes required for bones according to the effect defines.
  8970. * @param attribs The current list of supported attribs
  8971. * @param mesh The mesh to prepare the bones attributes for
  8972. * @param defines The current Defines of the effect
  8973. * @param fallbacks The current efffect fallback strategy
  8974. */
  8975. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8976. /**
  8977. * Check and prepare the list of attributes required for instances according to the effect defines.
  8978. * @param attribs The current list of supported attribs
  8979. * @param defines The current MaterialDefines of the effect
  8980. */
  8981. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8982. /**
  8983. * Add the list of attributes required for instances to the attribs array.
  8984. * @param attribs The current list of supported attribs
  8985. */
  8986. static PushAttributesForInstances(attribs: string[]): void;
  8987. /**
  8988. * Binds the light shadow information to the effect for the given mesh.
  8989. * @param light The light containing the generator
  8990. * @param scene The scene the lights belongs to
  8991. * @param mesh The mesh we are binding the information to render
  8992. * @param lightIndex The light index in the effect used to render the mesh
  8993. * @param effect The effect we are binding the data to
  8994. */
  8995. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8996. /**
  8997. * Binds the light information to the effect.
  8998. * @param light The light containing the generator
  8999. * @param effect The effect we are binding the data to
  9000. * @param lightIndex The light index in the effect used to render
  9001. */
  9002. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9003. /**
  9004. * Binds the lights information from the scene to the effect for the given mesh.
  9005. * @param light Light to bind
  9006. * @param lightIndex Light index
  9007. * @param scene The scene where the light belongs to
  9008. * @param mesh The mesh we are binding the information to render
  9009. * @param effect The effect we are binding the data to
  9010. * @param useSpecular Defines if specular is supported
  9011. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9012. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9013. */
  9014. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9015. /**
  9016. * Binds the lights information from the scene to the effect for the given mesh.
  9017. * @param scene The scene the lights belongs to
  9018. * @param mesh The mesh we are binding the information to render
  9019. * @param effect The effect we are binding the data to
  9020. * @param defines The generated defines for the effect
  9021. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9022. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9023. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9024. */
  9025. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9026. private static _tempFogColor;
  9027. /**
  9028. * Binds the fog information from the scene to the effect for the given mesh.
  9029. * @param scene The scene the lights belongs to
  9030. * @param mesh The mesh we are binding the information to render
  9031. * @param effect The effect we are binding the data to
  9032. * @param linearSpace Defines if the fog effect is applied in linear space
  9033. */
  9034. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9035. /**
  9036. * Binds the bones information from the mesh to the effect.
  9037. * @param mesh The mesh we are binding the information to render
  9038. * @param effect The effect we are binding the data to
  9039. */
  9040. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9041. /**
  9042. * Binds the morph targets information from the mesh to the effect.
  9043. * @param abstractMesh The mesh we are binding the information to render
  9044. * @param effect The effect we are binding the data to
  9045. */
  9046. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9047. /**
  9048. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9049. * @param defines The generated defines used in the effect
  9050. * @param effect The effect we are binding the data to
  9051. * @param scene The scene we are willing to render with logarithmic scale for
  9052. */
  9053. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9054. /**
  9055. * Binds the clip plane information from the scene to the effect.
  9056. * @param scene The scene the clip plane information are extracted from
  9057. * @param effect The effect we are binding the data to
  9058. */
  9059. static BindClipPlane(effect: Effect, scene: Scene): void;
  9060. }
  9061. }
  9062. declare module BABYLON {
  9063. /** @hidden */
  9064. export var packingFunctions: {
  9065. name: string;
  9066. shader: string;
  9067. };
  9068. }
  9069. declare module BABYLON {
  9070. /** @hidden */
  9071. export var shadowMapPixelShader: {
  9072. name: string;
  9073. shader: string;
  9074. };
  9075. }
  9076. declare module BABYLON {
  9077. /** @hidden */
  9078. export var bonesDeclaration: {
  9079. name: string;
  9080. shader: string;
  9081. };
  9082. }
  9083. declare module BABYLON {
  9084. /** @hidden */
  9085. export var morphTargetsVertexGlobalDeclaration: {
  9086. name: string;
  9087. shader: string;
  9088. };
  9089. }
  9090. declare module BABYLON {
  9091. /** @hidden */
  9092. export var morphTargetsVertexDeclaration: {
  9093. name: string;
  9094. shader: string;
  9095. };
  9096. }
  9097. declare module BABYLON {
  9098. /** @hidden */
  9099. export var instancesDeclaration: {
  9100. name: string;
  9101. shader: string;
  9102. };
  9103. }
  9104. declare module BABYLON {
  9105. /** @hidden */
  9106. export var helperFunctions: {
  9107. name: string;
  9108. shader: string;
  9109. };
  9110. }
  9111. declare module BABYLON {
  9112. /** @hidden */
  9113. export var morphTargetsVertex: {
  9114. name: string;
  9115. shader: string;
  9116. };
  9117. }
  9118. declare module BABYLON {
  9119. /** @hidden */
  9120. export var instancesVertex: {
  9121. name: string;
  9122. shader: string;
  9123. };
  9124. }
  9125. declare module BABYLON {
  9126. /** @hidden */
  9127. export var bonesVertex: {
  9128. name: string;
  9129. shader: string;
  9130. };
  9131. }
  9132. declare module BABYLON {
  9133. /** @hidden */
  9134. export var shadowMapVertexShader: {
  9135. name: string;
  9136. shader: string;
  9137. };
  9138. }
  9139. declare module BABYLON {
  9140. /** @hidden */
  9141. export var depthBoxBlurPixelShader: {
  9142. name: string;
  9143. shader: string;
  9144. };
  9145. }
  9146. declare module BABYLON {
  9147. /**
  9148. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9149. */
  9150. export interface ICustomShaderOptions {
  9151. /**
  9152. * Gets or sets the custom shader name to use
  9153. */
  9154. shaderName: string;
  9155. /**
  9156. * The list of attribute names used in the shader
  9157. */
  9158. attributes?: string[];
  9159. /**
  9160. * The list of unifrom names used in the shader
  9161. */
  9162. uniforms?: string[];
  9163. /**
  9164. * The list of sampler names used in the shader
  9165. */
  9166. samplers?: string[];
  9167. /**
  9168. * The list of defines used in the shader
  9169. */
  9170. defines?: string[];
  9171. }
  9172. /**
  9173. * Interface to implement to create a shadow generator compatible with BJS.
  9174. */
  9175. export interface IShadowGenerator {
  9176. /**
  9177. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9178. * @returns The render target texture if present otherwise, null
  9179. */
  9180. getShadowMap(): Nullable<RenderTargetTexture>;
  9181. /**
  9182. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9183. * @returns The render target texture if the shadow map is present otherwise, null
  9184. */
  9185. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9186. /**
  9187. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9188. * @param subMesh The submesh we want to render in the shadow map
  9189. * @param useInstances Defines wether will draw in the map using instances
  9190. * @returns true if ready otherwise, false
  9191. */
  9192. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9193. /**
  9194. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9195. * @param defines Defines of the material we want to update
  9196. * @param lightIndex Index of the light in the enabled light list of the material
  9197. */
  9198. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9199. /**
  9200. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9201. * defined in the generator but impacting the effect).
  9202. * It implies the unifroms available on the materials are the standard BJS ones.
  9203. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9204. * @param effect The effect we are binfing the information for
  9205. */
  9206. bindShadowLight(lightIndex: string, effect: Effect): void;
  9207. /**
  9208. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9209. * (eq to shadow prjection matrix * light transform matrix)
  9210. * @returns The transform matrix used to create the shadow map
  9211. */
  9212. getTransformMatrix(): Matrix;
  9213. /**
  9214. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9215. * Cube and 2D textures for instance.
  9216. */
  9217. recreateShadowMap(): void;
  9218. /**
  9219. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9220. * @param onCompiled Callback triggered at the and of the effects compilation
  9221. * @param options Sets of optional options forcing the compilation with different modes
  9222. */
  9223. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9224. useInstances: boolean;
  9225. }>): void;
  9226. /**
  9227. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9228. * @param options Sets of optional options forcing the compilation with different modes
  9229. * @returns A promise that resolves when the compilation completes
  9230. */
  9231. forceCompilationAsync(options?: Partial<{
  9232. useInstances: boolean;
  9233. }>): Promise<void>;
  9234. /**
  9235. * Serializes the shadow generator setup to a json object.
  9236. * @returns The serialized JSON object
  9237. */
  9238. serialize(): any;
  9239. /**
  9240. * Disposes the Shadow map and related Textures and effects.
  9241. */
  9242. dispose(): void;
  9243. }
  9244. /**
  9245. * Default implementation IShadowGenerator.
  9246. * This is the main object responsible of generating shadows in the framework.
  9247. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9248. */
  9249. export class ShadowGenerator implements IShadowGenerator {
  9250. /**
  9251. * Shadow generator mode None: no filtering applied.
  9252. */
  9253. static readonly FILTER_NONE: number;
  9254. /**
  9255. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9256. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9257. */
  9258. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9259. /**
  9260. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9261. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9262. */
  9263. static readonly FILTER_POISSONSAMPLING: number;
  9264. /**
  9265. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9266. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9267. */
  9268. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9269. /**
  9270. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9271. * edge artifacts on steep falloff.
  9272. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9273. */
  9274. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9275. /**
  9276. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9277. * edge artifacts on steep falloff.
  9278. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9279. */
  9280. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9281. /**
  9282. * Shadow generator mode PCF: Percentage Closer Filtering
  9283. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9284. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9285. */
  9286. static readonly FILTER_PCF: number;
  9287. /**
  9288. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9289. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9290. * Contact Hardening
  9291. */
  9292. static readonly FILTER_PCSS: number;
  9293. /**
  9294. * Reserved for PCF and PCSS
  9295. * Highest Quality.
  9296. *
  9297. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9298. *
  9299. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9300. */
  9301. static readonly QUALITY_HIGH: number;
  9302. /**
  9303. * Reserved for PCF and PCSS
  9304. * Good tradeoff for quality/perf cross devices
  9305. *
  9306. * Execute PCF on a 3*3 kernel.
  9307. *
  9308. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9309. */
  9310. static readonly QUALITY_MEDIUM: number;
  9311. /**
  9312. * Reserved for PCF and PCSS
  9313. * The lowest quality but the fastest.
  9314. *
  9315. * Execute PCF on a 1*1 kernel.
  9316. *
  9317. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9318. */
  9319. static readonly QUALITY_LOW: number;
  9320. /** Gets or sets the custom shader name to use */
  9321. customShaderOptions: ICustomShaderOptions;
  9322. /**
  9323. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9324. */
  9325. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9326. /**
  9327. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9328. */
  9329. onAfterShadowMapRenderObservable: Observable<Effect>;
  9330. /**
  9331. * Observable triggered before a mesh is rendered in the shadow map.
  9332. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9333. */
  9334. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9335. /**
  9336. * Observable triggered after a mesh is rendered in the shadow map.
  9337. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9338. */
  9339. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9340. private _bias;
  9341. /**
  9342. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9343. */
  9344. /**
  9345. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9346. */
  9347. bias: number;
  9348. private _normalBias;
  9349. /**
  9350. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9351. */
  9352. /**
  9353. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9354. */
  9355. normalBias: number;
  9356. private _blurBoxOffset;
  9357. /**
  9358. * Gets the blur box offset: offset applied during the blur pass.
  9359. * Only useful if useKernelBlur = false
  9360. */
  9361. /**
  9362. * Sets the blur box offset: offset applied during the blur pass.
  9363. * Only useful if useKernelBlur = false
  9364. */
  9365. blurBoxOffset: number;
  9366. private _blurScale;
  9367. /**
  9368. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9369. * 2 means half of the size.
  9370. */
  9371. /**
  9372. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9373. * 2 means half of the size.
  9374. */
  9375. blurScale: number;
  9376. private _blurKernel;
  9377. /**
  9378. * Gets the blur kernel: kernel size of the blur pass.
  9379. * Only useful if useKernelBlur = true
  9380. */
  9381. /**
  9382. * Sets the blur kernel: kernel size of the blur pass.
  9383. * Only useful if useKernelBlur = true
  9384. */
  9385. blurKernel: number;
  9386. private _useKernelBlur;
  9387. /**
  9388. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9389. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9390. */
  9391. /**
  9392. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9393. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9394. */
  9395. useKernelBlur: boolean;
  9396. private _depthScale;
  9397. /**
  9398. * Gets the depth scale used in ESM mode.
  9399. */
  9400. /**
  9401. * Sets the depth scale used in ESM mode.
  9402. * This can override the scale stored on the light.
  9403. */
  9404. depthScale: number;
  9405. private _filter;
  9406. /**
  9407. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9408. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9409. */
  9410. /**
  9411. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9412. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9413. */
  9414. filter: number;
  9415. /**
  9416. * Gets if the current filter is set to Poisson Sampling.
  9417. */
  9418. /**
  9419. * Sets the current filter to Poisson Sampling.
  9420. */
  9421. usePoissonSampling: boolean;
  9422. /**
  9423. * Gets if the current filter is set to ESM.
  9424. */
  9425. /**
  9426. * Sets the current filter is to ESM.
  9427. */
  9428. useExponentialShadowMap: boolean;
  9429. /**
  9430. * Gets if the current filter is set to filtered ESM.
  9431. */
  9432. /**
  9433. * Gets if the current filter is set to filtered ESM.
  9434. */
  9435. useBlurExponentialShadowMap: boolean;
  9436. /**
  9437. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9438. * exponential to prevent steep falloff artifacts).
  9439. */
  9440. /**
  9441. * Sets the current filter to "close ESM" (using the inverse of the
  9442. * exponential to prevent steep falloff artifacts).
  9443. */
  9444. useCloseExponentialShadowMap: boolean;
  9445. /**
  9446. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9447. * exponential to prevent steep falloff artifacts).
  9448. */
  9449. /**
  9450. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9451. * exponential to prevent steep falloff artifacts).
  9452. */
  9453. useBlurCloseExponentialShadowMap: boolean;
  9454. /**
  9455. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9456. */
  9457. /**
  9458. * Sets the current filter to "PCF" (percentage closer filtering).
  9459. */
  9460. usePercentageCloserFiltering: boolean;
  9461. private _filteringQuality;
  9462. /**
  9463. * Gets the PCF or PCSS Quality.
  9464. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9465. */
  9466. /**
  9467. * Sets the PCF or PCSS Quality.
  9468. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9469. */
  9470. filteringQuality: number;
  9471. /**
  9472. * Gets if the current filter is set to "PCSS" (contact hardening).
  9473. */
  9474. /**
  9475. * Sets the current filter to "PCSS" (contact hardening).
  9476. */
  9477. useContactHardeningShadow: boolean;
  9478. private _contactHardeningLightSizeUVRatio;
  9479. /**
  9480. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9481. * Using a ratio helps keeping shape stability independently of the map size.
  9482. *
  9483. * It does not account for the light projection as it was having too much
  9484. * instability during the light setup or during light position changes.
  9485. *
  9486. * Only valid if useContactHardeningShadow is true.
  9487. */
  9488. /**
  9489. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9490. * Using a ratio helps keeping shape stability independently of the map size.
  9491. *
  9492. * It does not account for the light projection as it was having too much
  9493. * instability during the light setup or during light position changes.
  9494. *
  9495. * Only valid if useContactHardeningShadow is true.
  9496. */
  9497. contactHardeningLightSizeUVRatio: number;
  9498. private _darkness;
  9499. /** Gets or sets the actual darkness of a shadow */
  9500. darkness: number;
  9501. /**
  9502. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9503. * 0 means strongest and 1 would means no shadow.
  9504. * @returns the darkness.
  9505. */
  9506. getDarkness(): number;
  9507. /**
  9508. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9509. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9510. * @returns the shadow generator allowing fluent coding.
  9511. */
  9512. setDarkness(darkness: number): ShadowGenerator;
  9513. private _transparencyShadow;
  9514. /** Gets or sets the ability to have transparent shadow */
  9515. transparencyShadow: boolean;
  9516. /**
  9517. * Sets the ability to have transparent shadow (boolean).
  9518. * @param transparent True if transparent else False
  9519. * @returns the shadow generator allowing fluent coding
  9520. */
  9521. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9522. private _shadowMap;
  9523. private _shadowMap2;
  9524. /**
  9525. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9526. * @returns The render target texture if present otherwise, null
  9527. */
  9528. getShadowMap(): Nullable<RenderTargetTexture>;
  9529. /**
  9530. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9531. * @returns The render target texture if the shadow map is present otherwise, null
  9532. */
  9533. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9534. /**
  9535. * Gets the class name of that object
  9536. * @returns "ShadowGenerator"
  9537. */
  9538. getClassName(): string;
  9539. /**
  9540. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9541. * @param mesh Mesh to add
  9542. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9543. * @returns the Shadow Generator itself
  9544. */
  9545. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9546. /**
  9547. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9548. * @param mesh Mesh to remove
  9549. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9550. * @returns the Shadow Generator itself
  9551. */
  9552. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9553. /**
  9554. * Controls the extent to which the shadows fade out at the edge of the frustum
  9555. * Used only by directionals and spots
  9556. */
  9557. frustumEdgeFalloff: number;
  9558. private _light;
  9559. /**
  9560. * Returns the associated light object.
  9561. * @returns the light generating the shadow
  9562. */
  9563. getLight(): IShadowLight;
  9564. /**
  9565. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9566. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9567. * It might on the other hand introduce peter panning.
  9568. */
  9569. forceBackFacesOnly: boolean;
  9570. private _scene;
  9571. private _lightDirection;
  9572. private _effect;
  9573. private _viewMatrix;
  9574. private _projectionMatrix;
  9575. private _transformMatrix;
  9576. private _cachedPosition;
  9577. private _cachedDirection;
  9578. private _cachedDefines;
  9579. private _currentRenderID;
  9580. private _boxBlurPostprocess;
  9581. private _kernelBlurXPostprocess;
  9582. private _kernelBlurYPostprocess;
  9583. private _blurPostProcesses;
  9584. private _mapSize;
  9585. private _currentFaceIndex;
  9586. private _currentFaceIndexCache;
  9587. private _textureType;
  9588. private _defaultTextureMatrix;
  9589. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9590. /**
  9591. * Creates a ShadowGenerator object.
  9592. * A ShadowGenerator is the required tool to use the shadows.
  9593. * Each light casting shadows needs to use its own ShadowGenerator.
  9594. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9595. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9596. * @param light The light object generating the shadows.
  9597. * @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.
  9598. */
  9599. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9600. private _initializeGenerator;
  9601. private _initializeShadowMap;
  9602. private _initializeBlurRTTAndPostProcesses;
  9603. private _renderForShadowMap;
  9604. private _renderSubMeshForShadowMap;
  9605. private _applyFilterValues;
  9606. /**
  9607. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9608. * @param onCompiled Callback triggered at the and of the effects compilation
  9609. * @param options Sets of optional options forcing the compilation with different modes
  9610. */
  9611. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9612. useInstances: boolean;
  9613. }>): void;
  9614. /**
  9615. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9616. * @param options Sets of optional options forcing the compilation with different modes
  9617. * @returns A promise that resolves when the compilation completes
  9618. */
  9619. forceCompilationAsync(options?: Partial<{
  9620. useInstances: boolean;
  9621. }>): Promise<void>;
  9622. /**
  9623. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9624. * @param subMesh The submesh we want to render in the shadow map
  9625. * @param useInstances Defines wether will draw in the map using instances
  9626. * @returns true if ready otherwise, false
  9627. */
  9628. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9629. /**
  9630. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9631. * @param defines Defines of the material we want to update
  9632. * @param lightIndex Index of the light in the enabled light list of the material
  9633. */
  9634. prepareDefines(defines: any, lightIndex: number): void;
  9635. /**
  9636. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9637. * defined in the generator but impacting the effect).
  9638. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9639. * @param effect The effect we are binfing the information for
  9640. */
  9641. bindShadowLight(lightIndex: string, effect: Effect): void;
  9642. /**
  9643. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9644. * (eq to shadow prjection matrix * light transform matrix)
  9645. * @returns The transform matrix used to create the shadow map
  9646. */
  9647. getTransformMatrix(): Matrix;
  9648. /**
  9649. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9650. * Cube and 2D textures for instance.
  9651. */
  9652. recreateShadowMap(): void;
  9653. private _disposeBlurPostProcesses;
  9654. private _disposeRTTandPostProcesses;
  9655. /**
  9656. * Disposes the ShadowGenerator.
  9657. * Returns nothing.
  9658. */
  9659. dispose(): void;
  9660. /**
  9661. * Serializes the shadow generator setup to a json object.
  9662. * @returns The serialized JSON object
  9663. */
  9664. serialize(): any;
  9665. /**
  9666. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9667. * @param parsedShadowGenerator The JSON object to parse
  9668. * @param scene The scene to create the shadow map for
  9669. * @returns The parsed shadow generator
  9670. */
  9671. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9672. }
  9673. }
  9674. declare module BABYLON {
  9675. /**
  9676. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9677. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9678. * 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.
  9679. */
  9680. export abstract class Light extends Node {
  9681. /**
  9682. * Falloff Default: light is falling off following the material specification:
  9683. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9684. */
  9685. static readonly FALLOFF_DEFAULT: number;
  9686. /**
  9687. * Falloff Physical: light is falling off following the inverse squared distance law.
  9688. */
  9689. static readonly FALLOFF_PHYSICAL: number;
  9690. /**
  9691. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9692. * to enhance interoperability with other engines.
  9693. */
  9694. static readonly FALLOFF_GLTF: number;
  9695. /**
  9696. * Falloff Standard: light is falling off like in the standard material
  9697. * to enhance interoperability with other materials.
  9698. */
  9699. static readonly FALLOFF_STANDARD: number;
  9700. /**
  9701. * If every light affecting the material is in this lightmapMode,
  9702. * material.lightmapTexture adds or multiplies
  9703. * (depends on material.useLightmapAsShadowmap)
  9704. * after every other light calculations.
  9705. */
  9706. static readonly LIGHTMAP_DEFAULT: number;
  9707. /**
  9708. * material.lightmapTexture as only diffuse lighting from this light
  9709. * adds only specular lighting from this light
  9710. * adds dynamic shadows
  9711. */
  9712. static readonly LIGHTMAP_SPECULAR: number;
  9713. /**
  9714. * material.lightmapTexture as only lighting
  9715. * no light calculation from this light
  9716. * only adds dynamic shadows from this light
  9717. */
  9718. static readonly LIGHTMAP_SHADOWSONLY: number;
  9719. /**
  9720. * Each light type uses the default quantity according to its type:
  9721. * point/spot lights use luminous intensity
  9722. * directional lights use illuminance
  9723. */
  9724. static readonly INTENSITYMODE_AUTOMATIC: number;
  9725. /**
  9726. * lumen (lm)
  9727. */
  9728. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9729. /**
  9730. * candela (lm/sr)
  9731. */
  9732. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9733. /**
  9734. * lux (lm/m^2)
  9735. */
  9736. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9737. /**
  9738. * nit (cd/m^2)
  9739. */
  9740. static readonly INTENSITYMODE_LUMINANCE: number;
  9741. /**
  9742. * Light type const id of the point light.
  9743. */
  9744. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9745. /**
  9746. * Light type const id of the directional light.
  9747. */
  9748. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9749. /**
  9750. * Light type const id of the spot light.
  9751. */
  9752. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9753. /**
  9754. * Light type const id of the hemispheric light.
  9755. */
  9756. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9757. /**
  9758. * Diffuse gives the basic color to an object.
  9759. */
  9760. diffuse: Color3;
  9761. /**
  9762. * Specular produces a highlight color on an object.
  9763. * Note: This is note affecting PBR materials.
  9764. */
  9765. specular: Color3;
  9766. /**
  9767. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9768. * falling off base on range or angle.
  9769. * This can be set to any values in Light.FALLOFF_x.
  9770. *
  9771. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9772. * other types of materials.
  9773. */
  9774. falloffType: number;
  9775. /**
  9776. * Strength of the light.
  9777. * Note: By default it is define in the framework own unit.
  9778. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9779. */
  9780. intensity: number;
  9781. private _range;
  9782. protected _inverseSquaredRange: number;
  9783. /**
  9784. * Defines how far from the source the light is impacting in scene units.
  9785. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9786. */
  9787. /**
  9788. * Defines how far from the source the light is impacting in scene units.
  9789. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9790. */
  9791. range: number;
  9792. /**
  9793. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9794. * of light.
  9795. */
  9796. private _photometricScale;
  9797. private _intensityMode;
  9798. /**
  9799. * Gets the photometric scale used to interpret the intensity.
  9800. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9801. */
  9802. /**
  9803. * Sets the photometric scale used to interpret the intensity.
  9804. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9805. */
  9806. intensityMode: number;
  9807. private _radius;
  9808. /**
  9809. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9810. */
  9811. /**
  9812. * sets the light radius used by PBR Materials to simulate soft area lights.
  9813. */
  9814. radius: number;
  9815. private _renderPriority;
  9816. /**
  9817. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9818. * exceeding the number allowed of the materials.
  9819. */
  9820. renderPriority: number;
  9821. private _shadowEnabled;
  9822. /**
  9823. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9824. * the current shadow generator.
  9825. */
  9826. /**
  9827. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9828. * the current shadow generator.
  9829. */
  9830. shadowEnabled: boolean;
  9831. private _includedOnlyMeshes;
  9832. /**
  9833. * Gets the only meshes impacted by this light.
  9834. */
  9835. /**
  9836. * Sets the only meshes impacted by this light.
  9837. */
  9838. includedOnlyMeshes: AbstractMesh[];
  9839. private _excludedMeshes;
  9840. /**
  9841. * Gets the meshes not impacted by this light.
  9842. */
  9843. /**
  9844. * Sets the meshes not impacted by this light.
  9845. */
  9846. excludedMeshes: AbstractMesh[];
  9847. private _excludeWithLayerMask;
  9848. /**
  9849. * Gets the layer id use to find what meshes are not impacted by the light.
  9850. * Inactive if 0
  9851. */
  9852. /**
  9853. * Sets the layer id use to find what meshes are not impacted by the light.
  9854. * Inactive if 0
  9855. */
  9856. excludeWithLayerMask: number;
  9857. private _includeOnlyWithLayerMask;
  9858. /**
  9859. * Gets the layer id use to find what meshes are impacted by the light.
  9860. * Inactive if 0
  9861. */
  9862. /**
  9863. * Sets the layer id use to find what meshes are impacted by the light.
  9864. * Inactive if 0
  9865. */
  9866. includeOnlyWithLayerMask: number;
  9867. private _lightmapMode;
  9868. /**
  9869. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9870. */
  9871. /**
  9872. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9873. */
  9874. lightmapMode: number;
  9875. /**
  9876. * Shadow generator associted to the light.
  9877. * @hidden Internal use only.
  9878. */ private _shadowGenerator: Nullable<IShadowGenerator>;
  9879. /**
  9880. * @hidden Internal use only.
  9881. */ private _excludedMeshesIds: string[];
  9882. /**
  9883. * @hidden Internal use only.
  9884. */ private _includedOnlyMeshesIds: string[];
  9885. /**
  9886. * The current light unifom buffer.
  9887. * @hidden Internal use only.
  9888. */ private _uniformBuffer: UniformBuffer;
  9889. /**
  9890. * Creates a Light object in the scene.
  9891. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9892. * @param name The firendly name of the light
  9893. * @param scene The scene the light belongs too
  9894. */
  9895. constructor(name: string, scene: Scene);
  9896. protected abstract _buildUniformLayout(): void;
  9897. /**
  9898. * Sets the passed Effect "effect" with the Light information.
  9899. * @param effect The effect to update
  9900. * @param lightIndex The index of the light in the effect to update
  9901. * @returns The light
  9902. */
  9903. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9904. /**
  9905. * Sets the passed Effect "effect" with the Light information.
  9906. * @param effect The effect to update
  9907. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9908. * @returns The light
  9909. */
  9910. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9911. /**
  9912. * Returns the string "Light".
  9913. * @returns the class name
  9914. */
  9915. getClassName(): string;
  9916. /** @hidden */ protected readonly _isLight: boolean;
  9917. /**
  9918. * Converts the light information to a readable string for debug purpose.
  9919. * @param fullDetails Supports for multiple levels of logging within scene loading
  9920. * @returns the human readable light info
  9921. */
  9922. toString(fullDetails?: boolean): string;
  9923. /** @hidden */
  9924. protected _syncParentEnabledState(): void;
  9925. /**
  9926. * Set the enabled state of this node.
  9927. * @param value - the new enabled state
  9928. */
  9929. setEnabled(value: boolean): void;
  9930. /**
  9931. * Returns the Light associated shadow generator if any.
  9932. * @return the associated shadow generator.
  9933. */
  9934. getShadowGenerator(): Nullable<IShadowGenerator>;
  9935. /**
  9936. * Returns a Vector3, the absolute light position in the World.
  9937. * @returns the world space position of the light
  9938. */
  9939. getAbsolutePosition(): Vector3;
  9940. /**
  9941. * Specifies if the light will affect the passed mesh.
  9942. * @param mesh The mesh to test against the light
  9943. * @return true the mesh is affected otherwise, false.
  9944. */
  9945. canAffectMesh(mesh: AbstractMesh): boolean;
  9946. /**
  9947. * Sort function to order lights for rendering.
  9948. * @param a First Light object to compare to second.
  9949. * @param b Second Light object to compare first.
  9950. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9951. */
  9952. static CompareLightsPriority(a: Light, b: Light): number;
  9953. /**
  9954. * Releases resources associated with this node.
  9955. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9956. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9957. */
  9958. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9959. /**
  9960. * Returns the light type ID (integer).
  9961. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9962. */
  9963. getTypeID(): number;
  9964. /**
  9965. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9966. * @returns the scaled intensity in intensity mode unit
  9967. */
  9968. getScaledIntensity(): number;
  9969. /**
  9970. * Returns a new Light object, named "name", from the current one.
  9971. * @param name The name of the cloned light
  9972. * @returns the new created light
  9973. */
  9974. clone(name: string): Nullable<Light>;
  9975. /**
  9976. * Serializes the current light into a Serialization object.
  9977. * @returns the serialized object.
  9978. */
  9979. serialize(): any;
  9980. /**
  9981. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9982. * This new light is named "name" and added to the passed scene.
  9983. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9984. * @param name The friendly name of the light
  9985. * @param scene The scene the new light will belong to
  9986. * @returns the constructor function
  9987. */
  9988. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9989. /**
  9990. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9991. * @param parsedLight The JSON representation of the light
  9992. * @param scene The scene to create the parsed light in
  9993. * @returns the created light after parsing
  9994. */
  9995. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9996. private _hookArrayForExcluded;
  9997. private _hookArrayForIncludedOnly;
  9998. private _resyncMeshes;
  9999. /**
  10000. * Forces the meshes to update their light related information in their rendering used effects
  10001. * @hidden Internal Use Only
  10002. */ private _markMeshesAsLightDirty(): void;
  10003. /**
  10004. * Recomputes the cached photometric scale if needed.
  10005. */
  10006. private _computePhotometricScale;
  10007. /**
  10008. * Returns the Photometric Scale according to the light type and intensity mode.
  10009. */
  10010. private _getPhotometricScale;
  10011. /**
  10012. * Reorder the light in the scene according to their defined priority.
  10013. * @hidden Internal Use Only
  10014. */ private _reorderLightsInScene(): void;
  10015. /**
  10016. * Prepares the list of defines specific to the light type.
  10017. * @param defines the list of defines
  10018. * @param lightIndex defines the index of the light for the effect
  10019. */
  10020. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10021. }
  10022. }
  10023. declare module BABYLON {
  10024. /**
  10025. * Interface used to define Action
  10026. */
  10027. export interface IAction {
  10028. /**
  10029. * Trigger for the action
  10030. */
  10031. trigger: number;
  10032. /** Options of the trigger */
  10033. triggerOptions: any;
  10034. /**
  10035. * Gets the trigger parameters
  10036. * @returns the trigger parameters
  10037. */
  10038. getTriggerParameter(): any;
  10039. /**
  10040. * Internal only - executes current action event
  10041. * @hidden
  10042. */ private _executeCurrent(evt?: ActionEvent): void;
  10043. /**
  10044. * Serialize placeholder for child classes
  10045. * @param parent of child
  10046. * @returns the serialized object
  10047. */
  10048. serialize(parent: any): any;
  10049. /**
  10050. * Internal only
  10051. * @hidden
  10052. */ private _prepare(): void;
  10053. /**
  10054. * Internal only - manager for action
  10055. * @hidden
  10056. */ private _actionManager: AbstractActionManager;
  10057. /**
  10058. * Adds action to chain of actions, may be a DoNothingAction
  10059. * @param action defines the next action to execute
  10060. * @returns The action passed in
  10061. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10062. */
  10063. then(action: IAction): IAction;
  10064. }
  10065. /**
  10066. * The action to be carried out following a trigger
  10067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10068. */
  10069. export class Action implements IAction {
  10070. /** the trigger, with or without parameters, for the action */
  10071. triggerOptions: any;
  10072. /**
  10073. * Trigger for the action
  10074. */
  10075. trigger: number;
  10076. /**
  10077. * Internal only - manager for action
  10078. * @hidden
  10079. */ private _actionManager: ActionManager;
  10080. private _nextActiveAction;
  10081. private _child;
  10082. private _condition?;
  10083. private _triggerParameter;
  10084. /**
  10085. * An event triggered prior to action being executed.
  10086. */
  10087. onBeforeExecuteObservable: Observable<Action>;
  10088. /**
  10089. * Creates a new Action
  10090. * @param triggerOptions the trigger, with or without parameters, for the action
  10091. * @param condition an optional determinant of action
  10092. */
  10093. constructor(
  10094. /** the trigger, with or without parameters, for the action */
  10095. triggerOptions: any, condition?: Condition);
  10096. /**
  10097. * Internal only
  10098. * @hidden
  10099. */ private _prepare(): void;
  10100. /**
  10101. * Gets the trigger parameters
  10102. * @returns the trigger parameters
  10103. */
  10104. getTriggerParameter(): any;
  10105. /**
  10106. * Internal only - executes current action event
  10107. * @hidden
  10108. */ private _executeCurrent(evt?: ActionEvent): void;
  10109. /**
  10110. * Execute placeholder for child classes
  10111. * @param evt optional action event
  10112. */
  10113. execute(evt?: ActionEvent): void;
  10114. /**
  10115. * Skips to next active action
  10116. */
  10117. skipToNextActiveAction(): void;
  10118. /**
  10119. * Adds action to chain of actions, may be a DoNothingAction
  10120. * @param action defines the next action to execute
  10121. * @returns The action passed in
  10122. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10123. */
  10124. then(action: Action): Action;
  10125. /**
  10126. * Internal only
  10127. * @hidden
  10128. */ private _getProperty(propertyPath: string): string;
  10129. /**
  10130. * Internal only
  10131. * @hidden
  10132. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10133. /**
  10134. * Serialize placeholder for child classes
  10135. * @param parent of child
  10136. * @returns the serialized object
  10137. */
  10138. serialize(parent: any): any;
  10139. /**
  10140. * Internal only called by serialize
  10141. * @hidden
  10142. */
  10143. protected _serialize(serializedAction: any, parent?: any): any;
  10144. /**
  10145. * Internal only
  10146. * @hidden
  10147. */ private static _SerializeValueAsString: (value: any) => string;
  10148. /**
  10149. * Internal only
  10150. * @hidden
  10151. */ private static _GetTargetProperty: (target: Node | Scene) => {
  10152. name: string;
  10153. targetType: string;
  10154. value: string;
  10155. };
  10156. }
  10157. }
  10158. declare module BABYLON {
  10159. /**
  10160. * A Condition applied to an Action
  10161. */
  10162. export class Condition {
  10163. /**
  10164. * Internal only - manager for action
  10165. * @hidden
  10166. */ private _actionManager: ActionManager;
  10167. /**
  10168. * Internal only
  10169. * @hidden
  10170. */ private _evaluationId: number;
  10171. /**
  10172. * Internal only
  10173. * @hidden
  10174. */ private _currentResult: boolean;
  10175. /**
  10176. * Creates a new Condition
  10177. * @param actionManager the manager of the action the condition is applied to
  10178. */
  10179. constructor(actionManager: ActionManager);
  10180. /**
  10181. * Check if the current condition is valid
  10182. * @returns a boolean
  10183. */
  10184. isValid(): boolean;
  10185. /**
  10186. * Internal only
  10187. * @hidden
  10188. */ private _getProperty(propertyPath: string): string;
  10189. /**
  10190. * Internal only
  10191. * @hidden
  10192. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10193. /**
  10194. * Serialize placeholder for child classes
  10195. * @returns the serialized object
  10196. */
  10197. serialize(): any;
  10198. /**
  10199. * Internal only
  10200. * @hidden
  10201. */
  10202. protected _serialize(serializedCondition: any): any;
  10203. }
  10204. /**
  10205. * Defines specific conditional operators as extensions of Condition
  10206. */
  10207. export class ValueCondition extends Condition {
  10208. /** path to specify the property of the target the conditional operator uses */
  10209. propertyPath: string;
  10210. /** the value compared by the conditional operator against the current value of the property */
  10211. value: any;
  10212. /** the conditional operator, default ValueCondition.IsEqual */
  10213. operator: number;
  10214. /**
  10215. * Internal only
  10216. * @hidden
  10217. */
  10218. private static _IsEqual;
  10219. /**
  10220. * Internal only
  10221. * @hidden
  10222. */
  10223. private static _IsDifferent;
  10224. /**
  10225. * Internal only
  10226. * @hidden
  10227. */
  10228. private static _IsGreater;
  10229. /**
  10230. * Internal only
  10231. * @hidden
  10232. */
  10233. private static _IsLesser;
  10234. /**
  10235. * returns the number for IsEqual
  10236. */
  10237. static readonly IsEqual: number;
  10238. /**
  10239. * Returns the number for IsDifferent
  10240. */
  10241. static readonly IsDifferent: number;
  10242. /**
  10243. * Returns the number for IsGreater
  10244. */
  10245. static readonly IsGreater: number;
  10246. /**
  10247. * Returns the number for IsLesser
  10248. */
  10249. static readonly IsLesser: number;
  10250. /**
  10251. * Internal only The action manager for the condition
  10252. * @hidden
  10253. */ private _actionManager: ActionManager;
  10254. /**
  10255. * Internal only
  10256. * @hidden
  10257. */
  10258. private _target;
  10259. /**
  10260. * Internal only
  10261. * @hidden
  10262. */
  10263. private _effectiveTarget;
  10264. /**
  10265. * Internal only
  10266. * @hidden
  10267. */
  10268. private _property;
  10269. /**
  10270. * Creates a new ValueCondition
  10271. * @param actionManager manager for the action the condition applies to
  10272. * @param target for the action
  10273. * @param propertyPath path to specify the property of the target the conditional operator uses
  10274. * @param value the value compared by the conditional operator against the current value of the property
  10275. * @param operator the conditional operator, default ValueCondition.IsEqual
  10276. */
  10277. constructor(actionManager: ActionManager, target: any,
  10278. /** path to specify the property of the target the conditional operator uses */
  10279. propertyPath: string,
  10280. /** the value compared by the conditional operator against the current value of the property */
  10281. value: any,
  10282. /** the conditional operator, default ValueCondition.IsEqual */
  10283. operator?: number);
  10284. /**
  10285. * Compares the given value with the property value for the specified conditional operator
  10286. * @returns the result of the comparison
  10287. */
  10288. isValid(): boolean;
  10289. /**
  10290. * Serialize the ValueCondition into a JSON compatible object
  10291. * @returns serialization object
  10292. */
  10293. serialize(): any;
  10294. /**
  10295. * Gets the name of the conditional operator for the ValueCondition
  10296. * @param operator the conditional operator
  10297. * @returns the name
  10298. */
  10299. static GetOperatorName(operator: number): string;
  10300. }
  10301. /**
  10302. * Defines a predicate condition as an extension of Condition
  10303. */
  10304. export class PredicateCondition extends Condition {
  10305. /** defines the predicate function used to validate the condition */
  10306. predicate: () => boolean;
  10307. /**
  10308. * Internal only - manager for action
  10309. * @hidden
  10310. */ private _actionManager: ActionManager;
  10311. /**
  10312. * Creates a new PredicateCondition
  10313. * @param actionManager manager for the action the condition applies to
  10314. * @param predicate defines the predicate function used to validate the condition
  10315. */
  10316. constructor(actionManager: ActionManager,
  10317. /** defines the predicate function used to validate the condition */
  10318. predicate: () => boolean);
  10319. /**
  10320. * @returns the validity of the predicate condition
  10321. */
  10322. isValid(): boolean;
  10323. }
  10324. /**
  10325. * Defines a state condition as an extension of Condition
  10326. */
  10327. export class StateCondition extends Condition {
  10328. /** Value to compare with target state */
  10329. value: string;
  10330. /**
  10331. * Internal only - manager for action
  10332. * @hidden
  10333. */ private _actionManager: ActionManager;
  10334. /**
  10335. * Internal only
  10336. * @hidden
  10337. */
  10338. private _target;
  10339. /**
  10340. * Creates a new StateCondition
  10341. * @param actionManager manager for the action the condition applies to
  10342. * @param target of the condition
  10343. * @param value to compare with target state
  10344. */
  10345. constructor(actionManager: ActionManager, target: any,
  10346. /** Value to compare with target state */
  10347. value: string);
  10348. /**
  10349. * Gets a boolean indicating if the current condition is met
  10350. * @returns the validity of the state
  10351. */
  10352. isValid(): boolean;
  10353. /**
  10354. * Serialize the StateCondition into a JSON compatible object
  10355. * @returns serialization object
  10356. */
  10357. serialize(): any;
  10358. }
  10359. }
  10360. declare module BABYLON {
  10361. /**
  10362. * This defines an action responsible to toggle a boolean once triggered.
  10363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10364. */
  10365. export class SwitchBooleanAction extends Action {
  10366. /**
  10367. * The path to the boolean property in the target object
  10368. */
  10369. propertyPath: string;
  10370. private _target;
  10371. private _effectiveTarget;
  10372. private _property;
  10373. /**
  10374. * Instantiate the action
  10375. * @param triggerOptions defines the trigger options
  10376. * @param target defines the object containing the boolean
  10377. * @param propertyPath defines the path to the boolean property in the target object
  10378. * @param condition defines the trigger related conditions
  10379. */
  10380. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10381. /** @hidden */ private _prepare(): void;
  10382. /**
  10383. * Execute the action toggle the boolean value.
  10384. */
  10385. execute(): void;
  10386. /**
  10387. * Serializes the actions and its related information.
  10388. * @param parent defines the object to serialize in
  10389. * @returns the serialized object
  10390. */
  10391. serialize(parent: any): any;
  10392. }
  10393. /**
  10394. * This defines an action responsible to set a the state field of the target
  10395. * to a desired value once triggered.
  10396. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10397. */
  10398. export class SetStateAction extends Action {
  10399. /**
  10400. * The value to store in the state field.
  10401. */
  10402. value: string;
  10403. private _target;
  10404. /**
  10405. * Instantiate the action
  10406. * @param triggerOptions defines the trigger options
  10407. * @param target defines the object containing the state property
  10408. * @param value defines the value to store in the state field
  10409. * @param condition defines the trigger related conditions
  10410. */
  10411. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10412. /**
  10413. * Execute the action and store the value on the target state property.
  10414. */
  10415. execute(): void;
  10416. /**
  10417. * Serializes the actions and its related information.
  10418. * @param parent defines the object to serialize in
  10419. * @returns the serialized object
  10420. */
  10421. serialize(parent: any): any;
  10422. }
  10423. /**
  10424. * This defines an action responsible to set a property of the target
  10425. * to a desired value once triggered.
  10426. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10427. */
  10428. export class SetValueAction extends Action {
  10429. /**
  10430. * The path of the property to set in the target.
  10431. */
  10432. propertyPath: string;
  10433. /**
  10434. * The value to set in the property
  10435. */
  10436. value: any;
  10437. private _target;
  10438. private _effectiveTarget;
  10439. private _property;
  10440. /**
  10441. * Instantiate the action
  10442. * @param triggerOptions defines the trigger options
  10443. * @param target defines the object containing the property
  10444. * @param propertyPath defines the path of the property to set in the target
  10445. * @param value defines the value to set in the property
  10446. * @param condition defines the trigger related conditions
  10447. */
  10448. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10449. /** @hidden */ private _prepare(): void;
  10450. /**
  10451. * Execute the action and set the targetted property to the desired value.
  10452. */
  10453. execute(): void;
  10454. /**
  10455. * Serializes the actions and its related information.
  10456. * @param parent defines the object to serialize in
  10457. * @returns the serialized object
  10458. */
  10459. serialize(parent: any): any;
  10460. }
  10461. /**
  10462. * This defines an action responsible to increment the target value
  10463. * to a desired value once triggered.
  10464. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10465. */
  10466. export class IncrementValueAction extends Action {
  10467. /**
  10468. * The path of the property to increment in the target.
  10469. */
  10470. propertyPath: string;
  10471. /**
  10472. * The value we should increment the property by.
  10473. */
  10474. value: any;
  10475. private _target;
  10476. private _effectiveTarget;
  10477. private _property;
  10478. /**
  10479. * Instantiate the action
  10480. * @param triggerOptions defines the trigger options
  10481. * @param target defines the object containing the property
  10482. * @param propertyPath defines the path of the property to increment in the target
  10483. * @param value defines the value value we should increment the property by
  10484. * @param condition defines the trigger related conditions
  10485. */
  10486. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10487. /** @hidden */ private _prepare(): void;
  10488. /**
  10489. * Execute the action and increment the target of the value amount.
  10490. */
  10491. execute(): void;
  10492. /**
  10493. * Serializes the actions and its related information.
  10494. * @param parent defines the object to serialize in
  10495. * @returns the serialized object
  10496. */
  10497. serialize(parent: any): any;
  10498. }
  10499. /**
  10500. * This defines an action responsible to start an animation once triggered.
  10501. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10502. */
  10503. export class PlayAnimationAction extends Action {
  10504. /**
  10505. * Where the animation should start (animation frame)
  10506. */
  10507. from: number;
  10508. /**
  10509. * Where the animation should stop (animation frame)
  10510. */
  10511. to: number;
  10512. /**
  10513. * Define if the animation should loop or stop after the first play.
  10514. */
  10515. loop?: boolean;
  10516. private _target;
  10517. /**
  10518. * Instantiate the action
  10519. * @param triggerOptions defines the trigger options
  10520. * @param target defines the target animation or animation name
  10521. * @param from defines from where the animation should start (animation frame)
  10522. * @param end defines where the animation should stop (animation frame)
  10523. * @param loop defines if the animation should loop or stop after the first play
  10524. * @param condition defines the trigger related conditions
  10525. */
  10526. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10527. /** @hidden */ private _prepare(): void;
  10528. /**
  10529. * Execute the action and play the animation.
  10530. */
  10531. execute(): void;
  10532. /**
  10533. * Serializes the actions and its related information.
  10534. * @param parent defines the object to serialize in
  10535. * @returns the serialized object
  10536. */
  10537. serialize(parent: any): any;
  10538. }
  10539. /**
  10540. * This defines an action responsible to stop an animation once triggered.
  10541. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10542. */
  10543. export class StopAnimationAction extends Action {
  10544. private _target;
  10545. /**
  10546. * Instantiate the action
  10547. * @param triggerOptions defines the trigger options
  10548. * @param target defines the target animation or animation name
  10549. * @param condition defines the trigger related conditions
  10550. */
  10551. constructor(triggerOptions: any, target: any, condition?: Condition);
  10552. /** @hidden */ private _prepare(): void;
  10553. /**
  10554. * Execute the action and stop the animation.
  10555. */
  10556. execute(): void;
  10557. /**
  10558. * Serializes the actions and its related information.
  10559. * @param parent defines the object to serialize in
  10560. * @returns the serialized object
  10561. */
  10562. serialize(parent: any): any;
  10563. }
  10564. /**
  10565. * This defines an action responsible that does nothing once triggered.
  10566. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10567. */
  10568. export class DoNothingAction extends Action {
  10569. /**
  10570. * Instantiate the action
  10571. * @param triggerOptions defines the trigger options
  10572. * @param condition defines the trigger related conditions
  10573. */
  10574. constructor(triggerOptions?: any, condition?: Condition);
  10575. /**
  10576. * Execute the action and do nothing.
  10577. */
  10578. execute(): void;
  10579. /**
  10580. * Serializes the actions and its related information.
  10581. * @param parent defines the object to serialize in
  10582. * @returns the serialized object
  10583. */
  10584. serialize(parent: any): any;
  10585. }
  10586. /**
  10587. * This defines an action responsible to trigger several actions once triggered.
  10588. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10589. */
  10590. export class CombineAction extends Action {
  10591. /**
  10592. * The list of aggregated animations to run.
  10593. */
  10594. children: Action[];
  10595. /**
  10596. * Instantiate the action
  10597. * @param triggerOptions defines the trigger options
  10598. * @param children defines the list of aggregated animations to run
  10599. * @param condition defines the trigger related conditions
  10600. */
  10601. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10602. /** @hidden */ private _prepare(): void;
  10603. /**
  10604. * Execute the action and executes all the aggregated actions.
  10605. */
  10606. execute(evt: ActionEvent): void;
  10607. /**
  10608. * Serializes the actions and its related information.
  10609. * @param parent defines the object to serialize in
  10610. * @returns the serialized object
  10611. */
  10612. serialize(parent: any): any;
  10613. }
  10614. /**
  10615. * This defines an action responsible to run code (external event) once triggered.
  10616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10617. */
  10618. export class ExecuteCodeAction extends Action {
  10619. /**
  10620. * The callback function to run.
  10621. */
  10622. func: (evt: ActionEvent) => void;
  10623. /**
  10624. * Instantiate the action
  10625. * @param triggerOptions defines the trigger options
  10626. * @param func defines the callback function to run
  10627. * @param condition defines the trigger related conditions
  10628. */
  10629. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10630. /**
  10631. * Execute the action and run the attached code.
  10632. */
  10633. execute(evt: ActionEvent): void;
  10634. }
  10635. /**
  10636. * This defines an action responsible to set the parent property of the target once triggered.
  10637. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10638. */
  10639. export class SetParentAction extends Action {
  10640. private _parent;
  10641. private _target;
  10642. /**
  10643. * Instantiate the action
  10644. * @param triggerOptions defines the trigger options
  10645. * @param target defines the target containing the parent property
  10646. * @param parent defines from where the animation should start (animation frame)
  10647. * @param condition defines the trigger related conditions
  10648. */
  10649. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10650. /** @hidden */ private _prepare(): void;
  10651. /**
  10652. * Execute the action and set the parent property.
  10653. */
  10654. execute(): void;
  10655. /**
  10656. * Serializes the actions and its related information.
  10657. * @param parent defines the object to serialize in
  10658. * @returns the serialized object
  10659. */
  10660. serialize(parent: any): any;
  10661. }
  10662. }
  10663. declare module BABYLON {
  10664. /**
  10665. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10666. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10668. */
  10669. export class ActionManager extends AbstractActionManager {
  10670. /**
  10671. * Nothing
  10672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10673. */
  10674. static readonly NothingTrigger: number;
  10675. /**
  10676. * On pick
  10677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10678. */
  10679. static readonly OnPickTrigger: number;
  10680. /**
  10681. * On left pick
  10682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10683. */
  10684. static readonly OnLeftPickTrigger: number;
  10685. /**
  10686. * On right pick
  10687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10688. */
  10689. static readonly OnRightPickTrigger: number;
  10690. /**
  10691. * On center pick
  10692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10693. */
  10694. static readonly OnCenterPickTrigger: number;
  10695. /**
  10696. * On pick down
  10697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10698. */
  10699. static readonly OnPickDownTrigger: number;
  10700. /**
  10701. * On double pick
  10702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10703. */
  10704. static readonly OnDoublePickTrigger: number;
  10705. /**
  10706. * On pick up
  10707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10708. */
  10709. static readonly OnPickUpTrigger: number;
  10710. /**
  10711. * On pick out.
  10712. * This trigger will only be raised if you also declared a OnPickDown
  10713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10714. */
  10715. static readonly OnPickOutTrigger: number;
  10716. /**
  10717. * On long press
  10718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10719. */
  10720. static readonly OnLongPressTrigger: number;
  10721. /**
  10722. * On pointer over
  10723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10724. */
  10725. static readonly OnPointerOverTrigger: number;
  10726. /**
  10727. * On pointer out
  10728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10729. */
  10730. static readonly OnPointerOutTrigger: number;
  10731. /**
  10732. * On every frame
  10733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10734. */
  10735. static readonly OnEveryFrameTrigger: number;
  10736. /**
  10737. * On intersection enter
  10738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10739. */
  10740. static readonly OnIntersectionEnterTrigger: number;
  10741. /**
  10742. * On intersection exit
  10743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10744. */
  10745. static readonly OnIntersectionExitTrigger: number;
  10746. /**
  10747. * On key down
  10748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10749. */
  10750. static readonly OnKeyDownTrigger: number;
  10751. /**
  10752. * On key up
  10753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10754. */
  10755. static readonly OnKeyUpTrigger: number;
  10756. private _scene;
  10757. /**
  10758. * Creates a new action manager
  10759. * @param scene defines the hosting scene
  10760. */
  10761. constructor(scene: Scene);
  10762. /**
  10763. * Releases all associated resources
  10764. */
  10765. dispose(): void;
  10766. /**
  10767. * Gets hosting scene
  10768. * @returns the hosting scene
  10769. */
  10770. getScene(): Scene;
  10771. /**
  10772. * Does this action manager handles actions of any of the given triggers
  10773. * @param triggers defines the triggers to be tested
  10774. * @return a boolean indicating whether one (or more) of the triggers is handled
  10775. */
  10776. hasSpecificTriggers(triggers: number[]): boolean;
  10777. /**
  10778. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10779. * speed.
  10780. * @param triggerA defines the trigger to be tested
  10781. * @param triggerB defines the trigger to be tested
  10782. * @return a boolean indicating whether one (or more) of the triggers is handled
  10783. */
  10784. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10785. /**
  10786. * Does this action manager handles actions of a given trigger
  10787. * @param trigger defines the trigger to be tested
  10788. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10789. * @return whether the trigger is handled
  10790. */
  10791. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10792. /**
  10793. * Does this action manager has pointer triggers
  10794. */
  10795. readonly hasPointerTriggers: boolean;
  10796. /**
  10797. * Does this action manager has pick triggers
  10798. */
  10799. readonly hasPickTriggers: boolean;
  10800. /**
  10801. * Registers an action to this action manager
  10802. * @param action defines the action to be registered
  10803. * @return the action amended (prepared) after registration
  10804. */
  10805. registerAction(action: IAction): Nullable<IAction>;
  10806. /**
  10807. * Unregisters an action to this action manager
  10808. * @param action defines the action to be unregistered
  10809. * @return a boolean indicating whether the action has been unregistered
  10810. */
  10811. unregisterAction(action: IAction): Boolean;
  10812. /**
  10813. * Process a specific trigger
  10814. * @param trigger defines the trigger to process
  10815. * @param evt defines the event details to be processed
  10816. */
  10817. processTrigger(trigger: number, evt?: IActionEvent): void;
  10818. /** @hidden */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10819. /** @hidden */ private _getProperty(propertyPath: string): string;
  10820. /**
  10821. * Serialize this manager to a JSON object
  10822. * @param name defines the property name to store this manager
  10823. * @returns a JSON representation of this manager
  10824. */
  10825. serialize(name: string): any;
  10826. /**
  10827. * Creates a new ActionManager from a JSON data
  10828. * @param parsedActions defines the JSON data to read from
  10829. * @param object defines the hosting mesh
  10830. * @param scene defines the hosting scene
  10831. */
  10832. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10833. /**
  10834. * Get a trigger name by index
  10835. * @param trigger defines the trigger index
  10836. * @returns a trigger name
  10837. */
  10838. static GetTriggerName(trigger: number): string;
  10839. }
  10840. }
  10841. declare module BABYLON {
  10842. /**
  10843. * Class representing a ray with position and direction
  10844. */
  10845. export class Ray {
  10846. /** origin point */
  10847. origin: Vector3;
  10848. /** direction */
  10849. direction: Vector3;
  10850. /** length of the ray */
  10851. length: number;
  10852. private static readonly TmpVector3;
  10853. private _tmpRay;
  10854. /**
  10855. * Creates a new ray
  10856. * @param origin origin point
  10857. * @param direction direction
  10858. * @param length length of the ray
  10859. */
  10860. constructor(
  10861. /** origin point */
  10862. origin: Vector3,
  10863. /** direction */
  10864. direction: Vector3,
  10865. /** length of the ray */
  10866. length?: number);
  10867. /**
  10868. * Checks if the ray intersects a box
  10869. * @param minimum bound of the box
  10870. * @param maximum bound of the box
  10871. * @param intersectionTreshold extra extend to be added to the box in all direction
  10872. * @returns if the box was hit
  10873. */
  10874. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10875. /**
  10876. * Checks if the ray intersects a box
  10877. * @param box the bounding box to check
  10878. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10879. * @returns if the box was hit
  10880. */
  10881. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10882. /**
  10883. * If the ray hits a sphere
  10884. * @param sphere the bounding sphere to check
  10885. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10886. * @returns true if it hits the sphere
  10887. */
  10888. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10889. /**
  10890. * If the ray hits a triange
  10891. * @param vertex0 triangle vertex
  10892. * @param vertex1 triangle vertex
  10893. * @param vertex2 triangle vertex
  10894. * @returns intersection information if hit
  10895. */
  10896. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10897. /**
  10898. * Checks if ray intersects a plane
  10899. * @param plane the plane to check
  10900. * @returns the distance away it was hit
  10901. */
  10902. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10903. /**
  10904. * Calculate the intercept of a ray on a given axis
  10905. * @param axis to check 'x' | 'y' | 'z'
  10906. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10907. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10908. */
  10909. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10910. /**
  10911. * Checks if ray intersects a mesh
  10912. * @param mesh the mesh to check
  10913. * @param fastCheck if only the bounding box should checked
  10914. * @returns picking info of the intersecton
  10915. */
  10916. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10917. /**
  10918. * Checks if ray intersects a mesh
  10919. * @param meshes the meshes to check
  10920. * @param fastCheck if only the bounding box should checked
  10921. * @param results array to store result in
  10922. * @returns Array of picking infos
  10923. */
  10924. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10925. private _comparePickingInfo;
  10926. private static smallnum;
  10927. private static rayl;
  10928. /**
  10929. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10930. * @param sega the first point of the segment to test the intersection against
  10931. * @param segb the second point of the segment to test the intersection against
  10932. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10933. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10934. */
  10935. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10936. /**
  10937. * Update the ray from viewport position
  10938. * @param x position
  10939. * @param y y position
  10940. * @param viewportWidth viewport width
  10941. * @param viewportHeight viewport height
  10942. * @param world world matrix
  10943. * @param view view matrix
  10944. * @param projection projection matrix
  10945. * @returns this ray updated
  10946. */
  10947. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10948. /**
  10949. * Creates a ray with origin and direction of 0,0,0
  10950. * @returns the new ray
  10951. */
  10952. static Zero(): Ray;
  10953. /**
  10954. * Creates a new ray from screen space and viewport
  10955. * @param x position
  10956. * @param y y position
  10957. * @param viewportWidth viewport width
  10958. * @param viewportHeight viewport height
  10959. * @param world world matrix
  10960. * @param view view matrix
  10961. * @param projection projection matrix
  10962. * @returns new ray
  10963. */
  10964. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10965. /**
  10966. * 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
  10967. * transformed to the given world matrix.
  10968. * @param origin The origin point
  10969. * @param end The end point
  10970. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10971. * @returns the new ray
  10972. */
  10973. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10974. /**
  10975. * Transforms a ray by a matrix
  10976. * @param ray ray to transform
  10977. * @param matrix matrix to apply
  10978. * @returns the resulting new ray
  10979. */
  10980. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10981. /**
  10982. * Transforms a ray by a matrix
  10983. * @param ray ray to transform
  10984. * @param matrix matrix to apply
  10985. * @param result ray to store result in
  10986. */
  10987. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10988. /**
  10989. * Unproject a ray from screen space to object space
  10990. * @param sourceX defines the screen space x coordinate to use
  10991. * @param sourceY defines the screen space y coordinate to use
  10992. * @param viewportWidth defines the current width of the viewport
  10993. * @param viewportHeight defines the current height of the viewport
  10994. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10995. * @param view defines the view matrix to use
  10996. * @param projection defines the projection matrix to use
  10997. */
  10998. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10999. }
  11000. /**
  11001. * Type used to define predicate used to select faces when a mesh intersection is detected
  11002. */
  11003. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11004. interface Scene {
  11005. /** @hidden */ private _tempPickingRay: Nullable<Ray>;
  11006. /** @hidden */ private _cachedRayForTransform: Ray;
  11007. /** @hidden */ private _pickWithRayInverseMatrix: Matrix;
  11008. /** @hidden */ private _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11009. /** @hidden */ private _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11010. }
  11011. }
  11012. declare module BABYLON {
  11013. /**
  11014. * Groups all the scene component constants in one place to ease maintenance.
  11015. * @hidden
  11016. */
  11017. export class SceneComponentConstants {
  11018. static readonly NAME_EFFECTLAYER: string;
  11019. static readonly NAME_LAYER: string;
  11020. static readonly NAME_LENSFLARESYSTEM: string;
  11021. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11022. static readonly NAME_PARTICLESYSTEM: string;
  11023. static readonly NAME_GAMEPAD: string;
  11024. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11025. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11026. static readonly NAME_DEPTHRENDERER: string;
  11027. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11028. static readonly NAME_SPRITE: string;
  11029. static readonly NAME_OUTLINERENDERER: string;
  11030. static readonly NAME_PROCEDURALTEXTURE: string;
  11031. static readonly NAME_SHADOWGENERATOR: string;
  11032. static readonly NAME_OCTREE: string;
  11033. static readonly NAME_PHYSICSENGINE: string;
  11034. static readonly NAME_AUDIO: string;
  11035. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11036. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11037. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11038. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11039. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11040. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11041. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11042. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11043. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11044. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11045. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11046. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11047. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11048. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11049. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11050. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11051. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11052. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11053. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11054. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11055. static readonly STEP_AFTERRENDER_AUDIO: number;
  11056. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11057. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11058. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11059. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11060. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11061. static readonly STEP_POINTERMOVE_SPRITE: number;
  11062. static readonly STEP_POINTERDOWN_SPRITE: number;
  11063. static readonly STEP_POINTERUP_SPRITE: number;
  11064. }
  11065. /**
  11066. * This represents a scene component.
  11067. *
  11068. * This is used to decouple the dependency the scene is having on the different workloads like
  11069. * layers, post processes...
  11070. */
  11071. export interface ISceneComponent {
  11072. /**
  11073. * The name of the component. Each component must have a unique name.
  11074. */
  11075. name: string;
  11076. /**
  11077. * The scene the component belongs to.
  11078. */
  11079. scene: Scene;
  11080. /**
  11081. * Register the component to one instance of a scene.
  11082. */
  11083. register(): void;
  11084. /**
  11085. * Rebuilds the elements related to this component in case of
  11086. * context lost for instance.
  11087. */
  11088. rebuild(): void;
  11089. /**
  11090. * Disposes the component and the associated ressources.
  11091. */
  11092. dispose(): void;
  11093. }
  11094. /**
  11095. * This represents a SERIALIZABLE scene component.
  11096. *
  11097. * This extends Scene Component to add Serialization methods on top.
  11098. */
  11099. export interface ISceneSerializableComponent extends ISceneComponent {
  11100. /**
  11101. * Adds all the elements from the container to the scene
  11102. * @param container the container holding the elements
  11103. */
  11104. addFromContainer(container: AbstractScene): void;
  11105. /**
  11106. * Removes all the elements in the container from the scene
  11107. * @param container contains the elements to remove
  11108. * @param dispose if the removed element should be disposed (default: false)
  11109. */
  11110. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11111. /**
  11112. * Serializes the component data to the specified json object
  11113. * @param serializationObject The object to serialize to
  11114. */
  11115. serialize(serializationObject: any): void;
  11116. }
  11117. /**
  11118. * Strong typing of a Mesh related stage step action
  11119. */
  11120. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11121. /**
  11122. * Strong typing of a Evaluate Sub Mesh related stage step action
  11123. */
  11124. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11125. /**
  11126. * Strong typing of a Active Mesh related stage step action
  11127. */
  11128. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11129. /**
  11130. * Strong typing of a Camera related stage step action
  11131. */
  11132. export type CameraStageAction = (camera: Camera) => void;
  11133. /**
  11134. * Strong typing of a Camera Frame buffer related stage step action
  11135. */
  11136. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11137. /**
  11138. * Strong typing of a Render Target related stage step action
  11139. */
  11140. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11141. /**
  11142. * Strong typing of a RenderingGroup related stage step action
  11143. */
  11144. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11145. /**
  11146. * Strong typing of a Mesh Render related stage step action
  11147. */
  11148. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11149. /**
  11150. * Strong typing of a simple stage step action
  11151. */
  11152. export type SimpleStageAction = () => void;
  11153. /**
  11154. * Strong typing of a render target action.
  11155. */
  11156. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11157. /**
  11158. * Strong typing of a pointer move action.
  11159. */
  11160. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11161. /**
  11162. * Strong typing of a pointer up/down action.
  11163. */
  11164. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11165. /**
  11166. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11167. * @hidden
  11168. */
  11169. export class Stage<T extends Function> extends Array<{
  11170. index: number;
  11171. component: ISceneComponent;
  11172. action: T;
  11173. }> {
  11174. /**
  11175. * Hide ctor from the rest of the world.
  11176. * @param items The items to add.
  11177. */
  11178. private constructor();
  11179. /**
  11180. * Creates a new Stage.
  11181. * @returns A new instance of a Stage
  11182. */
  11183. static Create<T extends Function>(): Stage<T>;
  11184. /**
  11185. * Registers a step in an ordered way in the targeted stage.
  11186. * @param index Defines the position to register the step in
  11187. * @param component Defines the component attached to the step
  11188. * @param action Defines the action to launch during the step
  11189. */
  11190. registerStep(index: number, component: ISceneComponent, action: T): void;
  11191. /**
  11192. * Clears all the steps from the stage.
  11193. */
  11194. clear(): void;
  11195. }
  11196. }
  11197. declare module BABYLON {
  11198. interface Scene {
  11199. /** @hidden */ private _pointerOverSprite: Nullable<Sprite>;
  11200. /** @hidden */ private _pickedDownSprite: Nullable<Sprite>;
  11201. /** @hidden */ private _tempSpritePickingRay: Nullable<Ray>;
  11202. /**
  11203. * All of the sprite managers added to this scene
  11204. * @see http://doc.babylonjs.com/babylon101/sprites
  11205. */
  11206. spriteManagers: Array<ISpriteManager>;
  11207. /**
  11208. * An event triggered when sprites rendering is about to start
  11209. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11210. */
  11211. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11212. /**
  11213. * An event triggered when sprites rendering is done
  11214. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11215. */
  11216. onAfterSpritesRenderingObservable: Observable<Scene>;
  11217. /** @hidden */ private _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11218. /** Launch a ray to try to pick a sprite in the scene
  11219. * @param x position on screen
  11220. * @param y position on screen
  11221. * @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
  11222. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11223. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11224. * @returns a PickingInfo
  11225. */
  11226. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11227. /** Use the given ray to pick a sprite in the scene
  11228. * @param ray The ray (in world space) to use to pick meshes
  11229. * @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
  11230. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11231. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11232. * @returns a PickingInfo
  11233. */
  11234. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11235. /** @hidden */ private _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11236. /** Launch a ray to try to pick sprites in the scene
  11237. * @param x position on screen
  11238. * @param y position on screen
  11239. * @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
  11240. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11241. * @returns a PickingInfo array
  11242. */
  11243. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11244. /** Use the given ray to pick sprites in the scene
  11245. * @param ray The ray (in world space) to use to pick meshes
  11246. * @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
  11247. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11248. * @returns a PickingInfo array
  11249. */
  11250. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11251. /**
  11252. * Force the sprite under the pointer
  11253. * @param sprite defines the sprite to use
  11254. */
  11255. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11256. /**
  11257. * Gets the sprite under the pointer
  11258. * @returns a Sprite or null if no sprite is under the pointer
  11259. */
  11260. getPointerOverSprite(): Nullable<Sprite>;
  11261. }
  11262. /**
  11263. * Defines the sprite scene component responsible to manage sprites
  11264. * in a given scene.
  11265. */
  11266. export class SpriteSceneComponent implements ISceneComponent {
  11267. /**
  11268. * The component name helpfull to identify the component in the list of scene components.
  11269. */
  11270. readonly name: string;
  11271. /**
  11272. * The scene the component belongs to.
  11273. */
  11274. scene: Scene;
  11275. /** @hidden */
  11276. private _spritePredicate;
  11277. /**
  11278. * Creates a new instance of the component for the given scene
  11279. * @param scene Defines the scene to register the component in
  11280. */
  11281. constructor(scene: Scene);
  11282. /**
  11283. * Registers the component in a given scene
  11284. */
  11285. register(): void;
  11286. /**
  11287. * Rebuilds the elements related to this component in case of
  11288. * context lost for instance.
  11289. */
  11290. rebuild(): void;
  11291. /**
  11292. * Disposes the component and the associated ressources.
  11293. */
  11294. dispose(): void;
  11295. private _pickSpriteButKeepRay;
  11296. private _pointerMove;
  11297. private _pointerDown;
  11298. private _pointerUp;
  11299. }
  11300. }
  11301. declare module BABYLON {
  11302. /** @hidden */
  11303. export var fogFragmentDeclaration: {
  11304. name: string;
  11305. shader: string;
  11306. };
  11307. }
  11308. declare module BABYLON {
  11309. /** @hidden */
  11310. export var fogFragment: {
  11311. name: string;
  11312. shader: string;
  11313. };
  11314. }
  11315. declare module BABYLON {
  11316. /** @hidden */
  11317. export var spritesPixelShader: {
  11318. name: string;
  11319. shader: string;
  11320. };
  11321. }
  11322. declare module BABYLON {
  11323. /** @hidden */
  11324. export var fogVertexDeclaration: {
  11325. name: string;
  11326. shader: string;
  11327. };
  11328. }
  11329. declare module BABYLON {
  11330. /** @hidden */
  11331. export var spritesVertexShader: {
  11332. name: string;
  11333. shader: string;
  11334. };
  11335. }
  11336. declare module BABYLON {
  11337. /**
  11338. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11339. */
  11340. export interface ISpriteManager extends IDisposable {
  11341. /**
  11342. * Restricts the camera to viewing objects with the same layerMask.
  11343. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11344. */
  11345. layerMask: number;
  11346. /**
  11347. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11348. */
  11349. isPickable: boolean;
  11350. /**
  11351. * Specifies the rendering group id for this mesh (0 by default)
  11352. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11353. */
  11354. renderingGroupId: number;
  11355. /**
  11356. * Defines the list of sprites managed by the manager.
  11357. */
  11358. sprites: Array<Sprite>;
  11359. /**
  11360. * Tests the intersection of a sprite with a specific ray.
  11361. * @param ray The ray we are sending to test the collision
  11362. * @param camera The camera space we are sending rays in
  11363. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11364. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11365. * @returns picking info or null.
  11366. */
  11367. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11368. /**
  11369. * Intersects the sprites with a ray
  11370. * @param ray defines the ray to intersect with
  11371. * @param camera defines the current active camera
  11372. * @param predicate defines a predicate used to select candidate sprites
  11373. * @returns null if no hit or a PickingInfo array
  11374. */
  11375. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11376. /**
  11377. * Renders the list of sprites on screen.
  11378. */
  11379. render(): void;
  11380. }
  11381. /**
  11382. * Class used to manage multiple sprites on the same spritesheet
  11383. * @see http://doc.babylonjs.com/babylon101/sprites
  11384. */
  11385. export class SpriteManager implements ISpriteManager {
  11386. /** defines the manager's name */
  11387. name: string;
  11388. /** Gets the list of sprites */
  11389. sprites: Sprite[];
  11390. /** Gets or sets the rendering group id (0 by default) */
  11391. renderingGroupId: number;
  11392. /** Gets or sets camera layer mask */
  11393. layerMask: number;
  11394. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11395. fogEnabled: boolean;
  11396. /** Gets or sets a boolean indicating if the sprites are pickable */
  11397. isPickable: boolean;
  11398. /** Defines the default width of a cell in the spritesheet */
  11399. cellWidth: number;
  11400. /** Defines the default height of a cell in the spritesheet */
  11401. cellHeight: number;
  11402. /** Associative array from JSON sprite data file */
  11403. private _cellData;
  11404. /** Array of sprite names from JSON sprite data file */
  11405. private _spriteMap;
  11406. /** True when packed cell data from JSON file is ready*/
  11407. private _packedAndReady;
  11408. /**
  11409. * An event triggered when the manager is disposed.
  11410. */
  11411. onDisposeObservable: Observable<SpriteManager>;
  11412. private _onDisposeObserver;
  11413. /**
  11414. * Callback called when the manager is disposed
  11415. */
  11416. onDispose: () => void;
  11417. private _capacity;
  11418. private _fromPacked;
  11419. private _spriteTexture;
  11420. private _epsilon;
  11421. private _scene;
  11422. private _vertexData;
  11423. private _buffer;
  11424. private _vertexBuffers;
  11425. private _indexBuffer;
  11426. private _effectBase;
  11427. private _effectFog;
  11428. /**
  11429. * Gets or sets the spritesheet texture
  11430. */
  11431. texture: Texture;
  11432. /**
  11433. * Creates a new sprite manager
  11434. * @param name defines the manager's name
  11435. * @param imgUrl defines the sprite sheet url
  11436. * @param capacity defines the maximum allowed number of sprites
  11437. * @param cellSize defines the size of a sprite cell
  11438. * @param scene defines the hosting scene
  11439. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11440. * @param samplingMode defines the smapling mode to use with spritesheet
  11441. * @param fromPacked set to false; do not alter
  11442. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11443. */
  11444. constructor(
  11445. /** defines the manager's name */
  11446. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11447. private _makePacked;
  11448. private _appendSpriteVertex;
  11449. /**
  11450. * Intersects the sprites with a ray
  11451. * @param ray defines the ray to intersect with
  11452. * @param camera defines the current active camera
  11453. * @param predicate defines a predicate used to select candidate sprites
  11454. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11455. * @returns null if no hit or a PickingInfo
  11456. */
  11457. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11458. /**
  11459. * Intersects the sprites with a ray
  11460. * @param ray defines the ray to intersect with
  11461. * @param camera defines the current active camera
  11462. * @param predicate defines a predicate used to select candidate sprites
  11463. * @returns null if no hit or a PickingInfo array
  11464. */
  11465. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11466. /**
  11467. * Render all child sprites
  11468. */
  11469. render(): void;
  11470. /**
  11471. * Release associated resources
  11472. */
  11473. dispose(): void;
  11474. }
  11475. }
  11476. declare module BABYLON {
  11477. /**
  11478. * Class used to represent a sprite
  11479. * @see http://doc.babylonjs.com/babylon101/sprites
  11480. */
  11481. export class Sprite {
  11482. /** defines the name */
  11483. name: string;
  11484. /** Gets or sets the current world position */
  11485. position: Vector3;
  11486. /** Gets or sets the main color */
  11487. color: Color4;
  11488. /** Gets or sets the width */
  11489. width: number;
  11490. /** Gets or sets the height */
  11491. height: number;
  11492. /** Gets or sets rotation angle */
  11493. angle: number;
  11494. /** Gets or sets the cell index in the sprite sheet */
  11495. cellIndex: number;
  11496. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11497. cellRef: string;
  11498. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11499. invertU: number;
  11500. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11501. invertV: number;
  11502. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11503. disposeWhenFinishedAnimating: boolean;
  11504. /** Gets the list of attached animations */
  11505. animations: Animation[];
  11506. /** Gets or sets a boolean indicating if the sprite can be picked */
  11507. isPickable: boolean;
  11508. /**
  11509. * Gets or sets the associated action manager
  11510. */
  11511. actionManager: Nullable<ActionManager>;
  11512. private _animationStarted;
  11513. private _loopAnimation;
  11514. private _fromIndex;
  11515. private _toIndex;
  11516. private _delay;
  11517. private _direction;
  11518. private _manager;
  11519. private _time;
  11520. private _onAnimationEnd;
  11521. /**
  11522. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11523. */
  11524. isVisible: boolean;
  11525. /**
  11526. * Gets or sets the sprite size
  11527. */
  11528. size: number;
  11529. /**
  11530. * Creates a new Sprite
  11531. * @param name defines the name
  11532. * @param manager defines the manager
  11533. */
  11534. constructor(
  11535. /** defines the name */
  11536. name: string, manager: ISpriteManager);
  11537. /**
  11538. * Starts an animation
  11539. * @param from defines the initial key
  11540. * @param to defines the end key
  11541. * @param loop defines if the animation must loop
  11542. * @param delay defines the start delay (in ms)
  11543. * @param onAnimationEnd defines a callback to call when animation ends
  11544. */
  11545. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11546. /** Stops current animation (if any) */
  11547. stopAnimation(): void;
  11548. /** @hidden */ private _animate(deltaTime: number): void;
  11549. /** Release associated resources */
  11550. dispose(): void;
  11551. }
  11552. }
  11553. declare module BABYLON {
  11554. /**
  11555. * Information about the result of picking within a scene
  11556. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11557. */
  11558. export class PickingInfo {
  11559. /** @hidden */ private _pickingUnavailable: boolean;
  11560. /**
  11561. * If the pick collided with an object
  11562. */
  11563. hit: boolean;
  11564. /**
  11565. * Distance away where the pick collided
  11566. */
  11567. distance: number;
  11568. /**
  11569. * The location of pick collision
  11570. */
  11571. pickedPoint: Nullable<Vector3>;
  11572. /**
  11573. * The mesh corresponding the the pick collision
  11574. */
  11575. pickedMesh: Nullable<AbstractMesh>;
  11576. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11577. bu: number;
  11578. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11579. bv: number;
  11580. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11581. faceId: number;
  11582. /** Id of the the submesh that was picked */
  11583. subMeshId: number;
  11584. /** If a sprite was picked, this will be the sprite the pick collided with */
  11585. pickedSprite: Nullable<Sprite>;
  11586. /**
  11587. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11588. */
  11589. originMesh: Nullable<AbstractMesh>;
  11590. /**
  11591. * The ray that was used to perform the picking.
  11592. */
  11593. ray: Nullable<Ray>;
  11594. /**
  11595. * Gets the normal correspodning to the face the pick collided with
  11596. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11597. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11598. * @returns The normal correspodning to the face the pick collided with
  11599. */
  11600. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11601. /**
  11602. * Gets the texture coordinates of where the pick occured
  11603. * @returns the vector containing the coordnates of the texture
  11604. */
  11605. getTextureCoordinates(): Nullable<Vector2>;
  11606. }
  11607. }
  11608. declare module BABYLON {
  11609. /**
  11610. * Gather the list of pointer event types as constants.
  11611. */
  11612. export class PointerEventTypes {
  11613. /**
  11614. * 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.
  11615. */
  11616. static readonly POINTERDOWN: number;
  11617. /**
  11618. * The pointerup event is fired when a pointer is no longer active.
  11619. */
  11620. static readonly POINTERUP: number;
  11621. /**
  11622. * The pointermove event is fired when a pointer changes coordinates.
  11623. */
  11624. static readonly POINTERMOVE: number;
  11625. /**
  11626. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11627. */
  11628. static readonly POINTERWHEEL: number;
  11629. /**
  11630. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11631. */
  11632. static readonly POINTERPICK: number;
  11633. /**
  11634. * The pointertap event is fired when a the object has been touched and released without drag.
  11635. */
  11636. static readonly POINTERTAP: number;
  11637. /**
  11638. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11639. */
  11640. static readonly POINTERDOUBLETAP: number;
  11641. }
  11642. /**
  11643. * Base class of pointer info types.
  11644. */
  11645. export class PointerInfoBase {
  11646. /**
  11647. * Defines the type of event (PointerEventTypes)
  11648. */
  11649. type: number;
  11650. /**
  11651. * Defines the related dom event
  11652. */
  11653. event: PointerEvent | MouseWheelEvent;
  11654. /**
  11655. * Instantiates the base class of pointers info.
  11656. * @param type Defines the type of event (PointerEventTypes)
  11657. * @param event Defines the related dom event
  11658. */
  11659. constructor(
  11660. /**
  11661. * Defines the type of event (PointerEventTypes)
  11662. */
  11663. type: number,
  11664. /**
  11665. * Defines the related dom event
  11666. */
  11667. event: PointerEvent | MouseWheelEvent);
  11668. }
  11669. /**
  11670. * This class is used to store pointer related info for the onPrePointerObservable event.
  11671. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11672. */
  11673. export class PointerInfoPre extends PointerInfoBase {
  11674. /**
  11675. * Ray from a pointer if availible (eg. 6dof controller)
  11676. */
  11677. ray: Nullable<Ray>;
  11678. /**
  11679. * Defines the local position of the pointer on the canvas.
  11680. */
  11681. localPosition: Vector2;
  11682. /**
  11683. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11684. */
  11685. skipOnPointerObservable: boolean;
  11686. /**
  11687. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11688. * @param type Defines the type of event (PointerEventTypes)
  11689. * @param event Defines the related dom event
  11690. * @param localX Defines the local x coordinates of the pointer when the event occured
  11691. * @param localY Defines the local y coordinates of the pointer when the event occured
  11692. */
  11693. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11694. }
  11695. /**
  11696. * This type contains all the data related to a pointer event in Babylon.js.
  11697. * 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.
  11698. */
  11699. export class PointerInfo extends PointerInfoBase {
  11700. /**
  11701. * Defines the picking info associated to the info (if any)\
  11702. */
  11703. pickInfo: Nullable<PickingInfo>;
  11704. /**
  11705. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11706. * @param type Defines the type of event (PointerEventTypes)
  11707. * @param event Defines the related dom event
  11708. * @param pickInfo Defines the picking info associated to the info (if any)\
  11709. */
  11710. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11711. /**
  11712. * Defines the picking info associated to the info (if any)\
  11713. */
  11714. pickInfo: Nullable<PickingInfo>);
  11715. }
  11716. /**
  11717. * Data relating to a touch event on the screen.
  11718. */
  11719. export interface PointerTouch {
  11720. /**
  11721. * X coordinate of touch.
  11722. */
  11723. x: number;
  11724. /**
  11725. * Y coordinate of touch.
  11726. */
  11727. y: number;
  11728. /**
  11729. * Id of touch. Unique for each finger.
  11730. */
  11731. pointerId: number;
  11732. /**
  11733. * Event type passed from DOM.
  11734. */
  11735. type: any;
  11736. }
  11737. }
  11738. declare module BABYLON {
  11739. /**
  11740. * Manage the mouse inputs to control the movement of a free camera.
  11741. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11742. */
  11743. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11744. /**
  11745. * Define if touch is enabled in the mouse input
  11746. */
  11747. touchEnabled: boolean;
  11748. /**
  11749. * Defines the camera the input is attached to.
  11750. */
  11751. camera: FreeCamera;
  11752. /**
  11753. * Defines the buttons associated with the input to handle camera move.
  11754. */
  11755. buttons: number[];
  11756. /**
  11757. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11758. */
  11759. angularSensibility: number;
  11760. private _pointerInput;
  11761. private _onMouseMove;
  11762. private _observer;
  11763. private previousPosition;
  11764. /**
  11765. * Observable for when a pointer move event occurs containing the move offset
  11766. */
  11767. onPointerMovedObservable: Observable<{
  11768. offsetX: number;
  11769. offsetY: number;
  11770. }>;
  11771. /**
  11772. * @hidden
  11773. * If the camera should be rotated automatically based on pointer movement
  11774. */ private _allowCameraRotation: boolean;
  11775. /**
  11776. * Manage the mouse inputs to control the movement of a free camera.
  11777. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11778. * @param touchEnabled Defines if touch is enabled or not
  11779. */
  11780. constructor(
  11781. /**
  11782. * Define if touch is enabled in the mouse input
  11783. */
  11784. touchEnabled?: boolean);
  11785. /**
  11786. * Attach the input controls to a specific dom element to get the input from.
  11787. * @param element Defines the element the controls should be listened from
  11788. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11789. */
  11790. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11791. /**
  11792. * Called on JS contextmenu event.
  11793. * Override this method to provide functionality.
  11794. */
  11795. protected onContextMenu(evt: PointerEvent): void;
  11796. /**
  11797. * Detach the current controls from the specified dom element.
  11798. * @param element Defines the element to stop listening the inputs from
  11799. */
  11800. detachControl(element: Nullable<HTMLElement>): void;
  11801. /**
  11802. * Gets the class name of the current intput.
  11803. * @returns the class name
  11804. */
  11805. getClassName(): string;
  11806. /**
  11807. * Get the friendly name associated with the input class.
  11808. * @returns the input friendly name
  11809. */
  11810. getSimpleName(): string;
  11811. }
  11812. }
  11813. declare module BABYLON {
  11814. /**
  11815. * Manage the touch inputs to control the movement of a free camera.
  11816. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11817. */
  11818. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11819. /**
  11820. * Defines the camera the input is attached to.
  11821. */
  11822. camera: FreeCamera;
  11823. /**
  11824. * Defines the touch sensibility for rotation.
  11825. * The higher the faster.
  11826. */
  11827. touchAngularSensibility: number;
  11828. /**
  11829. * Defines the touch sensibility for move.
  11830. * The higher the faster.
  11831. */
  11832. touchMoveSensibility: number;
  11833. private _offsetX;
  11834. private _offsetY;
  11835. private _pointerPressed;
  11836. private _pointerInput;
  11837. private _observer;
  11838. private _onLostFocus;
  11839. /**
  11840. * Attach the input controls to a specific dom element to get the input from.
  11841. * @param element Defines the element the controls should be listened from
  11842. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11843. */
  11844. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11845. /**
  11846. * Detach the current controls from the specified dom element.
  11847. * @param element Defines the element to stop listening the inputs from
  11848. */
  11849. detachControl(element: Nullable<HTMLElement>): void;
  11850. /**
  11851. * Update the current camera state depending on the inputs that have been used this frame.
  11852. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11853. */
  11854. checkInputs(): void;
  11855. /**
  11856. * Gets the class name of the current intput.
  11857. * @returns the class name
  11858. */
  11859. getClassName(): string;
  11860. /**
  11861. * Get the friendly name associated with the input class.
  11862. * @returns the input friendly name
  11863. */
  11864. getSimpleName(): string;
  11865. }
  11866. }
  11867. declare module BABYLON {
  11868. /**
  11869. * Default Inputs manager for the FreeCamera.
  11870. * It groups all the default supported inputs for ease of use.
  11871. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11872. */
  11873. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11874. /**
  11875. * @hidden
  11876. */ private _mouseInput: Nullable<FreeCameraMouseInput>;
  11877. /**
  11878. * Instantiates a new FreeCameraInputsManager.
  11879. * @param camera Defines the camera the inputs belong to
  11880. */
  11881. constructor(camera: FreeCamera);
  11882. /**
  11883. * Add keyboard input support to the input manager.
  11884. * @returns the current input manager
  11885. */
  11886. addKeyboard(): FreeCameraInputsManager;
  11887. /**
  11888. * Add mouse input support to the input manager.
  11889. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11890. * @returns the current input manager
  11891. */
  11892. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11893. /**
  11894. * Removes the mouse input support from the manager
  11895. * @returns the current input manager
  11896. */
  11897. removeMouse(): FreeCameraInputsManager;
  11898. /**
  11899. * Add touch input support to the input manager.
  11900. * @returns the current input manager
  11901. */
  11902. addTouch(): FreeCameraInputsManager;
  11903. /**
  11904. * Remove all attached input methods from a camera
  11905. */
  11906. clear(): void;
  11907. }
  11908. }
  11909. declare module BABYLON {
  11910. /**
  11911. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11912. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11913. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11914. */
  11915. export class FreeCamera extends TargetCamera {
  11916. /**
  11917. * Define the collision ellipsoid of the camera.
  11918. * This is helpful to simulate a camera body like the player body around the camera
  11919. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11920. */
  11921. ellipsoid: Vector3;
  11922. /**
  11923. * Define an offset for the position of the ellipsoid around the camera.
  11924. * This can be helpful to determine the center of the body near the gravity center of the body
  11925. * instead of its head.
  11926. */
  11927. ellipsoidOffset: Vector3;
  11928. /**
  11929. * Enable or disable collisions of the camera with the rest of the scene objects.
  11930. */
  11931. checkCollisions: boolean;
  11932. /**
  11933. * Enable or disable gravity on the camera.
  11934. */
  11935. applyGravity: boolean;
  11936. /**
  11937. * Define the input manager associated to the camera.
  11938. */
  11939. inputs: FreeCameraInputsManager;
  11940. /**
  11941. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11942. * Higher values reduce sensitivity.
  11943. */
  11944. /**
  11945. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11946. * Higher values reduce sensitivity.
  11947. */
  11948. angularSensibility: number;
  11949. /**
  11950. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11951. */
  11952. keysUp: number[];
  11953. /**
  11954. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11955. */
  11956. keysDown: number[];
  11957. /**
  11958. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11959. */
  11960. keysLeft: number[];
  11961. /**
  11962. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11963. */
  11964. keysRight: number[];
  11965. /**
  11966. * Event raised when the camera collide with a mesh in the scene.
  11967. */
  11968. onCollide: (collidedMesh: AbstractMesh) => void;
  11969. private _collider;
  11970. private _needMoveForGravity;
  11971. private _oldPosition;
  11972. private _diffPosition;
  11973. private _newPosition;
  11974. /** @hidden */ private _localDirection: Vector3;
  11975. /** @hidden */ private _transformedDirection: Vector3;
  11976. /**
  11977. * Instantiates a Free Camera.
  11978. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11979. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11980. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11981. * @param name Define the name of the camera in the scene
  11982. * @param position Define the start position of the camera in the scene
  11983. * @param scene Define the scene the camera belongs to
  11984. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11985. */
  11986. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11987. /**
  11988. * Attached controls to the current camera.
  11989. * @param element Defines the element the controls should be listened from
  11990. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11991. */
  11992. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11993. /**
  11994. * Detach the current controls from the camera.
  11995. * The camera will stop reacting to inputs.
  11996. * @param element Defines the element to stop listening the inputs from
  11997. */
  11998. detachControl(element: HTMLElement): void;
  11999. private _collisionMask;
  12000. /**
  12001. * Define a collision mask to limit the list of object the camera can collide with
  12002. */
  12003. collisionMask: number;
  12004. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  12005. private _onCollisionPositionChange;
  12006. /** @hidden */ private _checkInputs(): void;
  12007. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  12008. /** @hidden */ private _updatePosition(): void;
  12009. /**
  12010. * Destroy the camera and release the current resources hold by it.
  12011. */
  12012. dispose(): void;
  12013. /**
  12014. * Gets the current object class name.
  12015. * @return the class name
  12016. */
  12017. getClassName(): string;
  12018. }
  12019. }
  12020. declare module BABYLON {
  12021. /**
  12022. * Represents a gamepad control stick position
  12023. */
  12024. export class StickValues {
  12025. /**
  12026. * The x component of the control stick
  12027. */
  12028. x: number;
  12029. /**
  12030. * The y component of the control stick
  12031. */
  12032. y: number;
  12033. /**
  12034. * Initializes the gamepad x and y control stick values
  12035. * @param x The x component of the gamepad control stick value
  12036. * @param y The y component of the gamepad control stick value
  12037. */
  12038. constructor(
  12039. /**
  12040. * The x component of the control stick
  12041. */
  12042. x: number,
  12043. /**
  12044. * The y component of the control stick
  12045. */
  12046. y: number);
  12047. }
  12048. /**
  12049. * An interface which manages callbacks for gamepad button changes
  12050. */
  12051. export interface GamepadButtonChanges {
  12052. /**
  12053. * Called when a gamepad has been changed
  12054. */
  12055. changed: boolean;
  12056. /**
  12057. * Called when a gamepad press event has been triggered
  12058. */
  12059. pressChanged: boolean;
  12060. /**
  12061. * Called when a touch event has been triggered
  12062. */
  12063. touchChanged: boolean;
  12064. /**
  12065. * Called when a value has changed
  12066. */
  12067. valueChanged: boolean;
  12068. }
  12069. /**
  12070. * Represents a gamepad
  12071. */
  12072. export class Gamepad {
  12073. /**
  12074. * The id of the gamepad
  12075. */
  12076. id: string;
  12077. /**
  12078. * The index of the gamepad
  12079. */
  12080. index: number;
  12081. /**
  12082. * The browser gamepad
  12083. */
  12084. browserGamepad: any;
  12085. /**
  12086. * Specifies what type of gamepad this represents
  12087. */
  12088. type: number;
  12089. private _leftStick;
  12090. private _rightStick;
  12091. /** @hidden */ private _isConnected: boolean;
  12092. private _leftStickAxisX;
  12093. private _leftStickAxisY;
  12094. private _rightStickAxisX;
  12095. private _rightStickAxisY;
  12096. /**
  12097. * Triggered when the left control stick has been changed
  12098. */
  12099. private _onleftstickchanged;
  12100. /**
  12101. * Triggered when the right control stick has been changed
  12102. */
  12103. private _onrightstickchanged;
  12104. /**
  12105. * Represents a gamepad controller
  12106. */
  12107. static GAMEPAD: number;
  12108. /**
  12109. * Represents a generic controller
  12110. */
  12111. static GENERIC: number;
  12112. /**
  12113. * Represents an XBox controller
  12114. */
  12115. static XBOX: number;
  12116. /**
  12117. * Represents a pose-enabled controller
  12118. */
  12119. static POSE_ENABLED: number;
  12120. /**
  12121. * Represents an Dual Shock controller
  12122. */
  12123. static DUALSHOCK: number;
  12124. /**
  12125. * Specifies whether the left control stick should be Y-inverted
  12126. */
  12127. protected _invertLeftStickY: boolean;
  12128. /**
  12129. * Specifies if the gamepad has been connected
  12130. */
  12131. readonly isConnected: boolean;
  12132. /**
  12133. * Initializes the gamepad
  12134. * @param id The id of the gamepad
  12135. * @param index The index of the gamepad
  12136. * @param browserGamepad The browser gamepad
  12137. * @param leftStickX The x component of the left joystick
  12138. * @param leftStickY The y component of the left joystick
  12139. * @param rightStickX The x component of the right joystick
  12140. * @param rightStickY The y component of the right joystick
  12141. */
  12142. constructor(
  12143. /**
  12144. * The id of the gamepad
  12145. */
  12146. id: string,
  12147. /**
  12148. * The index of the gamepad
  12149. */
  12150. index: number,
  12151. /**
  12152. * The browser gamepad
  12153. */
  12154. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12155. /**
  12156. * Callback triggered when the left joystick has changed
  12157. * @param callback
  12158. */
  12159. onleftstickchanged(callback: (values: StickValues) => void): void;
  12160. /**
  12161. * Callback triggered when the right joystick has changed
  12162. * @param callback
  12163. */
  12164. onrightstickchanged(callback: (values: StickValues) => void): void;
  12165. /**
  12166. * Gets the left joystick
  12167. */
  12168. /**
  12169. * Sets the left joystick values
  12170. */
  12171. leftStick: StickValues;
  12172. /**
  12173. * Gets the right joystick
  12174. */
  12175. /**
  12176. * Sets the right joystick value
  12177. */
  12178. rightStick: StickValues;
  12179. /**
  12180. * Updates the gamepad joystick positions
  12181. */
  12182. update(): void;
  12183. /**
  12184. * Disposes the gamepad
  12185. */
  12186. dispose(): void;
  12187. }
  12188. /**
  12189. * Represents a generic gamepad
  12190. */
  12191. export class GenericPad extends Gamepad {
  12192. private _buttons;
  12193. private _onbuttondown;
  12194. private _onbuttonup;
  12195. /**
  12196. * Observable triggered when a button has been pressed
  12197. */
  12198. onButtonDownObservable: Observable<number>;
  12199. /**
  12200. * Observable triggered when a button has been released
  12201. */
  12202. onButtonUpObservable: Observable<number>;
  12203. /**
  12204. * Callback triggered when a button has been pressed
  12205. * @param callback Called when a button has been pressed
  12206. */
  12207. onbuttondown(callback: (buttonPressed: number) => void): void;
  12208. /**
  12209. * Callback triggered when a button has been released
  12210. * @param callback Called when a button has been released
  12211. */
  12212. onbuttonup(callback: (buttonReleased: number) => void): void;
  12213. /**
  12214. * Initializes the generic gamepad
  12215. * @param id The id of the generic gamepad
  12216. * @param index The index of the generic gamepad
  12217. * @param browserGamepad The browser gamepad
  12218. */
  12219. constructor(id: string, index: number, browserGamepad: any);
  12220. private _setButtonValue;
  12221. /**
  12222. * Updates the generic gamepad
  12223. */
  12224. update(): void;
  12225. /**
  12226. * Disposes the generic gamepad
  12227. */
  12228. dispose(): void;
  12229. }
  12230. }
  12231. declare module BABYLON {
  12232. interface BaseEngine {
  12233. /**
  12234. * Creates a raw texture
  12235. * @param data defines the data to store in the texture
  12236. * @param width defines the width of the texture
  12237. * @param height defines the height of the texture
  12238. * @param format defines the format of the data
  12239. * @param generateMipMaps defines if the engine should generate the mip levels
  12240. * @param invertY defines if data must be stored with Y axis inverted
  12241. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12242. * @param compression defines the compression used (null by default)
  12243. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12244. * @returns the raw texture inside an InternalTexture
  12245. */
  12246. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12247. /**
  12248. * Update a raw texture
  12249. * @param texture defines the texture to update
  12250. * @param data defines the data to store in the texture
  12251. * @param format defines the format of the data
  12252. * @param invertY defines if data must be stored with Y axis inverted
  12253. */
  12254. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12255. /**
  12256. * Update a raw texture
  12257. * @param texture defines the texture to update
  12258. * @param data defines the data to store in the texture
  12259. * @param format defines the format of the data
  12260. * @param invertY defines if data must be stored with Y axis inverted
  12261. * @param compression defines the compression used (null by default)
  12262. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12263. */
  12264. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12265. /**
  12266. * Creates a new raw cube texture
  12267. * @param data defines the array of data to use to create each face
  12268. * @param size defines the size of the textures
  12269. * @param format defines the format of the data
  12270. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12271. * @param generateMipMaps defines if the engine should generate the mip levels
  12272. * @param invertY defines if data must be stored with Y axis inverted
  12273. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12274. * @param compression defines the compression used (null by default)
  12275. * @returns the cube texture as an InternalTexture
  12276. */
  12277. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12278. /**
  12279. * Update a raw cube texture
  12280. * @param texture defines the texture to udpdate
  12281. * @param data defines the data to store
  12282. * @param format defines the data format
  12283. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12284. * @param invertY defines if data must be stored with Y axis inverted
  12285. */
  12286. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12287. /**
  12288. * Update a raw cube texture
  12289. * @param texture defines the texture to udpdate
  12290. * @param data defines the data to store
  12291. * @param format defines the data format
  12292. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12293. * @param invertY defines if data must be stored with Y axis inverted
  12294. * @param compression defines the compression used (null by default)
  12295. */
  12296. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12297. /**
  12298. * Update a raw cube texture
  12299. * @param texture defines the texture to udpdate
  12300. * @param data defines the data to store
  12301. * @param format defines the data format
  12302. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12303. * @param invertY defines if data must be stored with Y axis inverted
  12304. * @param compression defines the compression used (null by default)
  12305. * @param level defines which level of the texture to update
  12306. */
  12307. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12308. /**
  12309. * Creates a new raw cube texture from a specified url
  12310. * @param url defines the url where the data is located
  12311. * @param scene defines the current scene
  12312. * @param size defines the size of the textures
  12313. * @param format defines the format of the data
  12314. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12315. * @param noMipmap defines if the engine should avoid generating the mip levels
  12316. * @param callback defines a callback used to extract texture data from loaded data
  12317. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12318. * @param onLoad defines a callback called when texture is loaded
  12319. * @param onError defines a callback called if there is an error
  12320. * @returns the cube texture as an InternalTexture
  12321. */
  12322. 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;
  12323. /**
  12324. * Creates a new raw cube texture from a specified url
  12325. * @param url defines the url where the data is located
  12326. * @param scene defines the current scene
  12327. * @param size defines the size of the textures
  12328. * @param format defines the format of the data
  12329. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12330. * @param noMipmap defines if the engine should avoid generating the mip levels
  12331. * @param callback defines a callback used to extract texture data from loaded data
  12332. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12333. * @param onLoad defines a callback called when texture is loaded
  12334. * @param onError defines a callback called if there is an error
  12335. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12336. * @param invertY defines if data must be stored with Y axis inverted
  12337. * @returns the cube texture as an InternalTexture
  12338. */
  12339. 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;
  12340. /**
  12341. * Creates a new raw 3D 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 depth 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 3D texture (stored in an InternalTexture)
  12353. */
  12354. createRawTexture3D(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 3D 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. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12363. /**
  12364. * Update a raw 3D 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. updateRawTexture3D(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. interface Bone {
  13035. /**
  13036. * Copy an animation range from another bone
  13037. * @param source defines the source bone
  13038. * @param rangeName defines the range name to copy
  13039. * @param frameOffset defines the frame offset
  13040. * @param rescaleAsRequired defines if rescaling must be applied if required
  13041. * @param skelDimensionsRatio defines the scaling ratio
  13042. * @returns true if operation was successful
  13043. */
  13044. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13045. }
  13046. }
  13047. declare module BABYLON {
  13048. /**
  13049. * Class used to override all child animations of a given target
  13050. */
  13051. export class AnimationPropertiesOverride {
  13052. /**
  13053. * Gets or sets a value indicating if animation blending must be used
  13054. */
  13055. enableBlending: boolean;
  13056. /**
  13057. * Gets or sets the blending speed to use when enableBlending is true
  13058. */
  13059. blendingSpeed: number;
  13060. /**
  13061. * Gets or sets the default loop mode to use
  13062. */
  13063. loopMode: number;
  13064. }
  13065. }
  13066. declare module BABYLON {
  13067. /**
  13068. * Class used to handle skinning animations
  13069. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13070. */
  13071. export class Skeleton implements IAnimatable {
  13072. /** defines the skeleton name */
  13073. name: string;
  13074. /** defines the skeleton Id */
  13075. id: string;
  13076. /**
  13077. * Defines the list of child bones
  13078. */
  13079. bones: Bone[];
  13080. /**
  13081. * Defines an estimate of the dimension of the skeleton at rest
  13082. */
  13083. dimensionsAtRest: Vector3;
  13084. /**
  13085. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13086. */
  13087. needInitialSkinMatrix: boolean;
  13088. /**
  13089. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13090. */
  13091. overrideMesh: Nullable<AbstractMesh>;
  13092. /**
  13093. * Gets the list of animations attached to this skeleton
  13094. */
  13095. animations: Array<Animation>;
  13096. private _scene;
  13097. private _isDirty;
  13098. private _transformMatrices;
  13099. private _transformMatrixTexture;
  13100. private _meshesWithPoseMatrix;
  13101. private _animatables;
  13102. private _identity;
  13103. private _synchronizedWithMesh;
  13104. private _ranges;
  13105. private _lastAbsoluteTransformsUpdateId;
  13106. private _canUseTextureForBones;
  13107. private _uniqueId;
  13108. /** @hidden */ private _numBonesWithLinkedTransformNode: number;
  13109. /** @hidden */ private _hasWaitingData: Nullable<boolean>;
  13110. /**
  13111. * Specifies if the skeleton should be serialized
  13112. */
  13113. doNotSerialize: boolean;
  13114. private _useTextureToStoreBoneMatrices;
  13115. /**
  13116. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13117. * Please note that this option is not available if the hardware does not support it
  13118. */
  13119. useTextureToStoreBoneMatrices: boolean;
  13120. private _animationPropertiesOverride;
  13121. /**
  13122. * Gets or sets the animation properties override
  13123. */
  13124. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13125. /**
  13126. * List of inspectable custom properties (used by the Inspector)
  13127. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13128. */
  13129. inspectableCustomProperties: IInspectable[];
  13130. /**
  13131. * An observable triggered before computing the skeleton's matrices
  13132. */
  13133. onBeforeComputeObservable: Observable<Skeleton>;
  13134. /**
  13135. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13136. */
  13137. readonly isUsingTextureForMatrices: boolean;
  13138. /**
  13139. * Gets the unique ID of this skeleton
  13140. */
  13141. readonly uniqueId: number;
  13142. /**
  13143. * Creates a new skeleton
  13144. * @param name defines the skeleton name
  13145. * @param id defines the skeleton Id
  13146. * @param scene defines the hosting scene
  13147. */
  13148. constructor(
  13149. /** defines the skeleton name */
  13150. name: string,
  13151. /** defines the skeleton Id */
  13152. id: string, scene: Scene);
  13153. /**
  13154. * Gets the current object class name.
  13155. * @return the class name
  13156. */
  13157. getClassName(): string;
  13158. /**
  13159. * Returns an array containing the root bones
  13160. * @returns an array containing the root bones
  13161. */
  13162. getChildren(): Array<Bone>;
  13163. /**
  13164. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13165. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13166. * @returns a Float32Array containing matrices data
  13167. */
  13168. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13169. /**
  13170. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13171. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13172. * @returns a raw texture containing the data
  13173. */
  13174. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13175. /**
  13176. * Gets the current hosting scene
  13177. * @returns a scene object
  13178. */
  13179. getScene(): Scene;
  13180. /**
  13181. * Gets a string representing the current skeleton data
  13182. * @param fullDetails defines a boolean indicating if we want a verbose version
  13183. * @returns a string representing the current skeleton data
  13184. */
  13185. toString(fullDetails?: boolean): string;
  13186. /**
  13187. * Get bone's index searching by name
  13188. * @param name defines bone's name to search for
  13189. * @return the indice of the bone. Returns -1 if not found
  13190. */
  13191. getBoneIndexByName(name: string): number;
  13192. /**
  13193. * Creater a new animation range
  13194. * @param name defines the name of the range
  13195. * @param from defines the start key
  13196. * @param to defines the end key
  13197. */
  13198. createAnimationRange(name: string, from: number, to: number): void;
  13199. /**
  13200. * Delete a specific animation range
  13201. * @param name defines the name of the range
  13202. * @param deleteFrames defines if frames must be removed as well
  13203. */
  13204. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13205. /**
  13206. * Gets a specific animation range
  13207. * @param name defines the name of the range to look for
  13208. * @returns the requested animation range or null if not found
  13209. */
  13210. getAnimationRange(name: string): Nullable<AnimationRange>;
  13211. /**
  13212. * Gets the list of all animation ranges defined on this skeleton
  13213. * @returns an array
  13214. */
  13215. getAnimationRanges(): Nullable<AnimationRange>[];
  13216. /**
  13217. * Copy animation range from a source skeleton.
  13218. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13219. * @param source defines the source skeleton
  13220. * @param name defines the name of the range to copy
  13221. * @param rescaleAsRequired defines if rescaling must be applied if required
  13222. * @returns true if operation was successful
  13223. */
  13224. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13225. /**
  13226. * Forces the skeleton to go to rest pose
  13227. */
  13228. returnToRest(): void;
  13229. private _getHighestAnimationFrame;
  13230. /**
  13231. * Begin a specific animation range
  13232. * @param name defines the name of the range to start
  13233. * @param loop defines if looping must be turned on (false by default)
  13234. * @param speedRatio defines the speed ratio to apply (1 by default)
  13235. * @param onAnimationEnd defines a callback which will be called when animation will end
  13236. * @returns a new animatable
  13237. */
  13238. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13239. /** @hidden */ private _markAsDirty(): void;
  13240. /** @hidden */ private _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13241. /** @hidden */ private _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13242. private _computeTransformMatrices;
  13243. /**
  13244. * Build all resources required to render a skeleton
  13245. */
  13246. prepare(): void;
  13247. /**
  13248. * Gets the list of animatables currently running for this skeleton
  13249. * @returns an array of animatables
  13250. */
  13251. getAnimatables(): IAnimatable[];
  13252. /**
  13253. * Clone the current skeleton
  13254. * @param name defines the name of the new skeleton
  13255. * @param id defines the id of the new skeleton
  13256. * @returns the new skeleton
  13257. */
  13258. clone(name: string, id: string): Skeleton;
  13259. /**
  13260. * Enable animation blending for this skeleton
  13261. * @param blendingSpeed defines the blending speed to apply
  13262. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13263. */
  13264. enableBlending(blendingSpeed?: number): void;
  13265. /**
  13266. * Releases all resources associated with the current skeleton
  13267. */
  13268. dispose(): void;
  13269. /**
  13270. * Serialize the skeleton in a JSON object
  13271. * @returns a JSON object
  13272. */
  13273. serialize(): any;
  13274. /**
  13275. * Creates a new skeleton from serialized data
  13276. * @param parsedSkeleton defines the serialized data
  13277. * @param scene defines the hosting scene
  13278. * @returns a new skeleton
  13279. */
  13280. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13281. /**
  13282. * Compute all node absolute transforms
  13283. * @param forceUpdate defines if computation must be done even if cache is up to date
  13284. */
  13285. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13286. /**
  13287. * Gets the root pose matrix
  13288. * @returns a matrix
  13289. */
  13290. getPoseMatrix(): Nullable<Matrix>;
  13291. /**
  13292. * Sorts bones per internal index
  13293. */
  13294. sortBones(): void;
  13295. private _sortBones;
  13296. }
  13297. }
  13298. declare module BABYLON {
  13299. /**
  13300. * Class used to store bone information
  13301. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13302. */
  13303. export class Bone extends Node {
  13304. /**
  13305. * defines the bone name
  13306. */
  13307. name: string;
  13308. private static _tmpVecs;
  13309. private static _tmpQuat;
  13310. private static _tmpMats;
  13311. /**
  13312. * Gets the list of child bones
  13313. */
  13314. children: Bone[];
  13315. /** Gets the animations associated with this bone */
  13316. animations: Animation[];
  13317. /**
  13318. * Gets or sets bone length
  13319. */
  13320. length: number;
  13321. /**
  13322. * @hidden Internal only
  13323. * Set this value to map this bone to a different index in the transform matrices
  13324. * Set this value to -1 to exclude the bone from the transform matrices
  13325. */ private _index: Nullable<number>;
  13326. private _skeleton;
  13327. private _localMatrix;
  13328. private _restPose;
  13329. private _baseMatrix;
  13330. private _absoluteTransform;
  13331. private _invertedAbsoluteTransform;
  13332. private _parent;
  13333. private _scalingDeterminant;
  13334. private _worldTransform;
  13335. private _localScaling;
  13336. private _localRotation;
  13337. private _localPosition;
  13338. private _needToDecompose;
  13339. private _needToCompose;
  13340. /** @hidden */ private _linkedTransformNode: Nullable<TransformNode>;
  13341. /** @hidden */ private _waitingTransformNodeId: Nullable<string>;
  13342. /** @hidden */
  13343. /** @hidden */ private _matrix: Matrix;
  13344. /**
  13345. * Create a new bone
  13346. * @param name defines the bone name
  13347. * @param skeleton defines the parent skeleton
  13348. * @param parentBone defines the parent (can be null if the bone is the root)
  13349. * @param localMatrix defines the local matrix
  13350. * @param restPose defines the rest pose matrix
  13351. * @param baseMatrix defines the base matrix
  13352. * @param index defines index of the bone in the hiearchy
  13353. */
  13354. constructor(
  13355. /**
  13356. * defines the bone name
  13357. */
  13358. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13359. /**
  13360. * Gets the current object class name.
  13361. * @return the class name
  13362. */
  13363. getClassName(): string;
  13364. /**
  13365. * Gets the parent skeleton
  13366. * @returns a skeleton
  13367. */
  13368. getSkeleton(): Skeleton;
  13369. /**
  13370. * Gets parent bone
  13371. * @returns a bone or null if the bone is the root of the bone hierarchy
  13372. */
  13373. getParent(): Nullable<Bone>;
  13374. /**
  13375. * Returns an array containing the root bones
  13376. * @returns an array containing the root bones
  13377. */
  13378. getChildren(): Array<Bone>;
  13379. /**
  13380. * Sets the parent bone
  13381. * @param parent defines the parent (can be null if the bone is the root)
  13382. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13383. */
  13384. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13385. /**
  13386. * Gets the local matrix
  13387. * @returns a matrix
  13388. */
  13389. getLocalMatrix(): Matrix;
  13390. /**
  13391. * Gets the base matrix (initial matrix which remains unchanged)
  13392. * @returns a matrix
  13393. */
  13394. getBaseMatrix(): Matrix;
  13395. /**
  13396. * Gets the rest pose matrix
  13397. * @returns a matrix
  13398. */
  13399. getRestPose(): Matrix;
  13400. /**
  13401. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13402. */
  13403. getWorldMatrix(): Matrix;
  13404. /**
  13405. * Sets the local matrix to rest pose matrix
  13406. */
  13407. returnToRest(): void;
  13408. /**
  13409. * Gets the inverse of the absolute transform matrix.
  13410. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13411. * @returns a matrix
  13412. */
  13413. getInvertedAbsoluteTransform(): Matrix;
  13414. /**
  13415. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13416. * @returns a matrix
  13417. */
  13418. getAbsoluteTransform(): Matrix;
  13419. /**
  13420. * Links with the given transform node.
  13421. * The local matrix of this bone is copied from the transform node every frame.
  13422. * @param transformNode defines the transform node to link to
  13423. */
  13424. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13425. /**
  13426. * Gets the node used to drive the bone's transformation
  13427. * @returns a transform node or null
  13428. */
  13429. getTransformNode(): Nullable<TransformNode>;
  13430. /** Gets or sets current position (in local space) */
  13431. position: Vector3;
  13432. /** Gets or sets current rotation (in local space) */
  13433. rotation: Vector3;
  13434. /** Gets or sets current rotation quaternion (in local space) */
  13435. rotationQuaternion: Quaternion;
  13436. /** Gets or sets current scaling (in local space) */
  13437. scaling: Vector3;
  13438. /**
  13439. * Gets the animation properties override
  13440. */
  13441. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13442. private _decompose;
  13443. private _compose;
  13444. /**
  13445. * Update the base and local matrices
  13446. * @param matrix defines the new base or local matrix
  13447. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13448. * @param updateLocalMatrix defines if the local matrix should be updated
  13449. */
  13450. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13451. /** @hidden */ private _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13452. /**
  13453. * Flag the bone as dirty (Forcing it to update everything)
  13454. */
  13455. markAsDirty(): void;
  13456. /** @hidden */ private _markAsDirtyAndCompose(): void;
  13457. private _markAsDirtyAndDecompose;
  13458. /**
  13459. * Translate the bone in local or world space
  13460. * @param vec The amount to translate the bone
  13461. * @param space The space that the translation is in
  13462. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13463. */
  13464. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13465. /**
  13466. * Set the postion of the bone in local or world space
  13467. * @param position The position to set the bone
  13468. * @param space The space that the position is in
  13469. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13470. */
  13471. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13472. /**
  13473. * Set the absolute position of the bone (world space)
  13474. * @param position The position to set the bone
  13475. * @param mesh The mesh that this bone is attached to
  13476. */
  13477. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13478. /**
  13479. * Scale the bone on the x, y and z axes (in local space)
  13480. * @param x The amount to scale the bone on the x axis
  13481. * @param y The amount to scale the bone on the y axis
  13482. * @param z The amount to scale the bone on the z axis
  13483. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13484. */
  13485. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13486. /**
  13487. * Set the bone scaling in local space
  13488. * @param scale defines the scaling vector
  13489. */
  13490. setScale(scale: Vector3): void;
  13491. /**
  13492. * Gets the current scaling in local space
  13493. * @returns the current scaling vector
  13494. */
  13495. getScale(): Vector3;
  13496. /**
  13497. * Gets the current scaling in local space and stores it in a target vector
  13498. * @param result defines the target vector
  13499. */
  13500. getScaleToRef(result: Vector3): void;
  13501. /**
  13502. * Set the yaw, pitch, and roll of the bone in local or world space
  13503. * @param yaw The rotation of the bone on the y axis
  13504. * @param pitch The rotation of the bone on the x axis
  13505. * @param roll The rotation of the bone on the z axis
  13506. * @param space The space that the axes of rotation are in
  13507. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13508. */
  13509. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13510. /**
  13511. * Add a rotation to the bone on an axis in local or world space
  13512. * @param axis The axis to rotate the bone on
  13513. * @param amount The amount to rotate the bone
  13514. * @param space The space that the axis is in
  13515. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13516. */
  13517. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13518. /**
  13519. * Set the rotation of the bone to a particular axis angle in local or world space
  13520. * @param axis The axis to rotate the bone on
  13521. * @param angle The angle that the bone should be rotated to
  13522. * @param space The space that the axis is in
  13523. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13524. */
  13525. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13526. /**
  13527. * Set the euler rotation of the bone in local of world space
  13528. * @param rotation The euler rotation that the bone should be set to
  13529. * @param space The space that the rotation is in
  13530. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13531. */
  13532. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13533. /**
  13534. * Set the quaternion rotation of the bone in local of world space
  13535. * @param quat The quaternion rotation that the bone should be set to
  13536. * @param space The space that the rotation is in
  13537. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13538. */
  13539. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13540. /**
  13541. * Set the rotation matrix of the bone in local of world space
  13542. * @param rotMat The rotation matrix that the bone should be set to
  13543. * @param space The space that the rotation is in
  13544. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13545. */
  13546. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13547. private _rotateWithMatrix;
  13548. private _getNegativeRotationToRef;
  13549. /**
  13550. * Get the position of the bone in local or world space
  13551. * @param space The space that the returned position is in
  13552. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13553. * @returns The position of the bone
  13554. */
  13555. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13556. /**
  13557. * Copy the position of the bone to a vector3 in local or world space
  13558. * @param space The space that the returned position is in
  13559. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13560. * @param result The vector3 to copy the position to
  13561. */
  13562. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13563. /**
  13564. * Get the absolute position of the bone (world space)
  13565. * @param mesh The mesh that this bone is attached to
  13566. * @returns The absolute position of the bone
  13567. */
  13568. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13569. /**
  13570. * Copy the absolute position of the bone (world space) to the result param
  13571. * @param mesh The mesh that this bone is attached to
  13572. * @param result The vector3 to copy the absolute position to
  13573. */
  13574. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13575. /**
  13576. * Compute the absolute transforms of this bone and its children
  13577. */
  13578. computeAbsoluteTransforms(): void;
  13579. /**
  13580. * Get the world direction from an axis that is in the local space of the bone
  13581. * @param localAxis The local direction that is used to compute the world direction
  13582. * @param mesh The mesh that this bone is attached to
  13583. * @returns The world direction
  13584. */
  13585. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13586. /**
  13587. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13588. * @param localAxis The local direction that is used to compute the world direction
  13589. * @param mesh The mesh that this bone is attached to
  13590. * @param result The vector3 that the world direction will be copied to
  13591. */
  13592. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13593. /**
  13594. * Get the euler rotation of the bone in local or world space
  13595. * @param space The space that the rotation should be in
  13596. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13597. * @returns The euler rotation
  13598. */
  13599. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13600. /**
  13601. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13602. * @param space The space that the rotation should be in
  13603. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13604. * @param result The vector3 that the rotation should be copied to
  13605. */
  13606. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13607. /**
  13608. * Get the quaternion rotation of the bone in either local or world space
  13609. * @param space The space that the rotation should be in
  13610. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13611. * @returns The quaternion rotation
  13612. */
  13613. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13614. /**
  13615. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13616. * @param space The space that the rotation should be in
  13617. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13618. * @param result The quaternion that the rotation should be copied to
  13619. */
  13620. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13621. /**
  13622. * Get the rotation matrix of the bone in local or world space
  13623. * @param space The space that the rotation should be in
  13624. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13625. * @returns The rotation matrix
  13626. */
  13627. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13628. /**
  13629. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13630. * @param space The space that the rotation should be in
  13631. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13632. * @param result The quaternion that the rotation should be copied to
  13633. */
  13634. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13635. /**
  13636. * Get the world position of a point that is in the local space of the bone
  13637. * @param position The local position
  13638. * @param mesh The mesh that this bone is attached to
  13639. * @returns The world position
  13640. */
  13641. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13642. /**
  13643. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13644. * @param position The local position
  13645. * @param mesh The mesh that this bone is attached to
  13646. * @param result The vector3 that the world position should be copied to
  13647. */
  13648. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13649. /**
  13650. * Get the local position of a point that is in world space
  13651. * @param position The world position
  13652. * @param mesh The mesh that this bone is attached to
  13653. * @returns The local position
  13654. */
  13655. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13656. /**
  13657. * Get the local position of a point that is in world space and copy it to the result param
  13658. * @param position The world position
  13659. * @param mesh The mesh that this bone is attached to
  13660. * @param result The vector3 that the local position should be copied to
  13661. */
  13662. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13663. }
  13664. }
  13665. declare module BABYLON {
  13666. /**
  13667. * 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.
  13668. * @see https://doc.babylonjs.com/how_to/transformnode
  13669. */
  13670. export class TransformNode extends Node {
  13671. /**
  13672. * Object will not rotate to face the camera
  13673. */
  13674. static BILLBOARDMODE_NONE: number;
  13675. /**
  13676. * Object will rotate to face the camera but only on the x axis
  13677. */
  13678. static BILLBOARDMODE_X: number;
  13679. /**
  13680. * Object will rotate to face the camera but only on the y axis
  13681. */
  13682. static BILLBOARDMODE_Y: number;
  13683. /**
  13684. * Object will rotate to face the camera but only on the z axis
  13685. */
  13686. static BILLBOARDMODE_Z: number;
  13687. /**
  13688. * Object will rotate to face the camera
  13689. */
  13690. static BILLBOARDMODE_ALL: number;
  13691. /**
  13692. * Object will rotate to face the camera's position instead of orientation
  13693. */
  13694. static BILLBOARDMODE_USE_POSITION: number;
  13695. private _forward;
  13696. private _forwardInverted;
  13697. private _up;
  13698. private _right;
  13699. private _rightInverted;
  13700. private _position;
  13701. private _rotation;
  13702. private _rotationQuaternion;
  13703. protected _scaling: Vector3;
  13704. protected _isDirty: boolean;
  13705. private _transformToBoneReferal;
  13706. private _isAbsoluteSynced;
  13707. private _billboardMode;
  13708. /**
  13709. * Gets or sets the billboard mode. Default is 0.
  13710. *
  13711. * | Value | Type | Description |
  13712. * | --- | --- | --- |
  13713. * | 0 | BILLBOARDMODE_NONE | |
  13714. * | 1 | BILLBOARDMODE_X | |
  13715. * | 2 | BILLBOARDMODE_Y | |
  13716. * | 4 | BILLBOARDMODE_Z | |
  13717. * | 7 | BILLBOARDMODE_ALL | |
  13718. *
  13719. */
  13720. billboardMode: number;
  13721. private _preserveParentRotationForBillboard;
  13722. /**
  13723. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13724. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13725. */
  13726. preserveParentRotationForBillboard: boolean;
  13727. /**
  13728. * 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
  13729. */
  13730. scalingDeterminant: number;
  13731. private _infiniteDistance;
  13732. /**
  13733. * Gets or sets the distance of the object to max, often used by skybox
  13734. */
  13735. infiniteDistance: boolean;
  13736. /**
  13737. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13738. * By default the system will update normals to compensate
  13739. */
  13740. ignoreNonUniformScaling: boolean;
  13741. /**
  13742. * 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
  13743. */
  13744. reIntegrateRotationIntoRotationQuaternion: boolean;
  13745. /** @hidden */ private _poseMatrix: Nullable<Matrix>;
  13746. /** @hidden */ private _localMatrix: Matrix;
  13747. private _usePivotMatrix;
  13748. private _absolutePosition;
  13749. private _absoluteScaling;
  13750. private _absoluteRotationQuaternion;
  13751. private _pivotMatrix;
  13752. private _pivotMatrixInverse;
  13753. protected _postMultiplyPivotMatrix: boolean;
  13754. protected _isWorldMatrixFrozen: boolean;
  13755. /** @hidden */ private _indexInSceneTransformNodesArray: number;
  13756. /**
  13757. * An event triggered after the world matrix is updated
  13758. */
  13759. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13760. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13761. /**
  13762. * Gets a string identifying the name of the class
  13763. * @returns "TransformNode" string
  13764. */
  13765. getClassName(): string;
  13766. /**
  13767. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13768. */
  13769. position: Vector3;
  13770. /**
  13771. * 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)).
  13772. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13773. */
  13774. rotation: Vector3;
  13775. /**
  13776. * 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)).
  13777. */
  13778. scaling: Vector3;
  13779. /**
  13780. * 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).
  13781. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13782. */
  13783. rotationQuaternion: Nullable<Quaternion>;
  13784. /**
  13785. * The forward direction of that transform in world space.
  13786. */
  13787. readonly forward: Vector3;
  13788. /**
  13789. * The up direction of that transform in world space.
  13790. */
  13791. readonly up: Vector3;
  13792. /**
  13793. * The right direction of that transform in world space.
  13794. */
  13795. readonly right: Vector3;
  13796. /**
  13797. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13798. * @param matrix the matrix to copy the pose from
  13799. * @returns this TransformNode.
  13800. */
  13801. updatePoseMatrix(matrix: Matrix): TransformNode;
  13802. /**
  13803. * Returns the mesh Pose matrix.
  13804. * @returns the pose matrix
  13805. */
  13806. getPoseMatrix(): Matrix;
  13807. /** @hidden */ private _isSynchronized(): boolean;
  13808. /** @hidden */ private _initCache(): void;
  13809. /**
  13810. * Flag the transform node as dirty (Forcing it to update everything)
  13811. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13812. * @returns this transform node
  13813. */
  13814. markAsDirty(property: string): TransformNode;
  13815. /**
  13816. * Returns the current mesh absolute position.
  13817. * Returns a Vector3.
  13818. */
  13819. readonly absolutePosition: Vector3;
  13820. /**
  13821. * Returns the current mesh absolute scaling.
  13822. * Returns a Vector3.
  13823. */
  13824. readonly absoluteScaling: Vector3;
  13825. /**
  13826. * Returns the current mesh absolute rotation.
  13827. * Returns a Quaternion.
  13828. */
  13829. readonly absoluteRotationQuaternion: Quaternion;
  13830. /**
  13831. * Sets a new matrix to apply before all other transformation
  13832. * @param matrix defines the transform matrix
  13833. * @returns the current TransformNode
  13834. */
  13835. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13836. /**
  13837. * Sets a new pivot matrix to the current node
  13838. * @param matrix defines the new pivot matrix to use
  13839. * @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
  13840. * @returns the current TransformNode
  13841. */
  13842. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13843. /**
  13844. * Returns the mesh pivot matrix.
  13845. * Default : Identity.
  13846. * @returns the matrix
  13847. */
  13848. getPivotMatrix(): Matrix;
  13849. /**
  13850. * Instantiate (when possible) or clone that node with its hierarchy
  13851. * @param newParent defines the new parent to use for the instance (or clone)
  13852. * @returns an instance (or a clone) of the current node with its hiearchy
  13853. */
  13854. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13855. /**
  13856. * Prevents the World matrix to be computed any longer
  13857. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13858. * @returns the TransformNode.
  13859. */
  13860. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13861. /**
  13862. * Allows back the World matrix computation.
  13863. * @returns the TransformNode.
  13864. */
  13865. unfreezeWorldMatrix(): this;
  13866. /**
  13867. * True if the World matrix has been frozen.
  13868. */
  13869. readonly isWorldMatrixFrozen: boolean;
  13870. /**
  13871. * Retuns the mesh absolute position in the World.
  13872. * @returns a Vector3.
  13873. */
  13874. getAbsolutePosition(): Vector3;
  13875. /**
  13876. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13877. * @param absolutePosition the absolute position to set
  13878. * @returns the TransformNode.
  13879. */
  13880. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13881. /**
  13882. * Sets the mesh position in its local space.
  13883. * @param vector3 the position to set in localspace
  13884. * @returns the TransformNode.
  13885. */
  13886. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13887. /**
  13888. * Returns the mesh position in the local space from the current World matrix values.
  13889. * @returns a new Vector3.
  13890. */
  13891. getPositionExpressedInLocalSpace(): Vector3;
  13892. /**
  13893. * Translates the mesh along the passed Vector3 in its local space.
  13894. * @param vector3 the distance to translate in localspace
  13895. * @returns the TransformNode.
  13896. */
  13897. locallyTranslate(vector3: Vector3): TransformNode;
  13898. private static _lookAtVectorCache;
  13899. /**
  13900. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13901. * @param targetPoint the position (must be in same space as current mesh) to look at
  13902. * @param yawCor optional yaw (y-axis) correction in radians
  13903. * @param pitchCor optional pitch (x-axis) correction in radians
  13904. * @param rollCor optional roll (z-axis) correction in radians
  13905. * @param space the choosen space of the target
  13906. * @returns the TransformNode.
  13907. */
  13908. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13909. /**
  13910. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13911. * This Vector3 is expressed in the World space.
  13912. * @param localAxis axis to rotate
  13913. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13914. */
  13915. getDirection(localAxis: Vector3): Vector3;
  13916. /**
  13917. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13918. * localAxis is expressed in the mesh local space.
  13919. * result is computed in the Wordl space from the mesh World matrix.
  13920. * @param localAxis axis to rotate
  13921. * @param result the resulting transformnode
  13922. * @returns this TransformNode.
  13923. */
  13924. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13925. /**
  13926. * Sets this transform node rotation to the given local axis.
  13927. * @param localAxis the axis in local space
  13928. * @param yawCor optional yaw (y-axis) correction in radians
  13929. * @param pitchCor optional pitch (x-axis) correction in radians
  13930. * @param rollCor optional roll (z-axis) correction in radians
  13931. * @returns this TransformNode
  13932. */
  13933. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13934. /**
  13935. * Sets a new pivot point to the current node
  13936. * @param point defines the new pivot point to use
  13937. * @param space defines if the point is in world or local space (local by default)
  13938. * @returns the current TransformNode
  13939. */
  13940. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13941. /**
  13942. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13943. * @returns the pivot point
  13944. */
  13945. getPivotPoint(): Vector3;
  13946. /**
  13947. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13948. * @param result the vector3 to store the result
  13949. * @returns this TransformNode.
  13950. */
  13951. getPivotPointToRef(result: Vector3): TransformNode;
  13952. /**
  13953. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13954. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13955. */
  13956. getAbsolutePivotPoint(): Vector3;
  13957. /**
  13958. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13959. * @param result vector3 to store the result
  13960. * @returns this TransformNode.
  13961. */
  13962. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13963. /**
  13964. * Defines the passed node as the parent of the current node.
  13965. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13966. * @see https://doc.babylonjs.com/how_to/parenting
  13967. * @param node the node ot set as the parent
  13968. * @returns this TransformNode.
  13969. */
  13970. setParent(node: Nullable<Node>): TransformNode;
  13971. private _nonUniformScaling;
  13972. /**
  13973. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13974. */
  13975. readonly nonUniformScaling: boolean;
  13976. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  13977. /**
  13978. * Attach the current TransformNode to another TransformNode associated with a bone
  13979. * @param bone Bone affecting the TransformNode
  13980. * @param affectedTransformNode TransformNode associated with the bone
  13981. * @returns this object
  13982. */
  13983. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13984. /**
  13985. * Detach the transform node if its associated with a bone
  13986. * @returns this object
  13987. */
  13988. detachFromBone(): TransformNode;
  13989. private static _rotationAxisCache;
  13990. /**
  13991. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13992. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13993. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13994. * The passed axis is also normalized.
  13995. * @param axis the axis to rotate around
  13996. * @param amount the amount to rotate in radians
  13997. * @param space Space to rotate in (Default: local)
  13998. * @returns the TransformNode.
  13999. */
  14000. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14001. /**
  14002. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14003. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14004. * The passed axis is also normalized. .
  14005. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14006. * @param point the point to rotate around
  14007. * @param axis the axis to rotate around
  14008. * @param amount the amount to rotate in radians
  14009. * @returns the TransformNode
  14010. */
  14011. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14012. /**
  14013. * Translates the mesh along the axis vector for the passed distance in the given space.
  14014. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14015. * @param axis the axis to translate in
  14016. * @param distance the distance to translate
  14017. * @param space Space to rotate in (Default: local)
  14018. * @returns the TransformNode.
  14019. */
  14020. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14021. /**
  14022. * Adds a rotation step to the mesh current rotation.
  14023. * x, y, z are Euler angles expressed in radians.
  14024. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14025. * This means this rotation is made in the mesh local space only.
  14026. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14027. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14028. * ```javascript
  14029. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14030. * ```
  14031. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14032. * 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.
  14033. * @param x Rotation to add
  14034. * @param y Rotation to add
  14035. * @param z Rotation to add
  14036. * @returns the TransformNode.
  14037. */
  14038. addRotation(x: number, y: number, z: number): TransformNode;
  14039. /**
  14040. * @hidden
  14041. */
  14042. protected _getEffectiveParent(): Nullable<Node>;
  14043. /**
  14044. * Computes the world matrix of the node
  14045. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14046. * @returns the world matrix
  14047. */
  14048. computeWorldMatrix(force?: boolean): Matrix;
  14049. protected _afterComputeWorldMatrix(): void;
  14050. /**
  14051. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14052. * @param func callback function to add
  14053. *
  14054. * @returns the TransformNode.
  14055. */
  14056. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14057. /**
  14058. * Removes a registered callback function.
  14059. * @param func callback function to remove
  14060. * @returns the TransformNode.
  14061. */
  14062. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14063. /**
  14064. * Gets the position of the current mesh in camera space
  14065. * @param camera defines the camera to use
  14066. * @returns a position
  14067. */
  14068. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14069. /**
  14070. * Returns the distance from the mesh to the active camera
  14071. * @param camera defines the camera to use
  14072. * @returns the distance
  14073. */
  14074. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14075. /**
  14076. * Clone the current transform node
  14077. * @param name Name of the new clone
  14078. * @param newParent New parent for the clone
  14079. * @param doNotCloneChildren Do not clone children hierarchy
  14080. * @returns the new transform node
  14081. */
  14082. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14083. /**
  14084. * Serializes the objects information.
  14085. * @param currentSerializationObject defines the object to serialize in
  14086. * @returns the serialized object
  14087. */
  14088. serialize(currentSerializationObject?: any): any;
  14089. /**
  14090. * Returns a new TransformNode object parsed from the source provided.
  14091. * @param parsedTransformNode is the source.
  14092. * @param scene the scne the object belongs to
  14093. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14094. * @returns a new TransformNode object parsed from the source provided.
  14095. */
  14096. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14097. /**
  14098. * Get all child-transformNodes of this node
  14099. * @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
  14100. * @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
  14101. * @returns an array of TransformNode
  14102. */
  14103. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14104. /**
  14105. * Releases resources associated with this transform node.
  14106. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14107. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14108. */
  14109. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14110. /**
  14111. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14112. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14113. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14114. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14115. * @returns the current mesh
  14116. */
  14117. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14118. private _syncAbsoluteScalingAndRotation;
  14119. }
  14120. }
  14121. declare module BABYLON {
  14122. /**
  14123. * Defines the types of pose enabled controllers that are supported
  14124. */
  14125. export enum PoseEnabledControllerType {
  14126. /**
  14127. * HTC Vive
  14128. */
  14129. VIVE = 0,
  14130. /**
  14131. * Oculus Rift
  14132. */
  14133. OCULUS = 1,
  14134. /**
  14135. * Windows mixed reality
  14136. */
  14137. WINDOWS = 2,
  14138. /**
  14139. * Samsung gear VR
  14140. */
  14141. GEAR_VR = 3,
  14142. /**
  14143. * Google Daydream
  14144. */
  14145. DAYDREAM = 4,
  14146. /**
  14147. * Generic
  14148. */
  14149. GENERIC = 5
  14150. }
  14151. /**
  14152. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14153. */
  14154. export interface MutableGamepadButton {
  14155. /**
  14156. * Value of the button/trigger
  14157. */
  14158. value: number;
  14159. /**
  14160. * If the button/trigger is currently touched
  14161. */
  14162. touched: boolean;
  14163. /**
  14164. * If the button/trigger is currently pressed
  14165. */
  14166. pressed: boolean;
  14167. }
  14168. /**
  14169. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14170. * @hidden
  14171. */
  14172. export interface ExtendedGamepadButton extends GamepadButton {
  14173. /**
  14174. * If the button/trigger is currently pressed
  14175. */
  14176. readonly pressed: boolean;
  14177. /**
  14178. * If the button/trigger is currently touched
  14179. */
  14180. readonly touched: boolean;
  14181. /**
  14182. * Value of the button/trigger
  14183. */
  14184. readonly value: number;
  14185. }
  14186. /** @hidden */
  14187. export interface _GamePadFactory {
  14188. /**
  14189. * Returns wether or not the current gamepad can be created for this type of controller.
  14190. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14191. * @returns true if it can be created, otherwise false
  14192. */
  14193. canCreate(gamepadInfo: any): boolean;
  14194. /**
  14195. * Creates a new instance of the Gamepad.
  14196. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14197. * @returns the new gamepad instance
  14198. */
  14199. create(gamepadInfo: any): Gamepad;
  14200. }
  14201. /**
  14202. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14203. */
  14204. export class PoseEnabledControllerHelper {
  14205. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  14206. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14207. /**
  14208. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14209. * @param vrGamepad the gamepad to initialized
  14210. * @returns a vr controller of the type the gamepad identified as
  14211. */
  14212. static InitiateController(vrGamepad: any): Gamepad;
  14213. }
  14214. /**
  14215. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14216. */
  14217. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14218. /**
  14219. * If the controller is used in a webXR session
  14220. */
  14221. isXR: boolean;
  14222. private _deviceRoomPosition;
  14223. private _deviceRoomRotationQuaternion;
  14224. /**
  14225. * The device position in babylon space
  14226. */
  14227. devicePosition: Vector3;
  14228. /**
  14229. * The device rotation in babylon space
  14230. */
  14231. deviceRotationQuaternion: Quaternion;
  14232. /**
  14233. * The scale factor of the device in babylon space
  14234. */
  14235. deviceScaleFactor: number;
  14236. /**
  14237. * (Likely devicePosition should be used instead) The device position in its room space
  14238. */
  14239. position: Vector3;
  14240. /**
  14241. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14242. */
  14243. rotationQuaternion: Quaternion;
  14244. /**
  14245. * The type of controller (Eg. Windows mixed reality)
  14246. */
  14247. controllerType: PoseEnabledControllerType;
  14248. protected _calculatedPosition: Vector3;
  14249. private _calculatedRotation;
  14250. /**
  14251. * The raw pose from the device
  14252. */
  14253. rawPose: DevicePose;
  14254. private _trackPosition;
  14255. private _maxRotationDistFromHeadset;
  14256. private _draggedRoomRotation;
  14257. /**
  14258. * @hidden
  14259. */ private _disableTrackPosition(fixedPosition: Vector3): void;
  14260. /**
  14261. * Internal, the mesh attached to the controller
  14262. * @hidden
  14263. */ private _mesh: Nullable<AbstractMesh>;
  14264. private _poseControlledCamera;
  14265. private _leftHandSystemQuaternion;
  14266. /**
  14267. * Internal, matrix used to convert room space to babylon space
  14268. * @hidden
  14269. */ private _deviceToWorld: Matrix;
  14270. /**
  14271. * Node to be used when casting a ray from the controller
  14272. * @hidden
  14273. */ private _pointingPoseNode: Nullable<TransformNode>;
  14274. /**
  14275. * Name of the child mesh that can be used to cast a ray from the controller
  14276. */
  14277. static readonly POINTING_POSE: string;
  14278. /**
  14279. * Creates a new PoseEnabledController from a gamepad
  14280. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14281. */
  14282. constructor(browserGamepad: any);
  14283. private _workingMatrix;
  14284. /**
  14285. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14286. */
  14287. update(): void;
  14288. /**
  14289. * Updates only the pose device and mesh without doing any button event checking
  14290. */
  14291. protected _updatePoseAndMesh(): void;
  14292. /**
  14293. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14294. * @param poseData raw pose fromthe device
  14295. */
  14296. updateFromDevice(poseData: DevicePose): void;
  14297. /**
  14298. * @hidden
  14299. */ private _meshAttachedObservable: Observable<AbstractMesh>;
  14300. /**
  14301. * Attaches a mesh to the controller
  14302. * @param mesh the mesh to be attached
  14303. */
  14304. attachToMesh(mesh: AbstractMesh): void;
  14305. /**
  14306. * Attaches the controllers mesh to a camera
  14307. * @param camera the camera the mesh should be attached to
  14308. */
  14309. attachToPoseControlledCamera(camera: TargetCamera): void;
  14310. /**
  14311. * Disposes of the controller
  14312. */
  14313. dispose(): void;
  14314. /**
  14315. * The mesh that is attached to the controller
  14316. */
  14317. readonly mesh: Nullable<AbstractMesh>;
  14318. /**
  14319. * Gets the ray of the controller in the direction the controller is pointing
  14320. * @param length the length the resulting ray should be
  14321. * @returns a ray in the direction the controller is pointing
  14322. */
  14323. getForwardRay(length?: number): Ray;
  14324. }
  14325. }
  14326. declare module BABYLON {
  14327. /**
  14328. * Defines the WebVRController object that represents controllers tracked in 3D space
  14329. */
  14330. export abstract class WebVRController extends PoseEnabledController {
  14331. /**
  14332. * Internal, the default controller model for the controller
  14333. */
  14334. protected _defaultModel: Nullable<AbstractMesh>;
  14335. /**
  14336. * Fired when the trigger state has changed
  14337. */
  14338. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14339. /**
  14340. * Fired when the main button state has changed
  14341. */
  14342. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14343. /**
  14344. * Fired when the secondary button state has changed
  14345. */
  14346. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14347. /**
  14348. * Fired when the pad state has changed
  14349. */
  14350. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14351. /**
  14352. * Fired when controllers stick values have changed
  14353. */
  14354. onPadValuesChangedObservable: Observable<StickValues>;
  14355. /**
  14356. * Array of button availible on the controller
  14357. */
  14358. protected _buttons: Array<MutableGamepadButton>;
  14359. private _onButtonStateChange;
  14360. /**
  14361. * Fired when a controller button's state has changed
  14362. * @param callback the callback containing the button that was modified
  14363. */
  14364. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14365. /**
  14366. * X and Y axis corresponding to the controllers joystick
  14367. */
  14368. pad: StickValues;
  14369. /**
  14370. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14371. */
  14372. hand: string;
  14373. /**
  14374. * The default controller model for the controller
  14375. */
  14376. readonly defaultModel: Nullable<AbstractMesh>;
  14377. /**
  14378. * Creates a new WebVRController from a gamepad
  14379. * @param vrGamepad the gamepad that the WebVRController should be created from
  14380. */
  14381. constructor(vrGamepad: any);
  14382. /**
  14383. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14384. */
  14385. update(): void;
  14386. /**
  14387. * Function to be called when a button is modified
  14388. */
  14389. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14390. /**
  14391. * Loads a mesh and attaches it to the controller
  14392. * @param scene the scene the mesh should be added to
  14393. * @param meshLoaded callback for when the mesh has been loaded
  14394. */
  14395. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14396. private _setButtonValue;
  14397. private _changes;
  14398. private _checkChanges;
  14399. /**
  14400. * Disposes of th webVRCOntroller
  14401. */
  14402. dispose(): void;
  14403. }
  14404. }
  14405. declare module BABYLON {
  14406. /**
  14407. * The HemisphericLight simulates the ambient environment light,
  14408. * so the passed direction is the light reflection direction, not the incoming direction.
  14409. */
  14410. export class HemisphericLight extends Light {
  14411. /**
  14412. * The groundColor is the light in the opposite direction to the one specified during creation.
  14413. * 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.
  14414. */
  14415. groundColor: Color3;
  14416. /**
  14417. * The light reflection direction, not the incoming direction.
  14418. */
  14419. direction: Vector3;
  14420. /**
  14421. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14422. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14423. * The HemisphericLight can't cast shadows.
  14424. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14425. * @param name The friendly name of the light
  14426. * @param direction The direction of the light reflection
  14427. * @param scene The scene the light belongs to
  14428. */
  14429. constructor(name: string, direction: Vector3, scene: Scene);
  14430. protected _buildUniformLayout(): void;
  14431. /**
  14432. * Returns the string "HemisphericLight".
  14433. * @return The class name
  14434. */
  14435. getClassName(): string;
  14436. /**
  14437. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14438. * Returns the updated direction.
  14439. * @param target The target the direction should point to
  14440. * @return The computed direction
  14441. */
  14442. setDirectionToTarget(target: Vector3): Vector3;
  14443. /**
  14444. * Returns the shadow generator associated to the light.
  14445. * @returns Always null for hemispheric lights because it does not support shadows.
  14446. */
  14447. getShadowGenerator(): Nullable<IShadowGenerator>;
  14448. /**
  14449. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14450. * @param effect The effect to update
  14451. * @param lightIndex The index of the light in the effect to update
  14452. * @returns The hemispheric light
  14453. */
  14454. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14455. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14456. /**
  14457. * Computes the world matrix of the node
  14458. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14459. * @param useWasUpdatedFlag defines a reserved property
  14460. * @returns the world matrix
  14461. */
  14462. computeWorldMatrix(): Matrix;
  14463. /**
  14464. * Returns the integer 3.
  14465. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14466. */
  14467. getTypeID(): number;
  14468. /**
  14469. * Prepares the list of defines specific to the light type.
  14470. * @param defines the list of defines
  14471. * @param lightIndex defines the index of the light for the effect
  14472. */
  14473. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14474. }
  14475. }
  14476. declare module BABYLON {
  14477. /** @hidden */
  14478. export var vrMultiviewToSingleviewPixelShader: {
  14479. name: string;
  14480. shader: string;
  14481. };
  14482. }
  14483. declare module BABYLON {
  14484. /**
  14485. * Renders to multiple views with a single draw call
  14486. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14487. */
  14488. export class MultiviewRenderTarget extends RenderTargetTexture {
  14489. /**
  14490. * Creates a multiview render target
  14491. * @param scene scene used with the render target
  14492. * @param size the size of the render target (used for each view)
  14493. */
  14494. constructor(scene: Scene, size?: number | {
  14495. width: number;
  14496. height: number;
  14497. } | {
  14498. ratio: number;
  14499. });
  14500. /**
  14501. * @hidden
  14502. * @param faceIndex the face index, if its a cube texture
  14503. */ private _bindFrameBuffer(faceIndex?: number): void;
  14504. /**
  14505. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14506. * @returns the view count
  14507. */
  14508. getViewCount(): number;
  14509. }
  14510. }
  14511. declare module BABYLON {
  14512. /**
  14513. * Represents a camera frustum
  14514. */
  14515. export class Frustum {
  14516. /**
  14517. * Gets the planes representing the frustum
  14518. * @param transform matrix to be applied to the returned planes
  14519. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14520. */
  14521. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14522. /**
  14523. * Gets the near frustum plane transformed by the transform matrix
  14524. * @param transform transformation matrix to be applied to the resulting frustum plane
  14525. * @param frustumPlane the resuling frustum plane
  14526. */
  14527. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14528. /**
  14529. * Gets the far frustum plane transformed by the transform matrix
  14530. * @param transform transformation matrix to be applied to the resulting frustum plane
  14531. * @param frustumPlane the resuling frustum plane
  14532. */
  14533. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14534. /**
  14535. * Gets the left frustum plane transformed by the transform matrix
  14536. * @param transform transformation matrix to be applied to the resulting frustum plane
  14537. * @param frustumPlane the resuling frustum plane
  14538. */
  14539. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14540. /**
  14541. * Gets the right frustum plane transformed by the transform matrix
  14542. * @param transform transformation matrix to be applied to the resulting frustum plane
  14543. * @param frustumPlane the resuling frustum plane
  14544. */
  14545. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14546. /**
  14547. * Gets the top frustum plane transformed by the transform matrix
  14548. * @param transform transformation matrix to be applied to the resulting frustum plane
  14549. * @param frustumPlane the resuling frustum plane
  14550. */
  14551. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14552. /**
  14553. * Gets the bottom frustum plane transformed by the transform matrix
  14554. * @param transform transformation matrix to be applied to the resulting frustum plane
  14555. * @param frustumPlane the resuling frustum plane
  14556. */
  14557. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14558. /**
  14559. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14560. * @param transform transformation matrix to be applied to the resulting frustum planes
  14561. * @param frustumPlanes the resuling frustum planes
  14562. */
  14563. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14564. }
  14565. }
  14566. declare module BABYLON {
  14567. interface Engine {
  14568. /**
  14569. * Creates a new multiview render target
  14570. * @param width defines the width of the texture
  14571. * @param height defines the height of the texture
  14572. * @returns the created multiview texture
  14573. */
  14574. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14575. /**
  14576. * Binds a multiview framebuffer to be drawn to
  14577. * @param multiviewTexture texture to bind
  14578. */
  14579. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14580. }
  14581. interface Camera {
  14582. /**
  14583. * @hidden
  14584. * 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)
  14585. */ private _useMultiviewToSingleView: boolean;
  14586. /**
  14587. * @hidden
  14588. * 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)
  14589. */ private _multiviewTexture: Nullable<RenderTargetTexture>;
  14590. /**
  14591. * @hidden
  14592. * ensures the multiview texture of the camera exists and has the specified width/height
  14593. * @param width height to set on the multiview texture
  14594. * @param height width to set on the multiview texture
  14595. */ private _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14596. }
  14597. interface Scene {
  14598. /** @hidden */ private _transformMatrixR: Matrix;
  14599. /** @hidden */ private _multiviewSceneUbo: Nullable<UniformBuffer>;
  14600. /** @hidden */ private _createMultiviewUbo(): void;
  14601. /** @hidden */ private _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14602. /** @hidden */ private _renderMultiviewToSingleView(camera: Camera): void;
  14603. }
  14604. }
  14605. declare module BABYLON {
  14606. /**
  14607. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14608. * This will not be used for webXR as it supports displaying texture arrays directly
  14609. */
  14610. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14611. /**
  14612. * Initializes a VRMultiviewToSingleview
  14613. * @param name name of the post process
  14614. * @param camera camera to be applied to
  14615. * @param scaleFactor scaling factor to the size of the output texture
  14616. */
  14617. constructor(name: string, camera: Camera, scaleFactor: number);
  14618. }
  14619. }
  14620. declare module BABYLON {
  14621. interface Engine {
  14622. /** @hidden */ private _vrDisplay: any;
  14623. /** @hidden */ private _vrSupported: boolean;
  14624. /** @hidden */ private _oldSize: Size;
  14625. /** @hidden */ private _oldHardwareScaleFactor: number;
  14626. /** @hidden */ private _vrExclusivePointerMode: boolean;
  14627. /** @hidden */ private _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14628. /** @hidden */ private _onVRDisplayPointerRestricted: () => void;
  14629. /** @hidden */ private _onVRDisplayPointerUnrestricted: () => void;
  14630. /** @hidden */ private _onVrDisplayConnect: Nullable<(display: any) => void>;
  14631. /** @hidden */ private _onVrDisplayDisconnect: Nullable<() => void>;
  14632. /** @hidden */ private _onVrDisplayPresentChange: Nullable<() => void>;
  14633. /**
  14634. * Observable signaled when VR display mode changes
  14635. */
  14636. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14637. /**
  14638. * Observable signaled when VR request present is complete
  14639. */
  14640. onVRRequestPresentComplete: Observable<boolean>;
  14641. /**
  14642. * Observable signaled when VR request present starts
  14643. */
  14644. onVRRequestPresentStart: Observable<Engine>;
  14645. /**
  14646. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14647. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14648. */
  14649. isInVRExclusivePointerMode: boolean;
  14650. /**
  14651. * Gets a boolean indicating if a webVR device was detected
  14652. * @returns true if a webVR device was detected
  14653. */
  14654. isVRDevicePresent(): boolean;
  14655. /**
  14656. * Gets the current webVR device
  14657. * @returns the current webVR device (or null)
  14658. */
  14659. getVRDevice(): any;
  14660. /**
  14661. * Initializes a webVR display and starts listening to display change events
  14662. * The onVRDisplayChangedObservable will be notified upon these changes
  14663. * @returns A promise containing a VRDisplay and if vr is supported
  14664. */
  14665. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14666. /** @hidden */ private _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14667. /**
  14668. * Call this function to switch to webVR mode
  14669. * Will do nothing if webVR is not supported or if there is no webVR device
  14670. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14671. */
  14672. enableVR(): void;
  14673. /** @hidden */ private _onVRFullScreenTriggered(): void;
  14674. }
  14675. }
  14676. declare module BABYLON {
  14677. /**
  14678. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14679. * IMPORTANT!! The data is right-hand data.
  14680. * @export
  14681. * @interface DevicePose
  14682. */
  14683. export interface DevicePose {
  14684. /**
  14685. * The position of the device, values in array are [x,y,z].
  14686. */
  14687. readonly position: Nullable<Float32Array>;
  14688. /**
  14689. * The linearVelocity of the device, values in array are [x,y,z].
  14690. */
  14691. readonly linearVelocity: Nullable<Float32Array>;
  14692. /**
  14693. * The linearAcceleration of the device, values in array are [x,y,z].
  14694. */
  14695. readonly linearAcceleration: Nullable<Float32Array>;
  14696. /**
  14697. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14698. */
  14699. readonly orientation: Nullable<Float32Array>;
  14700. /**
  14701. * The angularVelocity of the device, values in array are [x,y,z].
  14702. */
  14703. readonly angularVelocity: Nullable<Float32Array>;
  14704. /**
  14705. * The angularAcceleration of the device, values in array are [x,y,z].
  14706. */
  14707. readonly angularAcceleration: Nullable<Float32Array>;
  14708. }
  14709. /**
  14710. * Interface representing a pose controlled object in Babylon.
  14711. * A pose controlled object has both regular pose values as well as pose values
  14712. * from an external device such as a VR head mounted display
  14713. */
  14714. export interface PoseControlled {
  14715. /**
  14716. * The position of the object in babylon space.
  14717. */
  14718. position: Vector3;
  14719. /**
  14720. * The rotation quaternion of the object in babylon space.
  14721. */
  14722. rotationQuaternion: Quaternion;
  14723. /**
  14724. * The position of the device in babylon space.
  14725. */
  14726. devicePosition?: Vector3;
  14727. /**
  14728. * The rotation quaternion of the device in babylon space.
  14729. */
  14730. deviceRotationQuaternion: Quaternion;
  14731. /**
  14732. * The raw pose coming from the device.
  14733. */
  14734. rawPose: Nullable<DevicePose>;
  14735. /**
  14736. * The scale of the device to be used when translating from device space to babylon space.
  14737. */
  14738. deviceScaleFactor: number;
  14739. /**
  14740. * Updates the poseControlled values based on the input device pose.
  14741. * @param poseData the pose data to update the object with
  14742. */
  14743. updateFromDevice(poseData: DevicePose): void;
  14744. }
  14745. /**
  14746. * Set of options to customize the webVRCamera
  14747. */
  14748. export interface WebVROptions {
  14749. /**
  14750. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14751. */
  14752. trackPosition?: boolean;
  14753. /**
  14754. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14755. */
  14756. positionScale?: number;
  14757. /**
  14758. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14759. */
  14760. displayName?: string;
  14761. /**
  14762. * Should the native controller meshes be initialized. (default: true)
  14763. */
  14764. controllerMeshes?: boolean;
  14765. /**
  14766. * Creating a default HemiLight only on controllers. (default: true)
  14767. */
  14768. defaultLightingOnControllers?: boolean;
  14769. /**
  14770. * If you don't want to use the default VR button of the helper. (default: false)
  14771. */
  14772. useCustomVRButton?: boolean;
  14773. /**
  14774. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14775. */
  14776. customVRButton?: HTMLButtonElement;
  14777. /**
  14778. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14779. */
  14780. rayLength?: number;
  14781. /**
  14782. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14783. */
  14784. defaultHeight?: number;
  14785. /**
  14786. * If multiview should be used if availible (default: false)
  14787. */
  14788. useMultiview?: boolean;
  14789. }
  14790. /**
  14791. * This represents a WebVR camera.
  14792. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14793. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14794. */
  14795. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14796. private webVROptions;
  14797. /**
  14798. * @hidden
  14799. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14800. */ private _vrDevice: any;
  14801. /**
  14802. * The rawPose of the vrDevice.
  14803. */
  14804. rawPose: Nullable<DevicePose>;
  14805. private _onVREnabled;
  14806. private _specsVersion;
  14807. private _attached;
  14808. private _frameData;
  14809. protected _descendants: Array<Node>;
  14810. private _deviceRoomPosition;
  14811. /** @hidden */ private _deviceRoomRotationQuaternion: Quaternion;
  14812. private _standingMatrix;
  14813. /**
  14814. * Represents device position in babylon space.
  14815. */
  14816. devicePosition: Vector3;
  14817. /**
  14818. * Represents device rotation in babylon space.
  14819. */
  14820. deviceRotationQuaternion: Quaternion;
  14821. /**
  14822. * The scale of the device to be used when translating from device space to babylon space.
  14823. */
  14824. deviceScaleFactor: number;
  14825. private _deviceToWorld;
  14826. private _worldToDevice;
  14827. /**
  14828. * References to the webVR controllers for the vrDevice.
  14829. */
  14830. controllers: Array<WebVRController>;
  14831. /**
  14832. * Emits an event when a controller is attached.
  14833. */
  14834. onControllersAttachedObservable: Observable<WebVRController[]>;
  14835. /**
  14836. * Emits an event when a controller's mesh has been loaded;
  14837. */
  14838. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14839. /**
  14840. * Emits an event when the HMD's pose has been updated.
  14841. */
  14842. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14843. private _poseSet;
  14844. /**
  14845. * If the rig cameras be used as parent instead of this camera.
  14846. */
  14847. rigParenting: boolean;
  14848. private _lightOnControllers;
  14849. private _defaultHeight?;
  14850. /**
  14851. * Instantiates a WebVRFreeCamera.
  14852. * @param name The name of the WebVRFreeCamera
  14853. * @param position The starting anchor position for the camera
  14854. * @param scene The scene the camera belongs to
  14855. * @param webVROptions a set of customizable options for the webVRCamera
  14856. */
  14857. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14858. /**
  14859. * Gets the device distance from the ground in meters.
  14860. * @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.
  14861. */
  14862. deviceDistanceToRoomGround(): number;
  14863. /**
  14864. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14865. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14866. */
  14867. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14868. /**
  14869. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14870. * @returns A promise with a boolean set to if the standing matrix is supported.
  14871. */
  14872. useStandingMatrixAsync(): Promise<boolean>;
  14873. /**
  14874. * Disposes the camera
  14875. */
  14876. dispose(): void;
  14877. /**
  14878. * Gets a vrController by name.
  14879. * @param name The name of the controller to retreive
  14880. * @returns the controller matching the name specified or null if not found
  14881. */
  14882. getControllerByName(name: string): Nullable<WebVRController>;
  14883. private _leftController;
  14884. /**
  14885. * The controller corresponding to the users left hand.
  14886. */
  14887. readonly leftController: Nullable<WebVRController>;
  14888. private _rightController;
  14889. /**
  14890. * The controller corresponding to the users right hand.
  14891. */
  14892. readonly rightController: Nullable<WebVRController>;
  14893. /**
  14894. * Casts a ray forward from the vrCamera's gaze.
  14895. * @param length Length of the ray (default: 100)
  14896. * @returns the ray corresponding to the gaze
  14897. */
  14898. getForwardRay(length?: number): Ray;
  14899. /**
  14900. * @hidden
  14901. * Updates the camera based on device's frame data
  14902. */ private _checkInputs(): void;
  14903. /**
  14904. * Updates the poseControlled values based on the input device pose.
  14905. * @param poseData Pose coming from the device
  14906. */
  14907. updateFromDevice(poseData: DevicePose): void;
  14908. private _htmlElementAttached;
  14909. private _detachIfAttached;
  14910. /**
  14911. * WebVR's attach control will start broadcasting frames to the device.
  14912. * Note that in certain browsers (chrome for example) this function must be called
  14913. * within a user-interaction callback. Example:
  14914. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14915. *
  14916. * @param element html element to attach the vrDevice to
  14917. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14918. */
  14919. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14920. /**
  14921. * Detaches the camera from the html element and disables VR
  14922. *
  14923. * @param element html element to detach from
  14924. */
  14925. detachControl(element: HTMLElement): void;
  14926. /**
  14927. * @returns the name of this class
  14928. */
  14929. getClassName(): string;
  14930. /**
  14931. * Calls resetPose on the vrDisplay
  14932. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14933. */
  14934. resetToCurrentRotation(): void;
  14935. /**
  14936. * @hidden
  14937. * Updates the rig cameras (left and right eye)
  14938. */ private _updateRigCameras(): void;
  14939. private _workingVector;
  14940. private _oneVector;
  14941. private _workingMatrix;
  14942. private updateCacheCalled;
  14943. private _correctPositionIfNotTrackPosition;
  14944. /**
  14945. * @hidden
  14946. * Updates the cached values of the camera
  14947. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  14948. */ private _updateCache(ignoreParentClass?: boolean): void;
  14949. /**
  14950. * @hidden
  14951. * Get current device position in babylon world
  14952. */ private _computeDevicePosition(): void;
  14953. /**
  14954. * Updates the current device position and rotation in the babylon world
  14955. */
  14956. update(): void;
  14957. /**
  14958. * @hidden
  14959. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  14960. * @returns an identity matrix
  14961. */ private _getViewMatrix(): Matrix;
  14962. private _tmpMatrix;
  14963. /**
  14964. * This function is called by the two RIG cameras.
  14965. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  14966. * @hidden
  14967. */ private _getWebVRViewMatrix(): Matrix;
  14968. /** @hidden */ private _getWebVRProjectionMatrix(): Matrix;
  14969. private _onGamepadConnectedObserver;
  14970. private _onGamepadDisconnectedObserver;
  14971. private _updateCacheWhenTrackingDisabledObserver;
  14972. /**
  14973. * Initializes the controllers and their meshes
  14974. */
  14975. initControllers(): void;
  14976. }
  14977. }
  14978. declare module BABYLON {
  14979. /**
  14980. * Size options for a post process
  14981. */
  14982. export type PostProcessOptions = {
  14983. width: number;
  14984. height: number;
  14985. };
  14986. /**
  14987. * PostProcess can be used to apply a shader to a texture after it has been rendered
  14988. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14989. */
  14990. export class PostProcess {
  14991. /** Name of the PostProcess. */
  14992. name: string;
  14993. /**
  14994. * Gets or sets the unique id of the post process
  14995. */
  14996. uniqueId: number;
  14997. /**
  14998. * Width of the texture to apply the post process on
  14999. */
  15000. width: number;
  15001. /**
  15002. * Height of the texture to apply the post process on
  15003. */
  15004. height: number;
  15005. /**
  15006. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15007. * @hidden
  15008. */ private _outputTexture: Nullable<InternalTexture>;
  15009. /**
  15010. * Sampling mode used by the shader
  15011. * See https://doc.babylonjs.com/classes/3.1/texture
  15012. */
  15013. renderTargetSamplingMode: number;
  15014. /**
  15015. * Clear color to use when screen clearing
  15016. */
  15017. clearColor: Color4;
  15018. /**
  15019. * If the buffer needs to be cleared before applying the post process. (default: true)
  15020. * Should be set to false if shader will overwrite all previous pixels.
  15021. */
  15022. autoClear: boolean;
  15023. /**
  15024. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15025. */
  15026. alphaMode: number;
  15027. /**
  15028. * Sets the setAlphaBlendConstants of the babylon engine
  15029. */
  15030. alphaConstants: Color4;
  15031. /**
  15032. * Animations to be used for the post processing
  15033. */
  15034. animations: Animation[];
  15035. /**
  15036. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15037. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15038. */
  15039. enablePixelPerfectMode: boolean;
  15040. /**
  15041. * Force the postprocess to be applied without taking in account viewport
  15042. */
  15043. forceFullscreenViewport: boolean;
  15044. /**
  15045. * List of inspectable custom properties (used by the Inspector)
  15046. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15047. */
  15048. inspectableCustomProperties: IInspectable[];
  15049. /**
  15050. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15051. *
  15052. * | Value | Type | Description |
  15053. * | ----- | ----------------------------------- | ----------- |
  15054. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15055. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15056. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15057. *
  15058. */
  15059. scaleMode: number;
  15060. /**
  15061. * Force textures to be a power of two (default: false)
  15062. */
  15063. alwaysForcePOT: boolean;
  15064. private _samples;
  15065. /**
  15066. * Number of sample textures (default: 1)
  15067. */
  15068. samples: number;
  15069. /**
  15070. * Modify the scale of the post process to be the same as the viewport (default: false)
  15071. */
  15072. adaptScaleToCurrentViewport: boolean;
  15073. private _camera;
  15074. private _scene;
  15075. private _engine;
  15076. private _options;
  15077. private _reusable;
  15078. private _textureType;
  15079. /**
  15080. * Smart array of input and output textures for the post process.
  15081. * @hidden
  15082. */ private _textures: SmartArray<InternalTexture>;
  15083. /**
  15084. * The index in _textures that corresponds to the output texture.
  15085. * @hidden
  15086. */ private _currentRenderTextureInd: number;
  15087. private _effect;
  15088. private _samplers;
  15089. private _fragmentUrl;
  15090. private _vertexUrl;
  15091. private _parameters;
  15092. private _scaleRatio;
  15093. protected _indexParameters: any;
  15094. private _shareOutputWithPostProcess;
  15095. private _texelSize;
  15096. private _forcedOutputTexture;
  15097. /**
  15098. * Returns the fragment url or shader name used in the post process.
  15099. * @returns the fragment url or name in the shader store.
  15100. */
  15101. getEffectName(): string;
  15102. /**
  15103. * An event triggered when the postprocess is activated.
  15104. */
  15105. onActivateObservable: Observable<Camera>;
  15106. private _onActivateObserver;
  15107. /**
  15108. * A function that is added to the onActivateObservable
  15109. */
  15110. onActivate: Nullable<(camera: Camera) => void>;
  15111. /**
  15112. * An event triggered when the postprocess changes its size.
  15113. */
  15114. onSizeChangedObservable: Observable<PostProcess>;
  15115. private _onSizeChangedObserver;
  15116. /**
  15117. * A function that is added to the onSizeChangedObservable
  15118. */
  15119. onSizeChanged: (postProcess: PostProcess) => void;
  15120. /**
  15121. * An event triggered when the postprocess applies its effect.
  15122. */
  15123. onApplyObservable: Observable<Effect>;
  15124. private _onApplyObserver;
  15125. /**
  15126. * A function that is added to the onApplyObservable
  15127. */
  15128. onApply: (effect: Effect) => void;
  15129. /**
  15130. * An event triggered before rendering the postprocess
  15131. */
  15132. onBeforeRenderObservable: Observable<Effect>;
  15133. private _onBeforeRenderObserver;
  15134. /**
  15135. * A function that is added to the onBeforeRenderObservable
  15136. */
  15137. onBeforeRender: (effect: Effect) => void;
  15138. /**
  15139. * An event triggered after rendering the postprocess
  15140. */
  15141. onAfterRenderObservable: Observable<Effect>;
  15142. private _onAfterRenderObserver;
  15143. /**
  15144. * A function that is added to the onAfterRenderObservable
  15145. */
  15146. onAfterRender: (efect: Effect) => void;
  15147. /**
  15148. * 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
  15149. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15150. */
  15151. inputTexture: InternalTexture;
  15152. /**
  15153. * Gets the camera which post process is applied to.
  15154. * @returns The camera the post process is applied to.
  15155. */
  15156. getCamera(): Camera;
  15157. /**
  15158. * Gets the texel size of the postprocess.
  15159. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15160. */
  15161. readonly texelSize: Vector2;
  15162. /**
  15163. * Creates a new instance PostProcess
  15164. * @param name The name of the PostProcess.
  15165. * @param fragmentUrl The url of the fragment shader to be used.
  15166. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15167. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15168. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15169. * @param camera The camera to apply the render pass to.
  15170. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15171. * @param engine The engine which the post process will be applied. (default: current engine)
  15172. * @param reusable If the post process can be reused on the same frame. (default: false)
  15173. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15174. * @param textureType Type of textures used when performing the post process. (default: 0)
  15175. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15176. * @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
  15177. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15178. */
  15179. constructor(
  15180. /** Name of the PostProcess. */
  15181. 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);
  15182. /**
  15183. * Gets a string idenfifying the name of the class
  15184. * @returns "PostProcess" string
  15185. */
  15186. getClassName(): string;
  15187. /**
  15188. * Gets the engine which this post process belongs to.
  15189. * @returns The engine the post process was enabled with.
  15190. */
  15191. getEngine(): Engine;
  15192. /**
  15193. * The effect that is created when initializing the post process.
  15194. * @returns The created effect corresponding the the postprocess.
  15195. */
  15196. getEffect(): Effect;
  15197. /**
  15198. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15199. * @param postProcess The post process to share the output with.
  15200. * @returns This post process.
  15201. */
  15202. shareOutputWith(postProcess: PostProcess): PostProcess;
  15203. /**
  15204. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15205. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15206. */
  15207. useOwnOutput(): void;
  15208. /**
  15209. * Updates the effect with the current post process compile time values and recompiles the shader.
  15210. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15211. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15212. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15213. * @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
  15214. * @param onCompiled Called when the shader has been compiled.
  15215. * @param onError Called if there is an error when compiling a shader.
  15216. */
  15217. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15218. /**
  15219. * The post process is reusable if it can be used multiple times within one frame.
  15220. * @returns If the post process is reusable
  15221. */
  15222. isReusable(): boolean;
  15223. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15224. markTextureDirty(): void;
  15225. /**
  15226. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15227. * 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.
  15228. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15229. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15230. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15231. * @returns The target texture that was bound to be written to.
  15232. */
  15233. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15234. /**
  15235. * If the post process is supported.
  15236. */
  15237. readonly isSupported: boolean;
  15238. /**
  15239. * The aspect ratio of the output texture.
  15240. */
  15241. readonly aspectRatio: number;
  15242. /**
  15243. * Get a value indicating if the post-process is ready to be used
  15244. * @returns true if the post-process is ready (shader is compiled)
  15245. */
  15246. isReady(): boolean;
  15247. /**
  15248. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15249. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15250. */
  15251. apply(): Nullable<Effect>;
  15252. private _disposeTextures;
  15253. /**
  15254. * Disposes the post process.
  15255. * @param camera The camera to dispose the post process on.
  15256. */
  15257. dispose(camera?: Camera): void;
  15258. }
  15259. }
  15260. declare module BABYLON {
  15261. /** @hidden */
  15262. export var kernelBlurVaryingDeclaration: {
  15263. name: string;
  15264. shader: string;
  15265. };
  15266. }
  15267. declare module BABYLON {
  15268. /** @hidden */
  15269. export var kernelBlurFragment: {
  15270. name: string;
  15271. shader: string;
  15272. };
  15273. }
  15274. declare module BABYLON {
  15275. /** @hidden */
  15276. export var kernelBlurFragment2: {
  15277. name: string;
  15278. shader: string;
  15279. };
  15280. }
  15281. declare module BABYLON {
  15282. /** @hidden */
  15283. export var kernelBlurPixelShader: {
  15284. name: string;
  15285. shader: string;
  15286. };
  15287. }
  15288. declare module BABYLON {
  15289. /** @hidden */
  15290. export var kernelBlurVertex: {
  15291. name: string;
  15292. shader: string;
  15293. };
  15294. }
  15295. declare module BABYLON {
  15296. /** @hidden */
  15297. export var kernelBlurVertexShader: {
  15298. name: string;
  15299. shader: string;
  15300. };
  15301. }
  15302. declare module BABYLON {
  15303. /**
  15304. * The Blur Post Process which blurs an image based on a kernel and direction.
  15305. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15306. */
  15307. export class BlurPostProcess extends PostProcess {
  15308. /** The direction in which to blur the image. */
  15309. direction: Vector2;
  15310. private blockCompilation;
  15311. protected _kernel: number;
  15312. protected _idealKernel: number;
  15313. protected _packedFloat: boolean;
  15314. private _staticDefines;
  15315. /**
  15316. * Sets the length in pixels of the blur sample region
  15317. */
  15318. /**
  15319. * Gets the length in pixels of the blur sample region
  15320. */
  15321. kernel: number;
  15322. /**
  15323. * Sets wether or not the blur needs to unpack/repack floats
  15324. */
  15325. /**
  15326. * Gets wether or not the blur is unpacking/repacking floats
  15327. */
  15328. packedFloat: boolean;
  15329. /**
  15330. * Creates a new instance BlurPostProcess
  15331. * @param name The name of the effect.
  15332. * @param direction The direction in which to blur the image.
  15333. * @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.
  15334. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15335. * @param camera The camera to apply the render pass to.
  15336. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15337. * @param engine The engine which the post process will be applied. (default: current engine)
  15338. * @param reusable If the post process can be reused on the same frame. (default: false)
  15339. * @param textureType Type of textures used when performing the post process. (default: 0)
  15340. * @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)
  15341. */
  15342. constructor(name: string,
  15343. /** The direction in which to blur the image. */
  15344. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15345. /**
  15346. * Updates the effect with the current post process compile time values and recompiles the shader.
  15347. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15348. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15349. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15350. * @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
  15351. * @param onCompiled Called when the shader has been compiled.
  15352. * @param onError Called if there is an error when compiling a shader.
  15353. */
  15354. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15355. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15356. /**
  15357. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15358. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15359. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15360. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15361. * The gaps between physical kernels are compensated for in the weighting of the samples
  15362. * @param idealKernel Ideal blur kernel.
  15363. * @return Nearest best kernel.
  15364. */
  15365. protected _nearestBestKernel(idealKernel: number): number;
  15366. /**
  15367. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15368. * @param x The point on the Gaussian distribution to sample.
  15369. * @return the value of the Gaussian function at x.
  15370. */
  15371. protected _gaussianWeight(x: number): number;
  15372. /**
  15373. * Generates a string that can be used as a floating point number in GLSL.
  15374. * @param x Value to print.
  15375. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15376. * @return GLSL float string.
  15377. */
  15378. protected _glslFloat(x: number, decimalFigures?: number): string;
  15379. }
  15380. }
  15381. declare module BABYLON {
  15382. /**
  15383. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15384. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15385. * You can then easily use it as a reflectionTexture on a flat surface.
  15386. * In case the surface is not a plane, please consider relying on reflection probes.
  15387. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15388. */
  15389. export class MirrorTexture extends RenderTargetTexture {
  15390. private scene;
  15391. /**
  15392. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15393. * 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.
  15394. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15395. */
  15396. mirrorPlane: Plane;
  15397. /**
  15398. * Define the blur ratio used to blur the reflection if needed.
  15399. */
  15400. blurRatio: number;
  15401. /**
  15402. * Define the adaptive blur kernel used to blur the reflection if needed.
  15403. * This will autocompute the closest best match for the `blurKernel`
  15404. */
  15405. adaptiveBlurKernel: number;
  15406. /**
  15407. * Define the blur kernel used to blur the reflection if needed.
  15408. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15409. */
  15410. blurKernel: number;
  15411. /**
  15412. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15413. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15414. */
  15415. blurKernelX: number;
  15416. /**
  15417. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15418. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15419. */
  15420. blurKernelY: number;
  15421. private _autoComputeBlurKernel;
  15422. protected _onRatioRescale(): void;
  15423. private _updateGammaSpace;
  15424. private _imageProcessingConfigChangeObserver;
  15425. private _transformMatrix;
  15426. private _mirrorMatrix;
  15427. private _savedViewMatrix;
  15428. private _blurX;
  15429. private _blurY;
  15430. private _adaptiveBlurKernel;
  15431. private _blurKernelX;
  15432. private _blurKernelY;
  15433. private _blurRatio;
  15434. /**
  15435. * Instantiates a Mirror Texture.
  15436. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15437. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15438. * You can then easily use it as a reflectionTexture on a flat surface.
  15439. * In case the surface is not a plane, please consider relying on reflection probes.
  15440. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15441. * @param name
  15442. * @param size
  15443. * @param scene
  15444. * @param generateMipMaps
  15445. * @param type
  15446. * @param samplingMode
  15447. * @param generateDepthBuffer
  15448. */
  15449. constructor(name: string, size: number | {
  15450. width: number;
  15451. height: number;
  15452. } | {
  15453. ratio: number;
  15454. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15455. private _preparePostProcesses;
  15456. /**
  15457. * Clone the mirror texture.
  15458. * @returns the cloned texture
  15459. */
  15460. clone(): MirrorTexture;
  15461. /**
  15462. * Serialize the texture to a JSON representation you could use in Parse later on
  15463. * @returns the serialized JSON representation
  15464. */
  15465. serialize(): any;
  15466. /**
  15467. * Dispose the texture and release its associated resources.
  15468. */
  15469. dispose(): void;
  15470. }
  15471. }
  15472. declare module BABYLON {
  15473. /**
  15474. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15475. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15476. */
  15477. export class Texture extends BaseTexture {
  15478. /**
  15479. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15480. */
  15481. static SerializeBuffers: boolean;
  15482. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15483. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15484. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15485. /** nearest is mag = nearest and min = nearest and mip = linear */
  15486. static readonly NEAREST_SAMPLINGMODE: number;
  15487. /** nearest is mag = nearest and min = nearest and mip = linear */
  15488. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15489. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15490. static readonly BILINEAR_SAMPLINGMODE: number;
  15491. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15492. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15493. /** Trilinear is mag = linear and min = linear and mip = linear */
  15494. static readonly TRILINEAR_SAMPLINGMODE: number;
  15495. /** Trilinear is mag = linear and min = linear and mip = linear */
  15496. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15497. /** mag = nearest and min = nearest and mip = nearest */
  15498. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15499. /** mag = nearest and min = linear and mip = nearest */
  15500. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15501. /** mag = nearest and min = linear and mip = linear */
  15502. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15503. /** mag = nearest and min = linear and mip = none */
  15504. static readonly NEAREST_LINEAR: number;
  15505. /** mag = nearest and min = nearest and mip = none */
  15506. static readonly NEAREST_NEAREST: number;
  15507. /** mag = linear and min = nearest and mip = nearest */
  15508. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15509. /** mag = linear and min = nearest and mip = linear */
  15510. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15511. /** mag = linear and min = linear and mip = none */
  15512. static readonly LINEAR_LINEAR: number;
  15513. /** mag = linear and min = nearest and mip = none */
  15514. static readonly LINEAR_NEAREST: number;
  15515. /** Explicit coordinates mode */
  15516. static readonly EXPLICIT_MODE: number;
  15517. /** Spherical coordinates mode */
  15518. static readonly SPHERICAL_MODE: number;
  15519. /** Planar coordinates mode */
  15520. static readonly PLANAR_MODE: number;
  15521. /** Cubic coordinates mode */
  15522. static readonly CUBIC_MODE: number;
  15523. /** Projection coordinates mode */
  15524. static readonly PROJECTION_MODE: number;
  15525. /** Inverse Cubic coordinates mode */
  15526. static readonly SKYBOX_MODE: number;
  15527. /** Inverse Cubic coordinates mode */
  15528. static readonly INVCUBIC_MODE: number;
  15529. /** Equirectangular coordinates mode */
  15530. static readonly EQUIRECTANGULAR_MODE: number;
  15531. /** Equirectangular Fixed coordinates mode */
  15532. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15533. /** Equirectangular Fixed Mirrored coordinates mode */
  15534. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15535. /** Texture is not repeating outside of 0..1 UVs */
  15536. static readonly CLAMP_ADDRESSMODE: number;
  15537. /** Texture is repeating outside of 0..1 UVs */
  15538. static readonly WRAP_ADDRESSMODE: number;
  15539. /** Texture is repeating and mirrored */
  15540. static readonly MIRROR_ADDRESSMODE: number;
  15541. /**
  15542. * 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
  15543. */
  15544. static UseSerializedUrlIfAny: boolean;
  15545. /**
  15546. * Define the url of the texture.
  15547. */
  15548. url: Nullable<string>;
  15549. /**
  15550. * Define an offset on the texture to offset the u coordinates of the UVs
  15551. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15552. */
  15553. uOffset: number;
  15554. /**
  15555. * Define an offset on the texture to offset the v coordinates of the UVs
  15556. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15557. */
  15558. vOffset: number;
  15559. /**
  15560. * Define an offset on the texture to scale the u coordinates of the UVs
  15561. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15562. */
  15563. uScale: number;
  15564. /**
  15565. * Define an offset on the texture to scale the v coordinates of the UVs
  15566. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15567. */
  15568. vScale: number;
  15569. /**
  15570. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15571. * @see http://doc.babylonjs.com/how_to/more_materials
  15572. */
  15573. uAng: number;
  15574. /**
  15575. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15576. * @see http://doc.babylonjs.com/how_to/more_materials
  15577. */
  15578. vAng: number;
  15579. /**
  15580. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15581. * @see http://doc.babylonjs.com/how_to/more_materials
  15582. */
  15583. wAng: number;
  15584. /**
  15585. * Defines the center of rotation (U)
  15586. */
  15587. uRotationCenter: number;
  15588. /**
  15589. * Defines the center of rotation (V)
  15590. */
  15591. vRotationCenter: number;
  15592. /**
  15593. * Defines the center of rotation (W)
  15594. */
  15595. wRotationCenter: number;
  15596. /**
  15597. * Are mip maps generated for this texture or not.
  15598. */
  15599. readonly noMipmap: boolean;
  15600. /**
  15601. * List of inspectable custom properties (used by the Inspector)
  15602. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15603. */
  15604. inspectableCustomProperties: Nullable<IInspectable[]>;
  15605. private _noMipmap;
  15606. /** @hidden */ private _invertY: boolean;
  15607. private _rowGenerationMatrix;
  15608. private _cachedTextureMatrix;
  15609. private _projectionModeMatrix;
  15610. private _t0;
  15611. private _t1;
  15612. private _t2;
  15613. private _cachedUOffset;
  15614. private _cachedVOffset;
  15615. private _cachedUScale;
  15616. private _cachedVScale;
  15617. private _cachedUAng;
  15618. private _cachedVAng;
  15619. private _cachedWAng;
  15620. private _cachedProjectionMatrixId;
  15621. private _cachedCoordinatesMode;
  15622. /** @hidden */
  15623. protected _initialSamplingMode: number;
  15624. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  15625. private _deleteBuffer;
  15626. protected _format: Nullable<number>;
  15627. private _delayedOnLoad;
  15628. private _delayedOnError;
  15629. /**
  15630. * Observable triggered once the texture has been loaded.
  15631. */
  15632. onLoadObservable: Observable<Texture>;
  15633. protected _isBlocking: boolean;
  15634. /**
  15635. * Is the texture preventing material to render while loading.
  15636. * If false, a default texture will be used instead of the loading one during the preparation step.
  15637. */
  15638. isBlocking: boolean;
  15639. /**
  15640. * Get the current sampling mode associated with the texture.
  15641. */
  15642. readonly samplingMode: number;
  15643. /**
  15644. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15645. */
  15646. readonly invertY: boolean;
  15647. /**
  15648. * Instantiates a new texture.
  15649. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15650. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15651. * @param url define the url of the picture to load as a texture
  15652. * @param scene define the scene or engine the texture will belong to
  15653. * @param noMipmap define if the texture will require mip maps or not
  15654. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15655. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15656. * @param onLoad define a callback triggered when the texture has been loaded
  15657. * @param onError define a callback triggered when an error occurred during the loading session
  15658. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15659. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15660. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15661. */
  15662. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15663. /**
  15664. * Update the url (and optional buffer) of this texture if url was null during construction.
  15665. * @param url the url of the texture
  15666. * @param buffer the buffer of the texture (defaults to null)
  15667. * @param onLoad callback called when the texture is loaded (defaults to null)
  15668. */
  15669. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15670. /**
  15671. * Finish the loading sequence of a texture flagged as delayed load.
  15672. * @hidden
  15673. */
  15674. delayLoad(): void;
  15675. private _prepareRowForTextureGeneration;
  15676. /**
  15677. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15678. * @returns the transform matrix of the texture.
  15679. */
  15680. getTextureMatrix(): Matrix;
  15681. /**
  15682. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15683. * @returns The reflection texture transform
  15684. */
  15685. getReflectionTextureMatrix(): Matrix;
  15686. /**
  15687. * Clones the texture.
  15688. * @returns the cloned texture
  15689. */
  15690. clone(): Texture;
  15691. /**
  15692. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15693. * @returns The JSON representation of the texture
  15694. */
  15695. serialize(): any;
  15696. /**
  15697. * Get the current class name of the texture useful for serialization or dynamic coding.
  15698. * @returns "Texture"
  15699. */
  15700. getClassName(): string;
  15701. /**
  15702. * Dispose the texture and release its associated resources.
  15703. */
  15704. dispose(): void;
  15705. /**
  15706. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15707. * @param parsedTexture Define the JSON representation of the texture
  15708. * @param scene Define the scene the parsed texture should be instantiated in
  15709. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15710. * @returns The parsed texture if successful
  15711. */
  15712. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15713. /**
  15714. * Creates a texture from its base 64 representation.
  15715. * @param data Define the base64 payload without the data: prefix
  15716. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15717. * @param scene Define the scene the texture should belong to
  15718. * @param noMipmap Forces the texture to not create mip map information if true
  15719. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15720. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15721. * @param onLoad define a callback triggered when the texture has been loaded
  15722. * @param onError define a callback triggered when an error occurred during the loading session
  15723. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15724. * @returns the created texture
  15725. */
  15726. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15727. /**
  15728. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15729. * @param data Define the base64 payload without the data: prefix
  15730. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15731. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15732. * @param scene Define the scene the texture should belong to
  15733. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15734. * @param noMipmap Forces the texture to not create mip map information if true
  15735. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15736. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15737. * @param onLoad define a callback triggered when the texture has been loaded
  15738. * @param onError define a callback triggered when an error occurred during the loading session
  15739. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15740. * @returns the created texture
  15741. */
  15742. 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;
  15743. }
  15744. }
  15745. declare module BABYLON {
  15746. /**
  15747. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15748. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15749. */
  15750. export class PostProcessManager {
  15751. private _scene;
  15752. private _indexBuffer;
  15753. private _vertexBuffers;
  15754. /**
  15755. * Creates a new instance PostProcess
  15756. * @param scene The scene that the post process is associated with.
  15757. */
  15758. constructor(scene: Scene);
  15759. private _prepareBuffers;
  15760. private _buildIndexBuffer;
  15761. /**
  15762. * Rebuilds the vertex buffers of the manager.
  15763. * @hidden
  15764. */ private _rebuild(): void;
  15765. /**
  15766. * Prepares a frame to be run through a post process.
  15767. * @param sourceTexture The input texture to the post procesess. (default: null)
  15768. * @param postProcesses An array of post processes to be run. (default: null)
  15769. * @returns True if the post processes were able to be run.
  15770. * @hidden
  15771. */ private _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15772. /**
  15773. * Manually render a set of post processes to a texture.
  15774. * @param postProcesses An array of post processes to be run.
  15775. * @param targetTexture The target texture to render to.
  15776. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15777. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15778. * @param lodLevel defines which lod of the texture to render to
  15779. */
  15780. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15781. /**
  15782. * Finalize the result of the output of the postprocesses.
  15783. * @param doNotPresent If true the result will not be displayed to the screen.
  15784. * @param targetTexture The target texture to render to.
  15785. * @param faceIndex The index of the face to bind the target texture to.
  15786. * @param postProcesses The array of post processes to render.
  15787. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15788. * @hidden
  15789. */ private _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15790. /**
  15791. * Disposes of the post process manager.
  15792. */
  15793. dispose(): void;
  15794. }
  15795. }
  15796. declare module BABYLON {
  15797. /** Interface used by value gradients (color, factor, ...) */
  15798. export interface IValueGradient {
  15799. /**
  15800. * Gets or sets the gradient value (between 0 and 1)
  15801. */
  15802. gradient: number;
  15803. }
  15804. /** Class used to store color4 gradient */
  15805. export class ColorGradient implements IValueGradient {
  15806. /**
  15807. * Gets or sets the gradient value (between 0 and 1)
  15808. */
  15809. gradient: number;
  15810. /**
  15811. * Gets or sets first associated color
  15812. */
  15813. color1: Color4;
  15814. /**
  15815. * Gets or sets second associated color
  15816. */
  15817. color2?: Color4;
  15818. /**
  15819. * Will get a color picked randomly between color1 and color2.
  15820. * If color2 is undefined then color1 will be used
  15821. * @param result defines the target Color4 to store the result in
  15822. */
  15823. getColorToRef(result: Color4): void;
  15824. }
  15825. /** Class used to store color 3 gradient */
  15826. export class Color3Gradient implements IValueGradient {
  15827. /**
  15828. * Gets or sets the gradient value (between 0 and 1)
  15829. */
  15830. gradient: number;
  15831. /**
  15832. * Gets or sets the associated color
  15833. */
  15834. color: Color3;
  15835. }
  15836. /** Class used to store factor gradient */
  15837. export class FactorGradient 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 factor
  15844. */
  15845. factor1: number;
  15846. /**
  15847. * Gets or sets second associated factor
  15848. */
  15849. factor2?: number;
  15850. /**
  15851. * Will get a number picked randomly between factor1 and factor2.
  15852. * If factor2 is undefined then factor1 will be used
  15853. * @returns the picked number
  15854. */
  15855. getFactor(): number;
  15856. }
  15857. /**
  15858. * Helper used to simplify some generic gradient tasks
  15859. */
  15860. export class GradientHelper {
  15861. /**
  15862. * Gets the current gradient from an array of IValueGradient
  15863. * @param ratio defines the current ratio to get
  15864. * @param gradients defines the array of IValueGradient
  15865. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15866. */
  15867. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15868. }
  15869. }
  15870. declare module BABYLON {
  15871. /**
  15872. * A class extending Texture allowing drawing on a texture
  15873. * @see http://doc.babylonjs.com/how_to/dynamictexture
  15874. */
  15875. export class DynamicTexture extends Texture {
  15876. private _generateMipMaps;
  15877. private _canvas;
  15878. private _context;
  15879. private _engine;
  15880. /**
  15881. * Creates a DynamicTexture
  15882. * @param name defines the name of the texture
  15883. * @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
  15884. * @param scene defines the scene where you want the texture
  15885. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  15886. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  15887. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  15888. */
  15889. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  15890. /**
  15891. * Get the current class name of the texture useful for serialization or dynamic coding.
  15892. * @returns "DynamicTexture"
  15893. */
  15894. getClassName(): string;
  15895. /**
  15896. * Gets the current state of canRescale
  15897. */
  15898. readonly canRescale: boolean;
  15899. private _recreate;
  15900. /**
  15901. * Scales the texture
  15902. * @param ratio the scale factor to apply to both width and height
  15903. */
  15904. scale(ratio: number): void;
  15905. /**
  15906. * Resizes the texture
  15907. * @param width the new width
  15908. * @param height the new height
  15909. */
  15910. scaleTo(width: number, height: number): void;
  15911. /**
  15912. * Gets the context of the canvas used by the texture
  15913. * @returns the canvas context of the dynamic texture
  15914. */
  15915. getContext(): CanvasRenderingContext2D;
  15916. /**
  15917. * Clears the texture
  15918. */
  15919. clear(): void;
  15920. /**
  15921. * Updates the texture
  15922. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  15923. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  15924. */
  15925. update(invertY?: boolean, premulAlpha?: boolean): void;
  15926. /**
  15927. * Draws text onto the texture
  15928. * @param text defines the text to be drawn
  15929. * @param x defines the placement of the text from the left
  15930. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  15931. * @param font defines the font to be used with font-style, font-size, font-name
  15932. * @param color defines the color used for the text
  15933. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  15934. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  15935. * @param update defines whether texture is immediately update (default is true)
  15936. */
  15937. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  15938. /**
  15939. * Clones the texture
  15940. * @returns the clone of the texture.
  15941. */
  15942. clone(): DynamicTexture;
  15943. /**
  15944. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  15945. * @returns a serialized dynamic texture object
  15946. */
  15947. serialize(): any;
  15948. /** @hidden */ private _rebuild(): void;
  15949. }
  15950. }
  15951. declare module BABYLON {
  15952. interface AbstractScene {
  15953. /**
  15954. * The list of procedural textures added to the scene
  15955. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15956. */
  15957. proceduralTextures: Array<ProceduralTexture>;
  15958. }
  15959. /**
  15960. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15961. * in a given scene.
  15962. */
  15963. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15964. /**
  15965. * The component name helpfull to identify the component in the list of scene components.
  15966. */
  15967. readonly name: string;
  15968. /**
  15969. * The scene the component belongs to.
  15970. */
  15971. scene: Scene;
  15972. /**
  15973. * Creates a new instance of the component for the given scene
  15974. * @param scene Defines the scene to register the component in
  15975. */
  15976. constructor(scene: Scene);
  15977. /**
  15978. * Registers the component in a given scene
  15979. */
  15980. register(): void;
  15981. /**
  15982. * Rebuilds the elements related to this component in case of
  15983. * context lost for instance.
  15984. */
  15985. rebuild(): void;
  15986. /**
  15987. * Disposes the component and the associated ressources.
  15988. */
  15989. dispose(): void;
  15990. private _beforeClear;
  15991. }
  15992. }
  15993. declare module BABYLON {
  15994. interface BaseEngine {
  15995. /**
  15996. * Creates a new render target cube texture
  15997. * @param size defines the size of the texture
  15998. * @param options defines the options used to create the texture
  15999. * @returns a new render target cube texture stored in an InternalTexture
  16000. */
  16001. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16002. }
  16003. }
  16004. declare module BABYLON {
  16005. /** @hidden */
  16006. export var proceduralVertexShader: {
  16007. name: string;
  16008. shader: string;
  16009. };
  16010. }
  16011. declare module BABYLON {
  16012. /**
  16013. * 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.
  16014. * This is the base class of any Procedural texture and contains most of the shareable code.
  16015. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16016. */
  16017. export class ProceduralTexture extends Texture {
  16018. isCube: boolean;
  16019. /**
  16020. * Define if the texture is enabled or not (disabled texture will not render)
  16021. */
  16022. isEnabled: boolean;
  16023. /**
  16024. * Define if the texture must be cleared before rendering (default is true)
  16025. */
  16026. autoClear: boolean;
  16027. /**
  16028. * Callback called when the texture is generated
  16029. */
  16030. onGenerated: () => void;
  16031. /**
  16032. * Event raised when the texture is generated
  16033. */
  16034. onGeneratedObservable: Observable<ProceduralTexture>;
  16035. /** @hidden */ private _generateMipMaps: boolean;
  16036. /** @hidden **/ private _effect: Effect;
  16037. /** @hidden */ private _textures: {
  16038. [key: string]: Texture;
  16039. };
  16040. private _size;
  16041. private _currentRefreshId;
  16042. private _refreshRate;
  16043. private _vertexBuffers;
  16044. private _indexBuffer;
  16045. private _uniforms;
  16046. private _samplers;
  16047. private _fragment;
  16048. private _floats;
  16049. private _ints;
  16050. private _floatsArrays;
  16051. private _colors3;
  16052. private _colors4;
  16053. private _vectors2;
  16054. private _vectors3;
  16055. private _matrices;
  16056. private _fallbackTexture;
  16057. private _fallbackTextureUsed;
  16058. private _engine;
  16059. private _cachedDefines;
  16060. private _contentUpdateId;
  16061. private _contentData;
  16062. /**
  16063. * Instantiates a new procedural texture.
  16064. * 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.
  16065. * This is the base class of any Procedural texture and contains most of the shareable code.
  16066. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16067. * @param name Define the name of the texture
  16068. * @param size Define the size of the texture to create
  16069. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16070. * @param scene Define the scene the texture belongs to
  16071. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16072. * @param generateMipMaps Define if the texture should creates mip maps or not
  16073. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16074. */
  16075. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16076. /**
  16077. * The effect that is created when initializing the post process.
  16078. * @returns The created effect corresponding the the postprocess.
  16079. */
  16080. getEffect(): Effect;
  16081. /**
  16082. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16083. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16084. */
  16085. getContent(): Nullable<ArrayBufferView>;
  16086. private _createIndexBuffer;
  16087. /** @hidden */ private _rebuild(): void;
  16088. /**
  16089. * Resets the texture in order to recreate its associated resources.
  16090. * This can be called in case of context loss
  16091. */
  16092. reset(): void;
  16093. protected _getDefines(): string;
  16094. /**
  16095. * Is the texture ready to be used ? (rendered at least once)
  16096. * @returns true if ready, otherwise, false.
  16097. */
  16098. isReady(): boolean;
  16099. /**
  16100. * Resets the refresh counter of the texture and start bak from scratch.
  16101. * Could be useful to regenerate the texture if it is setup to render only once.
  16102. */
  16103. resetRefreshCounter(): void;
  16104. /**
  16105. * Set the fragment shader to use in order to render the texture.
  16106. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16107. */
  16108. setFragment(fragment: any): void;
  16109. /**
  16110. * Define the refresh rate of the texture or the rendering frequency.
  16111. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16112. */
  16113. refreshRate: number;
  16114. /** @hidden */ private _shouldRender(): boolean;
  16115. /**
  16116. * Get the size the texture is rendering at.
  16117. * @returns the size (texture is always squared)
  16118. */
  16119. getRenderSize(): number;
  16120. /**
  16121. * Resize the texture to new value.
  16122. * @param size Define the new size the texture should have
  16123. * @param generateMipMaps Define whether the new texture should create mip maps
  16124. */
  16125. resize(size: number, generateMipMaps: boolean): void;
  16126. private _checkUniform;
  16127. /**
  16128. * Set a texture in the shader program used to render.
  16129. * @param name Define the name of the uniform samplers as defined in the shader
  16130. * @param texture Define the texture to bind to this sampler
  16131. * @return the texture itself allowing "fluent" like uniform updates
  16132. */
  16133. setTexture(name: string, texture: Texture): ProceduralTexture;
  16134. /**
  16135. * Set a float in the shader.
  16136. * @param name Define the name of the uniform as defined in the shader
  16137. * @param value Define the value to give to the uniform
  16138. * @return the texture itself allowing "fluent" like uniform updates
  16139. */
  16140. setFloat(name: string, value: number): ProceduralTexture;
  16141. /**
  16142. * Set a int in the shader.
  16143. * @param name Define the name of the uniform as defined in the shader
  16144. * @param value Define the value to give to the uniform
  16145. * @return the texture itself allowing "fluent" like uniform updates
  16146. */
  16147. setInt(name: string, value: number): ProceduralTexture;
  16148. /**
  16149. * Set an array of floats in the shader.
  16150. * @param name Define the name of the uniform as defined in the shader
  16151. * @param value Define the value to give to the uniform
  16152. * @return the texture itself allowing "fluent" like uniform updates
  16153. */
  16154. setFloats(name: string, value: number[]): ProceduralTexture;
  16155. /**
  16156. * Set a vec3 in the shader from a Color3.
  16157. * @param name Define the name of the uniform as defined in the shader
  16158. * @param value Define the value to give to the uniform
  16159. * @return the texture itself allowing "fluent" like uniform updates
  16160. */
  16161. setColor3(name: string, value: Color3): ProceduralTexture;
  16162. /**
  16163. * Set a vec4 in the shader from a Color4.
  16164. * @param name Define the name of the uniform as defined in the shader
  16165. * @param value Define the value to give to the uniform
  16166. * @return the texture itself allowing "fluent" like uniform updates
  16167. */
  16168. setColor4(name: string, value: Color4): ProceduralTexture;
  16169. /**
  16170. * Set a vec2 in the shader from a Vector2.
  16171. * @param name Define the name of the uniform as defined in the shader
  16172. * @param value Define the value to give to the uniform
  16173. * @return the texture itself allowing "fluent" like uniform updates
  16174. */
  16175. setVector2(name: string, value: Vector2): ProceduralTexture;
  16176. /**
  16177. * Set a vec3 in the shader from a Vector3.
  16178. * @param name Define the name of the uniform as defined in the shader
  16179. * @param value Define the value to give to the uniform
  16180. * @return the texture itself allowing "fluent" like uniform updates
  16181. */
  16182. setVector3(name: string, value: Vector3): ProceduralTexture;
  16183. /**
  16184. * Set a mat4 in the shader from a MAtrix.
  16185. * @param name Define the name of the uniform as defined in the shader
  16186. * @param value Define the value to give to the uniform
  16187. * @return the texture itself allowing "fluent" like uniform updates
  16188. */
  16189. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16190. /**
  16191. * Render the texture to its associated render target.
  16192. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16193. */
  16194. render(useCameraPostProcess?: boolean): void;
  16195. /**
  16196. * Clone the texture.
  16197. * @returns the cloned texture
  16198. */
  16199. clone(): ProceduralTexture;
  16200. /**
  16201. * Dispose the texture and release its asoociated resources.
  16202. */
  16203. dispose(): void;
  16204. }
  16205. }
  16206. declare module BABYLON {
  16207. /**
  16208. * This represents the base class for particle system in Babylon.
  16209. * 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.
  16210. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16211. * @example https://doc.babylonjs.com/babylon101/particles
  16212. */
  16213. export class BaseParticleSystem {
  16214. /**
  16215. * Source color is added to the destination color without alpha affecting the result
  16216. */
  16217. static BLENDMODE_ONEONE: number;
  16218. /**
  16219. * Blend current color and particle color using particle’s alpha
  16220. */
  16221. static BLENDMODE_STANDARD: number;
  16222. /**
  16223. * Add current color and particle color multiplied by particle’s alpha
  16224. */
  16225. static BLENDMODE_ADD: number;
  16226. /**
  16227. * Multiply current color with particle color
  16228. */
  16229. static BLENDMODE_MULTIPLY: number;
  16230. /**
  16231. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16232. */
  16233. static BLENDMODE_MULTIPLYADD: number;
  16234. /**
  16235. * List of animations used by the particle system.
  16236. */
  16237. animations: Animation[];
  16238. /**
  16239. * The id of the Particle system.
  16240. */
  16241. id: string;
  16242. /**
  16243. * The friendly name of the Particle system.
  16244. */
  16245. name: string;
  16246. /**
  16247. * The rendering group used by the Particle system to chose when to render.
  16248. */
  16249. renderingGroupId: number;
  16250. /**
  16251. * The emitter represents the Mesh or position we are attaching the particle system to.
  16252. */
  16253. emitter: Nullable<AbstractMesh | Vector3>;
  16254. /**
  16255. * The maximum number of particles to emit per frame
  16256. */
  16257. emitRate: number;
  16258. /**
  16259. * If you want to launch only a few particles at once, that can be done, as well.
  16260. */
  16261. manualEmitCount: number;
  16262. /**
  16263. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16264. */
  16265. updateSpeed: number;
  16266. /**
  16267. * The amount of time the particle system is running (depends of the overall update speed).
  16268. */
  16269. targetStopDuration: number;
  16270. /**
  16271. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16272. */
  16273. disposeOnStop: boolean;
  16274. /**
  16275. * Minimum power of emitting particles.
  16276. */
  16277. minEmitPower: number;
  16278. /**
  16279. * Maximum power of emitting particles.
  16280. */
  16281. maxEmitPower: number;
  16282. /**
  16283. * Minimum life time of emitting particles.
  16284. */
  16285. minLifeTime: number;
  16286. /**
  16287. * Maximum life time of emitting particles.
  16288. */
  16289. maxLifeTime: number;
  16290. /**
  16291. * Minimum Size of emitting particles.
  16292. */
  16293. minSize: number;
  16294. /**
  16295. * Maximum Size of emitting particles.
  16296. */
  16297. maxSize: number;
  16298. /**
  16299. * Minimum scale of emitting particles on X axis.
  16300. */
  16301. minScaleX: number;
  16302. /**
  16303. * Maximum scale of emitting particles on X axis.
  16304. */
  16305. maxScaleX: number;
  16306. /**
  16307. * Minimum scale of emitting particles on Y axis.
  16308. */
  16309. minScaleY: number;
  16310. /**
  16311. * Maximum scale of emitting particles on Y axis.
  16312. */
  16313. maxScaleY: number;
  16314. /**
  16315. * Gets or sets the minimal initial rotation in radians.
  16316. */
  16317. minInitialRotation: number;
  16318. /**
  16319. * Gets or sets the maximal initial rotation in radians.
  16320. */
  16321. maxInitialRotation: number;
  16322. /**
  16323. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16324. */
  16325. minAngularSpeed: number;
  16326. /**
  16327. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16328. */
  16329. maxAngularSpeed: number;
  16330. /**
  16331. * The texture used to render each particle. (this can be a spritesheet)
  16332. */
  16333. particleTexture: Nullable<Texture>;
  16334. /**
  16335. * The layer mask we are rendering the particles through.
  16336. */
  16337. layerMask: number;
  16338. /**
  16339. * This can help using your own shader to render the particle system.
  16340. * The according effect will be created
  16341. */
  16342. customShader: any;
  16343. /**
  16344. * By default particle system starts as soon as they are created. This prevents the
  16345. * automatic start to happen and let you decide when to start emitting particles.
  16346. */
  16347. preventAutoStart: boolean;
  16348. private _noiseTexture;
  16349. /**
  16350. * Gets or sets a texture used to add random noise to particle positions
  16351. */
  16352. noiseTexture: Nullable<ProceduralTexture>;
  16353. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16354. noiseStrength: Vector3;
  16355. /**
  16356. * Callback triggered when the particle animation is ending.
  16357. */
  16358. onAnimationEnd: Nullable<() => void>;
  16359. /**
  16360. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16361. */
  16362. blendMode: number;
  16363. /**
  16364. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16365. * to override the particles.
  16366. */
  16367. forceDepthWrite: boolean;
  16368. /** 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 */
  16369. preWarmCycles: number;
  16370. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16371. preWarmStepOffset: number;
  16372. /**
  16373. * 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)
  16374. */
  16375. spriteCellChangeSpeed: number;
  16376. /**
  16377. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16378. */
  16379. startSpriteCellID: number;
  16380. /**
  16381. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16382. */
  16383. endSpriteCellID: number;
  16384. /**
  16385. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16386. */
  16387. spriteCellWidth: number;
  16388. /**
  16389. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16390. */
  16391. spriteCellHeight: number;
  16392. /**
  16393. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16394. */
  16395. spriteRandomStartCell: boolean;
  16396. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16397. translationPivot: Vector2;
  16398. /** @hidden */
  16399. protected _isAnimationSheetEnabled: boolean;
  16400. /**
  16401. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16402. */
  16403. beginAnimationOnStart: boolean;
  16404. /**
  16405. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16406. */
  16407. beginAnimationFrom: number;
  16408. /**
  16409. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16410. */
  16411. beginAnimationTo: number;
  16412. /**
  16413. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16414. */
  16415. beginAnimationLoop: boolean;
  16416. /**
  16417. * Gets or sets a world offset applied to all particles
  16418. */
  16419. worldOffset: Vector3;
  16420. /**
  16421. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16422. */
  16423. isAnimationSheetEnabled: boolean;
  16424. /**
  16425. * Get hosting scene
  16426. * @returns the scene
  16427. */
  16428. getScene(): Scene;
  16429. /**
  16430. * You can use gravity if you want to give an orientation to your particles.
  16431. */
  16432. gravity: Vector3;
  16433. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16434. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16435. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16436. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16437. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16438. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16439. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16440. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16441. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16442. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16443. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16444. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16445. protected _hasTargetStopDurationDependantGradient(): Nullable<boolean>;
  16446. /**
  16447. * Defines the delay in milliseconds before starting the system (0 by default)
  16448. */
  16449. startDelay: number;
  16450. /**
  16451. * Gets the current list of drag gradients.
  16452. * You must use addDragGradient and removeDragGradient to udpate this list
  16453. * @returns the list of drag gradients
  16454. */
  16455. getDragGradients(): Nullable<Array<FactorGradient>>;
  16456. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16457. limitVelocityDamping: number;
  16458. /**
  16459. * Gets the current list of limit velocity gradients.
  16460. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16461. * @returns the list of limit velocity gradients
  16462. */
  16463. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16464. /**
  16465. * Gets the current list of color gradients.
  16466. * You must use addColorGradient and removeColorGradient to udpate this list
  16467. * @returns the list of color gradients
  16468. */
  16469. getColorGradients(): Nullable<Array<ColorGradient>>;
  16470. /**
  16471. * Gets the current list of size gradients.
  16472. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16473. * @returns the list of size gradients
  16474. */
  16475. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16476. /**
  16477. * Gets the current list of color remap gradients.
  16478. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16479. * @returns the list of color remap gradients
  16480. */
  16481. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16482. /**
  16483. * Gets the current list of alpha remap gradients.
  16484. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16485. * @returns the list of alpha remap gradients
  16486. */
  16487. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16488. /**
  16489. * Gets the current list of life time gradients.
  16490. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16491. * @returns the list of life time gradients
  16492. */
  16493. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16494. /**
  16495. * Gets the current list of angular speed gradients.
  16496. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16497. * @returns the list of angular speed gradients
  16498. */
  16499. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16500. /**
  16501. * Gets the current list of velocity gradients.
  16502. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16503. * @returns the list of velocity gradients
  16504. */
  16505. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16506. /**
  16507. * Gets the current list of start size gradients.
  16508. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16509. * @returns the list of start size gradients
  16510. */
  16511. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16512. /**
  16513. * Gets the current list of emit rate gradients.
  16514. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16515. * @returns the list of emit rate gradients
  16516. */
  16517. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16518. /**
  16519. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16520. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16521. */
  16522. direction1: Vector3;
  16523. /**
  16524. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16525. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16526. */
  16527. direction2: Vector3;
  16528. /**
  16529. * 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.
  16530. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16531. */
  16532. minEmitBox: Vector3;
  16533. /**
  16534. * 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.
  16535. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16536. */
  16537. maxEmitBox: Vector3;
  16538. /**
  16539. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16540. */
  16541. color1: Color4;
  16542. /**
  16543. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16544. */
  16545. color2: Color4;
  16546. /**
  16547. * Color the particle will have at the end of its lifetime
  16548. */
  16549. colorDead: Color4;
  16550. /**
  16551. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16552. */
  16553. textureMask: Color4;
  16554. /**
  16555. * The particle emitter type defines the emitter used by the particle system.
  16556. * It can be for example box, sphere, or cone...
  16557. */
  16558. particleEmitterType: IParticleEmitterType;
  16559. /** @hidden */ private _isSubEmitter: boolean;
  16560. /**
  16561. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16562. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16563. */
  16564. billboardMode: number;
  16565. protected _isBillboardBased: boolean;
  16566. /**
  16567. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16568. */
  16569. isBillboardBased: boolean;
  16570. /**
  16571. * The scene the particle system belongs to.
  16572. */
  16573. protected _scene: Scene;
  16574. /**
  16575. * Local cache of defines for image processing.
  16576. */
  16577. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16578. /**
  16579. * Default configuration related to image processing available in the standard Material.
  16580. */
  16581. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16582. /**
  16583. * Gets the image processing configuration used either in this material.
  16584. */
  16585. /**
  16586. * Sets the Default image processing configuration used either in the this material.
  16587. *
  16588. * If sets to null, the scene one is in use.
  16589. */
  16590. imageProcessingConfiguration: ImageProcessingConfiguration;
  16591. /**
  16592. * Attaches a new image processing configuration to the Standard Material.
  16593. * @param configuration
  16594. */
  16595. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16596. /** @hidden */
  16597. protected _reset(): void;
  16598. /** @hidden */
  16599. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16600. /**
  16601. * Instantiates a particle system.
  16602. * 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.
  16603. * @param name The name of the particle system
  16604. */
  16605. constructor(name: string);
  16606. /**
  16607. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16608. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16609. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16610. * @returns the emitter
  16611. */
  16612. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16613. /**
  16614. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16615. * @param radius The radius of the hemisphere to emit from
  16616. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16617. * @returns the emitter
  16618. */
  16619. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16620. /**
  16621. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16622. * @param radius The radius of the sphere to emit from
  16623. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16624. * @returns the emitter
  16625. */
  16626. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16627. /**
  16628. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16629. * @param radius The radius of the sphere to emit from
  16630. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16631. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16632. * @returns the emitter
  16633. */
  16634. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16635. /**
  16636. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16637. * @param radius The radius of the emission cylinder
  16638. * @param height The height of the emission cylinder
  16639. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16640. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16641. * @returns the emitter
  16642. */
  16643. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16644. /**
  16645. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16646. * @param radius The radius of the cylinder to emit from
  16647. * @param height The height of the emission cylinder
  16648. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16649. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16650. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16651. * @returns the emitter
  16652. */
  16653. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16654. /**
  16655. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16656. * @param radius The radius of the cone to emit from
  16657. * @param angle The base angle of the cone
  16658. * @returns the emitter
  16659. */
  16660. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16661. /**
  16662. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16663. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16664. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16665. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16666. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16667. * @returns the emitter
  16668. */
  16669. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16670. }
  16671. }
  16672. declare module BABYLON {
  16673. /**
  16674. * Type of sub emitter
  16675. */
  16676. export enum SubEmitterType {
  16677. /**
  16678. * Attached to the particle over it's lifetime
  16679. */
  16680. ATTACHED = 0,
  16681. /**
  16682. * Created when the particle dies
  16683. */
  16684. END = 1
  16685. }
  16686. /**
  16687. * Sub emitter class used to emit particles from an existing particle
  16688. */
  16689. export class SubEmitter {
  16690. /**
  16691. * the particle system to be used by the sub emitter
  16692. */
  16693. particleSystem: ParticleSystem;
  16694. /**
  16695. * Type of the submitter (Default: END)
  16696. */
  16697. type: SubEmitterType;
  16698. /**
  16699. * 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)
  16700. * Note: This only is supported when using an emitter of type Mesh
  16701. */
  16702. inheritDirection: boolean;
  16703. /**
  16704. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16705. */
  16706. inheritedVelocityAmount: number;
  16707. /**
  16708. * Creates a sub emitter
  16709. * @param particleSystem the particle system to be used by the sub emitter
  16710. */
  16711. constructor(
  16712. /**
  16713. * the particle system to be used by the sub emitter
  16714. */
  16715. particleSystem: ParticleSystem);
  16716. /**
  16717. * Clones the sub emitter
  16718. * @returns the cloned sub emitter
  16719. */
  16720. clone(): SubEmitter;
  16721. /**
  16722. * Serialize current object to a JSON object
  16723. * @returns the serialized object
  16724. */
  16725. serialize(): any;
  16726. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16727. /**
  16728. * Creates a new SubEmitter from a serialized JSON version
  16729. * @param serializationObject defines the JSON object to read from
  16730. * @param scene defines the hosting scene
  16731. * @param rootUrl defines the rootUrl for data loading
  16732. * @returns a new SubEmitter
  16733. */
  16734. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16735. /** Release associated resources */
  16736. dispose(): void;
  16737. }
  16738. }
  16739. declare module BABYLON {
  16740. /** @hidden */
  16741. export var clipPlaneFragmentDeclaration: {
  16742. name: string;
  16743. shader: string;
  16744. };
  16745. }
  16746. declare module BABYLON {
  16747. /** @hidden */
  16748. export var imageProcessingDeclaration: {
  16749. name: string;
  16750. shader: string;
  16751. };
  16752. }
  16753. declare module BABYLON {
  16754. /** @hidden */
  16755. export var imageProcessingFunctions: {
  16756. name: string;
  16757. shader: string;
  16758. };
  16759. }
  16760. declare module BABYLON {
  16761. /** @hidden */
  16762. export var clipPlaneFragment: {
  16763. name: string;
  16764. shader: string;
  16765. };
  16766. }
  16767. declare module BABYLON {
  16768. /** @hidden */
  16769. export var particlesPixelShader: {
  16770. name: string;
  16771. shader: string;
  16772. };
  16773. }
  16774. declare module BABYLON {
  16775. /** @hidden */
  16776. export var clipPlaneVertexDeclaration: {
  16777. name: string;
  16778. shader: string;
  16779. };
  16780. }
  16781. declare module BABYLON {
  16782. /** @hidden */
  16783. export var clipPlaneVertex: {
  16784. name: string;
  16785. shader: string;
  16786. };
  16787. }
  16788. declare module BABYLON {
  16789. /** @hidden */
  16790. export var particlesVertexShader: {
  16791. name: string;
  16792. shader: string;
  16793. };
  16794. }
  16795. declare module BABYLON {
  16796. /**
  16797. * This represents a particle system in Babylon.
  16798. * 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.
  16799. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16800. * @example https://doc.babylonjs.com/babylon101/particles
  16801. */
  16802. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16803. /**
  16804. * Billboard mode will only apply to Y axis
  16805. */
  16806. static readonly BILLBOARDMODE_Y: number;
  16807. /**
  16808. * Billboard mode will apply to all axes
  16809. */
  16810. static readonly BILLBOARDMODE_ALL: number;
  16811. /**
  16812. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16813. */
  16814. static readonly BILLBOARDMODE_STRETCHED: number;
  16815. /**
  16816. * This function can be defined to provide custom update for active particles.
  16817. * This function will be called instead of regular update (age, position, color, etc.).
  16818. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16819. */
  16820. updateFunction: (particles: Particle[]) => void;
  16821. private _emitterWorldMatrix;
  16822. /**
  16823. * This function can be defined to specify initial direction for every new particle.
  16824. * It by default use the emitterType defined function
  16825. */
  16826. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16827. /**
  16828. * This function can be defined to specify initial position for every new particle.
  16829. * It by default use the emitterType defined function
  16830. */
  16831. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16832. /**
  16833. * @hidden
  16834. */ private _inheritedVelocityOffset: Vector3;
  16835. /**
  16836. * An event triggered when the system is disposed
  16837. */
  16838. onDisposeObservable: Observable<ParticleSystem>;
  16839. private _onDisposeObserver;
  16840. /**
  16841. * Sets a callback that will be triggered when the system is disposed
  16842. */
  16843. onDispose: () => void;
  16844. private _particles;
  16845. private _epsilon;
  16846. private _capacity;
  16847. private _stockParticles;
  16848. private _newPartsExcess;
  16849. private _vertexData;
  16850. private _vertexBuffer;
  16851. private _vertexBuffers;
  16852. private _spriteBuffer;
  16853. private _indexBuffer;
  16854. private _effect;
  16855. private _customEffect;
  16856. private _cachedDefines;
  16857. private _scaledColorStep;
  16858. private _colorDiff;
  16859. private _scaledDirection;
  16860. private _scaledGravity;
  16861. private _currentRenderId;
  16862. private _alive;
  16863. private _useInstancing;
  16864. private _started;
  16865. private _stopped;
  16866. private _actualFrame;
  16867. private _scaledUpdateSpeed;
  16868. private _vertexBufferSize;
  16869. /** @hidden */ private _currentEmitRateGradient: Nullable<FactorGradient>;
  16870. /** @hidden */ private _currentEmitRate1: number;
  16871. /** @hidden */ private _currentEmitRate2: number;
  16872. /** @hidden */ private _currentStartSizeGradient: Nullable<FactorGradient>;
  16873. /** @hidden */ private _currentStartSize1: number;
  16874. /** @hidden */ private _currentStartSize2: number;
  16875. private readonly _rawTextureWidth;
  16876. private _rampGradientsTexture;
  16877. private _useRampGradients;
  16878. /** Gets or sets a boolean indicating that ramp gradients must be used
  16879. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16880. */
  16881. useRampGradients: boolean;
  16882. /**
  16883. * 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.
  16884. * 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: [])
  16885. */
  16886. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16887. private _subEmitters;
  16888. /**
  16889. * @hidden
  16890. * If the particle systems emitter should be disposed when the particle system is disposed
  16891. */ private _disposeEmitterOnDispose: boolean;
  16892. /**
  16893. * The current active Sub-systems, this property is used by the root particle system only.
  16894. */
  16895. activeSubSystems: Array<ParticleSystem>;
  16896. private _rootParticleSystem;
  16897. /**
  16898. * Gets the current list of active particles
  16899. */
  16900. readonly particles: Particle[];
  16901. /**
  16902. * Returns the string "ParticleSystem"
  16903. * @returns a string containing the class name
  16904. */
  16905. getClassName(): string;
  16906. /**
  16907. * Instantiates a particle system.
  16908. * 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.
  16909. * @param name The name of the particle system
  16910. * @param capacity The max number of particles alive at the same time
  16911. * @param scene The scene the particle system belongs to
  16912. * @param customEffect a custom effect used to change the way particles are rendered by default
  16913. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16914. * @param epsilon Offset used to render the particles
  16915. */
  16916. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16917. private _addFactorGradient;
  16918. private _removeFactorGradient;
  16919. /**
  16920. * Adds a new life time gradient
  16921. * @param gradient defines the gradient to use (between 0 and 1)
  16922. * @param factor defines the life time factor to affect to the specified gradient
  16923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16924. * @returns the current particle system
  16925. */
  16926. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16927. /**
  16928. * Remove a specific life time gradient
  16929. * @param gradient defines the gradient to remove
  16930. * @returns the current particle system
  16931. */
  16932. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16933. /**
  16934. * Adds a new size gradient
  16935. * @param gradient defines the gradient to use (between 0 and 1)
  16936. * @param factor defines the size factor to affect to the specified gradient
  16937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16938. * @returns the current particle system
  16939. */
  16940. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16941. /**
  16942. * Remove a specific size gradient
  16943. * @param gradient defines the gradient to remove
  16944. * @returns the current particle system
  16945. */
  16946. removeSizeGradient(gradient: number): IParticleSystem;
  16947. /**
  16948. * Adds a new color remap gradient
  16949. * @param gradient defines the gradient to use (between 0 and 1)
  16950. * @param min defines the color remap minimal range
  16951. * @param max defines the color remap maximal range
  16952. * @returns the current particle system
  16953. */
  16954. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16955. /**
  16956. * Remove a specific color remap gradient
  16957. * @param gradient defines the gradient to remove
  16958. * @returns the current particle system
  16959. */
  16960. removeColorRemapGradient(gradient: number): IParticleSystem;
  16961. /**
  16962. * Adds a new alpha remap gradient
  16963. * @param gradient defines the gradient to use (between 0 and 1)
  16964. * @param min defines the alpha remap minimal range
  16965. * @param max defines the alpha remap maximal range
  16966. * @returns the current particle system
  16967. */
  16968. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16969. /**
  16970. * Remove a specific alpha remap gradient
  16971. * @param gradient defines the gradient to remove
  16972. * @returns the current particle system
  16973. */
  16974. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16975. /**
  16976. * Adds a new angular speed gradient
  16977. * @param gradient defines the gradient to use (between 0 and 1)
  16978. * @param factor defines the angular speed to affect to the specified gradient
  16979. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16980. * @returns the current particle system
  16981. */
  16982. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16983. /**
  16984. * Remove a specific angular speed gradient
  16985. * @param gradient defines the gradient to remove
  16986. * @returns the current particle system
  16987. */
  16988. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16989. /**
  16990. * Adds a new velocity gradient
  16991. * @param gradient defines the gradient to use (between 0 and 1)
  16992. * @param factor defines the velocity to affect to the specified gradient
  16993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16994. * @returns the current particle system
  16995. */
  16996. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16997. /**
  16998. * Remove a specific velocity gradient
  16999. * @param gradient defines the gradient to remove
  17000. * @returns the current particle system
  17001. */
  17002. removeVelocityGradient(gradient: number): IParticleSystem;
  17003. /**
  17004. * Adds a new limit velocity gradient
  17005. * @param gradient defines the gradient to use (between 0 and 1)
  17006. * @param factor defines the limit velocity value to affect to the specified gradient
  17007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17008. * @returns the current particle system
  17009. */
  17010. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17011. /**
  17012. * Remove a specific limit velocity gradient
  17013. * @param gradient defines the gradient to remove
  17014. * @returns the current particle system
  17015. */
  17016. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17017. /**
  17018. * Adds a new drag gradient
  17019. * @param gradient defines the gradient to use (between 0 and 1)
  17020. * @param factor defines the drag value to affect to the specified gradient
  17021. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17022. * @returns the current particle system
  17023. */
  17024. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17025. /**
  17026. * Remove a specific drag gradient
  17027. * @param gradient defines the gradient to remove
  17028. * @returns the current particle system
  17029. */
  17030. removeDragGradient(gradient: number): IParticleSystem;
  17031. /**
  17032. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17033. * @param gradient defines the gradient to use (between 0 and 1)
  17034. * @param factor defines the emit rate value to affect to the specified gradient
  17035. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17036. * @returns the current particle system
  17037. */
  17038. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17039. /**
  17040. * Remove a specific emit rate gradient
  17041. * @param gradient defines the gradient to remove
  17042. * @returns the current particle system
  17043. */
  17044. removeEmitRateGradient(gradient: number): IParticleSystem;
  17045. /**
  17046. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17047. * @param gradient defines the gradient to use (between 0 and 1)
  17048. * @param factor defines the start size value to affect to the specified gradient
  17049. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17050. * @returns the current particle system
  17051. */
  17052. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17053. /**
  17054. * Remove a specific start size gradient
  17055. * @param gradient defines the gradient to remove
  17056. * @returns the current particle system
  17057. */
  17058. removeStartSizeGradient(gradient: number): IParticleSystem;
  17059. private _createRampGradientTexture;
  17060. /**
  17061. * Gets the current list of ramp gradients.
  17062. * You must use addRampGradient and removeRampGradient to udpate this list
  17063. * @returns the list of ramp gradients
  17064. */
  17065. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17066. /**
  17067. * Adds a new ramp gradient used to remap particle colors
  17068. * @param gradient defines the gradient to use (between 0 and 1)
  17069. * @param color defines the color to affect to the specified gradient
  17070. * @returns the current particle system
  17071. */
  17072. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17073. /**
  17074. * Remove a specific ramp gradient
  17075. * @param gradient defines the gradient to remove
  17076. * @returns the current particle system
  17077. */
  17078. removeRampGradient(gradient: number): ParticleSystem;
  17079. /**
  17080. * Adds a new color gradient
  17081. * @param gradient defines the gradient to use (between 0 and 1)
  17082. * @param color1 defines the color to affect to the specified gradient
  17083. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17084. * @returns this particle system
  17085. */
  17086. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17087. /**
  17088. * Remove a specific color gradient
  17089. * @param gradient defines the gradient to remove
  17090. * @returns this particle system
  17091. */
  17092. removeColorGradient(gradient: number): IParticleSystem;
  17093. private _fetchR;
  17094. protected _reset(): void;
  17095. private _resetEffect;
  17096. private _createVertexBuffers;
  17097. private _createIndexBuffer;
  17098. /**
  17099. * Gets the maximum number of particles active at the same time.
  17100. * @returns The max number of active particles.
  17101. */
  17102. getCapacity(): number;
  17103. /**
  17104. * Gets whether there are still active particles in the system.
  17105. * @returns True if it is alive, otherwise false.
  17106. */
  17107. isAlive(): boolean;
  17108. /**
  17109. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17110. * @returns True if it has been started, otherwise false.
  17111. */
  17112. isStarted(): boolean;
  17113. private _prepareSubEmitterInternalArray;
  17114. /**
  17115. * Starts the particle system and begins to emit
  17116. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17117. */
  17118. start(delay?: number): void;
  17119. /**
  17120. * Stops the particle system.
  17121. * @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.
  17122. */
  17123. stop(stopSubEmitters?: boolean): void;
  17124. /**
  17125. * Remove all active particles
  17126. */
  17127. reset(): void;
  17128. /**
  17129. * @hidden (for internal use only)
  17130. */ private _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17131. /**
  17132. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17133. * Its lifetime will start back at 0.
  17134. */
  17135. recycleParticle: (particle: Particle) => void;
  17136. private _stopSubEmitters;
  17137. private _createParticle;
  17138. private _removeFromRoot;
  17139. private _emitFromParticle;
  17140. private _update;
  17141. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17142. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17143. /** @hidden */
  17144. private _getEffect;
  17145. /**
  17146. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17147. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17148. */
  17149. animate(preWarmOnly?: boolean): void;
  17150. private _appendParticleVertices;
  17151. /**
  17152. * Rebuilds the particle system.
  17153. */
  17154. rebuild(): void;
  17155. /**
  17156. * Is this system ready to be used/rendered
  17157. * @return true if the system is ready
  17158. */
  17159. isReady(): boolean;
  17160. private _render;
  17161. /**
  17162. * Renders the particle system in its current state.
  17163. * @returns the current number of particles
  17164. */
  17165. render(): number;
  17166. /**
  17167. * Disposes the particle system and free the associated resources
  17168. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17169. */
  17170. dispose(disposeTexture?: boolean): void;
  17171. /**
  17172. * Clones the particle system.
  17173. * @param name The name of the cloned object
  17174. * @param newEmitter The new emitter to use
  17175. * @returns the cloned particle system
  17176. */
  17177. clone(name: string, newEmitter: any): ParticleSystem;
  17178. /**
  17179. * Serializes the particle system to a JSON object.
  17180. * @returns the JSON object
  17181. */
  17182. serialize(): any;
  17183. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17184. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17185. /**
  17186. * Parses a JSON object to create a particle system.
  17187. * @param parsedParticleSystem The JSON object to parse
  17188. * @param scene The scene to create the particle system in
  17189. * @param rootUrl The root url to use to load external dependencies like texture
  17190. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17191. * @returns the Parsed particle system
  17192. */
  17193. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17194. }
  17195. }
  17196. declare module BABYLON {
  17197. /**
  17198. * A particle represents one of the element emitted by a particle system.
  17199. * This is mainly define by its coordinates, direction, velocity and age.
  17200. */
  17201. export class Particle {
  17202. /**
  17203. * The particle system the particle belongs to.
  17204. */
  17205. particleSystem: ParticleSystem;
  17206. private static _Count;
  17207. /**
  17208. * Unique ID of the particle
  17209. */
  17210. id: number;
  17211. /**
  17212. * The world position of the particle in the scene.
  17213. */
  17214. position: Vector3;
  17215. /**
  17216. * The world direction of the particle in the scene.
  17217. */
  17218. direction: Vector3;
  17219. /**
  17220. * The color of the particle.
  17221. */
  17222. color: Color4;
  17223. /**
  17224. * The color change of the particle per step.
  17225. */
  17226. colorStep: Color4;
  17227. /**
  17228. * Defines how long will the life of the particle be.
  17229. */
  17230. lifeTime: number;
  17231. /**
  17232. * The current age of the particle.
  17233. */
  17234. age: number;
  17235. /**
  17236. * The current size of the particle.
  17237. */
  17238. size: number;
  17239. /**
  17240. * The current scale of the particle.
  17241. */
  17242. scale: Vector2;
  17243. /**
  17244. * The current angle of the particle.
  17245. */
  17246. angle: number;
  17247. /**
  17248. * Defines how fast is the angle changing.
  17249. */
  17250. angularSpeed: number;
  17251. /**
  17252. * Defines the cell index used by the particle to be rendered from a sprite.
  17253. */
  17254. cellIndex: number;
  17255. /**
  17256. * The information required to support color remapping
  17257. */
  17258. remapData: Vector4;
  17259. /** @hidden */ private _randomCellOffset?: number;
  17260. /** @hidden */ private _initialDirection: Nullable<Vector3>;
  17261. /** @hidden */ private _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17262. /** @hidden */ private _initialStartSpriteCellID: number;
  17263. /** @hidden */ private _initialEndSpriteCellID: number;
  17264. /** @hidden */ private _currentColorGradient: Nullable<ColorGradient>;
  17265. /** @hidden */ private _currentColor1: Color4;
  17266. /** @hidden */ private _currentColor2: Color4;
  17267. /** @hidden */ private _currentSizeGradient: Nullable<FactorGradient>;
  17268. /** @hidden */ private _currentSize1: number;
  17269. /** @hidden */ private _currentSize2: number;
  17270. /** @hidden */ private _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17271. /** @hidden */ private _currentAngularSpeed1: number;
  17272. /** @hidden */ private _currentAngularSpeed2: number;
  17273. /** @hidden */ private _currentVelocityGradient: Nullable<FactorGradient>;
  17274. /** @hidden */ private _currentVelocity1: number;
  17275. /** @hidden */ private _currentVelocity2: number;
  17276. /** @hidden */ private _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17277. /** @hidden */ private _currentLimitVelocity1: number;
  17278. /** @hidden */ private _currentLimitVelocity2: number;
  17279. /** @hidden */ private _currentDragGradient: Nullable<FactorGradient>;
  17280. /** @hidden */ private _currentDrag1: number;
  17281. /** @hidden */ private _currentDrag2: number;
  17282. /** @hidden */ private _randomNoiseCoordinates1: Vector3;
  17283. /** @hidden */ private _randomNoiseCoordinates2: Vector3;
  17284. /**
  17285. * Creates a new instance Particle
  17286. * @param particleSystem the particle system the particle belongs to
  17287. */
  17288. constructor(
  17289. /**
  17290. * The particle system the particle belongs to.
  17291. */
  17292. particleSystem: ParticleSystem);
  17293. private updateCellInfoFromSystem;
  17294. /**
  17295. * Defines how the sprite cell index is updated for the particle
  17296. */
  17297. updateCellIndex(): void;
  17298. /** @hidden */ private _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17299. /** @hidden */ private _inheritParticleInfoToSubEmitters(): void;
  17300. /** @hidden */ private _reset(): void;
  17301. /**
  17302. * Copy the properties of particle to another one.
  17303. * @param other the particle to copy the information to.
  17304. */
  17305. copyTo(other: Particle): void;
  17306. }
  17307. }
  17308. declare module BABYLON {
  17309. /**
  17310. * Particle emitter represents a volume emitting particles.
  17311. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17312. */
  17313. export interface IParticleEmitterType {
  17314. /**
  17315. * Called by the particle System when the direction is computed for the created particle.
  17316. * @param worldMatrix is the world matrix of the particle system
  17317. * @param directionToUpdate is the direction vector to update with the result
  17318. * @param particle is the particle we are computed the direction for
  17319. */
  17320. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17321. /**
  17322. * Called by the particle System when the position is computed for the created particle.
  17323. * @param worldMatrix is the world matrix of the particle system
  17324. * @param positionToUpdate is the position vector to update with the result
  17325. * @param particle is the particle we are computed the position for
  17326. */
  17327. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17328. /**
  17329. * Clones the current emitter and returns a copy of it
  17330. * @returns the new emitter
  17331. */
  17332. clone(): IParticleEmitterType;
  17333. /**
  17334. * Called by the GPUParticleSystem to setup the update shader
  17335. * @param effect defines the update shader
  17336. */
  17337. applyToShader(effect: Effect): void;
  17338. /**
  17339. * Returns a string to use to update the GPU particles update shader
  17340. * @returns the effect defines string
  17341. */
  17342. getEffectDefines(): string;
  17343. /**
  17344. * Returns a string representing the class name
  17345. * @returns a string containing the class name
  17346. */
  17347. getClassName(): string;
  17348. /**
  17349. * Serializes the particle system to a JSON object.
  17350. * @returns the JSON object
  17351. */
  17352. serialize(): any;
  17353. /**
  17354. * Parse properties from a JSON object
  17355. * @param serializationObject defines the JSON object
  17356. */
  17357. parse(serializationObject: any): void;
  17358. }
  17359. }
  17360. declare module BABYLON {
  17361. /**
  17362. * Particle emitter emitting particles from the inside of a box.
  17363. * It emits the particles randomly between 2 given directions.
  17364. */
  17365. export class BoxParticleEmitter implements IParticleEmitterType {
  17366. /**
  17367. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17368. */
  17369. direction1: Vector3;
  17370. /**
  17371. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17372. */
  17373. direction2: Vector3;
  17374. /**
  17375. * 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.
  17376. */
  17377. minEmitBox: Vector3;
  17378. /**
  17379. * 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.
  17380. */
  17381. maxEmitBox: Vector3;
  17382. /**
  17383. * Creates a new instance BoxParticleEmitter
  17384. */
  17385. constructor();
  17386. /**
  17387. * Called by the particle System when the direction is computed for the created particle.
  17388. * @param worldMatrix is the world matrix of the particle system
  17389. * @param directionToUpdate is the direction vector to update with the result
  17390. * @param particle is the particle we are computed the direction for
  17391. */
  17392. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17393. /**
  17394. * Called by the particle System when the position is computed for the created particle.
  17395. * @param worldMatrix is the world matrix of the particle system
  17396. * @param positionToUpdate is the position vector to update with the result
  17397. * @param particle is the particle we are computed the position for
  17398. */
  17399. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17400. /**
  17401. * Clones the current emitter and returns a copy of it
  17402. * @returns the new emitter
  17403. */
  17404. clone(): BoxParticleEmitter;
  17405. /**
  17406. * Called by the GPUParticleSystem to setup the update shader
  17407. * @param effect defines the update shader
  17408. */
  17409. applyToShader(effect: Effect): void;
  17410. /**
  17411. * Returns a string to use to update the GPU particles update shader
  17412. * @returns a string containng the defines string
  17413. */
  17414. getEffectDefines(): string;
  17415. /**
  17416. * Returns the string "BoxParticleEmitter"
  17417. * @returns a string containing the class name
  17418. */
  17419. getClassName(): string;
  17420. /**
  17421. * Serializes the particle system to a JSON object.
  17422. * @returns the JSON object
  17423. */
  17424. serialize(): any;
  17425. /**
  17426. * Parse properties from a JSON object
  17427. * @param serializationObject defines the JSON object
  17428. */
  17429. parse(serializationObject: any): void;
  17430. }
  17431. }
  17432. declare module BABYLON {
  17433. /**
  17434. * Particle emitter emitting particles from the inside of a cone.
  17435. * It emits the particles alongside the cone volume from the base to the particle.
  17436. * The emission direction might be randomized.
  17437. */
  17438. export class ConeParticleEmitter implements IParticleEmitterType {
  17439. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17440. directionRandomizer: number;
  17441. private _radius;
  17442. private _angle;
  17443. private _height;
  17444. /**
  17445. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17446. */
  17447. radiusRange: number;
  17448. /**
  17449. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17450. */
  17451. heightRange: number;
  17452. /**
  17453. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17454. */
  17455. emitFromSpawnPointOnly: boolean;
  17456. /**
  17457. * Gets or sets the radius of the emission cone
  17458. */
  17459. radius: number;
  17460. /**
  17461. * Gets or sets the angle of the emission cone
  17462. */
  17463. angle: number;
  17464. private _buildHeight;
  17465. /**
  17466. * Creates a new instance ConeParticleEmitter
  17467. * @param radius the radius of the emission cone (1 by default)
  17468. * @param angle the cone base angle (PI by default)
  17469. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17470. */
  17471. constructor(radius?: number, angle?: number,
  17472. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17473. directionRandomizer?: number);
  17474. /**
  17475. * Called by the particle System when the direction is computed for the created particle.
  17476. * @param worldMatrix is the world matrix of the particle system
  17477. * @param directionToUpdate is the direction vector to update with the result
  17478. * @param particle is the particle we are computed the direction for
  17479. */
  17480. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17481. /**
  17482. * Called by the particle System when the position is computed for the created particle.
  17483. * @param worldMatrix is the world matrix of the particle system
  17484. * @param positionToUpdate is the position vector to update with the result
  17485. * @param particle is the particle we are computed the position for
  17486. */
  17487. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17488. /**
  17489. * Clones the current emitter and returns a copy of it
  17490. * @returns the new emitter
  17491. */
  17492. clone(): ConeParticleEmitter;
  17493. /**
  17494. * Called by the GPUParticleSystem to setup the update shader
  17495. * @param effect defines the update shader
  17496. */
  17497. applyToShader(effect: Effect): void;
  17498. /**
  17499. * Returns a string to use to update the GPU particles update shader
  17500. * @returns a string containng the defines string
  17501. */
  17502. getEffectDefines(): string;
  17503. /**
  17504. * Returns the string "ConeParticleEmitter"
  17505. * @returns a string containing the class name
  17506. */
  17507. getClassName(): string;
  17508. /**
  17509. * Serializes the particle system to a JSON object.
  17510. * @returns the JSON object
  17511. */
  17512. serialize(): any;
  17513. /**
  17514. * Parse properties from a JSON object
  17515. * @param serializationObject defines the JSON object
  17516. */
  17517. parse(serializationObject: any): void;
  17518. }
  17519. }
  17520. declare module BABYLON {
  17521. /**
  17522. * Particle emitter emitting particles from the inside of a cylinder.
  17523. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17524. */
  17525. export class CylinderParticleEmitter implements IParticleEmitterType {
  17526. /**
  17527. * The radius of the emission cylinder.
  17528. */
  17529. radius: number;
  17530. /**
  17531. * The height of the emission cylinder.
  17532. */
  17533. height: number;
  17534. /**
  17535. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17536. */
  17537. radiusRange: number;
  17538. /**
  17539. * How much to randomize the particle direction [0-1].
  17540. */
  17541. directionRandomizer: number;
  17542. /**
  17543. * Creates a new instance CylinderParticleEmitter
  17544. * @param radius the radius of the emission cylinder (1 by default)
  17545. * @param height the height of the emission cylinder (1 by default)
  17546. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17547. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17548. */
  17549. constructor(
  17550. /**
  17551. * The radius of the emission cylinder.
  17552. */
  17553. radius?: number,
  17554. /**
  17555. * The height of the emission cylinder.
  17556. */
  17557. height?: number,
  17558. /**
  17559. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17560. */
  17561. radiusRange?: number,
  17562. /**
  17563. * How much to randomize the particle direction [0-1].
  17564. */
  17565. directionRandomizer?: number);
  17566. /**
  17567. * Called by the particle System when the direction is computed for the created particle.
  17568. * @param worldMatrix is the world matrix of the particle system
  17569. * @param directionToUpdate is the direction vector to update with the result
  17570. * @param particle is the particle we are computed the direction for
  17571. */
  17572. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17573. /**
  17574. * Called by the particle System when the position is computed for the created particle.
  17575. * @param worldMatrix is the world matrix of the particle system
  17576. * @param positionToUpdate is the position vector to update with the result
  17577. * @param particle is the particle we are computed the position for
  17578. */
  17579. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17580. /**
  17581. * Clones the current emitter and returns a copy of it
  17582. * @returns the new emitter
  17583. */
  17584. clone(): CylinderParticleEmitter;
  17585. /**
  17586. * Called by the GPUParticleSystem to setup the update shader
  17587. * @param effect defines the update shader
  17588. */
  17589. applyToShader(effect: Effect): void;
  17590. /**
  17591. * Returns a string to use to update the GPU particles update shader
  17592. * @returns a string containng the defines string
  17593. */
  17594. getEffectDefines(): string;
  17595. /**
  17596. * Returns the string "CylinderParticleEmitter"
  17597. * @returns a string containing the class name
  17598. */
  17599. getClassName(): string;
  17600. /**
  17601. * Serializes the particle system to a JSON object.
  17602. * @returns the JSON object
  17603. */
  17604. serialize(): any;
  17605. /**
  17606. * Parse properties from a JSON object
  17607. * @param serializationObject defines the JSON object
  17608. */
  17609. parse(serializationObject: any): void;
  17610. }
  17611. /**
  17612. * Particle emitter emitting particles from the inside of a cylinder.
  17613. * It emits the particles randomly between two vectors.
  17614. */
  17615. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17616. /**
  17617. * The min limit of the emission direction.
  17618. */
  17619. direction1: Vector3;
  17620. /**
  17621. * The max limit of the emission direction.
  17622. */
  17623. direction2: Vector3;
  17624. /**
  17625. * Creates a new instance CylinderDirectedParticleEmitter
  17626. * @param radius the radius of the emission cylinder (1 by default)
  17627. * @param height the height of the emission cylinder (1 by default)
  17628. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17629. * @param direction1 the min limit of the emission direction (up vector by default)
  17630. * @param direction2 the max limit of the emission direction (up vector by default)
  17631. */
  17632. constructor(radius?: number, height?: number, radiusRange?: number,
  17633. /**
  17634. * The min limit of the emission direction.
  17635. */
  17636. direction1?: Vector3,
  17637. /**
  17638. * The max limit of the emission direction.
  17639. */
  17640. direction2?: Vector3);
  17641. /**
  17642. * Called by the particle System when the direction is computed for the created particle.
  17643. * @param worldMatrix is the world matrix of the particle system
  17644. * @param directionToUpdate is the direction vector to update with the result
  17645. * @param particle is the particle we are computed the direction for
  17646. */
  17647. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17648. /**
  17649. * Clones the current emitter and returns a copy of it
  17650. * @returns the new emitter
  17651. */
  17652. clone(): CylinderDirectedParticleEmitter;
  17653. /**
  17654. * Called by the GPUParticleSystem to setup the update shader
  17655. * @param effect defines the update shader
  17656. */
  17657. applyToShader(effect: Effect): void;
  17658. /**
  17659. * Returns a string to use to update the GPU particles update shader
  17660. * @returns a string containng the defines string
  17661. */
  17662. getEffectDefines(): string;
  17663. /**
  17664. * Returns the string "CylinderDirectedParticleEmitter"
  17665. * @returns a string containing the class name
  17666. */
  17667. getClassName(): string;
  17668. /**
  17669. * Serializes the particle system to a JSON object.
  17670. * @returns the JSON object
  17671. */
  17672. serialize(): any;
  17673. /**
  17674. * Parse properties from a JSON object
  17675. * @param serializationObject defines the JSON object
  17676. */
  17677. parse(serializationObject: any): void;
  17678. }
  17679. }
  17680. declare module BABYLON {
  17681. /**
  17682. * Particle emitter emitting particles from the inside of a hemisphere.
  17683. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17684. */
  17685. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17686. /**
  17687. * The radius of the emission hemisphere.
  17688. */
  17689. radius: number;
  17690. /**
  17691. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17692. */
  17693. radiusRange: number;
  17694. /**
  17695. * How much to randomize the particle direction [0-1].
  17696. */
  17697. directionRandomizer: number;
  17698. /**
  17699. * Creates a new instance HemisphericParticleEmitter
  17700. * @param radius the radius of the emission hemisphere (1 by default)
  17701. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17702. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17703. */
  17704. constructor(
  17705. /**
  17706. * The radius of the emission hemisphere.
  17707. */
  17708. radius?: number,
  17709. /**
  17710. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17711. */
  17712. radiusRange?: number,
  17713. /**
  17714. * How much to randomize the particle direction [0-1].
  17715. */
  17716. directionRandomizer?: number);
  17717. /**
  17718. * Called by the particle System when the direction is computed for the created particle.
  17719. * @param worldMatrix is the world matrix of the particle system
  17720. * @param directionToUpdate is the direction vector to update with the result
  17721. * @param particle is the particle we are computed the direction for
  17722. */
  17723. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17724. /**
  17725. * Called by the particle System when the position is computed for the created particle.
  17726. * @param worldMatrix is the world matrix of the particle system
  17727. * @param positionToUpdate is the position vector to update with the result
  17728. * @param particle is the particle we are computed the position for
  17729. */
  17730. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17731. /**
  17732. * Clones the current emitter and returns a copy of it
  17733. * @returns the new emitter
  17734. */
  17735. clone(): HemisphericParticleEmitter;
  17736. /**
  17737. * Called by the GPUParticleSystem to setup the update shader
  17738. * @param effect defines the update shader
  17739. */
  17740. applyToShader(effect: Effect): void;
  17741. /**
  17742. * Returns a string to use to update the GPU particles update shader
  17743. * @returns a string containng the defines string
  17744. */
  17745. getEffectDefines(): string;
  17746. /**
  17747. * Returns the string "HemisphericParticleEmitter"
  17748. * @returns a string containing the class name
  17749. */
  17750. getClassName(): string;
  17751. /**
  17752. * Serializes the particle system to a JSON object.
  17753. * @returns the JSON object
  17754. */
  17755. serialize(): any;
  17756. /**
  17757. * Parse properties from a JSON object
  17758. * @param serializationObject defines the JSON object
  17759. */
  17760. parse(serializationObject: any): void;
  17761. }
  17762. }
  17763. declare module BABYLON {
  17764. /**
  17765. * Particle emitter emitting particles from a point.
  17766. * It emits the particles randomly between 2 given directions.
  17767. */
  17768. export class PointParticleEmitter implements IParticleEmitterType {
  17769. /**
  17770. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17771. */
  17772. direction1: Vector3;
  17773. /**
  17774. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17775. */
  17776. direction2: Vector3;
  17777. /**
  17778. * Creates a new instance PointParticleEmitter
  17779. */
  17780. constructor();
  17781. /**
  17782. * Called by the particle System when the direction is computed for the created particle.
  17783. * @param worldMatrix is the world matrix of the particle system
  17784. * @param directionToUpdate is the direction vector to update with the result
  17785. * @param particle is the particle we are computed the direction for
  17786. */
  17787. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17788. /**
  17789. * Called by the particle System when the position is computed for the created particle.
  17790. * @param worldMatrix is the world matrix of the particle system
  17791. * @param positionToUpdate is the position vector to update with the result
  17792. * @param particle is the particle we are computed the position for
  17793. */
  17794. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17795. /**
  17796. * Clones the current emitter and returns a copy of it
  17797. * @returns the new emitter
  17798. */
  17799. clone(): PointParticleEmitter;
  17800. /**
  17801. * Called by the GPUParticleSystem to setup the update shader
  17802. * @param effect defines the update shader
  17803. */
  17804. applyToShader(effect: Effect): void;
  17805. /**
  17806. * Returns a string to use to update the GPU particles update shader
  17807. * @returns a string containng the defines string
  17808. */
  17809. getEffectDefines(): string;
  17810. /**
  17811. * Returns the string "PointParticleEmitter"
  17812. * @returns a string containing the class name
  17813. */
  17814. getClassName(): string;
  17815. /**
  17816. * Serializes the particle system to a JSON object.
  17817. * @returns the JSON object
  17818. */
  17819. serialize(): any;
  17820. /**
  17821. * Parse properties from a JSON object
  17822. * @param serializationObject defines the JSON object
  17823. */
  17824. parse(serializationObject: any): void;
  17825. }
  17826. }
  17827. declare module BABYLON {
  17828. /**
  17829. * Particle emitter emitting particles from the inside of a sphere.
  17830. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17831. */
  17832. export class SphereParticleEmitter implements IParticleEmitterType {
  17833. /**
  17834. * The radius of the emission sphere.
  17835. */
  17836. radius: number;
  17837. /**
  17838. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17839. */
  17840. radiusRange: number;
  17841. /**
  17842. * How much to randomize the particle direction [0-1].
  17843. */
  17844. directionRandomizer: number;
  17845. /**
  17846. * Creates a new instance SphereParticleEmitter
  17847. * @param radius the radius of the emission sphere (1 by default)
  17848. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17849. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17850. */
  17851. constructor(
  17852. /**
  17853. * The radius of the emission sphere.
  17854. */
  17855. radius?: number,
  17856. /**
  17857. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17858. */
  17859. radiusRange?: number,
  17860. /**
  17861. * How much to randomize the particle direction [0-1].
  17862. */
  17863. directionRandomizer?: number);
  17864. /**
  17865. * Called by the particle System when the direction is computed for the created particle.
  17866. * @param worldMatrix is the world matrix of the particle system
  17867. * @param directionToUpdate is the direction vector to update with the result
  17868. * @param particle is the particle we are computed the direction for
  17869. */
  17870. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17871. /**
  17872. * Called by the particle System when the position is computed for the created particle.
  17873. * @param worldMatrix is the world matrix of the particle system
  17874. * @param positionToUpdate is the position vector to update with the result
  17875. * @param particle is the particle we are computed the position for
  17876. */
  17877. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17878. /**
  17879. * Clones the current emitter and returns a copy of it
  17880. * @returns the new emitter
  17881. */
  17882. clone(): SphereParticleEmitter;
  17883. /**
  17884. * Called by the GPUParticleSystem to setup the update shader
  17885. * @param effect defines the update shader
  17886. */
  17887. applyToShader(effect: Effect): void;
  17888. /**
  17889. * Returns a string to use to update the GPU particles update shader
  17890. * @returns a string containng the defines string
  17891. */
  17892. getEffectDefines(): string;
  17893. /**
  17894. * Returns the string "SphereParticleEmitter"
  17895. * @returns a string containing the class name
  17896. */
  17897. getClassName(): string;
  17898. /**
  17899. * Serializes the particle system to a JSON object.
  17900. * @returns the JSON object
  17901. */
  17902. serialize(): any;
  17903. /**
  17904. * Parse properties from a JSON object
  17905. * @param serializationObject defines the JSON object
  17906. */
  17907. parse(serializationObject: any): void;
  17908. }
  17909. /**
  17910. * Particle emitter emitting particles from the inside of a sphere.
  17911. * It emits the particles randomly between two vectors.
  17912. */
  17913. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17914. /**
  17915. * The min limit of the emission direction.
  17916. */
  17917. direction1: Vector3;
  17918. /**
  17919. * The max limit of the emission direction.
  17920. */
  17921. direction2: Vector3;
  17922. /**
  17923. * Creates a new instance SphereDirectedParticleEmitter
  17924. * @param radius the radius of the emission sphere (1 by default)
  17925. * @param direction1 the min limit of the emission direction (up vector by default)
  17926. * @param direction2 the max limit of the emission direction (up vector by default)
  17927. */
  17928. constructor(radius?: number,
  17929. /**
  17930. * The min limit of the emission direction.
  17931. */
  17932. direction1?: Vector3,
  17933. /**
  17934. * The max limit of the emission direction.
  17935. */
  17936. direction2?: Vector3);
  17937. /**
  17938. * Called by the particle System when the direction is computed for the created particle.
  17939. * @param worldMatrix is the world matrix of the particle system
  17940. * @param directionToUpdate is the direction vector to update with the result
  17941. * @param particle is the particle we are computed the direction for
  17942. */
  17943. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17944. /**
  17945. * Clones the current emitter and returns a copy of it
  17946. * @returns the new emitter
  17947. */
  17948. clone(): SphereDirectedParticleEmitter;
  17949. /**
  17950. * Called by the GPUParticleSystem to setup the update shader
  17951. * @param effect defines the update shader
  17952. */
  17953. applyToShader(effect: Effect): void;
  17954. /**
  17955. * Returns a string to use to update the GPU particles update shader
  17956. * @returns a string containng the defines string
  17957. */
  17958. getEffectDefines(): string;
  17959. /**
  17960. * Returns the string "SphereDirectedParticleEmitter"
  17961. * @returns a string containing the class name
  17962. */
  17963. getClassName(): string;
  17964. /**
  17965. * Serializes the particle system to a JSON object.
  17966. * @returns the JSON object
  17967. */
  17968. serialize(): any;
  17969. /**
  17970. * Parse properties from a JSON object
  17971. * @param serializationObject defines the JSON object
  17972. */
  17973. parse(serializationObject: any): void;
  17974. }
  17975. }
  17976. declare module BABYLON {
  17977. /**
  17978. * Interface representing a particle system in Babylon.js.
  17979. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17980. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17981. */
  17982. export interface IParticleSystem {
  17983. /**
  17984. * List of animations used by the particle system.
  17985. */
  17986. animations: Animation[];
  17987. /**
  17988. * The id of the Particle system.
  17989. */
  17990. id: string;
  17991. /**
  17992. * The name of the Particle system.
  17993. */
  17994. name: string;
  17995. /**
  17996. * The emitter represents the Mesh or position we are attaching the particle system to.
  17997. */
  17998. emitter: Nullable<AbstractMesh | Vector3>;
  17999. /**
  18000. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18001. */
  18002. isBillboardBased: boolean;
  18003. /**
  18004. * The rendering group used by the Particle system to chose when to render.
  18005. */
  18006. renderingGroupId: number;
  18007. /**
  18008. * The layer mask we are rendering the particles through.
  18009. */
  18010. layerMask: number;
  18011. /**
  18012. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18013. */
  18014. updateSpeed: number;
  18015. /**
  18016. * The amount of time the particle system is running (depends of the overall update speed).
  18017. */
  18018. targetStopDuration: number;
  18019. /**
  18020. * The texture used to render each particle. (this can be a spritesheet)
  18021. */
  18022. particleTexture: Nullable<Texture>;
  18023. /**
  18024. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18025. */
  18026. blendMode: number;
  18027. /**
  18028. * Minimum life time of emitting particles.
  18029. */
  18030. minLifeTime: number;
  18031. /**
  18032. * Maximum life time of emitting particles.
  18033. */
  18034. maxLifeTime: number;
  18035. /**
  18036. * Minimum Size of emitting particles.
  18037. */
  18038. minSize: number;
  18039. /**
  18040. * Maximum Size of emitting particles.
  18041. */
  18042. maxSize: number;
  18043. /**
  18044. * Minimum scale of emitting particles on X axis.
  18045. */
  18046. minScaleX: number;
  18047. /**
  18048. * Maximum scale of emitting particles on X axis.
  18049. */
  18050. maxScaleX: number;
  18051. /**
  18052. * Minimum scale of emitting particles on Y axis.
  18053. */
  18054. minScaleY: number;
  18055. /**
  18056. * Maximum scale of emitting particles on Y axis.
  18057. */
  18058. maxScaleY: number;
  18059. /**
  18060. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18061. */
  18062. color1: Color4;
  18063. /**
  18064. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18065. */
  18066. color2: Color4;
  18067. /**
  18068. * Color the particle will have at the end of its lifetime.
  18069. */
  18070. colorDead: Color4;
  18071. /**
  18072. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18073. */
  18074. emitRate: number;
  18075. /**
  18076. * You can use gravity if you want to give an orientation to your particles.
  18077. */
  18078. gravity: Vector3;
  18079. /**
  18080. * Minimum power of emitting particles.
  18081. */
  18082. minEmitPower: number;
  18083. /**
  18084. * Maximum power of emitting particles.
  18085. */
  18086. maxEmitPower: number;
  18087. /**
  18088. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18089. */
  18090. minAngularSpeed: number;
  18091. /**
  18092. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18093. */
  18094. maxAngularSpeed: number;
  18095. /**
  18096. * Gets or sets the minimal initial rotation in radians.
  18097. */
  18098. minInitialRotation: number;
  18099. /**
  18100. * Gets or sets the maximal initial rotation in radians.
  18101. */
  18102. maxInitialRotation: number;
  18103. /**
  18104. * The particle emitter type defines the emitter used by the particle system.
  18105. * It can be for example box, sphere, or cone...
  18106. */
  18107. particleEmitterType: Nullable<IParticleEmitterType>;
  18108. /**
  18109. * Defines the delay in milliseconds before starting the system (0 by default)
  18110. */
  18111. startDelay: number;
  18112. /**
  18113. * 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
  18114. */
  18115. preWarmCycles: number;
  18116. /**
  18117. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18118. */
  18119. preWarmStepOffset: number;
  18120. /**
  18121. * 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)
  18122. */
  18123. spriteCellChangeSpeed: number;
  18124. /**
  18125. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18126. */
  18127. startSpriteCellID: number;
  18128. /**
  18129. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18130. */
  18131. endSpriteCellID: number;
  18132. /**
  18133. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18134. */
  18135. spriteCellWidth: number;
  18136. /**
  18137. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18138. */
  18139. spriteCellHeight: number;
  18140. /**
  18141. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18142. */
  18143. spriteRandomStartCell: boolean;
  18144. /**
  18145. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18146. */
  18147. isAnimationSheetEnabled: boolean;
  18148. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18149. translationPivot: Vector2;
  18150. /**
  18151. * Gets or sets a texture used to add random noise to particle positions
  18152. */
  18153. noiseTexture: Nullable<BaseTexture>;
  18154. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18155. noiseStrength: Vector3;
  18156. /**
  18157. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18158. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18159. */
  18160. billboardMode: number;
  18161. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18162. limitVelocityDamping: number;
  18163. /**
  18164. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18165. */
  18166. beginAnimationOnStart: boolean;
  18167. /**
  18168. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18169. */
  18170. beginAnimationFrom: number;
  18171. /**
  18172. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18173. */
  18174. beginAnimationTo: number;
  18175. /**
  18176. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18177. */
  18178. beginAnimationLoop: boolean;
  18179. /**
  18180. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18181. */
  18182. disposeOnStop: boolean;
  18183. /**
  18184. * Gets the maximum number of particles active at the same time.
  18185. * @returns The max number of active particles.
  18186. */
  18187. getCapacity(): number;
  18188. /**
  18189. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18190. * @returns True if it has been started, otherwise false.
  18191. */
  18192. isStarted(): boolean;
  18193. /**
  18194. * Animates the particle system for this frame.
  18195. */
  18196. animate(): void;
  18197. /**
  18198. * Renders the particle system in its current state.
  18199. * @returns the current number of particles
  18200. */
  18201. render(): number;
  18202. /**
  18203. * Dispose the particle system and frees its associated resources.
  18204. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18205. */
  18206. dispose(disposeTexture?: boolean): void;
  18207. /**
  18208. * Clones the particle system.
  18209. * @param name The name of the cloned object
  18210. * @param newEmitter The new emitter to use
  18211. * @returns the cloned particle system
  18212. */
  18213. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18214. /**
  18215. * Serializes the particle system to a JSON object.
  18216. * @returns the JSON object
  18217. */
  18218. serialize(): any;
  18219. /**
  18220. * Rebuild the particle system
  18221. */
  18222. rebuild(): void;
  18223. /**
  18224. * Starts the particle system and begins to emit
  18225. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18226. */
  18227. start(delay?: number): void;
  18228. /**
  18229. * Stops the particle system.
  18230. */
  18231. stop(): void;
  18232. /**
  18233. * Remove all active particles
  18234. */
  18235. reset(): void;
  18236. /**
  18237. * Is this system ready to be used/rendered
  18238. * @return true if the system is ready
  18239. */
  18240. isReady(): boolean;
  18241. /**
  18242. * Adds a new color gradient
  18243. * @param gradient defines the gradient to use (between 0 and 1)
  18244. * @param color1 defines the color to affect to the specified gradient
  18245. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18246. * @returns the current particle system
  18247. */
  18248. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18249. /**
  18250. * Remove a specific color gradient
  18251. * @param gradient defines the gradient to remove
  18252. * @returns the current particle system
  18253. */
  18254. removeColorGradient(gradient: number): IParticleSystem;
  18255. /**
  18256. * Adds a new size gradient
  18257. * @param gradient defines the gradient to use (between 0 and 1)
  18258. * @param factor defines the size factor to affect to the specified gradient
  18259. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18260. * @returns the current particle system
  18261. */
  18262. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18263. /**
  18264. * Remove a specific size gradient
  18265. * @param gradient defines the gradient to remove
  18266. * @returns the current particle system
  18267. */
  18268. removeSizeGradient(gradient: number): IParticleSystem;
  18269. /**
  18270. * Gets the current list of color gradients.
  18271. * You must use addColorGradient and removeColorGradient to udpate this list
  18272. * @returns the list of color gradients
  18273. */
  18274. getColorGradients(): Nullable<Array<ColorGradient>>;
  18275. /**
  18276. * Gets the current list of size gradients.
  18277. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18278. * @returns the list of size gradients
  18279. */
  18280. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18281. /**
  18282. * Gets the current list of angular speed gradients.
  18283. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18284. * @returns the list of angular speed gradients
  18285. */
  18286. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18287. /**
  18288. * Adds a new angular speed gradient
  18289. * @param gradient defines the gradient to use (between 0 and 1)
  18290. * @param factor defines the angular speed to affect to the specified gradient
  18291. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18292. * @returns the current particle system
  18293. */
  18294. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18295. /**
  18296. * Remove a specific angular speed gradient
  18297. * @param gradient defines the gradient to remove
  18298. * @returns the current particle system
  18299. */
  18300. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18301. /**
  18302. * Gets the current list of velocity gradients.
  18303. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18304. * @returns the list of velocity gradients
  18305. */
  18306. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18307. /**
  18308. * Adds a new velocity gradient
  18309. * @param gradient defines the gradient to use (between 0 and 1)
  18310. * @param factor defines the velocity to affect to the specified gradient
  18311. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18312. * @returns the current particle system
  18313. */
  18314. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18315. /**
  18316. * Remove a specific velocity gradient
  18317. * @param gradient defines the gradient to remove
  18318. * @returns the current particle system
  18319. */
  18320. removeVelocityGradient(gradient: number): IParticleSystem;
  18321. /**
  18322. * Gets the current list of limit velocity gradients.
  18323. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18324. * @returns the list of limit velocity gradients
  18325. */
  18326. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18327. /**
  18328. * Adds a new limit velocity gradient
  18329. * @param gradient defines the gradient to use (between 0 and 1)
  18330. * @param factor defines the limit velocity to affect to the specified gradient
  18331. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18332. * @returns the current particle system
  18333. */
  18334. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18335. /**
  18336. * Remove a specific limit velocity gradient
  18337. * @param gradient defines the gradient to remove
  18338. * @returns the current particle system
  18339. */
  18340. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18341. /**
  18342. * Adds a new drag gradient
  18343. * @param gradient defines the gradient to use (between 0 and 1)
  18344. * @param factor defines the drag to affect to the specified gradient
  18345. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18346. * @returns the current particle system
  18347. */
  18348. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18349. /**
  18350. * Remove a specific drag gradient
  18351. * @param gradient defines the gradient to remove
  18352. * @returns the current particle system
  18353. */
  18354. removeDragGradient(gradient: number): IParticleSystem;
  18355. /**
  18356. * Gets the current list of drag gradients.
  18357. * You must use addDragGradient and removeDragGradient to udpate this list
  18358. * @returns the list of drag gradients
  18359. */
  18360. getDragGradients(): Nullable<Array<FactorGradient>>;
  18361. /**
  18362. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18363. * @param gradient defines the gradient to use (between 0 and 1)
  18364. * @param factor defines the emit rate to affect to the specified gradient
  18365. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18366. * @returns the current particle system
  18367. */
  18368. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18369. /**
  18370. * Remove a specific emit rate gradient
  18371. * @param gradient defines the gradient to remove
  18372. * @returns the current particle system
  18373. */
  18374. removeEmitRateGradient(gradient: number): IParticleSystem;
  18375. /**
  18376. * Gets the current list of emit rate gradients.
  18377. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18378. * @returns the list of emit rate gradients
  18379. */
  18380. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18381. /**
  18382. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18383. * @param gradient defines the gradient to use (between 0 and 1)
  18384. * @param factor defines the start size to affect to the specified gradient
  18385. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18386. * @returns the current particle system
  18387. */
  18388. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18389. /**
  18390. * Remove a specific start size gradient
  18391. * @param gradient defines the gradient to remove
  18392. * @returns the current particle system
  18393. */
  18394. removeStartSizeGradient(gradient: number): IParticleSystem;
  18395. /**
  18396. * Gets the current list of start size gradients.
  18397. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18398. * @returns the list of start size gradients
  18399. */
  18400. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18401. /**
  18402. * Adds a new life time gradient
  18403. * @param gradient defines the gradient to use (between 0 and 1)
  18404. * @param factor defines the life time factor to affect to the specified gradient
  18405. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18406. * @returns the current particle system
  18407. */
  18408. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18409. /**
  18410. * Remove a specific life time gradient
  18411. * @param gradient defines the gradient to remove
  18412. * @returns the current particle system
  18413. */
  18414. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18415. /**
  18416. * Gets the current list of life time gradients.
  18417. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18418. * @returns the list of life time gradients
  18419. */
  18420. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18421. /**
  18422. * Gets the current list of color gradients.
  18423. * You must use addColorGradient and removeColorGradient to udpate this list
  18424. * @returns the list of color gradients
  18425. */
  18426. getColorGradients(): Nullable<Array<ColorGradient>>;
  18427. /**
  18428. * Adds a new ramp gradient used to remap particle colors
  18429. * @param gradient defines the gradient to use (between 0 and 1)
  18430. * @param color defines the color to affect to the specified gradient
  18431. * @returns the current particle system
  18432. */
  18433. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18434. /**
  18435. * Gets the current list of ramp gradients.
  18436. * You must use addRampGradient and removeRampGradient to udpate this list
  18437. * @returns the list of ramp gradients
  18438. */
  18439. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18440. /** Gets or sets a boolean indicating that ramp gradients must be used
  18441. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18442. */
  18443. useRampGradients: boolean;
  18444. /**
  18445. * Adds a new color remap gradient
  18446. * @param gradient defines the gradient to use (between 0 and 1)
  18447. * @param min defines the color remap minimal range
  18448. * @param max defines the color remap maximal range
  18449. * @returns the current particle system
  18450. */
  18451. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18452. /**
  18453. * Gets the current list of color remap gradients.
  18454. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18455. * @returns the list of color remap gradients
  18456. */
  18457. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18458. /**
  18459. * Adds a new alpha remap gradient
  18460. * @param gradient defines the gradient to use (between 0 and 1)
  18461. * @param min defines the alpha remap minimal range
  18462. * @param max defines the alpha remap maximal range
  18463. * @returns the current particle system
  18464. */
  18465. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18466. /**
  18467. * Gets the current list of alpha remap gradients.
  18468. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18469. * @returns the list of alpha remap gradients
  18470. */
  18471. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18472. /**
  18473. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18474. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18475. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18476. * @returns the emitter
  18477. */
  18478. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18479. /**
  18480. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18481. * @param radius The radius of the hemisphere to emit from
  18482. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18483. * @returns the emitter
  18484. */
  18485. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18486. /**
  18487. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18488. * @param radius The radius of the sphere to emit from
  18489. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18490. * @returns the emitter
  18491. */
  18492. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18493. /**
  18494. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18495. * @param radius The radius of the sphere to emit from
  18496. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18497. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18498. * @returns the emitter
  18499. */
  18500. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18501. /**
  18502. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18503. * @param radius The radius of the emission cylinder
  18504. * @param height The height of the emission cylinder
  18505. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18506. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18507. * @returns the emitter
  18508. */
  18509. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18510. /**
  18511. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18512. * @param radius The radius of the cylinder to emit from
  18513. * @param height The height of the emission cylinder
  18514. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18515. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18516. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18517. * @returns the emitter
  18518. */
  18519. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18520. /**
  18521. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18522. * @param radius The radius of the cone to emit from
  18523. * @param angle The base angle of the cone
  18524. * @returns the emitter
  18525. */
  18526. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18527. /**
  18528. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18529. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18530. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18531. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18532. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18533. * @returns the emitter
  18534. */
  18535. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18536. /**
  18537. * Get hosting scene
  18538. * @returns the scene
  18539. */
  18540. getScene(): Scene;
  18541. }
  18542. }
  18543. declare module BABYLON {
  18544. /**
  18545. * Creates an instance based on a source mesh.
  18546. */
  18547. export class InstancedMesh extends AbstractMesh {
  18548. private _sourceMesh;
  18549. private _currentLOD;
  18550. /** @hidden */ private _indexInSourceMeshInstanceArray: number;
  18551. constructor(name: string, source: Mesh);
  18552. /**
  18553. * Returns the string "InstancedMesh".
  18554. */
  18555. getClassName(): string;
  18556. /** Gets the list of lights affecting that mesh */
  18557. readonly lightSources: Light[]; private _resyncLightSources(): void; private _resyncLighSource(light: Light): void; private _removeLightSource(light: Light, dispose: boolean): void;
  18558. /**
  18559. * If the source mesh receives shadows
  18560. */
  18561. readonly receiveShadows: boolean;
  18562. /**
  18563. * The material of the source mesh
  18564. */
  18565. readonly material: Nullable<Material>;
  18566. /**
  18567. * Visibility of the source mesh
  18568. */
  18569. readonly visibility: number;
  18570. /**
  18571. * Skeleton of the source mesh
  18572. */
  18573. readonly skeleton: Nullable<Skeleton>;
  18574. /**
  18575. * Rendering ground id of the source mesh
  18576. */
  18577. renderingGroupId: number;
  18578. /**
  18579. * Returns the total number of vertices (integer).
  18580. */
  18581. getTotalVertices(): number;
  18582. /**
  18583. * Returns a positive integer : the total number of indices in this mesh geometry.
  18584. * @returns the numner of indices or zero if the mesh has no geometry.
  18585. */
  18586. getTotalIndices(): number;
  18587. /**
  18588. * The source mesh of the instance
  18589. */
  18590. readonly sourceMesh: Mesh;
  18591. /**
  18592. * Is this node ready to be used/rendered
  18593. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18594. * @return {boolean} is it ready
  18595. */
  18596. isReady(completeCheck?: boolean): boolean;
  18597. /**
  18598. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18599. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18600. * @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.
  18601. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18602. */
  18603. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18604. /**
  18605. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18606. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18607. * The `data` are either a numeric array either a Float32Array.
  18608. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18609. * 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).
  18610. * Note that a new underlying VertexBuffer object is created each call.
  18611. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18612. *
  18613. * Possible `kind` values :
  18614. * - VertexBuffer.PositionKind
  18615. * - VertexBuffer.UVKind
  18616. * - VertexBuffer.UV2Kind
  18617. * - VertexBuffer.UV3Kind
  18618. * - VertexBuffer.UV4Kind
  18619. * - VertexBuffer.UV5Kind
  18620. * - VertexBuffer.UV6Kind
  18621. * - VertexBuffer.ColorKind
  18622. * - VertexBuffer.MatricesIndicesKind
  18623. * - VertexBuffer.MatricesIndicesExtraKind
  18624. * - VertexBuffer.MatricesWeightsKind
  18625. * - VertexBuffer.MatricesWeightsExtraKind
  18626. *
  18627. * Returns the Mesh.
  18628. */
  18629. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18630. /**
  18631. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18632. * If the mesh has no geometry, it is simply returned as it is.
  18633. * The `data` are either a numeric array either a Float32Array.
  18634. * No new underlying VertexBuffer object is created.
  18635. * 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.
  18636. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18637. *
  18638. * Possible `kind` values :
  18639. * - VertexBuffer.PositionKind
  18640. * - VertexBuffer.UVKind
  18641. * - VertexBuffer.UV2Kind
  18642. * - VertexBuffer.UV3Kind
  18643. * - VertexBuffer.UV4Kind
  18644. * - VertexBuffer.UV5Kind
  18645. * - VertexBuffer.UV6Kind
  18646. * - VertexBuffer.ColorKind
  18647. * - VertexBuffer.MatricesIndicesKind
  18648. * - VertexBuffer.MatricesIndicesExtraKind
  18649. * - VertexBuffer.MatricesWeightsKind
  18650. * - VertexBuffer.MatricesWeightsExtraKind
  18651. *
  18652. * Returns the Mesh.
  18653. */
  18654. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18655. /**
  18656. * Sets the mesh indices.
  18657. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18658. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18659. * This method creates a new index buffer each call.
  18660. * Returns the Mesh.
  18661. */
  18662. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18663. /**
  18664. * Boolean : True if the mesh owns the requested kind of data.
  18665. */
  18666. isVerticesDataPresent(kind: string): boolean;
  18667. /**
  18668. * Returns an array of indices (IndicesArray).
  18669. */
  18670. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  18671. /**
  18672. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18673. * This means the mesh underlying bounding box and sphere are recomputed.
  18674. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18675. * @returns the current mesh
  18676. */
  18677. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18678. /** @hidden */ private _preActivate(): InstancedMesh;
  18679. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  18680. /** @hidden */ private _postActivate(): void;
  18681. getWorldMatrix(): Matrix;
  18682. readonly isAnInstance: boolean;
  18683. /**
  18684. * Returns the current associated LOD AbstractMesh.
  18685. */
  18686. getLOD(camera: Camera): AbstractMesh;
  18687. /** @hidden */ private _syncSubMeshes(): InstancedMesh;
  18688. /** @hidden */ private _generatePointsArray(): boolean;
  18689. /**
  18690. * Creates a new InstancedMesh from the current mesh.
  18691. * - name (string) : the cloned mesh name
  18692. * - newParent (optional Node) : the optional Node to parent the clone to.
  18693. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18694. *
  18695. * Returns the clone.
  18696. */
  18697. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18698. /**
  18699. * Disposes the InstancedMesh.
  18700. * Returns nothing.
  18701. */
  18702. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18703. }
  18704. }
  18705. declare module BABYLON {
  18706. /**
  18707. * Defines the options associated with the creation of a shader material.
  18708. */
  18709. export interface IShaderMaterialOptions {
  18710. /**
  18711. * Does the material work in alpha blend mode
  18712. */
  18713. needAlphaBlending: boolean;
  18714. /**
  18715. * Does the material work in alpha test mode
  18716. */
  18717. needAlphaTesting: boolean;
  18718. /**
  18719. * The list of attribute names used in the shader
  18720. */
  18721. attributes: string[];
  18722. /**
  18723. * The list of unifrom names used in the shader
  18724. */
  18725. uniforms: string[];
  18726. /**
  18727. * The list of UBO names used in the shader
  18728. */
  18729. uniformBuffers: string[];
  18730. /**
  18731. * The list of sampler names used in the shader
  18732. */
  18733. samplers: string[];
  18734. /**
  18735. * The list of defines used in the shader
  18736. */
  18737. defines: string[];
  18738. }
  18739. /**
  18740. * 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.
  18741. *
  18742. * This returned material effects how the mesh will look based on the code in the shaders.
  18743. *
  18744. * @see http://doc.babylonjs.com/how_to/shader_material
  18745. */
  18746. export class ShaderMaterial extends Material {
  18747. private _shaderPath;
  18748. private _options;
  18749. private _textures;
  18750. private _textureArrays;
  18751. private _floats;
  18752. private _ints;
  18753. private _floatsArrays;
  18754. private _colors3;
  18755. private _colors3Arrays;
  18756. private _colors4;
  18757. private _colors4Arrays;
  18758. private _vectors2;
  18759. private _vectors3;
  18760. private _vectors4;
  18761. private _matrices;
  18762. private _matrices3x3;
  18763. private _matrices2x2;
  18764. private _vectors2Arrays;
  18765. private _vectors3Arrays;
  18766. private _vectors4Arrays;
  18767. private _cachedWorldViewMatrix;
  18768. private _cachedWorldViewProjectionMatrix;
  18769. private _renderId;
  18770. /**
  18771. * Instantiate a new shader material.
  18772. * 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.
  18773. * This returned material effects how the mesh will look based on the code in the shaders.
  18774. * @see http://doc.babylonjs.com/how_to/shader_material
  18775. * @param name Define the name of the material in the scene
  18776. * @param scene Define the scene the material belongs to
  18777. * @param shaderPath Defines the route to the shader code in one of three ways:
  18778. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18779. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  18780. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  18781. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18782. * @param options Define the options used to create the shader
  18783. */
  18784. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18785. /**
  18786. * Gets the options used to compile the shader.
  18787. * They can be modified to trigger a new compilation
  18788. */
  18789. readonly options: IShaderMaterialOptions;
  18790. /**
  18791. * Gets the current class name of the material e.g. "ShaderMaterial"
  18792. * Mainly use in serialization.
  18793. * @returns the class name
  18794. */
  18795. getClassName(): string;
  18796. /**
  18797. * Specifies if the material will require alpha blending
  18798. * @returns a boolean specifying if alpha blending is needed
  18799. */
  18800. needAlphaBlending(): boolean;
  18801. /**
  18802. * Specifies if this material should be rendered in alpha test mode
  18803. * @returns a boolean specifying if an alpha test is needed.
  18804. */
  18805. needAlphaTesting(): boolean;
  18806. private _checkUniform;
  18807. /**
  18808. * Set a texture in the shader.
  18809. * @param name Define the name of the uniform samplers as defined in the shader
  18810. * @param texture Define the texture to bind to this sampler
  18811. * @return the material itself allowing "fluent" like uniform updates
  18812. */
  18813. setTexture(name: string, texture: Texture): ShaderMaterial;
  18814. /**
  18815. * Set a texture array in the shader.
  18816. * @param name Define the name of the uniform sampler array as defined in the shader
  18817. * @param textures Define the list of textures to bind to this sampler
  18818. * @return the material itself allowing "fluent" like uniform updates
  18819. */
  18820. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18821. /**
  18822. * Set a float in the shader.
  18823. * @param name Define the name of the uniform as defined in the shader
  18824. * @param value Define the value to give to the uniform
  18825. * @return the material itself allowing "fluent" like uniform updates
  18826. */
  18827. setFloat(name: string, value: number): ShaderMaterial;
  18828. /**
  18829. * Set a int in the shader.
  18830. * @param name Define the name of the uniform as defined in the shader
  18831. * @param value Define the value to give to the uniform
  18832. * @return the material itself allowing "fluent" like uniform updates
  18833. */
  18834. setInt(name: string, value: number): ShaderMaterial;
  18835. /**
  18836. * Set an array of floats in the shader.
  18837. * @param name Define the name of the uniform as defined in the shader
  18838. * @param value Define the value to give to the uniform
  18839. * @return the material itself allowing "fluent" like uniform updates
  18840. */
  18841. setFloats(name: string, value: number[]): ShaderMaterial;
  18842. /**
  18843. * Set a vec3 in the shader from a Color3.
  18844. * @param name Define the name of the uniform as defined in the shader
  18845. * @param value Define the value to give to the uniform
  18846. * @return the material itself allowing "fluent" like uniform updates
  18847. */
  18848. setColor3(name: string, value: Color3): ShaderMaterial;
  18849. /**
  18850. * Set a vec3 array in the shader from a Color3 array.
  18851. * @param name Define the name of the uniform as defined in the shader
  18852. * @param value Define the value to give to the uniform
  18853. * @return the material itself allowing "fluent" like uniform updates
  18854. */
  18855. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18856. /**
  18857. * Set a vec4 in the shader from a Color4.
  18858. * @param name Define the name of the uniform as defined in the shader
  18859. * @param value Define the value to give to the uniform
  18860. * @return the material itself allowing "fluent" like uniform updates
  18861. */
  18862. setColor4(name: string, value: Color4): ShaderMaterial;
  18863. /**
  18864. * Set a vec4 array in the shader from a Color4 array.
  18865. * @param name Define the name of the uniform as defined in the shader
  18866. * @param value Define the value to give to the uniform
  18867. * @return the material itself allowing "fluent" like uniform updates
  18868. */
  18869. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18870. /**
  18871. * Set a vec2 in the shader from a Vector2.
  18872. * @param name Define the name of the uniform as defined in the shader
  18873. * @param value Define the value to give to the uniform
  18874. * @return the material itself allowing "fluent" like uniform updates
  18875. */
  18876. setVector2(name: string, value: Vector2): ShaderMaterial;
  18877. /**
  18878. * Set a vec3 in the shader from a Vector3.
  18879. * @param name Define the name of the uniform as defined in the shader
  18880. * @param value Define the value to give to the uniform
  18881. * @return the material itself allowing "fluent" like uniform updates
  18882. */
  18883. setVector3(name: string, value: Vector3): ShaderMaterial;
  18884. /**
  18885. * Set a vec4 in the shader from a Vector4.
  18886. * @param name Define the name of the uniform as defined in the shader
  18887. * @param value Define the value to give to the uniform
  18888. * @return the material itself allowing "fluent" like uniform updates
  18889. */
  18890. setVector4(name: string, value: Vector4): ShaderMaterial;
  18891. /**
  18892. * Set a mat4 in the shader from a Matrix.
  18893. * @param name Define the name of the uniform as defined in the shader
  18894. * @param value Define the value to give to the uniform
  18895. * @return the material itself allowing "fluent" like uniform updates
  18896. */
  18897. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18898. /**
  18899. * Set a mat3 in the shader from a Float32Array.
  18900. * @param name Define the name of the uniform as defined in the shader
  18901. * @param value Define the value to give to the uniform
  18902. * @return the material itself allowing "fluent" like uniform updates
  18903. */
  18904. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18905. /**
  18906. * Set a mat2 in the shader from a Float32Array.
  18907. * @param name Define the name of the uniform as defined in the shader
  18908. * @param value Define the value to give to the uniform
  18909. * @return the material itself allowing "fluent" like uniform updates
  18910. */
  18911. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18912. /**
  18913. * Set a vec2 array in the shader from a number array.
  18914. * @param name Define the name of the uniform as defined in the shader
  18915. * @param value Define the value to give to the uniform
  18916. * @return the material itself allowing "fluent" like uniform updates
  18917. */
  18918. setArray2(name: string, value: number[]): ShaderMaterial;
  18919. /**
  18920. * Set a vec3 array in the shader from a number array.
  18921. * @param name Define the name of the uniform as defined in the shader
  18922. * @param value Define the value to give to the uniform
  18923. * @return the material itself allowing "fluent" like uniform updates
  18924. */
  18925. setArray3(name: string, value: number[]): ShaderMaterial;
  18926. /**
  18927. * Set a vec4 array in the shader from a number array.
  18928. * @param name Define the name of the uniform as defined in the shader
  18929. * @param value Define the value to give to the uniform
  18930. * @return the material itself allowing "fluent" like uniform updates
  18931. */
  18932. setArray4(name: string, value: number[]): ShaderMaterial;
  18933. private _checkCache;
  18934. /**
  18935. * Specifies that the submesh is ready to be used
  18936. * @param mesh defines the mesh to check
  18937. * @param subMesh defines which submesh to check
  18938. * @param useInstances specifies that instances should be used
  18939. * @returns a boolean indicating that the submesh is ready or not
  18940. */
  18941. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18942. /**
  18943. * Checks if the material is ready to render the requested mesh
  18944. * @param mesh Define the mesh to render
  18945. * @param useInstances Define whether or not the material is used with instances
  18946. * @returns true if ready, otherwise false
  18947. */
  18948. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18949. /**
  18950. * Binds the world matrix to the material
  18951. * @param world defines the world transformation matrix
  18952. */
  18953. bindOnlyWorldMatrix(world: Matrix): void;
  18954. /**
  18955. * Binds the material to the mesh
  18956. * @param world defines the world transformation matrix
  18957. * @param mesh defines the mesh to bind the material to
  18958. */
  18959. bind(world: Matrix, mesh?: Mesh): void;
  18960. /**
  18961. * Gets the active textures from the material
  18962. * @returns an array of textures
  18963. */
  18964. getActiveTextures(): BaseTexture[];
  18965. /**
  18966. * Specifies if the material uses a texture
  18967. * @param texture defines the texture to check against the material
  18968. * @returns a boolean specifying if the material uses the texture
  18969. */
  18970. hasTexture(texture: BaseTexture): boolean;
  18971. /**
  18972. * Makes a duplicate of the material, and gives it a new name
  18973. * @param name defines the new name for the duplicated material
  18974. * @returns the cloned material
  18975. */
  18976. clone(name: string): ShaderMaterial;
  18977. /**
  18978. * Disposes the material
  18979. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18980. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18981. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18982. */
  18983. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18984. /**
  18985. * Serializes this material in a JSON representation
  18986. * @returns the serialized material object
  18987. */
  18988. serialize(): any;
  18989. /**
  18990. * Creates a shader material from parsed shader material data
  18991. * @param source defines the JSON represnetation of the material
  18992. * @param scene defines the hosting scene
  18993. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18994. * @returns a new material
  18995. */
  18996. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18997. }
  18998. }
  18999. declare module BABYLON {
  19000. /** @hidden */
  19001. export var colorPixelShader: {
  19002. name: string;
  19003. shader: string;
  19004. };
  19005. }
  19006. declare module BABYLON {
  19007. /** @hidden */
  19008. export var colorVertexShader: {
  19009. name: string;
  19010. shader: string;
  19011. };
  19012. }
  19013. declare module BABYLON {
  19014. /**
  19015. * Line mesh
  19016. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19017. */
  19018. export class LinesMesh extends Mesh {
  19019. /**
  19020. * If vertex color should be applied to the mesh
  19021. */
  19022. readonly useVertexColor?: boolean | undefined;
  19023. /**
  19024. * If vertex alpha should be applied to the mesh
  19025. */
  19026. readonly useVertexAlpha?: boolean | undefined;
  19027. /**
  19028. * Color of the line (Default: White)
  19029. */
  19030. color: Color3;
  19031. /**
  19032. * Alpha of the line (Default: 1)
  19033. */
  19034. alpha: number;
  19035. /**
  19036. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19037. * This margin is expressed in world space coordinates, so its value may vary.
  19038. * Default value is 0.1
  19039. */
  19040. intersectionThreshold: number;
  19041. private _colorShader;
  19042. private color4;
  19043. /**
  19044. * Creates a new LinesMesh
  19045. * @param name defines the name
  19046. * @param scene defines the hosting scene
  19047. * @param parent defines the parent mesh if any
  19048. * @param source defines the optional source LinesMesh used to clone data from
  19049. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19050. * When false, achieved by calling a clone(), also passing False.
  19051. * This will make creation of children, recursive.
  19052. * @param useVertexColor defines if this LinesMesh supports vertex color
  19053. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19054. */
  19055. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19056. /**
  19057. * If vertex color should be applied to the mesh
  19058. */
  19059. useVertexColor?: boolean | undefined,
  19060. /**
  19061. * If vertex alpha should be applied to the mesh
  19062. */
  19063. useVertexAlpha?: boolean | undefined);
  19064. private _addClipPlaneDefine;
  19065. private _removeClipPlaneDefine;
  19066. isReady(): boolean;
  19067. /**
  19068. * Returns the string "LineMesh"
  19069. */
  19070. getClassName(): string;
  19071. /**
  19072. * @hidden
  19073. */
  19074. /**
  19075. * @hidden
  19076. */
  19077. material: Material;
  19078. /**
  19079. * @hidden
  19080. */
  19081. readonly checkCollisions: boolean;
  19082. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19083. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19084. /**
  19085. * Disposes of the line mesh
  19086. * @param doNotRecurse If children should be disposed
  19087. */
  19088. dispose(doNotRecurse?: boolean): void;
  19089. /**
  19090. * Returns a new LineMesh object cloned from the current one.
  19091. */
  19092. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19093. /**
  19094. * Creates a new InstancedLinesMesh object from the mesh model.
  19095. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19096. * @param name defines the name of the new instance
  19097. * @returns a new InstancedLinesMesh
  19098. */
  19099. createInstance(name: string): InstancedLinesMesh;
  19100. }
  19101. /**
  19102. * Creates an instance based on a source LinesMesh
  19103. */
  19104. export class InstancedLinesMesh extends InstancedMesh {
  19105. /**
  19106. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19107. * This margin is expressed in world space coordinates, so its value may vary.
  19108. * Initilized with the intersectionThreshold value of the source LinesMesh
  19109. */
  19110. intersectionThreshold: number;
  19111. constructor(name: string, source: LinesMesh);
  19112. /**
  19113. * Returns the string "InstancedLinesMesh".
  19114. */
  19115. getClassName(): string;
  19116. }
  19117. }
  19118. declare module BABYLON {
  19119. /** @hidden */
  19120. export var linePixelShader: {
  19121. name: string;
  19122. shader: string;
  19123. };
  19124. }
  19125. declare module BABYLON {
  19126. /** @hidden */
  19127. export var lineVertexShader: {
  19128. name: string;
  19129. shader: string;
  19130. };
  19131. }
  19132. declare module BABYLON {
  19133. interface AbstractMesh {
  19134. /**
  19135. * Gets the edgesRenderer associated with the mesh
  19136. */
  19137. edgesRenderer: Nullable<EdgesRenderer>;
  19138. }
  19139. interface LinesMesh {
  19140. /**
  19141. * Enables the edge rendering mode on the mesh.
  19142. * This mode makes the mesh edges visible
  19143. * @param epsilon defines the maximal distance between two angles to detect a face
  19144. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19145. * @returns the currentAbstractMesh
  19146. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19147. */
  19148. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19149. }
  19150. interface InstancedLinesMesh {
  19151. /**
  19152. * Enables the edge rendering mode on the mesh.
  19153. * This mode makes the mesh edges visible
  19154. * @param epsilon defines the maximal distance between two angles to detect a face
  19155. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19156. * @returns the current InstancedLinesMesh
  19157. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19158. */
  19159. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19160. }
  19161. /**
  19162. * Defines the minimum contract an Edges renderer should follow.
  19163. */
  19164. export interface IEdgesRenderer extends IDisposable {
  19165. /**
  19166. * Gets or sets a boolean indicating if the edgesRenderer is active
  19167. */
  19168. isEnabled: boolean;
  19169. /**
  19170. * Renders the edges of the attached mesh,
  19171. */
  19172. render(): void;
  19173. /**
  19174. * Checks wether or not the edges renderer is ready to render.
  19175. * @return true if ready, otherwise false.
  19176. */
  19177. isReady(): boolean;
  19178. }
  19179. /**
  19180. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19181. */
  19182. export class EdgesRenderer implements IEdgesRenderer {
  19183. /**
  19184. * Define the size of the edges with an orthographic camera
  19185. */
  19186. edgesWidthScalerForOrthographic: number;
  19187. /**
  19188. * Define the size of the edges with a perspective camera
  19189. */
  19190. edgesWidthScalerForPerspective: number;
  19191. protected _source: AbstractMesh;
  19192. protected _linesPositions: number[];
  19193. protected _linesNormals: number[];
  19194. protected _linesIndices: number[];
  19195. protected _epsilon: number;
  19196. protected _indicesCount: number;
  19197. protected _lineShader: ShaderMaterial;
  19198. protected _ib: DataBuffer;
  19199. protected _buffers: {
  19200. [key: string]: Nullable<VertexBuffer>;
  19201. };
  19202. protected _checkVerticesInsteadOfIndices: boolean;
  19203. private _meshRebuildObserver;
  19204. private _meshDisposeObserver;
  19205. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19206. isEnabled: boolean;
  19207. /**
  19208. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19209. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19210. * @param source Mesh used to create edges
  19211. * @param epsilon sum of angles in adjacency to check for edge
  19212. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19213. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19214. */
  19215. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19216. protected _prepareRessources(): void;
  19217. /** @hidden */ private _rebuild(): void;
  19218. /**
  19219. * Releases the required resources for the edges renderer
  19220. */
  19221. dispose(): void;
  19222. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19223. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19224. /**
  19225. * Checks if the pair of p0 and p1 is en edge
  19226. * @param faceIndex
  19227. * @param edge
  19228. * @param faceNormals
  19229. * @param p0
  19230. * @param p1
  19231. * @private
  19232. */
  19233. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19234. /**
  19235. * push line into the position, normal and index buffer
  19236. * @protected
  19237. */
  19238. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19239. /**
  19240. * Generates lines edges from adjacencjes
  19241. * @private
  19242. */ private _generateEdgesLines(): void;
  19243. /**
  19244. * Checks wether or not the edges renderer is ready to render.
  19245. * @return true if ready, otherwise false.
  19246. */
  19247. isReady(): boolean;
  19248. /**
  19249. * Renders the edges of the attached mesh,
  19250. */
  19251. render(): void;
  19252. }
  19253. /**
  19254. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19255. */
  19256. export class LineEdgesRenderer extends EdgesRenderer {
  19257. /**
  19258. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19259. * @param source LineMesh used to generate edges
  19260. * @param epsilon not important (specified angle for edge detection)
  19261. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19262. */
  19263. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19264. /**
  19265. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19266. */ private _generateEdgesLines(): void;
  19267. }
  19268. }
  19269. declare module BABYLON {
  19270. /**
  19271. * This represents the object necessary to create a rendering group.
  19272. * This is exclusively used and created by the rendering manager.
  19273. * To modify the behavior, you use the available helpers in your scene or meshes.
  19274. * @hidden
  19275. */
  19276. export class RenderingGroup {
  19277. index: number;
  19278. private static _zeroVector;
  19279. private _scene;
  19280. private _opaqueSubMeshes;
  19281. private _transparentSubMeshes;
  19282. private _alphaTestSubMeshes;
  19283. private _depthOnlySubMeshes;
  19284. private _particleSystems;
  19285. private _spriteManagers;
  19286. private _opaqueSortCompareFn;
  19287. private _alphaTestSortCompareFn;
  19288. private _transparentSortCompareFn;
  19289. private _renderOpaque;
  19290. private _renderAlphaTest;
  19291. private _renderTransparent;
  19292. /** @hidden */ private _edgesRenderers: SmartArray<IEdgesRenderer>;
  19293. onBeforeTransparentRendering: () => void;
  19294. /**
  19295. * Set the opaque sort comparison function.
  19296. * If null the sub meshes will be render in the order they were created
  19297. */
  19298. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19299. /**
  19300. * Set the alpha test sort comparison function.
  19301. * If null the sub meshes will be render in the order they were created
  19302. */
  19303. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19304. /**
  19305. * Set the transparent sort comparison function.
  19306. * If null the sub meshes will be render in the order they were created
  19307. */
  19308. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19309. /**
  19310. * Creates a new rendering group.
  19311. * @param index The rendering group index
  19312. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19313. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19314. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19315. */
  19316. 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>);
  19317. /**
  19318. * Render all the sub meshes contained in the group.
  19319. * @param customRenderFunction Used to override the default render behaviour of the group.
  19320. * @returns true if rendered some submeshes.
  19321. */
  19322. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19323. /**
  19324. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19325. * @param subMeshes The submeshes to render
  19326. */
  19327. private renderOpaqueSorted;
  19328. /**
  19329. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19330. * @param subMeshes The submeshes to render
  19331. */
  19332. private renderAlphaTestSorted;
  19333. /**
  19334. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19335. * @param subMeshes The submeshes to render
  19336. */
  19337. private renderTransparentSorted;
  19338. /**
  19339. * Renders the submeshes in a specified order.
  19340. * @param subMeshes The submeshes to sort before render
  19341. * @param sortCompareFn The comparison function use to sort
  19342. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19343. * @param transparent Specifies to activate blending if true
  19344. */
  19345. private static renderSorted;
  19346. /**
  19347. * Renders the submeshes in the order they were dispatched (no sort applied).
  19348. * @param subMeshes The submeshes to render
  19349. */
  19350. private static renderUnsorted;
  19351. /**
  19352. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19353. * are rendered back to front if in the same alpha index.
  19354. *
  19355. * @param a The first submesh
  19356. * @param b The second submesh
  19357. * @returns The result of the comparison
  19358. */
  19359. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19360. /**
  19361. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19362. * are rendered back to front.
  19363. *
  19364. * @param a The first submesh
  19365. * @param b The second submesh
  19366. * @returns The result of the comparison
  19367. */
  19368. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19369. /**
  19370. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19371. * are rendered front to back (prevent overdraw).
  19372. *
  19373. * @param a The first submesh
  19374. * @param b The second submesh
  19375. * @returns The result of the comparison
  19376. */
  19377. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19378. /**
  19379. * Resets the different lists of submeshes to prepare a new frame.
  19380. */
  19381. prepare(): void;
  19382. dispose(): void;
  19383. /**
  19384. * Inserts the submesh in its correct queue depending on its material.
  19385. * @param subMesh The submesh to dispatch
  19386. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19387. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19388. */
  19389. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19390. dispatchSprites(spriteManager: ISpriteManager): void;
  19391. dispatchParticles(particleSystem: IParticleSystem): void;
  19392. private _renderParticles;
  19393. private _renderSprites;
  19394. }
  19395. }
  19396. declare module BABYLON {
  19397. /**
  19398. * Interface describing the different options available in the rendering manager
  19399. * regarding Auto Clear between groups.
  19400. */
  19401. export interface IRenderingManagerAutoClearSetup {
  19402. /**
  19403. * Defines whether or not autoclear is enable.
  19404. */
  19405. autoClear: boolean;
  19406. /**
  19407. * Defines whether or not to autoclear the depth buffer.
  19408. */
  19409. depth: boolean;
  19410. /**
  19411. * Defines whether or not to autoclear the stencil buffer.
  19412. */
  19413. stencil: boolean;
  19414. }
  19415. /**
  19416. * This class is used by the onRenderingGroupObservable
  19417. */
  19418. export class RenderingGroupInfo {
  19419. /**
  19420. * The Scene that being rendered
  19421. */
  19422. scene: Scene;
  19423. /**
  19424. * The camera currently used for the rendering pass
  19425. */
  19426. camera: Nullable<Camera>;
  19427. /**
  19428. * The ID of the renderingGroup being processed
  19429. */
  19430. renderingGroupId: number;
  19431. }
  19432. /**
  19433. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19434. * It is enable to manage the different groups as well as the different necessary sort functions.
  19435. * This should not be used directly aside of the few static configurations
  19436. */
  19437. export class RenderingManager {
  19438. /**
  19439. * The max id used for rendering groups (not included)
  19440. */
  19441. static MAX_RENDERINGGROUPS: number;
  19442. /**
  19443. * The min id used for rendering groups (included)
  19444. */
  19445. static MIN_RENDERINGGROUPS: number;
  19446. /**
  19447. * Used to globally prevent autoclearing scenes.
  19448. */
  19449. static AUTOCLEAR: boolean;
  19450. /**
  19451. * @hidden
  19452. */ private _useSceneAutoClearSetup: boolean;
  19453. private _scene;
  19454. private _renderingGroups;
  19455. private _depthStencilBufferAlreadyCleaned;
  19456. private _autoClearDepthStencil;
  19457. private _customOpaqueSortCompareFn;
  19458. private _customAlphaTestSortCompareFn;
  19459. private _customTransparentSortCompareFn;
  19460. private _renderingGroupInfo;
  19461. /**
  19462. * Instantiates a new rendering group for a particular scene
  19463. * @param scene Defines the scene the groups belongs to
  19464. */
  19465. constructor(scene: Scene);
  19466. private _clearDepthStencilBuffer;
  19467. /**
  19468. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19469. * @hidden
  19470. */
  19471. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19472. /**
  19473. * Resets the different information of the group to prepare a new frame
  19474. * @hidden
  19475. */
  19476. reset(): void;
  19477. /**
  19478. * Dispose and release the group and its associated resources.
  19479. * @hidden
  19480. */
  19481. dispose(): void;
  19482. /**
  19483. * Clear the info related to rendering groups preventing retention points during dispose.
  19484. */
  19485. freeRenderingGroups(): void;
  19486. private _prepareRenderingGroup;
  19487. /**
  19488. * Add a sprite manager to the rendering manager in order to render it this frame.
  19489. * @param spriteManager Define the sprite manager to render
  19490. */
  19491. dispatchSprites(spriteManager: ISpriteManager): void;
  19492. /**
  19493. * Add a particle system to the rendering manager in order to render it this frame.
  19494. * @param particleSystem Define the particle system to render
  19495. */
  19496. dispatchParticles(particleSystem: IParticleSystem): void;
  19497. /**
  19498. * Add a submesh to the manager in order to render it this frame
  19499. * @param subMesh The submesh to dispatch
  19500. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19501. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19502. */
  19503. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19504. /**
  19505. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19506. * This allowed control for front to back rendering or reversly depending of the special needs.
  19507. *
  19508. * @param renderingGroupId The rendering group id corresponding to its index
  19509. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19510. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19511. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19512. */
  19513. 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;
  19514. /**
  19515. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19516. *
  19517. * @param renderingGroupId The rendering group id corresponding to its index
  19518. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19519. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19520. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19521. */
  19522. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19523. /**
  19524. * Gets the current auto clear configuration for one rendering group of the rendering
  19525. * manager.
  19526. * @param index the rendering group index to get the information for
  19527. * @returns The auto clear setup for the requested rendering group
  19528. */
  19529. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19530. }
  19531. }
  19532. declare module BABYLON {
  19533. /**
  19534. * This Helps creating a texture that will be created from a camera in your scene.
  19535. * It is basically a dynamic texture that could be used to create special effects for instance.
  19536. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19537. */
  19538. export class RenderTargetTexture extends Texture {
  19539. isCube: boolean;
  19540. /**
  19541. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19542. */
  19543. static readonly REFRESHRATE_RENDER_ONCE: number;
  19544. /**
  19545. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19546. */
  19547. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19548. /**
  19549. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19550. * the central point of your effect and can save a lot of performances.
  19551. */
  19552. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19553. /**
  19554. * Use this predicate to dynamically define the list of mesh you want to render.
  19555. * If set, the renderList property will be overwritten.
  19556. */
  19557. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19558. private _renderList;
  19559. /**
  19560. * Use this list to define the list of mesh you want to render.
  19561. */
  19562. renderList: Nullable<Array<AbstractMesh>>;
  19563. private _hookArray;
  19564. /**
  19565. * Define if particles should be rendered in your texture.
  19566. */
  19567. renderParticles: boolean;
  19568. /**
  19569. * Define if sprites should be rendered in your texture.
  19570. */
  19571. renderSprites: boolean;
  19572. /**
  19573. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19574. */
  19575. coordinatesMode: number;
  19576. /**
  19577. * Define the camera used to render the texture.
  19578. */
  19579. activeCamera: Nullable<Camera>;
  19580. /**
  19581. * Override the render function of the texture with your own one.
  19582. */
  19583. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19584. /**
  19585. * Define if camera post processes should be use while rendering the texture.
  19586. */
  19587. useCameraPostProcesses: boolean;
  19588. /**
  19589. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19590. */
  19591. ignoreCameraViewport: boolean;
  19592. private _postProcessManager;
  19593. private _postProcesses;
  19594. private _resizeObserver;
  19595. /**
  19596. * An event triggered when the texture is unbind.
  19597. */
  19598. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19599. /**
  19600. * An event triggered when the texture is unbind.
  19601. */
  19602. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19603. private _onAfterUnbindObserver;
  19604. /**
  19605. * Set a after unbind callback in the texture.
  19606. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19607. */
  19608. onAfterUnbind: () => void;
  19609. /**
  19610. * An event triggered before rendering the texture
  19611. */
  19612. onBeforeRenderObservable: Observable<number>;
  19613. private _onBeforeRenderObserver;
  19614. /**
  19615. * Set a before render callback in the texture.
  19616. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19617. */
  19618. onBeforeRender: (faceIndex: number) => void;
  19619. /**
  19620. * An event triggered after rendering the texture
  19621. */
  19622. onAfterRenderObservable: Observable<number>;
  19623. private _onAfterRenderObserver;
  19624. /**
  19625. * Set a after render callback in the texture.
  19626. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19627. */
  19628. onAfterRender: (faceIndex: number) => void;
  19629. /**
  19630. * An event triggered after the texture clear
  19631. */
  19632. onClearObservable: Observable<Engine>;
  19633. private _onClearObserver;
  19634. /**
  19635. * Set a clear callback in the texture.
  19636. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19637. */
  19638. onClear: (Engine: Engine) => void;
  19639. /**
  19640. * An event triggered when the texture is resized.
  19641. */
  19642. onResizeObservable: Observable<RenderTargetTexture>;
  19643. /**
  19644. * Define the clear color of the Render Target if it should be different from the scene.
  19645. */
  19646. clearColor: Color4;
  19647. protected _size: number | {
  19648. width: number;
  19649. height: number;
  19650. };
  19651. protected _initialSizeParameter: number | {
  19652. width: number;
  19653. height: number;
  19654. } | {
  19655. ratio: number;
  19656. };
  19657. protected _sizeRatio: Nullable<number>;
  19658. /** @hidden */ private _generateMipMaps: boolean;
  19659. protected _renderingManager: RenderingManager;
  19660. /** @hidden */ private _waitingRenderList: string[];
  19661. protected _doNotChangeAspectRatio: boolean;
  19662. protected _currentRefreshId: number;
  19663. protected _refreshRate: number;
  19664. protected _textureMatrix: Matrix;
  19665. protected _samples: number;
  19666. protected _renderTargetOptions: RenderTargetCreationOptions;
  19667. /**
  19668. * Gets render target creation options that were used.
  19669. */
  19670. readonly renderTargetOptions: RenderTargetCreationOptions;
  19671. protected _engine: Engine;
  19672. protected _onRatioRescale(): void;
  19673. /**
  19674. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19675. * It must define where the camera used to render the texture is set
  19676. */
  19677. boundingBoxPosition: Vector3;
  19678. private _boundingBoxSize;
  19679. /**
  19680. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19681. * When defined, the cubemap will switch to local mode
  19682. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19683. * @example https://www.babylonjs-playground.com/#RNASML
  19684. */
  19685. boundingBoxSize: Vector3;
  19686. /**
  19687. * In case the RTT has been created with a depth texture, get the associated
  19688. * depth texture.
  19689. * Otherwise, return null.
  19690. */
  19691. depthStencilTexture: Nullable<InternalTexture>;
  19692. /**
  19693. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19694. * or used a shadow, depth texture...
  19695. * @param name The friendly name of the texture
  19696. * @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)
  19697. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19698. * @param generateMipMaps True if mip maps need to be generated after render.
  19699. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19700. * @param type The type of the buffer in the RTT (int, half float, float...)
  19701. * @param isCube True if a cube texture needs to be created
  19702. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19703. * @param generateDepthBuffer True to generate a depth buffer
  19704. * @param generateStencilBuffer True to generate a stencil buffer
  19705. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19706. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19707. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19708. */
  19709. constructor(name: string, size: number | {
  19710. width: number;
  19711. height: number;
  19712. } | {
  19713. ratio: number;
  19714. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19715. /**
  19716. * Creates a depth stencil texture.
  19717. * This is only available in WebGL 2 or with the depth texture extension available.
  19718. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19719. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19720. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19721. */
  19722. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19723. private _processSizeParameter;
  19724. /**
  19725. * Define the number of samples to use in case of MSAA.
  19726. * It defaults to one meaning no MSAA has been enabled.
  19727. */
  19728. samples: number;
  19729. /**
  19730. * Resets the refresh counter of the texture and start bak from scratch.
  19731. * Could be useful to regenerate the texture if it is setup to render only once.
  19732. */
  19733. resetRefreshCounter(): void;
  19734. /**
  19735. * Define the refresh rate of the texture or the rendering frequency.
  19736. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19737. */
  19738. refreshRate: number;
  19739. /**
  19740. * Adds a post process to the render target rendering passes.
  19741. * @param postProcess define the post process to add
  19742. */
  19743. addPostProcess(postProcess: PostProcess): void;
  19744. /**
  19745. * Clear all the post processes attached to the render target
  19746. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19747. */
  19748. clearPostProcesses(dispose?: boolean): void;
  19749. /**
  19750. * Remove one of the post process from the list of attached post processes to the texture
  19751. * @param postProcess define the post process to remove from the list
  19752. */
  19753. removePostProcess(postProcess: PostProcess): void;
  19754. /** @hidden */ private _shouldRender(): boolean;
  19755. /**
  19756. * Gets the actual render size of the texture.
  19757. * @returns the width of the render size
  19758. */
  19759. getRenderSize(): number;
  19760. /**
  19761. * Gets the actual render width of the texture.
  19762. * @returns the width of the render size
  19763. */
  19764. getRenderWidth(): number;
  19765. /**
  19766. * Gets the actual render height of the texture.
  19767. * @returns the height of the render size
  19768. */
  19769. getRenderHeight(): number;
  19770. /**
  19771. * Get if the texture can be rescaled or not.
  19772. */
  19773. readonly canRescale: boolean;
  19774. /**
  19775. * Resize the texture using a ratio.
  19776. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19777. */
  19778. scale(ratio: number): void;
  19779. /**
  19780. * Get the texture reflection matrix used to rotate/transform the reflection.
  19781. * @returns the reflection matrix
  19782. */
  19783. getReflectionTextureMatrix(): Matrix;
  19784. /**
  19785. * Resize the texture to a new desired size.
  19786. * Be carrefull as it will recreate all the data in the new texture.
  19787. * @param size Define the new size. It can be:
  19788. * - a number for squared texture,
  19789. * - an object containing { width: number, height: number }
  19790. * - or an object containing a ratio { ratio: number }
  19791. */
  19792. resize(size: number | {
  19793. width: number;
  19794. height: number;
  19795. } | {
  19796. ratio: number;
  19797. }): void;
  19798. /**
  19799. * Renders all the objects from the render list into the texture.
  19800. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19801. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19802. */
  19803. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19804. private _bestReflectionRenderTargetDimension;
  19805. /**
  19806. * @hidden
  19807. * @param faceIndex face index to bind to if this is a cubetexture
  19808. */ private _bindFrameBuffer(faceIndex?: number): void;
  19809. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19810. private renderToTarget;
  19811. /**
  19812. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19813. * This allowed control for front to back rendering or reversly depending of the special needs.
  19814. *
  19815. * @param renderingGroupId The rendering group id corresponding to its index
  19816. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19817. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19818. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19819. */
  19820. 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;
  19821. /**
  19822. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19823. *
  19824. * @param renderingGroupId The rendering group id corresponding to its index
  19825. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19826. */
  19827. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19828. /**
  19829. * Clones the texture.
  19830. * @returns the cloned texture
  19831. */
  19832. clone(): RenderTargetTexture;
  19833. /**
  19834. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19835. * @returns The JSON representation of the texture
  19836. */
  19837. serialize(): any;
  19838. /**
  19839. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19840. */
  19841. disposeFramebufferObjects(): void;
  19842. /**
  19843. * Dispose the texture and release its associated resources.
  19844. */
  19845. dispose(): void;
  19846. /** @hidden */ private _rebuild(): void;
  19847. /**
  19848. * Clear the info related to rendering groups preventing retention point in material dispose.
  19849. */
  19850. freeRenderingGroups(): void;
  19851. /**
  19852. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19853. * @returns the view count
  19854. */
  19855. getViewCount(): number;
  19856. }
  19857. }
  19858. declare module BABYLON {
  19859. /**
  19860. * Base class for the main features of a material in Babylon.js
  19861. */
  19862. export class Material implements IAnimatable {
  19863. /**
  19864. * Returns the triangle fill mode
  19865. */
  19866. static readonly TriangleFillMode: number;
  19867. /**
  19868. * Returns the wireframe mode
  19869. */
  19870. static readonly WireFrameFillMode: number;
  19871. /**
  19872. * Returns the point fill mode
  19873. */
  19874. static readonly PointFillMode: number;
  19875. /**
  19876. * Returns the point list draw mode
  19877. */
  19878. static readonly PointListDrawMode: number;
  19879. /**
  19880. * Returns the line list draw mode
  19881. */
  19882. static readonly LineListDrawMode: number;
  19883. /**
  19884. * Returns the line loop draw mode
  19885. */
  19886. static readonly LineLoopDrawMode: number;
  19887. /**
  19888. * Returns the line strip draw mode
  19889. */
  19890. static readonly LineStripDrawMode: number;
  19891. /**
  19892. * Returns the triangle strip draw mode
  19893. */
  19894. static readonly TriangleStripDrawMode: number;
  19895. /**
  19896. * Returns the triangle fan draw mode
  19897. */
  19898. static readonly TriangleFanDrawMode: number;
  19899. /**
  19900. * Stores the clock-wise side orientation
  19901. */
  19902. static readonly ClockWiseSideOrientation: number;
  19903. /**
  19904. * Stores the counter clock-wise side orientation
  19905. */
  19906. static readonly CounterClockWiseSideOrientation: number;
  19907. /**
  19908. * The dirty texture flag value
  19909. */
  19910. static readonly TextureDirtyFlag: number;
  19911. /**
  19912. * The dirty light flag value
  19913. */
  19914. static readonly LightDirtyFlag: number;
  19915. /**
  19916. * The dirty fresnel flag value
  19917. */
  19918. static readonly FresnelDirtyFlag: number;
  19919. /**
  19920. * The dirty attribute flag value
  19921. */
  19922. static readonly AttributesDirtyFlag: number;
  19923. /**
  19924. * The dirty misc flag value
  19925. */
  19926. static readonly MiscDirtyFlag: number;
  19927. /**
  19928. * The all dirty flag value
  19929. */
  19930. static readonly AllDirtyFlag: number;
  19931. /**
  19932. * The ID of the material
  19933. */
  19934. id: string;
  19935. /**
  19936. * Gets or sets the unique id of the material
  19937. */
  19938. uniqueId: number;
  19939. /**
  19940. * The name of the material
  19941. */
  19942. name: string;
  19943. /**
  19944. * Gets or sets user defined metadata
  19945. */
  19946. metadata: any;
  19947. /**
  19948. * For internal use only. Please do not use.
  19949. */
  19950. reservedDataStore: any;
  19951. /**
  19952. * Specifies if the ready state should be checked on each call
  19953. */
  19954. checkReadyOnEveryCall: boolean;
  19955. /**
  19956. * Specifies if the ready state should be checked once
  19957. */
  19958. checkReadyOnlyOnce: boolean;
  19959. /**
  19960. * The state of the material
  19961. */
  19962. state: string;
  19963. /**
  19964. * The alpha value of the material
  19965. */
  19966. protected _alpha: number;
  19967. /**
  19968. * List of inspectable custom properties (used by the Inspector)
  19969. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19970. */
  19971. inspectableCustomProperties: IInspectable[];
  19972. /**
  19973. * Sets the alpha value of the material
  19974. */
  19975. /**
  19976. * Gets the alpha value of the material
  19977. */
  19978. alpha: number;
  19979. /**
  19980. * Specifies if back face culling is enabled
  19981. */
  19982. protected _backFaceCulling: boolean;
  19983. /**
  19984. * Sets the back-face culling state
  19985. */
  19986. /**
  19987. * Gets the back-face culling state
  19988. */
  19989. backFaceCulling: boolean;
  19990. /**
  19991. * Stores the value for side orientation
  19992. */
  19993. sideOrientation: number;
  19994. /**
  19995. * Callback triggered when the material is compiled
  19996. */
  19997. onCompiled: Nullable<(effect: Effect) => void>;
  19998. /**
  19999. * Callback triggered when an error occurs
  20000. */
  20001. onError: Nullable<(effect: Effect, errors: string) => void>;
  20002. /**
  20003. * Callback triggered to get the render target textures
  20004. */
  20005. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20006. /**
  20007. * Gets a boolean indicating that current material needs to register RTT
  20008. */
  20009. readonly hasRenderTargetTextures: boolean;
  20010. /**
  20011. * Specifies if the material should be serialized
  20012. */
  20013. doNotSerialize: boolean;
  20014. /**
  20015. * @hidden
  20016. */ private _storeEffectOnSubMeshes: boolean;
  20017. /**
  20018. * Stores the animations for the material
  20019. */
  20020. animations: Nullable<Array<Animation>>;
  20021. /**
  20022. * An event triggered when the material is disposed
  20023. */
  20024. onDisposeObservable: Observable<Material>;
  20025. /**
  20026. * An observer which watches for dispose events
  20027. */
  20028. private _onDisposeObserver;
  20029. private _onUnBindObservable;
  20030. /**
  20031. * Called during a dispose event
  20032. */
  20033. onDispose: () => void;
  20034. private _onBindObservable;
  20035. /**
  20036. * An event triggered when the material is bound
  20037. */
  20038. readonly onBindObservable: Observable<AbstractMesh>;
  20039. /**
  20040. * An observer which watches for bind events
  20041. */
  20042. private _onBindObserver;
  20043. /**
  20044. * Called during a bind event
  20045. */
  20046. onBind: (Mesh: AbstractMesh) => void;
  20047. /**
  20048. * An event triggered when the material is unbound
  20049. */
  20050. readonly onUnBindObservable: Observable<Material>;
  20051. /**
  20052. * Stores the value of the alpha mode
  20053. */
  20054. private _alphaMode;
  20055. /**
  20056. * Sets the value of the alpha mode.
  20057. *
  20058. * | Value | Type | Description |
  20059. * | --- | --- | --- |
  20060. * | 0 | ALPHA_DISABLE | |
  20061. * | 1 | ALPHA_ADD | |
  20062. * | 2 | ALPHA_COMBINE | |
  20063. * | 3 | ALPHA_SUBTRACT | |
  20064. * | 4 | ALPHA_MULTIPLY | |
  20065. * | 5 | ALPHA_MAXIMIZED | |
  20066. * | 6 | ALPHA_ONEONE | |
  20067. * | 7 | ALPHA_PREMULTIPLIED | |
  20068. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20069. * | 9 | ALPHA_INTERPOLATE | |
  20070. * | 10 | ALPHA_SCREENMODE | |
  20071. *
  20072. */
  20073. /**
  20074. * Gets the value of the alpha mode
  20075. */
  20076. alphaMode: number;
  20077. /**
  20078. * Stores the state of the need depth pre-pass value
  20079. */
  20080. private _needDepthPrePass;
  20081. /**
  20082. * Sets the need depth pre-pass value
  20083. */
  20084. /**
  20085. * Gets the depth pre-pass value
  20086. */
  20087. needDepthPrePass: boolean;
  20088. /**
  20089. * Specifies if depth writing should be disabled
  20090. */
  20091. disableDepthWrite: boolean;
  20092. /**
  20093. * Specifies if depth writing should be forced
  20094. */
  20095. forceDepthWrite: boolean;
  20096. /**
  20097. * Specifies if there should be a separate pass for culling
  20098. */
  20099. separateCullingPass: boolean;
  20100. /**
  20101. * Stores the state specifing if fog should be enabled
  20102. */
  20103. private _fogEnabled;
  20104. /**
  20105. * Sets the state for enabling fog
  20106. */
  20107. /**
  20108. * Gets the value of the fog enabled state
  20109. */
  20110. fogEnabled: boolean;
  20111. /**
  20112. * Stores the size of points
  20113. */
  20114. pointSize: number;
  20115. /**
  20116. * Stores the z offset value
  20117. */
  20118. zOffset: number;
  20119. /**
  20120. * Gets a value specifying if wireframe mode is enabled
  20121. */
  20122. /**
  20123. * Sets the state of wireframe mode
  20124. */
  20125. wireframe: boolean;
  20126. /**
  20127. * Gets the value specifying if point clouds are enabled
  20128. */
  20129. /**
  20130. * Sets the state of point cloud mode
  20131. */
  20132. pointsCloud: boolean;
  20133. /**
  20134. * Gets the material fill mode
  20135. */
  20136. /**
  20137. * Sets the material fill mode
  20138. */
  20139. fillMode: number;
  20140. /**
  20141. * @hidden
  20142. * Stores the effects for the material
  20143. */ private _effect: Nullable<Effect>;
  20144. /**
  20145. * @hidden
  20146. * Specifies if the material was previously ready
  20147. */ private _wasPreviouslyReady: boolean;
  20148. /**
  20149. * Specifies if uniform buffers should be used
  20150. */
  20151. private _useUBO;
  20152. /**
  20153. * Stores a reference to the scene
  20154. */
  20155. private _scene;
  20156. /**
  20157. * Stores the fill mode state
  20158. */
  20159. private _fillMode;
  20160. /**
  20161. * Specifies if the depth write state should be cached
  20162. */
  20163. private _cachedDepthWriteState;
  20164. /**
  20165. * Stores the uniform buffer
  20166. */
  20167. protected _uniformBuffer: UniformBuffer;
  20168. /** @hidden */ private _indexInSceneMaterialArray: number;
  20169. /** @hidden */
  20170. meshMap: Nullable<{
  20171. [id: string]: AbstractMesh | undefined;
  20172. }>;
  20173. /**
  20174. * Creates a material instance
  20175. * @param name defines the name of the material
  20176. * @param scene defines the scene to reference
  20177. * @param doNotAdd specifies if the material should be added to the scene
  20178. */
  20179. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20180. /**
  20181. * Returns a string representation of the current material
  20182. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20183. * @returns a string with material information
  20184. */
  20185. toString(fullDetails?: boolean): string;
  20186. /**
  20187. * Gets the class name of the material
  20188. * @returns a string with the class name of the material
  20189. */
  20190. getClassName(): string;
  20191. /**
  20192. * Specifies if updates for the material been locked
  20193. */
  20194. readonly isFrozen: boolean;
  20195. /**
  20196. * Locks updates for the material
  20197. */
  20198. freeze(): void;
  20199. /**
  20200. * Unlocks updates for the material
  20201. */
  20202. unfreeze(): void;
  20203. /**
  20204. * Specifies if the material is ready to be used
  20205. * @param mesh defines the mesh to check
  20206. * @param useInstances specifies if instances should be used
  20207. * @returns a boolean indicating if the material is ready to be used
  20208. */
  20209. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20210. /**
  20211. * Specifies that the submesh is ready to be used
  20212. * @param mesh defines the mesh to check
  20213. * @param subMesh defines which submesh to check
  20214. * @param useInstances specifies that instances should be used
  20215. * @returns a boolean indicating that the submesh is ready or not
  20216. */
  20217. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20218. /**
  20219. * Returns the material effect
  20220. * @returns the effect associated with the material
  20221. */
  20222. getEffect(): Nullable<Effect>;
  20223. /**
  20224. * Returns the current scene
  20225. * @returns a Scene
  20226. */
  20227. getScene(): Scene;
  20228. /**
  20229. * Specifies if the material will require alpha blending
  20230. * @returns a boolean specifying if alpha blending is needed
  20231. */
  20232. needAlphaBlending(): boolean;
  20233. /**
  20234. * Specifies if the mesh will require alpha blending
  20235. * @param mesh defines the mesh to check
  20236. * @returns a boolean specifying if alpha blending is needed for the mesh
  20237. */
  20238. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20239. /**
  20240. * Specifies if this material should be rendered in alpha test mode
  20241. * @returns a boolean specifying if an alpha test is needed.
  20242. */
  20243. needAlphaTesting(): boolean;
  20244. /**
  20245. * Gets the texture used for the alpha test
  20246. * @returns the texture to use for alpha testing
  20247. */
  20248. getAlphaTestTexture(): Nullable<BaseTexture>;
  20249. /**
  20250. * Marks the material to indicate that it needs to be re-calculated
  20251. */
  20252. markDirty(): void;
  20253. /** @hidden */ private _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20254. /**
  20255. * Binds the material to the mesh
  20256. * @param world defines the world transformation matrix
  20257. * @param mesh defines the mesh to bind the material to
  20258. */
  20259. bind(world: Matrix, mesh?: Mesh): void;
  20260. /**
  20261. * Binds the submesh to the material
  20262. * @param world defines the world transformation matrix
  20263. * @param mesh defines the mesh containing the submesh
  20264. * @param subMesh defines the submesh to bind the material to
  20265. */
  20266. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20267. /**
  20268. * Binds the world matrix to the material
  20269. * @param world defines the world transformation matrix
  20270. */
  20271. bindOnlyWorldMatrix(world: Matrix): void;
  20272. /**
  20273. * Binds the scene's uniform buffer to the effect.
  20274. * @param effect defines the effect to bind to the scene uniform buffer
  20275. * @param sceneUbo defines the uniform buffer storing scene data
  20276. */
  20277. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20278. /**
  20279. * Binds the view matrix to the effect
  20280. * @param effect defines the effect to bind the view matrix to
  20281. */
  20282. bindView(effect: Effect): void;
  20283. /**
  20284. * Binds the view projection matrix to the effect
  20285. * @param effect defines the effect to bind the view projection matrix to
  20286. */
  20287. bindViewProjection(effect: Effect): void;
  20288. /**
  20289. * Specifies if material alpha testing should be turned on for the mesh
  20290. * @param mesh defines the mesh to check
  20291. */
  20292. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20293. /**
  20294. * Processes to execute after binding the material to a mesh
  20295. * @param mesh defines the rendered mesh
  20296. */
  20297. protected _afterBind(mesh?: Mesh): void;
  20298. /**
  20299. * Unbinds the material from the mesh
  20300. */
  20301. unbind(): void;
  20302. /**
  20303. * Gets the active textures from the material
  20304. * @returns an array of textures
  20305. */
  20306. getActiveTextures(): BaseTexture[];
  20307. /**
  20308. * Specifies if the material uses a texture
  20309. * @param texture defines the texture to check against the material
  20310. * @returns a boolean specifying if the material uses the texture
  20311. */
  20312. hasTexture(texture: BaseTexture): boolean;
  20313. /**
  20314. * Makes a duplicate of the material, and gives it a new name
  20315. * @param name defines the new name for the duplicated material
  20316. * @returns the cloned material
  20317. */
  20318. clone(name: string): Nullable<Material>;
  20319. /**
  20320. * Gets the meshes bound to the material
  20321. * @returns an array of meshes bound to the material
  20322. */
  20323. getBindedMeshes(): AbstractMesh[];
  20324. /**
  20325. * Force shader compilation
  20326. * @param mesh defines the mesh associated with this material
  20327. * @param onCompiled defines a function to execute once the material is compiled
  20328. * @param options defines the options to configure the compilation
  20329. */
  20330. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20331. clipPlane: boolean;
  20332. }>): void;
  20333. /**
  20334. * Force shader compilation
  20335. * @param mesh defines the mesh that will use this material
  20336. * @param options defines additional options for compiling the shaders
  20337. * @returns a promise that resolves when the compilation completes
  20338. */
  20339. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20340. clipPlane: boolean;
  20341. }>): Promise<void>;
  20342. private static readonly _AllDirtyCallBack;
  20343. private static readonly _ImageProcessingDirtyCallBack;
  20344. private static readonly _TextureDirtyCallBack;
  20345. private static readonly _FresnelDirtyCallBack;
  20346. private static readonly _MiscDirtyCallBack;
  20347. private static readonly _LightsDirtyCallBack;
  20348. private static readonly _AttributeDirtyCallBack;
  20349. private static _FresnelAndMiscDirtyCallBack;
  20350. private static _TextureAndMiscDirtyCallBack;
  20351. private static readonly _DirtyCallbackArray;
  20352. private static readonly _RunDirtyCallBacks;
  20353. /**
  20354. * Marks a define in the material to indicate that it needs to be re-computed
  20355. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20356. */
  20357. markAsDirty(flag: number): void;
  20358. /**
  20359. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20360. * @param func defines a function which checks material defines against the submeshes
  20361. */
  20362. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20363. /**
  20364. * Indicates that we need to re-calculated for all submeshes
  20365. */
  20366. protected _markAllSubMeshesAsAllDirty(): void;
  20367. /**
  20368. * Indicates that image processing needs to be re-calculated for all submeshes
  20369. */
  20370. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20371. /**
  20372. * Indicates that textures need to be re-calculated for all submeshes
  20373. */
  20374. protected _markAllSubMeshesAsTexturesDirty(): void;
  20375. /**
  20376. * Indicates that fresnel needs to be re-calculated for all submeshes
  20377. */
  20378. protected _markAllSubMeshesAsFresnelDirty(): void;
  20379. /**
  20380. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20381. */
  20382. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20383. /**
  20384. * Indicates that lights need to be re-calculated for all submeshes
  20385. */
  20386. protected _markAllSubMeshesAsLightsDirty(): void;
  20387. /**
  20388. * Indicates that attributes need to be re-calculated for all submeshes
  20389. */
  20390. protected _markAllSubMeshesAsAttributesDirty(): void;
  20391. /**
  20392. * Indicates that misc needs to be re-calculated for all submeshes
  20393. */
  20394. protected _markAllSubMeshesAsMiscDirty(): void;
  20395. /**
  20396. * Indicates that textures and misc need to be re-calculated for all submeshes
  20397. */
  20398. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20399. /**
  20400. * Disposes the material
  20401. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20402. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20403. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20404. */
  20405. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20406. /** @hidden */
  20407. private releaseVertexArrayObject;
  20408. /**
  20409. * Serializes this material
  20410. * @returns the serialized material object
  20411. */
  20412. serialize(): any;
  20413. /**
  20414. * Creates a material from parsed material data
  20415. * @param parsedMaterial defines parsed material data
  20416. * @param scene defines the hosting scene
  20417. * @param rootUrl defines the root URL to use to load textures
  20418. * @returns a new material
  20419. */
  20420. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20421. }
  20422. }
  20423. declare module BABYLON {
  20424. /**
  20425. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20426. * separate meshes. This can be use to improve performances.
  20427. * @see http://doc.babylonjs.com/how_to/multi_materials
  20428. */
  20429. export class MultiMaterial extends Material {
  20430. private _subMaterials;
  20431. /**
  20432. * Gets or Sets the list of Materials used within the multi material.
  20433. * They need to be ordered according to the submeshes order in the associated mesh
  20434. */
  20435. subMaterials: Nullable<Material>[];
  20436. /**
  20437. * Function used to align with Node.getChildren()
  20438. * @returns the list of Materials used within the multi material
  20439. */
  20440. getChildren(): Nullable<Material>[];
  20441. /**
  20442. * Instantiates a new Multi Material
  20443. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20444. * separate meshes. This can be use to improve performances.
  20445. * @see http://doc.babylonjs.com/how_to/multi_materials
  20446. * @param name Define the name in the scene
  20447. * @param scene Define the scene the material belongs to
  20448. */
  20449. constructor(name: string, scene: Scene);
  20450. private _hookArray;
  20451. /**
  20452. * Get one of the submaterial by its index in the submaterials array
  20453. * @param index The index to look the sub material at
  20454. * @returns The Material if the index has been defined
  20455. */
  20456. getSubMaterial(index: number): Nullable<Material>;
  20457. /**
  20458. * Get the list of active textures for the whole sub materials list.
  20459. * @returns All the textures that will be used during the rendering
  20460. */
  20461. getActiveTextures(): BaseTexture[];
  20462. /**
  20463. * Gets the current class name of the material e.g. "MultiMaterial"
  20464. * Mainly use in serialization.
  20465. * @returns the class name
  20466. */
  20467. getClassName(): string;
  20468. /**
  20469. * Checks if the material is ready to render the requested sub mesh
  20470. * @param mesh Define the mesh the submesh belongs to
  20471. * @param subMesh Define the sub mesh to look readyness for
  20472. * @param useInstances Define whether or not the material is used with instances
  20473. * @returns true if ready, otherwise false
  20474. */
  20475. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20476. /**
  20477. * Clones the current material and its related sub materials
  20478. * @param name Define the name of the newly cloned material
  20479. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20480. * @returns the cloned material
  20481. */
  20482. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20483. /**
  20484. * Serializes the materials into a JSON representation.
  20485. * @returns the JSON representation
  20486. */
  20487. serialize(): any;
  20488. /**
  20489. * Dispose the material and release its associated resources
  20490. * @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)
  20491. * @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)
  20492. * @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)
  20493. */
  20494. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20495. /**
  20496. * Creates a MultiMaterial from parsed MultiMaterial data.
  20497. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20498. * @param scene defines the hosting scene
  20499. * @returns a new MultiMaterial
  20500. */
  20501. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20502. }
  20503. }
  20504. declare module BABYLON {
  20505. /**
  20506. * Base class for submeshes
  20507. */
  20508. export class BaseSubMesh {
  20509. /** @hidden */ private _materialDefines: Nullable<MaterialDefines>;
  20510. /** @hidden */ private _materialEffect: Nullable<Effect>;
  20511. /**
  20512. * Gets associated effect
  20513. */
  20514. readonly effect: Nullable<Effect>;
  20515. /**
  20516. * Sets associated effect (effect used to render this submesh)
  20517. * @param effect defines the effect to associate with
  20518. * @param defines defines the set of defines used to compile this effect
  20519. */
  20520. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20521. }
  20522. /**
  20523. * Defines a subdivision inside a mesh
  20524. */
  20525. export class SubMesh extends BaseSubMesh implements ICullable {
  20526. /** the material index to use */
  20527. materialIndex: number;
  20528. /** vertex index start */
  20529. verticesStart: number;
  20530. /** vertices count */
  20531. verticesCount: number;
  20532. /** index start */
  20533. indexStart: number;
  20534. /** indices count */
  20535. indexCount: number;
  20536. /** @hidden */ private _linesIndexCount: number;
  20537. private _mesh;
  20538. private _renderingMesh;
  20539. private _boundingInfo;
  20540. private _linesIndexBuffer;
  20541. /** @hidden */ private _lastColliderWorldVertices: Nullable<Vector3[]>;
  20542. /** @hidden */ private _trianglePlanes: Plane[];
  20543. /** @hidden */ private _lastColliderTransformMatrix: Nullable<Matrix>;
  20544. /** @hidden */ private _renderId: number;
  20545. /** @hidden */ private _alphaIndex: number;
  20546. /** @hidden */ private _distanceToCamera: number;
  20547. /** @hidden */ private _id: number;
  20548. private _currentMaterial;
  20549. /**
  20550. * Add a new submesh to a mesh
  20551. * @param materialIndex defines the material index to use
  20552. * @param verticesStart defines vertex index start
  20553. * @param verticesCount defines vertices count
  20554. * @param indexStart defines index start
  20555. * @param indexCount defines indices count
  20556. * @param mesh defines the parent mesh
  20557. * @param renderingMesh defines an optional rendering mesh
  20558. * @param createBoundingBox defines if bounding box should be created for this submesh
  20559. * @returns the new submesh
  20560. */
  20561. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20562. /**
  20563. * Creates a new submesh
  20564. * @param materialIndex defines the material index to use
  20565. * @param verticesStart defines vertex index start
  20566. * @param verticesCount defines vertices count
  20567. * @param indexStart defines index start
  20568. * @param indexCount defines indices count
  20569. * @param mesh defines the parent mesh
  20570. * @param renderingMesh defines an optional rendering mesh
  20571. * @param createBoundingBox defines if bounding box should be created for this submesh
  20572. */
  20573. constructor(
  20574. /** the material index to use */
  20575. materialIndex: number,
  20576. /** vertex index start */
  20577. verticesStart: number,
  20578. /** vertices count */
  20579. verticesCount: number,
  20580. /** index start */
  20581. indexStart: number,
  20582. /** indices count */
  20583. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20584. /**
  20585. * Returns true if this submesh covers the entire parent mesh
  20586. * @ignorenaming
  20587. */
  20588. readonly IsGlobal: boolean;
  20589. /**
  20590. * Returns the submesh BoudingInfo object
  20591. * @returns current bounding info (or mesh's one if the submesh is global)
  20592. */
  20593. getBoundingInfo(): BoundingInfo;
  20594. /**
  20595. * Sets the submesh BoundingInfo
  20596. * @param boundingInfo defines the new bounding info to use
  20597. * @returns the SubMesh
  20598. */
  20599. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20600. /**
  20601. * Returns the mesh of the current submesh
  20602. * @return the parent mesh
  20603. */
  20604. getMesh(): AbstractMesh;
  20605. /**
  20606. * Returns the rendering mesh of the submesh
  20607. * @returns the rendering mesh (could be different from parent mesh)
  20608. */
  20609. getRenderingMesh(): Mesh;
  20610. /**
  20611. * Returns the submesh material
  20612. * @returns null or the current material
  20613. */
  20614. getMaterial(): Nullable<Material>;
  20615. /**
  20616. * Sets a new updated BoundingInfo object to the submesh
  20617. * @param data defines an optional position array to use to determine the bounding info
  20618. * @returns the SubMesh
  20619. */
  20620. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20621. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  20622. /**
  20623. * Updates the submesh BoundingInfo
  20624. * @param world defines the world matrix to use to update the bounding info
  20625. * @returns the submesh
  20626. */
  20627. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20628. /**
  20629. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20630. * @param frustumPlanes defines the frustum planes
  20631. * @returns true if the submesh is intersecting with the frustum
  20632. */
  20633. isInFrustum(frustumPlanes: Plane[]): boolean;
  20634. /**
  20635. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20636. * @param frustumPlanes defines the frustum planes
  20637. * @returns true if the submesh is inside the frustum
  20638. */
  20639. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20640. /**
  20641. * Renders the submesh
  20642. * @param enableAlphaMode defines if alpha needs to be used
  20643. * @returns the submesh
  20644. */
  20645. render(enableAlphaMode: boolean): SubMesh;
  20646. /**
  20647. * @hidden
  20648. */ private _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20649. /**
  20650. * Checks if the submesh intersects with a ray
  20651. * @param ray defines the ray to test
  20652. * @returns true is the passed ray intersects the submesh bounding box
  20653. */
  20654. canIntersects(ray: Ray): boolean;
  20655. /**
  20656. * Intersects current submesh with a ray
  20657. * @param ray defines the ray to test
  20658. * @param positions defines mesh's positions array
  20659. * @param indices defines mesh's indices array
  20660. * @param fastCheck defines if only bounding info should be used
  20661. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20662. * @returns intersection info or null if no intersection
  20663. */
  20664. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20665. /** @hidden */
  20666. private _intersectLines;
  20667. /** @hidden */
  20668. private _intersectUnIndexedLines;
  20669. /** @hidden */
  20670. private _intersectTriangles;
  20671. /** @hidden */
  20672. private _intersectUnIndexedTriangles;
  20673. /** @hidden */ private _rebuild(): void;
  20674. /**
  20675. * Creates a new submesh from the passed mesh
  20676. * @param newMesh defines the new hosting mesh
  20677. * @param newRenderingMesh defines an optional rendering mesh
  20678. * @returns the new submesh
  20679. */
  20680. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20681. /**
  20682. * Release associated resources
  20683. */
  20684. dispose(): void;
  20685. /**
  20686. * Gets the class name
  20687. * @returns the string "SubMesh".
  20688. */
  20689. getClassName(): string;
  20690. /**
  20691. * Creates a new submesh from indices data
  20692. * @param materialIndex the index of the main mesh material
  20693. * @param startIndex the index where to start the copy in the mesh indices array
  20694. * @param indexCount the number of indices to copy then from the startIndex
  20695. * @param mesh the main mesh to create the submesh from
  20696. * @param renderingMesh the optional rendering mesh
  20697. * @returns a new submesh
  20698. */
  20699. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20700. }
  20701. }
  20702. declare module BABYLON {
  20703. /**
  20704. * Class used to represent data loading progression
  20705. */
  20706. export class SceneLoaderFlags {
  20707. private static _ForceFullSceneLoadingForIncremental;
  20708. private static _ShowLoadingScreen;
  20709. private static _CleanBoneMatrixWeights;
  20710. private static _loggingLevel;
  20711. /**
  20712. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20713. */
  20714. static ForceFullSceneLoadingForIncremental: boolean;
  20715. /**
  20716. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20717. */
  20718. static ShowLoadingScreen: boolean;
  20719. /**
  20720. * Defines the current logging level (while loading the scene)
  20721. * @ignorenaming
  20722. */
  20723. static loggingLevel: number;
  20724. /**
  20725. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20726. */
  20727. static CleanBoneMatrixWeights: boolean;
  20728. }
  20729. }
  20730. declare module BABYLON {
  20731. /**
  20732. * Class used to store geometry data (vertex buffers + index buffer)
  20733. */
  20734. export class Geometry implements IGetSetVerticesData {
  20735. /**
  20736. * Gets or sets the ID of the geometry
  20737. */
  20738. id: string;
  20739. /**
  20740. * Gets or sets the unique ID of the geometry
  20741. */
  20742. uniqueId: number;
  20743. /**
  20744. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20745. */
  20746. delayLoadState: number;
  20747. /**
  20748. * Gets the file containing the data to load when running in delay load state
  20749. */
  20750. delayLoadingFile: Nullable<string>;
  20751. /**
  20752. * Callback called when the geometry is updated
  20753. */
  20754. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20755. private _scene;
  20756. private _engine;
  20757. private _meshes;
  20758. private _totalVertices;
  20759. /** @hidden */ private _indices: IndicesArray;
  20760. /** @hidden */ private _vertexBuffers: {
  20761. [key: string]: VertexBuffer;
  20762. };
  20763. private _isDisposed;
  20764. private _extend;
  20765. private _boundingBias;
  20766. /** @hidden */ private _delayInfo: Array<string>;
  20767. private _indexBuffer;
  20768. private _indexBufferIsUpdatable;
  20769. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  20770. /** @hidden */ private _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20771. /** @hidden */ private _softwareSkinningFrameId: number;
  20772. private _vertexArrayObjects;
  20773. private _updatable;
  20774. /** @hidden */ private _positions: Nullable<Vector3[]>;
  20775. /**
  20776. * 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
  20777. */
  20778. /**
  20779. * 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
  20780. */
  20781. boundingBias: Vector2;
  20782. /**
  20783. * Static function used to attach a new empty geometry to a mesh
  20784. * @param mesh defines the mesh to attach the geometry to
  20785. * @returns the new Geometry
  20786. */
  20787. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20788. /**
  20789. * Creates a new geometry
  20790. * @param id defines the unique ID
  20791. * @param scene defines the hosting scene
  20792. * @param vertexData defines the VertexData used to get geometry data
  20793. * @param updatable defines if geometry must be updatable (false by default)
  20794. * @param mesh defines the mesh that will be associated with the geometry
  20795. */
  20796. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20797. /**
  20798. * Gets the current extend of the geometry
  20799. */
  20800. readonly extend: {
  20801. minimum: Vector3;
  20802. maximum: Vector3;
  20803. };
  20804. /**
  20805. * Gets the hosting scene
  20806. * @returns the hosting Scene
  20807. */
  20808. getScene(): Scene;
  20809. /**
  20810. * Gets the hosting engine
  20811. * @returns the hosting Engine
  20812. */
  20813. getEngine(): Engine;
  20814. /**
  20815. * Defines if the geometry is ready to use
  20816. * @returns true if the geometry is ready to be used
  20817. */
  20818. isReady(): boolean;
  20819. /**
  20820. * Gets a value indicating that the geometry should not be serialized
  20821. */
  20822. readonly doNotSerialize: boolean;
  20823. /** @hidden */ private _rebuild(): void;
  20824. /**
  20825. * Affects all geometry data in one call
  20826. * @param vertexData defines the geometry data
  20827. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20828. */
  20829. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20830. /**
  20831. * Set specific vertex data
  20832. * @param kind defines the data kind (Position, normal, etc...)
  20833. * @param data defines the vertex data to use
  20834. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20835. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20836. */
  20837. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20838. /**
  20839. * Removes a specific vertex data
  20840. * @param kind defines the data kind (Position, normal, etc...)
  20841. */
  20842. removeVerticesData(kind: string): void;
  20843. /**
  20844. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20845. * @param buffer defines the vertex buffer to use
  20846. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20847. */
  20848. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20849. /**
  20850. * Update a specific vertex buffer
  20851. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20852. * It will do nothing if the buffer is not updatable
  20853. * @param kind defines the data kind (Position, normal, etc...)
  20854. * @param data defines the data to use
  20855. * @param offset defines the offset in the target buffer where to store the data
  20856. * @param useBytes set to true if the offset is in bytes
  20857. */
  20858. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20859. /**
  20860. * Update a specific vertex buffer
  20861. * This function will create a new buffer if the current one is not updatable
  20862. * @param kind defines the data kind (Position, normal, etc...)
  20863. * @param data defines the data to use
  20864. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20865. */
  20866. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20867. private _updateBoundingInfo;
  20868. /** @hidden */ private _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20869. /**
  20870. * Gets total number of vertices
  20871. * @returns the total number of vertices
  20872. */
  20873. getTotalVertices(): number;
  20874. /**
  20875. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20876. * @param kind defines the data kind (Position, normal, etc...)
  20877. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20878. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20879. * @returns a float array containing vertex data
  20880. */
  20881. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20882. /**
  20883. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20884. * @param kind defines the data kind (Position, normal, etc...)
  20885. * @returns true if the vertex buffer with the specified kind is updatable
  20886. */
  20887. isVertexBufferUpdatable(kind: string): boolean;
  20888. /**
  20889. * Gets a specific vertex buffer
  20890. * @param kind defines the data kind (Position, normal, etc...)
  20891. * @returns a VertexBuffer
  20892. */
  20893. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20894. /**
  20895. * Returns all vertex buffers
  20896. * @return an object holding all vertex buffers indexed by kind
  20897. */
  20898. getVertexBuffers(): Nullable<{
  20899. [key: string]: VertexBuffer;
  20900. }>;
  20901. /**
  20902. * Gets a boolean indicating if specific vertex buffer is present
  20903. * @param kind defines the data kind (Position, normal, etc...)
  20904. * @returns true if data is present
  20905. */
  20906. isVerticesDataPresent(kind: string): boolean;
  20907. /**
  20908. * Gets a list of all attached data kinds (Position, normal, etc...)
  20909. * @returns a list of string containing all kinds
  20910. */
  20911. getVerticesDataKinds(): string[];
  20912. /**
  20913. * Update index buffer
  20914. * @param indices defines the indices to store in the index buffer
  20915. * @param offset defines the offset in the target buffer where to store the data
  20916. * @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)
  20917. */
  20918. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  20919. /**
  20920. * Creates a new index buffer
  20921. * @param indices defines the indices to store in the index buffer
  20922. * @param totalVertices defines the total number of vertices (could be null)
  20923. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20924. */
  20925. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20926. /**
  20927. * Return the total number of indices
  20928. * @returns the total number of indices
  20929. */
  20930. getTotalIndices(): number;
  20931. /**
  20932. * Gets the index buffer array
  20933. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20934. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20935. * @returns the index buffer array
  20936. */
  20937. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20938. /**
  20939. * Gets the index buffer
  20940. * @return the index buffer
  20941. */
  20942. getIndexBuffer(): Nullable<DataBuffer>;
  20943. /** @hidden */ private _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20944. /**
  20945. * Release the associated resources for a specific mesh
  20946. * @param mesh defines the source mesh
  20947. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20948. */
  20949. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20950. /**
  20951. * Apply current geometry to a given mesh
  20952. * @param mesh defines the mesh to apply geometry to
  20953. */
  20954. applyToMesh(mesh: Mesh): void;
  20955. private _updateExtend;
  20956. private _applyToMesh;
  20957. private notifyUpdate;
  20958. /**
  20959. * Load the geometry if it was flagged as delay loaded
  20960. * @param scene defines the hosting scene
  20961. * @param onLoaded defines a callback called when the geometry is loaded
  20962. */
  20963. load(scene: Scene, onLoaded?: () => void): void;
  20964. private _queueLoad;
  20965. /**
  20966. * Invert the geometry to move from a right handed system to a left handed one.
  20967. */
  20968. toLeftHanded(): void;
  20969. /** @hidden */ private _resetPointsArrayCache(): void;
  20970. /** @hidden */ private _generatePointsArray(): boolean;
  20971. /**
  20972. * Gets a value indicating if the geometry is disposed
  20973. * @returns true if the geometry was disposed
  20974. */
  20975. isDisposed(): boolean;
  20976. private _disposeVertexArrayObjects;
  20977. /**
  20978. * Free all associated resources
  20979. */
  20980. dispose(): void;
  20981. /**
  20982. * Clone the current geometry into a new geometry
  20983. * @param id defines the unique ID of the new geometry
  20984. * @returns a new geometry object
  20985. */
  20986. copy(id: string): Geometry;
  20987. /**
  20988. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20989. * @return a JSON representation of the current geometry data (without the vertices data)
  20990. */
  20991. serialize(): any;
  20992. private toNumberArray;
  20993. /**
  20994. * Serialize all vertices data into a JSON oject
  20995. * @returns a JSON representation of the current geometry data
  20996. */
  20997. serializeVerticeData(): any;
  20998. /**
  20999. * Extracts a clone of a mesh geometry
  21000. * @param mesh defines the source mesh
  21001. * @param id defines the unique ID of the new geometry object
  21002. * @returns the new geometry object
  21003. */
  21004. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21005. /**
  21006. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21007. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21008. * Be aware Math.random() could cause collisions, but:
  21009. * "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"
  21010. * @returns a string containing a new GUID
  21011. */
  21012. static RandomId(): string;
  21013. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21014. private static _CleanMatricesWeights;
  21015. /**
  21016. * Create a new geometry from persisted data (Using .babylon file format)
  21017. * @param parsedVertexData defines the persisted data
  21018. * @param scene defines the hosting scene
  21019. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21020. * @returns the new geometry object
  21021. */
  21022. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21023. }
  21024. }
  21025. declare module BABYLON {
  21026. /**
  21027. * Define an interface for all classes that will get and set the data on vertices
  21028. */
  21029. export interface IGetSetVerticesData {
  21030. /**
  21031. * Gets a boolean indicating if specific vertex data is present
  21032. * @param kind defines the vertex data kind to use
  21033. * @returns true is data kind is present
  21034. */
  21035. isVerticesDataPresent(kind: string): boolean;
  21036. /**
  21037. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21038. * @param kind defines the data kind (Position, normal, etc...)
  21039. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21040. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21041. * @returns a float array containing vertex data
  21042. */
  21043. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21044. /**
  21045. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21046. * @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.
  21047. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21048. * @returns the indices array or an empty array if the mesh has no geometry
  21049. */
  21050. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21051. /**
  21052. * Set specific vertex data
  21053. * @param kind defines the data kind (Position, normal, etc...)
  21054. * @param data defines the vertex data to use
  21055. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21056. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21057. */
  21058. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21059. /**
  21060. * Update a specific associated vertex buffer
  21061. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21062. * - VertexBuffer.PositionKind
  21063. * - VertexBuffer.UVKind
  21064. * - VertexBuffer.UV2Kind
  21065. * - VertexBuffer.UV3Kind
  21066. * - VertexBuffer.UV4Kind
  21067. * - VertexBuffer.UV5Kind
  21068. * - VertexBuffer.UV6Kind
  21069. * - VertexBuffer.ColorKind
  21070. * - VertexBuffer.MatricesIndicesKind
  21071. * - VertexBuffer.MatricesIndicesExtraKind
  21072. * - VertexBuffer.MatricesWeightsKind
  21073. * - VertexBuffer.MatricesWeightsExtraKind
  21074. * @param data defines the data source
  21075. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21076. * @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)
  21077. */
  21078. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21079. /**
  21080. * Creates a new index buffer
  21081. * @param indices defines the indices to store in the index buffer
  21082. * @param totalVertices defines the total number of vertices (could be null)
  21083. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21084. */
  21085. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21086. }
  21087. /**
  21088. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21089. */
  21090. export class VertexData {
  21091. /**
  21092. * Mesh side orientation : usually the external or front surface
  21093. */
  21094. static readonly FRONTSIDE: number;
  21095. /**
  21096. * Mesh side orientation : usually the internal or back surface
  21097. */
  21098. static readonly BACKSIDE: number;
  21099. /**
  21100. * Mesh side orientation : both internal and external or front and back surfaces
  21101. */
  21102. static readonly DOUBLESIDE: number;
  21103. /**
  21104. * Mesh side orientation : by default, `FRONTSIDE`
  21105. */
  21106. static readonly DEFAULTSIDE: number;
  21107. /**
  21108. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21109. */
  21110. positions: Nullable<FloatArray>;
  21111. /**
  21112. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21113. */
  21114. normals: Nullable<FloatArray>;
  21115. /**
  21116. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21117. */
  21118. tangents: Nullable<FloatArray>;
  21119. /**
  21120. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21121. */
  21122. uvs: Nullable<FloatArray>;
  21123. /**
  21124. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21125. */
  21126. uvs2: Nullable<FloatArray>;
  21127. /**
  21128. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21129. */
  21130. uvs3: Nullable<FloatArray>;
  21131. /**
  21132. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21133. */
  21134. uvs4: Nullable<FloatArray>;
  21135. /**
  21136. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21137. */
  21138. uvs5: Nullable<FloatArray>;
  21139. /**
  21140. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21141. */
  21142. uvs6: Nullable<FloatArray>;
  21143. /**
  21144. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21145. */
  21146. colors: Nullable<FloatArray>;
  21147. /**
  21148. * 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).
  21149. */
  21150. matricesIndices: Nullable<FloatArray>;
  21151. /**
  21152. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21153. */
  21154. matricesWeights: Nullable<FloatArray>;
  21155. /**
  21156. * An array extending the number of possible indices
  21157. */
  21158. matricesIndicesExtra: Nullable<FloatArray>;
  21159. /**
  21160. * An array extending the number of possible weights when the number of indices is extended
  21161. */
  21162. matricesWeightsExtra: Nullable<FloatArray>;
  21163. /**
  21164. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21165. */
  21166. indices: Nullable<IndicesArray>;
  21167. /**
  21168. * Uses the passed data array to set the set the values for the specified kind of data
  21169. * @param data a linear array of floating numbers
  21170. * @param kind the type of data that is being set, eg positions, colors etc
  21171. */
  21172. set(data: FloatArray, kind: string): void;
  21173. /**
  21174. * Associates the vertexData to the passed Mesh.
  21175. * Sets it as updatable or not (default `false`)
  21176. * @param mesh the mesh the vertexData is applied to
  21177. * @param updatable when used and having the value true allows new data to update the vertexData
  21178. * @returns the VertexData
  21179. */
  21180. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21181. /**
  21182. * Associates the vertexData to the passed Geometry.
  21183. * Sets it as updatable or not (default `false`)
  21184. * @param geometry the geometry the vertexData is applied to
  21185. * @param updatable when used and having the value true allows new data to update the vertexData
  21186. * @returns VertexData
  21187. */
  21188. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21189. /**
  21190. * Updates the associated mesh
  21191. * @param mesh the mesh to be updated
  21192. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21193. * @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
  21194. * @returns VertexData
  21195. */
  21196. updateMesh(mesh: Mesh): VertexData;
  21197. /**
  21198. * Updates the associated geometry
  21199. * @param geometry the geometry to be updated
  21200. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21201. * @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
  21202. * @returns VertexData.
  21203. */
  21204. updateGeometry(geometry: Geometry): VertexData;
  21205. private _applyTo;
  21206. private _update;
  21207. /**
  21208. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21209. * @param matrix the transforming matrix
  21210. * @returns the VertexData
  21211. */
  21212. transform(matrix: Matrix): VertexData;
  21213. /**
  21214. * Merges the passed VertexData into the current one
  21215. * @param other the VertexData to be merged into the current one
  21216. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21217. * @returns the modified VertexData
  21218. */
  21219. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21220. private _mergeElement;
  21221. private _validate;
  21222. /**
  21223. * Serializes the VertexData
  21224. * @returns a serialized object
  21225. */
  21226. serialize(): any;
  21227. /**
  21228. * Extracts the vertexData from a mesh
  21229. * @param mesh the mesh from which to extract the VertexData
  21230. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21231. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21232. * @returns the object VertexData associated to the passed mesh
  21233. */
  21234. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21235. /**
  21236. * Extracts the vertexData from the geometry
  21237. * @param geometry the geometry from which to extract the VertexData
  21238. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21239. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21240. * @returns the object VertexData associated to the passed mesh
  21241. */
  21242. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21243. private static _ExtractFrom;
  21244. /**
  21245. * Creates the VertexData for a Ribbon
  21246. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21247. * * pathArray array of paths, each of which an array of successive Vector3
  21248. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21249. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21250. * * 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
  21251. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21252. * * 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)
  21253. * * 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)
  21254. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21255. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21256. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21257. * @returns the VertexData of the ribbon
  21258. */
  21259. static CreateRibbon(options: {
  21260. pathArray: Vector3[][];
  21261. closeArray?: boolean;
  21262. closePath?: boolean;
  21263. offset?: number;
  21264. sideOrientation?: number;
  21265. frontUVs?: Vector4;
  21266. backUVs?: Vector4;
  21267. invertUV?: boolean;
  21268. uvs?: Vector2[];
  21269. colors?: Color4[];
  21270. }): VertexData;
  21271. /**
  21272. * Creates the VertexData for a box
  21273. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21274. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21275. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21276. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21277. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21278. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21279. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21280. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21281. * * 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)
  21282. * * 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)
  21283. * @returns the VertexData of the box
  21284. */
  21285. static CreateBox(options: {
  21286. size?: number;
  21287. width?: number;
  21288. height?: number;
  21289. depth?: number;
  21290. faceUV?: Vector4[];
  21291. faceColors?: Color4[];
  21292. sideOrientation?: number;
  21293. frontUVs?: Vector4;
  21294. backUVs?: Vector4;
  21295. }): VertexData;
  21296. /**
  21297. * Creates the VertexData for a tiled box
  21298. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21299. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21300. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21301. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21302. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21303. * @returns the VertexData of the box
  21304. */
  21305. static CreateTiledBox(options: {
  21306. pattern?: number;
  21307. width?: number;
  21308. height?: number;
  21309. depth?: number;
  21310. tileSize?: number;
  21311. tileWidth?: number;
  21312. tileHeight?: number;
  21313. alignHorizontal?: number;
  21314. alignVertical?: number;
  21315. faceUV?: Vector4[];
  21316. faceColors?: Color4[];
  21317. sideOrientation?: number;
  21318. }): VertexData;
  21319. /**
  21320. * Creates the VertexData for a tiled plane
  21321. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21322. * * pattern a limited pattern arrangement depending on the number
  21323. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21324. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21325. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21326. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21327. * * 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)
  21328. * * 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)
  21329. * @returns the VertexData of the tiled plane
  21330. */
  21331. static CreateTiledPlane(options: {
  21332. pattern?: number;
  21333. tileSize?: number;
  21334. tileWidth?: number;
  21335. tileHeight?: number;
  21336. size?: number;
  21337. width?: number;
  21338. height?: number;
  21339. alignHorizontal?: number;
  21340. alignVertical?: number;
  21341. sideOrientation?: number;
  21342. frontUVs?: Vector4;
  21343. backUVs?: Vector4;
  21344. }): VertexData;
  21345. /**
  21346. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21347. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21348. * * segments sets the number of horizontal strips optional, default 32
  21349. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21350. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21351. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21352. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21353. * * 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
  21354. * * 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
  21355. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21356. * * 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)
  21357. * * 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)
  21358. * @returns the VertexData of the ellipsoid
  21359. */
  21360. static CreateSphere(options: {
  21361. segments?: number;
  21362. diameter?: number;
  21363. diameterX?: number;
  21364. diameterY?: number;
  21365. diameterZ?: number;
  21366. arc?: number;
  21367. slice?: number;
  21368. sideOrientation?: number;
  21369. frontUVs?: Vector4;
  21370. backUVs?: Vector4;
  21371. }): VertexData;
  21372. /**
  21373. * Creates the VertexData for a cylinder, cone or prism
  21374. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21375. * * height sets the height (y direction) of the cylinder, optional, default 2
  21376. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21377. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21378. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21379. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21380. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21381. * * 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
  21382. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21383. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21384. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21385. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21386. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21387. * * 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)
  21388. * * 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)
  21389. * @returns the VertexData of the cylinder, cone or prism
  21390. */
  21391. static CreateCylinder(options: {
  21392. height?: number;
  21393. diameterTop?: number;
  21394. diameterBottom?: number;
  21395. diameter?: number;
  21396. tessellation?: number;
  21397. subdivisions?: number;
  21398. arc?: number;
  21399. faceColors?: Color4[];
  21400. faceUV?: Vector4[];
  21401. hasRings?: boolean;
  21402. enclose?: boolean;
  21403. sideOrientation?: number;
  21404. frontUVs?: Vector4;
  21405. backUVs?: Vector4;
  21406. }): VertexData;
  21407. /**
  21408. * Creates the VertexData for a torus
  21409. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21410. * * diameter the diameter of the torus, optional default 1
  21411. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21412. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21413. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21414. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21415. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21416. * @returns the VertexData of the torus
  21417. */
  21418. static CreateTorus(options: {
  21419. diameter?: number;
  21420. thickness?: number;
  21421. tessellation?: number;
  21422. sideOrientation?: number;
  21423. frontUVs?: Vector4;
  21424. backUVs?: Vector4;
  21425. }): VertexData;
  21426. /**
  21427. * Creates the VertexData of the LineSystem
  21428. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21429. * - lines an array of lines, each line being an array of successive Vector3
  21430. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21431. * @returns the VertexData of the LineSystem
  21432. */
  21433. static CreateLineSystem(options: {
  21434. lines: Vector3[][];
  21435. colors?: Nullable<Color4[][]>;
  21436. }): VertexData;
  21437. /**
  21438. * Create the VertexData for a DashedLines
  21439. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21440. * - points an array successive Vector3
  21441. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21442. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21443. * - dashNb the intended total number of dashes, optional, default 200
  21444. * @returns the VertexData for the DashedLines
  21445. */
  21446. static CreateDashedLines(options: {
  21447. points: Vector3[];
  21448. dashSize?: number;
  21449. gapSize?: number;
  21450. dashNb?: number;
  21451. }): VertexData;
  21452. /**
  21453. * Creates the VertexData for a Ground
  21454. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21455. * - width the width (x direction) of the ground, optional, default 1
  21456. * - height the height (z direction) of the ground, optional, default 1
  21457. * - subdivisions the number of subdivisions per side, optional, default 1
  21458. * @returns the VertexData of the Ground
  21459. */
  21460. static CreateGround(options: {
  21461. width?: number;
  21462. height?: number;
  21463. subdivisions?: number;
  21464. subdivisionsX?: number;
  21465. subdivisionsY?: number;
  21466. }): VertexData;
  21467. /**
  21468. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21469. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21470. * * xmin the ground minimum X coordinate, optional, default -1
  21471. * * zmin the ground minimum Z coordinate, optional, default -1
  21472. * * xmax the ground maximum X coordinate, optional, default 1
  21473. * * zmax the ground maximum Z coordinate, optional, default 1
  21474. * * 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}
  21475. * * 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}
  21476. * @returns the VertexData of the TiledGround
  21477. */
  21478. static CreateTiledGround(options: {
  21479. xmin: number;
  21480. zmin: number;
  21481. xmax: number;
  21482. zmax: number;
  21483. subdivisions?: {
  21484. w: number;
  21485. h: number;
  21486. };
  21487. precision?: {
  21488. w: number;
  21489. h: number;
  21490. };
  21491. }): VertexData;
  21492. /**
  21493. * Creates the VertexData of the Ground designed from a heightmap
  21494. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21495. * * width the width (x direction) of the ground
  21496. * * height the height (z direction) of the ground
  21497. * * subdivisions the number of subdivisions per side
  21498. * * minHeight the minimum altitude on the ground, optional, default 0
  21499. * * maxHeight the maximum altitude on the ground, optional default 1
  21500. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21501. * * buffer the array holding the image color data
  21502. * * bufferWidth the width of image
  21503. * * bufferHeight the height of image
  21504. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21505. * @returns the VertexData of the Ground designed from a heightmap
  21506. */
  21507. static CreateGroundFromHeightMap(options: {
  21508. width: number;
  21509. height: number;
  21510. subdivisions: number;
  21511. minHeight: number;
  21512. maxHeight: number;
  21513. colorFilter: Color3;
  21514. buffer: Uint8Array;
  21515. bufferWidth: number;
  21516. bufferHeight: number;
  21517. alphaFilter: number;
  21518. }): VertexData;
  21519. /**
  21520. * Creates the VertexData for a Plane
  21521. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21522. * * size sets the width and height of the plane to the value of size, optional default 1
  21523. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21524. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21525. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21526. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21527. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21528. * @returns the VertexData of the box
  21529. */
  21530. static CreatePlane(options: {
  21531. size?: number;
  21532. width?: number;
  21533. height?: number;
  21534. sideOrientation?: number;
  21535. frontUVs?: Vector4;
  21536. backUVs?: Vector4;
  21537. }): VertexData;
  21538. /**
  21539. * Creates the VertexData of the Disc or regular Polygon
  21540. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21541. * * radius the radius of the disc, optional default 0.5
  21542. * * tessellation the number of polygon sides, optional, default 64
  21543. * * 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
  21544. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21545. * * 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)
  21546. * * 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)
  21547. * @returns the VertexData of the box
  21548. */
  21549. static CreateDisc(options: {
  21550. radius?: number;
  21551. tessellation?: number;
  21552. arc?: number;
  21553. sideOrientation?: number;
  21554. frontUVs?: Vector4;
  21555. backUVs?: Vector4;
  21556. }): VertexData;
  21557. /**
  21558. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21559. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21560. * @param polygon a mesh built from polygonTriangulation.build()
  21561. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21562. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21563. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21564. * @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)
  21565. * @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)
  21566. * @returns the VertexData of the Polygon
  21567. */
  21568. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21569. /**
  21570. * Creates the VertexData of the IcoSphere
  21571. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21572. * * radius the radius of the IcoSphere, optional default 1
  21573. * * radiusX allows stretching in the x direction, optional, default radius
  21574. * * radiusY allows stretching in the y direction, optional, default radius
  21575. * * radiusZ allows stretching in the z direction, optional, default radius
  21576. * * flat when true creates a flat shaded mesh, optional, default true
  21577. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21578. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21579. * * 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)
  21580. * * 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)
  21581. * @returns the VertexData of the IcoSphere
  21582. */
  21583. static CreateIcoSphere(options: {
  21584. radius?: number;
  21585. radiusX?: number;
  21586. radiusY?: number;
  21587. radiusZ?: number;
  21588. flat?: boolean;
  21589. subdivisions?: number;
  21590. sideOrientation?: number;
  21591. frontUVs?: Vector4;
  21592. backUVs?: Vector4;
  21593. }): VertexData;
  21594. /**
  21595. * Creates the VertexData for a Polyhedron
  21596. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21597. * * type provided types are:
  21598. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21599. * * 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)
  21600. * * size the size of the IcoSphere, optional default 1
  21601. * * sizeX allows stretching in the x direction, optional, default size
  21602. * * sizeY allows stretching in the y direction, optional, default size
  21603. * * sizeZ allows stretching in the z direction, optional, default size
  21604. * * 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
  21605. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21606. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21607. * * flat when true creates a flat shaded mesh, optional, default true
  21608. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21609. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21610. * * 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)
  21611. * * 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)
  21612. * @returns the VertexData of the Polyhedron
  21613. */
  21614. static CreatePolyhedron(options: {
  21615. type?: number;
  21616. size?: number;
  21617. sizeX?: number;
  21618. sizeY?: number;
  21619. sizeZ?: number;
  21620. custom?: any;
  21621. faceUV?: Vector4[];
  21622. faceColors?: Color4[];
  21623. flat?: boolean;
  21624. sideOrientation?: number;
  21625. frontUVs?: Vector4;
  21626. backUVs?: Vector4;
  21627. }): VertexData;
  21628. /**
  21629. * Creates the VertexData for a TorusKnot
  21630. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21631. * * radius the radius of the torus knot, optional, default 2
  21632. * * tube the thickness of the tube, optional, default 0.5
  21633. * * radialSegments the number of sides on each tube segments, optional, default 32
  21634. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21635. * * p the number of windings around the z axis, optional, default 2
  21636. * * q the number of windings around the x axis, optional, default 3
  21637. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21638. * * 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)
  21639. * * 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)
  21640. * @returns the VertexData of the Torus Knot
  21641. */
  21642. static CreateTorusKnot(options: {
  21643. radius?: number;
  21644. tube?: number;
  21645. radialSegments?: number;
  21646. tubularSegments?: number;
  21647. p?: number;
  21648. q?: number;
  21649. sideOrientation?: number;
  21650. frontUVs?: Vector4;
  21651. backUVs?: Vector4;
  21652. }): VertexData;
  21653. /**
  21654. * Compute normals for given positions and indices
  21655. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21656. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21657. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21658. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21659. * * facetNormals : optional array of facet normals (vector3)
  21660. * * facetPositions : optional array of facet positions (vector3)
  21661. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21662. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21663. * * bInfo : optional bounding info, required for facetPartitioning computation
  21664. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21665. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21666. * * useRightHandedSystem: optional boolean to for right handed system computation
  21667. * * depthSort : optional boolean to enable the facet depth sort computation
  21668. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21669. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21670. */
  21671. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21672. facetNormals?: any;
  21673. facetPositions?: any;
  21674. facetPartitioning?: any;
  21675. ratio?: number;
  21676. bInfo?: any;
  21677. bbSize?: Vector3;
  21678. subDiv?: any;
  21679. useRightHandedSystem?: boolean;
  21680. depthSort?: boolean;
  21681. distanceTo?: Vector3;
  21682. depthSortedFacets?: any;
  21683. }): void;
  21684. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21685. /**
  21686. * Applies VertexData created from the imported parameters to the geometry
  21687. * @param parsedVertexData the parsed data from an imported file
  21688. * @param geometry the geometry to apply the VertexData to
  21689. */
  21690. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21691. }
  21692. }
  21693. declare module BABYLON {
  21694. /**
  21695. * Defines a target to use with MorphTargetManager
  21696. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21697. */
  21698. export class MorphTarget implements IAnimatable {
  21699. /** defines the name of the target */
  21700. name: string;
  21701. /**
  21702. * Gets or sets the list of animations
  21703. */
  21704. animations: Animation[];
  21705. private _scene;
  21706. private _positions;
  21707. private _normals;
  21708. private _tangents;
  21709. private _uvs;
  21710. private _influence;
  21711. /**
  21712. * Observable raised when the influence changes
  21713. */
  21714. onInfluenceChanged: Observable<boolean>;
  21715. /** @hidden */ private _onDataLayoutChanged: Observable<void>;
  21716. /**
  21717. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21718. */
  21719. influence: number;
  21720. /**
  21721. * Gets or sets the id of the morph Target
  21722. */
  21723. id: string;
  21724. private _animationPropertiesOverride;
  21725. /**
  21726. * Gets or sets the animation properties override
  21727. */
  21728. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21729. /**
  21730. * Creates a new MorphTarget
  21731. * @param name defines the name of the target
  21732. * @param influence defines the influence to use
  21733. * @param scene defines the scene the morphtarget belongs to
  21734. */
  21735. constructor(
  21736. /** defines the name of the target */
  21737. name: string, influence?: number, scene?: Nullable<Scene>);
  21738. /**
  21739. * Gets a boolean defining if the target contains position data
  21740. */
  21741. readonly hasPositions: boolean;
  21742. /**
  21743. * Gets a boolean defining if the target contains normal data
  21744. */
  21745. readonly hasNormals: boolean;
  21746. /**
  21747. * Gets a boolean defining if the target contains tangent data
  21748. */
  21749. readonly hasTangents: boolean;
  21750. /**
  21751. * Gets a boolean defining if the target contains texture coordinates data
  21752. */
  21753. readonly hasUVs: boolean;
  21754. /**
  21755. * Affects position data to this target
  21756. * @param data defines the position data to use
  21757. */
  21758. setPositions(data: Nullable<FloatArray>): void;
  21759. /**
  21760. * Gets the position data stored in this target
  21761. * @returns a FloatArray containing the position data (or null if not present)
  21762. */
  21763. getPositions(): Nullable<FloatArray>;
  21764. /**
  21765. * Affects normal data to this target
  21766. * @param data defines the normal data to use
  21767. */
  21768. setNormals(data: Nullable<FloatArray>): void;
  21769. /**
  21770. * Gets the normal data stored in this target
  21771. * @returns a FloatArray containing the normal data (or null if not present)
  21772. */
  21773. getNormals(): Nullable<FloatArray>;
  21774. /**
  21775. * Affects tangent data to this target
  21776. * @param data defines the tangent data to use
  21777. */
  21778. setTangents(data: Nullable<FloatArray>): void;
  21779. /**
  21780. * Gets the tangent data stored in this target
  21781. * @returns a FloatArray containing the tangent data (or null if not present)
  21782. */
  21783. getTangents(): Nullable<FloatArray>;
  21784. /**
  21785. * Affects texture coordinates data to this target
  21786. * @param data defines the texture coordinates data to use
  21787. */
  21788. setUVs(data: Nullable<FloatArray>): void;
  21789. /**
  21790. * Gets the texture coordinates data stored in this target
  21791. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21792. */
  21793. getUVs(): Nullable<FloatArray>;
  21794. /**
  21795. * Serializes the current target into a Serialization object
  21796. * @returns the serialized object
  21797. */
  21798. serialize(): any;
  21799. /**
  21800. * Returns the string "MorphTarget"
  21801. * @returns "MorphTarget"
  21802. */
  21803. getClassName(): string;
  21804. /**
  21805. * Creates a new target from serialized data
  21806. * @param serializationObject defines the serialized data to use
  21807. * @returns a new MorphTarget
  21808. */
  21809. static Parse(serializationObject: any): MorphTarget;
  21810. /**
  21811. * Creates a MorphTarget from mesh data
  21812. * @param mesh defines the source mesh
  21813. * @param name defines the name to use for the new target
  21814. * @param influence defines the influence to attach to the target
  21815. * @returns a new MorphTarget
  21816. */
  21817. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21818. }
  21819. }
  21820. declare module BABYLON {
  21821. /**
  21822. * This class is used to deform meshes using morphing between different targets
  21823. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21824. */
  21825. export class MorphTargetManager {
  21826. private _targets;
  21827. private _targetInfluenceChangedObservers;
  21828. private _targetDataLayoutChangedObservers;
  21829. private _activeTargets;
  21830. private _scene;
  21831. private _influences;
  21832. private _supportsNormals;
  21833. private _supportsTangents;
  21834. private _supportsUVs;
  21835. private _vertexCount;
  21836. private _uniqueId;
  21837. private _tempInfluences;
  21838. /**
  21839. * Gets or sets a boolean indicating if normals must be morphed
  21840. */
  21841. enableNormalMorphing: boolean;
  21842. /**
  21843. * Gets or sets a boolean indicating if tangents must be morphed
  21844. */
  21845. enableTangentMorphing: boolean;
  21846. /**
  21847. * Gets or sets a boolean indicating if UV must be morphed
  21848. */
  21849. enableUVMorphing: boolean;
  21850. /**
  21851. * Creates a new MorphTargetManager
  21852. * @param scene defines the current scene
  21853. */
  21854. constructor(scene?: Nullable<Scene>);
  21855. /**
  21856. * Gets the unique ID of this manager
  21857. */
  21858. readonly uniqueId: number;
  21859. /**
  21860. * Gets the number of vertices handled by this manager
  21861. */
  21862. readonly vertexCount: number;
  21863. /**
  21864. * Gets a boolean indicating if this manager supports morphing of normals
  21865. */
  21866. readonly supportsNormals: boolean;
  21867. /**
  21868. * Gets a boolean indicating if this manager supports morphing of tangents
  21869. */
  21870. readonly supportsTangents: boolean;
  21871. /**
  21872. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21873. */
  21874. readonly supportsUVs: boolean;
  21875. /**
  21876. * Gets the number of targets stored in this manager
  21877. */
  21878. readonly numTargets: number;
  21879. /**
  21880. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21881. */
  21882. readonly numInfluencers: number;
  21883. /**
  21884. * Gets the list of influences (one per target)
  21885. */
  21886. readonly influences: Float32Array;
  21887. /**
  21888. * Gets the active target at specified index. An active target is a target with an influence > 0
  21889. * @param index defines the index to check
  21890. * @returns the requested target
  21891. */
  21892. getActiveTarget(index: number): MorphTarget;
  21893. /**
  21894. * Gets the target at specified index
  21895. * @param index defines the index to check
  21896. * @returns the requested target
  21897. */
  21898. getTarget(index: number): MorphTarget;
  21899. /**
  21900. * Add a new target to this manager
  21901. * @param target defines the target to add
  21902. */
  21903. addTarget(target: MorphTarget): void;
  21904. /**
  21905. * Removes a target from the manager
  21906. * @param target defines the target to remove
  21907. */
  21908. removeTarget(target: MorphTarget): void;
  21909. /**
  21910. * Serializes the current manager into a Serialization object
  21911. * @returns the serialized object
  21912. */
  21913. serialize(): any;
  21914. private _syncActiveTargets;
  21915. /**
  21916. * Syncrhonize the targets with all the meshes using this morph target manager
  21917. */
  21918. synchronize(): void;
  21919. /**
  21920. * Creates a new MorphTargetManager from serialized data
  21921. * @param serializationObject defines the serialized data
  21922. * @param scene defines the hosting scene
  21923. * @returns the new MorphTargetManager
  21924. */
  21925. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  21926. }
  21927. }
  21928. declare module BABYLON {
  21929. /**
  21930. * Class used to represent a specific level of detail of a mesh
  21931. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21932. */
  21933. export class MeshLODLevel {
  21934. /** Defines the distance where this level should start being displayed */
  21935. distance: number;
  21936. /** Defines the mesh to use to render this level */
  21937. mesh: Nullable<Mesh>;
  21938. /**
  21939. * Creates a new LOD level
  21940. * @param distance defines the distance where this level should star being displayed
  21941. * @param mesh defines the mesh to use to render this level
  21942. */
  21943. constructor(
  21944. /** Defines the distance where this level should start being displayed */
  21945. distance: number,
  21946. /** Defines the mesh to use to render this level */
  21947. mesh: Nullable<Mesh>);
  21948. }
  21949. }
  21950. declare module BABYLON {
  21951. /**
  21952. * Mesh representing the gorund
  21953. */
  21954. export class GroundMesh extends Mesh {
  21955. /** If octree should be generated */
  21956. generateOctree: boolean;
  21957. private _heightQuads;
  21958. /** @hidden */ private _subdivisionsX: number;
  21959. /** @hidden */ private _subdivisionsY: number;
  21960. /** @hidden */ private _width: number;
  21961. /** @hidden */ private _height: number;
  21962. /** @hidden */ private _minX: number;
  21963. /** @hidden */ private _maxX: number;
  21964. /** @hidden */ private _minZ: number;
  21965. /** @hidden */ private _maxZ: number;
  21966. constructor(name: string, scene: Scene);
  21967. /**
  21968. * "GroundMesh"
  21969. * @returns "GroundMesh"
  21970. */
  21971. getClassName(): string;
  21972. /**
  21973. * The minimum of x and y subdivisions
  21974. */
  21975. readonly subdivisions: number;
  21976. /**
  21977. * X subdivisions
  21978. */
  21979. readonly subdivisionsX: number;
  21980. /**
  21981. * Y subdivisions
  21982. */
  21983. readonly subdivisionsY: number;
  21984. /**
  21985. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  21986. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  21987. * @param chunksCount the number of subdivisions for x and y
  21988. * @param octreeBlocksSize (Default: 32)
  21989. */
  21990. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  21991. /**
  21992. * Returns a height (y) value in the Worl system :
  21993. * the ground altitude at the coordinates (x, z) expressed in the World system.
  21994. * @param x x coordinate
  21995. * @param z z coordinate
  21996. * @returns the ground y position if (x, z) are outside the ground surface.
  21997. */
  21998. getHeightAtCoordinates(x: number, z: number): number;
  21999. /**
  22000. * Returns a normalized vector (Vector3) orthogonal to the ground
  22001. * at the ground coordinates (x, z) expressed in the World system.
  22002. * @param x x coordinate
  22003. * @param z z coordinate
  22004. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22005. */
  22006. getNormalAtCoordinates(x: number, z: number): Vector3;
  22007. /**
  22008. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22009. * at the ground coordinates (x, z) expressed in the World system.
  22010. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22011. * @param x x coordinate
  22012. * @param z z coordinate
  22013. * @param ref vector to store the result
  22014. * @returns the GroundMesh.
  22015. */
  22016. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22017. /**
  22018. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22019. * if the ground has been updated.
  22020. * This can be used in the render loop.
  22021. * @returns the GroundMesh.
  22022. */
  22023. updateCoordinateHeights(): GroundMesh;
  22024. private _getFacetAt;
  22025. private _initHeightQuads;
  22026. private _computeHeightQuads;
  22027. /**
  22028. * Serializes this ground mesh
  22029. * @param serializationObject object to write serialization to
  22030. */
  22031. serialize(serializationObject: any): void;
  22032. /**
  22033. * Parses a serialized ground mesh
  22034. * @param parsedMesh the serialized mesh
  22035. * @param scene the scene to create the ground mesh in
  22036. * @returns the created ground mesh
  22037. */
  22038. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22039. }
  22040. }
  22041. declare module BABYLON {
  22042. /**
  22043. * Interface for Physics-Joint data
  22044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22045. */
  22046. export interface PhysicsJointData {
  22047. /**
  22048. * The main pivot of the joint
  22049. */
  22050. mainPivot?: Vector3;
  22051. /**
  22052. * The connected pivot of the joint
  22053. */
  22054. connectedPivot?: Vector3;
  22055. /**
  22056. * The main axis of the joint
  22057. */
  22058. mainAxis?: Vector3;
  22059. /**
  22060. * The connected axis of the joint
  22061. */
  22062. connectedAxis?: Vector3;
  22063. /**
  22064. * The collision of the joint
  22065. */
  22066. collision?: boolean;
  22067. /**
  22068. * Native Oimo/Cannon/Energy data
  22069. */
  22070. nativeParams?: any;
  22071. }
  22072. /**
  22073. * This is a holder class for the physics joint created by the physics plugin
  22074. * It holds a set of functions to control the underlying joint
  22075. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22076. */
  22077. export class PhysicsJoint {
  22078. /**
  22079. * The type of the physics joint
  22080. */
  22081. type: number;
  22082. /**
  22083. * The data for the physics joint
  22084. */
  22085. jointData: PhysicsJointData;
  22086. private _physicsJoint;
  22087. protected _physicsPlugin: IPhysicsEnginePlugin;
  22088. /**
  22089. * Initializes the physics joint
  22090. * @param type The type of the physics joint
  22091. * @param jointData The data for the physics joint
  22092. */
  22093. constructor(
  22094. /**
  22095. * The type of the physics joint
  22096. */
  22097. type: number,
  22098. /**
  22099. * The data for the physics joint
  22100. */
  22101. jointData: PhysicsJointData);
  22102. /**
  22103. * Gets the physics joint
  22104. */
  22105. /**
  22106. * Sets the physics joint
  22107. */
  22108. physicsJoint: any;
  22109. /**
  22110. * Sets the physics plugin
  22111. */
  22112. physicsPlugin: IPhysicsEnginePlugin;
  22113. /**
  22114. * Execute a function that is physics-plugin specific.
  22115. * @param {Function} func the function that will be executed.
  22116. * It accepts two parameters: the physics world and the physics joint
  22117. */
  22118. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22119. /**
  22120. * Distance-Joint type
  22121. */
  22122. static DistanceJoint: number;
  22123. /**
  22124. * Hinge-Joint type
  22125. */
  22126. static HingeJoint: number;
  22127. /**
  22128. * Ball-and-Socket joint type
  22129. */
  22130. static BallAndSocketJoint: number;
  22131. /**
  22132. * Wheel-Joint type
  22133. */
  22134. static WheelJoint: number;
  22135. /**
  22136. * Slider-Joint type
  22137. */
  22138. static SliderJoint: number;
  22139. /**
  22140. * Prismatic-Joint type
  22141. */
  22142. static PrismaticJoint: number;
  22143. /**
  22144. * Universal-Joint type
  22145. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22146. */
  22147. static UniversalJoint: number;
  22148. /**
  22149. * Hinge-Joint 2 type
  22150. */
  22151. static Hinge2Joint: number;
  22152. /**
  22153. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22154. */
  22155. static PointToPointJoint: number;
  22156. /**
  22157. * Spring-Joint type
  22158. */
  22159. static SpringJoint: number;
  22160. /**
  22161. * Lock-Joint type
  22162. */
  22163. static LockJoint: number;
  22164. }
  22165. /**
  22166. * A class representing a physics distance joint
  22167. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22168. */
  22169. export class DistanceJoint extends PhysicsJoint {
  22170. /**
  22171. *
  22172. * @param jointData The data for the Distance-Joint
  22173. */
  22174. constructor(jointData: DistanceJointData);
  22175. /**
  22176. * Update the predefined distance.
  22177. * @param maxDistance The maximum preferred distance
  22178. * @param minDistance The minimum preferred distance
  22179. */
  22180. updateDistance(maxDistance: number, minDistance?: number): void;
  22181. }
  22182. /**
  22183. * Represents a Motor-Enabled Joint
  22184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22185. */
  22186. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22187. /**
  22188. * Initializes the Motor-Enabled Joint
  22189. * @param type The type of the joint
  22190. * @param jointData The physica joint data for the joint
  22191. */
  22192. constructor(type: number, jointData: PhysicsJointData);
  22193. /**
  22194. * Set the motor values.
  22195. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22196. * @param force the force to apply
  22197. * @param maxForce max force for this motor.
  22198. */
  22199. setMotor(force?: number, maxForce?: number): void;
  22200. /**
  22201. * Set the motor's limits.
  22202. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22203. * @param upperLimit The upper limit of the motor
  22204. * @param lowerLimit The lower limit of the motor
  22205. */
  22206. setLimit(upperLimit: number, lowerLimit?: number): void;
  22207. }
  22208. /**
  22209. * This class represents a single physics Hinge-Joint
  22210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22211. */
  22212. export class HingeJoint extends MotorEnabledJoint {
  22213. /**
  22214. * Initializes the Hinge-Joint
  22215. * @param jointData The joint data for the Hinge-Joint
  22216. */
  22217. constructor(jointData: PhysicsJointData);
  22218. /**
  22219. * Set the motor values.
  22220. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22221. * @param {number} force the force to apply
  22222. * @param {number} maxForce max force for this motor.
  22223. */
  22224. setMotor(force?: number, maxForce?: number): void;
  22225. /**
  22226. * Set the motor's limits.
  22227. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22228. * @param upperLimit The upper limit of the motor
  22229. * @param lowerLimit The lower limit of the motor
  22230. */
  22231. setLimit(upperLimit: number, lowerLimit?: number): void;
  22232. }
  22233. /**
  22234. * This class represents a dual hinge physics joint (same as wheel joint)
  22235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22236. */
  22237. export class Hinge2Joint extends MotorEnabledJoint {
  22238. /**
  22239. * Initializes the Hinge2-Joint
  22240. * @param jointData The joint data for the Hinge2-Joint
  22241. */
  22242. constructor(jointData: PhysicsJointData);
  22243. /**
  22244. * Set the motor values.
  22245. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22246. * @param {number} targetSpeed the speed the motor is to reach
  22247. * @param {number} maxForce max force for this motor.
  22248. * @param {motorIndex} the motor's index, 0 or 1.
  22249. */
  22250. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22251. /**
  22252. * Set the motor limits.
  22253. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22254. * @param {number} upperLimit the upper limit
  22255. * @param {number} lowerLimit lower limit
  22256. * @param {motorIndex} the motor's index, 0 or 1.
  22257. */
  22258. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22259. }
  22260. /**
  22261. * Interface for a motor enabled joint
  22262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22263. */
  22264. export interface IMotorEnabledJoint {
  22265. /**
  22266. * Physics joint
  22267. */
  22268. physicsJoint: any;
  22269. /**
  22270. * Sets the motor of the motor-enabled joint
  22271. * @param force The force of the motor
  22272. * @param maxForce The maximum force of the motor
  22273. * @param motorIndex The index of the motor
  22274. */
  22275. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22276. /**
  22277. * Sets the limit of the motor
  22278. * @param upperLimit The upper limit of the motor
  22279. * @param lowerLimit The lower limit of the motor
  22280. * @param motorIndex The index of the motor
  22281. */
  22282. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22283. }
  22284. /**
  22285. * Joint data for a Distance-Joint
  22286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22287. */
  22288. export interface DistanceJointData extends PhysicsJointData {
  22289. /**
  22290. * Max distance the 2 joint objects can be apart
  22291. */
  22292. maxDistance: number;
  22293. }
  22294. /**
  22295. * Joint data from a spring joint
  22296. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22297. */
  22298. export interface SpringJointData extends PhysicsJointData {
  22299. /**
  22300. * Length of the spring
  22301. */
  22302. length: number;
  22303. /**
  22304. * Stiffness of the spring
  22305. */
  22306. stiffness: number;
  22307. /**
  22308. * Damping of the spring
  22309. */
  22310. damping: number;
  22311. /** this callback will be called when applying the force to the impostors. */
  22312. forceApplicationCallback: () => void;
  22313. }
  22314. }
  22315. declare module BABYLON {
  22316. /**
  22317. * Holds the data for the raycast result
  22318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22319. */
  22320. export class PhysicsRaycastResult {
  22321. private _hasHit;
  22322. private _hitDistance;
  22323. private _hitNormalWorld;
  22324. private _hitPointWorld;
  22325. private _rayFromWorld;
  22326. private _rayToWorld;
  22327. /**
  22328. * Gets if there was a hit
  22329. */
  22330. readonly hasHit: boolean;
  22331. /**
  22332. * Gets the distance from the hit
  22333. */
  22334. readonly hitDistance: number;
  22335. /**
  22336. * Gets the hit normal/direction in the world
  22337. */
  22338. readonly hitNormalWorld: Vector3;
  22339. /**
  22340. * Gets the hit point in the world
  22341. */
  22342. readonly hitPointWorld: Vector3;
  22343. /**
  22344. * Gets the ray "start point" of the ray in the world
  22345. */
  22346. readonly rayFromWorld: Vector3;
  22347. /**
  22348. * Gets the ray "end point" of the ray in the world
  22349. */
  22350. readonly rayToWorld: Vector3;
  22351. /**
  22352. * Sets the hit data (normal & point in world space)
  22353. * @param hitNormalWorld defines the normal in world space
  22354. * @param hitPointWorld defines the point in world space
  22355. */
  22356. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22357. /**
  22358. * Sets the distance from the start point to the hit point
  22359. * @param distance
  22360. */
  22361. setHitDistance(distance: number): void;
  22362. /**
  22363. * Calculates the distance manually
  22364. */
  22365. calculateHitDistance(): void;
  22366. /**
  22367. * Resets all the values to default
  22368. * @param from The from point on world space
  22369. * @param to The to point on world space
  22370. */
  22371. reset(from?: Vector3, to?: Vector3): void;
  22372. }
  22373. /**
  22374. * Interface for the size containing width and height
  22375. */
  22376. interface IXYZ {
  22377. /**
  22378. * X
  22379. */
  22380. x: number;
  22381. /**
  22382. * Y
  22383. */
  22384. y: number;
  22385. /**
  22386. * Z
  22387. */
  22388. z: number;
  22389. }
  22390. }
  22391. declare module BABYLON {
  22392. /**
  22393. * Interface used to describe a physics joint
  22394. */
  22395. export interface PhysicsImpostorJoint {
  22396. /** Defines the main impostor to which the joint is linked */
  22397. mainImpostor: PhysicsImpostor;
  22398. /** Defines the impostor that is connected to the main impostor using this joint */
  22399. connectedImpostor: PhysicsImpostor;
  22400. /** Defines the joint itself */
  22401. joint: PhysicsJoint;
  22402. }
  22403. /** @hidden */
  22404. export interface IPhysicsEnginePlugin {
  22405. world: any;
  22406. name: string;
  22407. setGravity(gravity: Vector3): void;
  22408. setTimeStep(timeStep: number): void;
  22409. getTimeStep(): number;
  22410. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22411. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22412. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22413. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22414. removePhysicsBody(impostor: PhysicsImpostor): void;
  22415. generateJoint(joint: PhysicsImpostorJoint): void;
  22416. removeJoint(joint: PhysicsImpostorJoint): void;
  22417. isSupported(): boolean;
  22418. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22419. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22420. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22421. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22422. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22423. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22424. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22425. getBodyMass(impostor: PhysicsImpostor): number;
  22426. getBodyFriction(impostor: PhysicsImpostor): number;
  22427. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22428. getBodyRestitution(impostor: PhysicsImpostor): number;
  22429. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22430. getBodyPressure?(impostor: PhysicsImpostor): number;
  22431. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22432. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22433. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22434. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22435. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22436. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22437. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22438. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22439. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22440. sleepBody(impostor: PhysicsImpostor): void;
  22441. wakeUpBody(impostor: PhysicsImpostor): void;
  22442. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22443. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22444. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22445. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22446. getRadius(impostor: PhysicsImpostor): number;
  22447. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22448. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22449. dispose(): void;
  22450. }
  22451. /**
  22452. * Interface used to define a physics engine
  22453. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22454. */
  22455. export interface IPhysicsEngine {
  22456. /**
  22457. * Gets the gravity vector used by the simulation
  22458. */
  22459. gravity: Vector3;
  22460. /**
  22461. * Sets the gravity vector used by the simulation
  22462. * @param gravity defines the gravity vector to use
  22463. */
  22464. setGravity(gravity: Vector3): void;
  22465. /**
  22466. * Set the time step of the physics engine.
  22467. * Default is 1/60.
  22468. * To slow it down, enter 1/600 for example.
  22469. * To speed it up, 1/30
  22470. * @param newTimeStep the new timestep to apply to this world.
  22471. */
  22472. setTimeStep(newTimeStep: number): void;
  22473. /**
  22474. * Get the time step of the physics engine.
  22475. * @returns the current time step
  22476. */
  22477. getTimeStep(): number;
  22478. /**
  22479. * Release all resources
  22480. */
  22481. dispose(): void;
  22482. /**
  22483. * Gets the name of the current physics plugin
  22484. * @returns the name of the plugin
  22485. */
  22486. getPhysicsPluginName(): string;
  22487. /**
  22488. * Adding a new impostor for the impostor tracking.
  22489. * This will be done by the impostor itself.
  22490. * @param impostor the impostor to add
  22491. */
  22492. addImpostor(impostor: PhysicsImpostor): void;
  22493. /**
  22494. * Remove an impostor from the engine.
  22495. * This impostor and its mesh will not longer be updated by the physics engine.
  22496. * @param impostor the impostor to remove
  22497. */
  22498. removeImpostor(impostor: PhysicsImpostor): void;
  22499. /**
  22500. * Add a joint to the physics engine
  22501. * @param mainImpostor defines the main impostor to which the joint is added.
  22502. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22503. * @param joint defines the joint that will connect both impostors.
  22504. */
  22505. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22506. /**
  22507. * Removes a joint from the simulation
  22508. * @param mainImpostor defines the impostor used with the joint
  22509. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22510. * @param joint defines the joint to remove
  22511. */
  22512. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22513. /**
  22514. * Gets the current plugin used to run the simulation
  22515. * @returns current plugin
  22516. */
  22517. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22518. /**
  22519. * Gets the list of physic impostors
  22520. * @returns an array of PhysicsImpostor
  22521. */
  22522. getImpostors(): Array<PhysicsImpostor>;
  22523. /**
  22524. * Gets the impostor for a physics enabled object
  22525. * @param object defines the object impersonated by the impostor
  22526. * @returns the PhysicsImpostor or null if not found
  22527. */
  22528. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22529. /**
  22530. * Gets the impostor for a physics body object
  22531. * @param body defines physics body used by the impostor
  22532. * @returns the PhysicsImpostor or null if not found
  22533. */
  22534. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22535. /**
  22536. * Does a raycast in the physics world
  22537. * @param from when should the ray start?
  22538. * @param to when should the ray end?
  22539. * @returns PhysicsRaycastResult
  22540. */
  22541. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22542. /**
  22543. * Called by the scene. No need to call it.
  22544. * @param delta defines the timespam between frames
  22545. */ private _step(delta: number): void;
  22546. }
  22547. }
  22548. declare module BABYLON {
  22549. /**
  22550. * The interface for the physics imposter parameters
  22551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22552. */
  22553. export interface PhysicsImpostorParameters {
  22554. /**
  22555. * The mass of the physics imposter
  22556. */
  22557. mass: number;
  22558. /**
  22559. * The friction of the physics imposter
  22560. */
  22561. friction?: number;
  22562. /**
  22563. * The coefficient of restitution of the physics imposter
  22564. */
  22565. restitution?: number;
  22566. /**
  22567. * The native options of the physics imposter
  22568. */
  22569. nativeOptions?: any;
  22570. /**
  22571. * Specifies if the parent should be ignored
  22572. */
  22573. ignoreParent?: boolean;
  22574. /**
  22575. * Specifies if bi-directional transformations should be disabled
  22576. */
  22577. disableBidirectionalTransformation?: boolean;
  22578. /**
  22579. * The pressure inside the physics imposter, soft object only
  22580. */
  22581. pressure?: number;
  22582. /**
  22583. * The stiffness the physics imposter, soft object only
  22584. */
  22585. stiffness?: number;
  22586. /**
  22587. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22588. */
  22589. velocityIterations?: number;
  22590. /**
  22591. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22592. */
  22593. positionIterations?: number;
  22594. /**
  22595. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22596. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22597. * Add to fix multiple points
  22598. */
  22599. fixedPoints?: number;
  22600. /**
  22601. * The collision margin around a soft object
  22602. */
  22603. margin?: number;
  22604. /**
  22605. * The collision margin around a soft object
  22606. */
  22607. damping?: number;
  22608. /**
  22609. * The path for a rope based on an extrusion
  22610. */
  22611. path?: any;
  22612. /**
  22613. * The shape of an extrusion used for a rope based on an extrusion
  22614. */
  22615. shape?: any;
  22616. }
  22617. /**
  22618. * Interface for a physics-enabled object
  22619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22620. */
  22621. export interface IPhysicsEnabledObject {
  22622. /**
  22623. * The position of the physics-enabled object
  22624. */
  22625. position: Vector3;
  22626. /**
  22627. * The rotation of the physics-enabled object
  22628. */
  22629. rotationQuaternion: Nullable<Quaternion>;
  22630. /**
  22631. * The scale of the physics-enabled object
  22632. */
  22633. scaling: Vector3;
  22634. /**
  22635. * The rotation of the physics-enabled object
  22636. */
  22637. rotation?: Vector3;
  22638. /**
  22639. * The parent of the physics-enabled object
  22640. */
  22641. parent?: any;
  22642. /**
  22643. * The bounding info of the physics-enabled object
  22644. * @returns The bounding info of the physics-enabled object
  22645. */
  22646. getBoundingInfo(): BoundingInfo;
  22647. /**
  22648. * Computes the world matrix
  22649. * @param force Specifies if the world matrix should be computed by force
  22650. * @returns A world matrix
  22651. */
  22652. computeWorldMatrix(force: boolean): Matrix;
  22653. /**
  22654. * Gets the world matrix
  22655. * @returns A world matrix
  22656. */
  22657. getWorldMatrix?(): Matrix;
  22658. /**
  22659. * Gets the child meshes
  22660. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22661. * @returns An array of abstract meshes
  22662. */
  22663. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22664. /**
  22665. * Gets the vertex data
  22666. * @param kind The type of vertex data
  22667. * @returns A nullable array of numbers, or a float32 array
  22668. */
  22669. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22670. /**
  22671. * Gets the indices from the mesh
  22672. * @returns A nullable array of index arrays
  22673. */
  22674. getIndices?(): Nullable<IndicesArray>;
  22675. /**
  22676. * Gets the scene from the mesh
  22677. * @returns the indices array or null
  22678. */
  22679. getScene?(): Scene;
  22680. /**
  22681. * Gets the absolute position from the mesh
  22682. * @returns the absolute position
  22683. */
  22684. getAbsolutePosition(): Vector3;
  22685. /**
  22686. * Gets the absolute pivot point from the mesh
  22687. * @returns the absolute pivot point
  22688. */
  22689. getAbsolutePivotPoint(): Vector3;
  22690. /**
  22691. * Rotates the mesh
  22692. * @param axis The axis of rotation
  22693. * @param amount The amount of rotation
  22694. * @param space The space of the rotation
  22695. * @returns The rotation transform node
  22696. */
  22697. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22698. /**
  22699. * Translates the mesh
  22700. * @param axis The axis of translation
  22701. * @param distance The distance of translation
  22702. * @param space The space of the translation
  22703. * @returns The transform node
  22704. */
  22705. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22706. /**
  22707. * Sets the absolute position of the mesh
  22708. * @param absolutePosition The absolute position of the mesh
  22709. * @returns The transform node
  22710. */
  22711. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22712. /**
  22713. * Gets the class name of the mesh
  22714. * @returns The class name
  22715. */
  22716. getClassName(): string;
  22717. }
  22718. /**
  22719. * Represents a physics imposter
  22720. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22721. */
  22722. export class PhysicsImpostor {
  22723. /**
  22724. * The physics-enabled object used as the physics imposter
  22725. */
  22726. object: IPhysicsEnabledObject;
  22727. /**
  22728. * The type of the physics imposter
  22729. */
  22730. type: number;
  22731. private _options;
  22732. private _scene?;
  22733. /**
  22734. * The default object size of the imposter
  22735. */
  22736. static DEFAULT_OBJECT_SIZE: Vector3;
  22737. /**
  22738. * The identity quaternion of the imposter
  22739. */
  22740. static IDENTITY_QUATERNION: Quaternion;
  22741. /** @hidden */ private _pluginData: any;
  22742. private _physicsEngine;
  22743. private _physicsBody;
  22744. private _bodyUpdateRequired;
  22745. private _onBeforePhysicsStepCallbacks;
  22746. private _onAfterPhysicsStepCallbacks;
  22747. /** @hidden */ private _onPhysicsCollideCallbacks: Array<{
  22748. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22749. otherImpostors: Array<PhysicsImpostor>;
  22750. }>;
  22751. private _deltaPosition;
  22752. private _deltaRotation;
  22753. private _deltaRotationConjugated;
  22754. /** @hidden */ private _isFromLine: boolean;
  22755. private _parent;
  22756. private _isDisposed;
  22757. private static _tmpVecs;
  22758. private static _tmpQuat;
  22759. /**
  22760. * Specifies if the physics imposter is disposed
  22761. */
  22762. readonly isDisposed: boolean;
  22763. /**
  22764. * Gets the mass of the physics imposter
  22765. */
  22766. mass: number;
  22767. /**
  22768. * Gets the coefficient of friction
  22769. */
  22770. /**
  22771. * Sets the coefficient of friction
  22772. */
  22773. friction: number;
  22774. /**
  22775. * Gets the coefficient of restitution
  22776. */
  22777. /**
  22778. * Sets the coefficient of restitution
  22779. */
  22780. restitution: number;
  22781. /**
  22782. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22783. */
  22784. /**
  22785. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22786. */
  22787. pressure: number;
  22788. /**
  22789. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22790. */
  22791. /**
  22792. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22793. */
  22794. stiffness: number;
  22795. /**
  22796. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22797. */
  22798. /**
  22799. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22800. */
  22801. velocityIterations: number;
  22802. /**
  22803. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22804. */
  22805. /**
  22806. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22807. */
  22808. positionIterations: number;
  22809. /**
  22810. * The unique id of the physics imposter
  22811. * set by the physics engine when adding this impostor to the array
  22812. */
  22813. uniqueId: number;
  22814. /**
  22815. * @hidden
  22816. */
  22817. soft: boolean;
  22818. /**
  22819. * @hidden
  22820. */
  22821. segments: number;
  22822. private _joints;
  22823. /**
  22824. * Initializes the physics imposter
  22825. * @param object The physics-enabled object used as the physics imposter
  22826. * @param type The type of the physics imposter
  22827. * @param _options The options for the physics imposter
  22828. * @param _scene The Babylon scene
  22829. */
  22830. constructor(
  22831. /**
  22832. * The physics-enabled object used as the physics imposter
  22833. */
  22834. object: IPhysicsEnabledObject,
  22835. /**
  22836. * The type of the physics imposter
  22837. */
  22838. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22839. /**
  22840. * This function will completly initialize this impostor.
  22841. * It will create a new body - but only if this mesh has no parent.
  22842. * If it has, this impostor will not be used other than to define the impostor
  22843. * of the child mesh.
  22844. * @hidden
  22845. */ private _init(): void;
  22846. private _getPhysicsParent;
  22847. /**
  22848. * Should a new body be generated.
  22849. * @returns boolean specifying if body initialization is required
  22850. */
  22851. isBodyInitRequired(): boolean;
  22852. /**
  22853. * Sets the updated scaling
  22854. * @param updated Specifies if the scaling is updated
  22855. */
  22856. setScalingUpdated(): void;
  22857. /**
  22858. * Force a regeneration of this or the parent's impostor's body.
  22859. * Use under cautious - This will remove all joints already implemented.
  22860. */
  22861. forceUpdate(): void;
  22862. /**
  22863. * Gets the body that holds this impostor. Either its own, or its parent.
  22864. */
  22865. /**
  22866. * Set the physics body. Used mainly by the physics engine/plugin
  22867. */
  22868. physicsBody: any;
  22869. /**
  22870. * Get the parent of the physics imposter
  22871. * @returns Physics imposter or null
  22872. */
  22873. /**
  22874. * Sets the parent of the physics imposter
  22875. */
  22876. parent: Nullable<PhysicsImpostor>;
  22877. /**
  22878. * Resets the update flags
  22879. */
  22880. resetUpdateFlags(): void;
  22881. /**
  22882. * Gets the object extend size
  22883. * @returns the object extend size
  22884. */
  22885. getObjectExtendSize(): Vector3;
  22886. /**
  22887. * Gets the object center
  22888. * @returns The object center
  22889. */
  22890. getObjectCenter(): Vector3;
  22891. /**
  22892. * Get a specific parametes from the options parameter
  22893. * @param paramName The object parameter name
  22894. * @returns The object parameter
  22895. */
  22896. getParam(paramName: string): any;
  22897. /**
  22898. * Sets a specific parameter in the options given to the physics plugin
  22899. * @param paramName The parameter name
  22900. * @param value The value of the parameter
  22901. */
  22902. setParam(paramName: string, value: number): void;
  22903. /**
  22904. * Specifically change the body's mass option. Won't recreate the physics body object
  22905. * @param mass The mass of the physics imposter
  22906. */
  22907. setMass(mass: number): void;
  22908. /**
  22909. * Gets the linear velocity
  22910. * @returns linear velocity or null
  22911. */
  22912. getLinearVelocity(): Nullable<Vector3>;
  22913. /**
  22914. * Sets the linear velocity
  22915. * @param velocity linear velocity or null
  22916. */
  22917. setLinearVelocity(velocity: Nullable<Vector3>): void;
  22918. /**
  22919. * Gets the angular velocity
  22920. * @returns angular velocity or null
  22921. */
  22922. getAngularVelocity(): Nullable<Vector3>;
  22923. /**
  22924. * Sets the angular velocity
  22925. * @param velocity The velocity or null
  22926. */
  22927. setAngularVelocity(velocity: Nullable<Vector3>): void;
  22928. /**
  22929. * Execute a function with the physics plugin native code
  22930. * Provide a function the will have two variables - the world object and the physics body object
  22931. * @param func The function to execute with the physics plugin native code
  22932. */
  22933. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  22934. /**
  22935. * Register a function that will be executed before the physics world is stepping forward
  22936. * @param func The function to execute before the physics world is stepped forward
  22937. */
  22938. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22939. /**
  22940. * Unregister a function that will be executed before the physics world is stepping forward
  22941. * @param func The function to execute before the physics world is stepped forward
  22942. */
  22943. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22944. /**
  22945. * Register a function that will be executed after the physics step
  22946. * @param func The function to execute after physics step
  22947. */
  22948. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22949. /**
  22950. * Unregisters a function that will be executed after the physics step
  22951. * @param func The function to execute after physics step
  22952. */
  22953. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22954. /**
  22955. * register a function that will be executed when this impostor collides against a different body
  22956. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  22957. * @param func Callback that is executed on collision
  22958. */
  22959. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  22960. /**
  22961. * Unregisters the physics imposter on contact
  22962. * @param collideAgainst The physics object to collide against
  22963. * @param func Callback to execute on collision
  22964. */
  22965. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  22966. private _tmpQuat;
  22967. private _tmpQuat2;
  22968. /**
  22969. * Get the parent rotation
  22970. * @returns The parent rotation
  22971. */
  22972. getParentsRotation(): Quaternion;
  22973. /**
  22974. * this function is executed by the physics engine.
  22975. */
  22976. beforeStep: () => void;
  22977. /**
  22978. * this function is executed by the physics engine
  22979. */
  22980. afterStep: () => void;
  22981. /**
  22982. * Legacy collision detection event support
  22983. */
  22984. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  22985. /**
  22986. * event and body object due to cannon's event-based architecture.
  22987. */
  22988. onCollide: (e: {
  22989. body: any;
  22990. }) => void;
  22991. /**
  22992. * Apply a force
  22993. * @param force The force to apply
  22994. * @param contactPoint The contact point for the force
  22995. * @returns The physics imposter
  22996. */
  22997. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  22998. /**
  22999. * Apply an impulse
  23000. * @param force The impulse force
  23001. * @param contactPoint The contact point for the impulse force
  23002. * @returns The physics imposter
  23003. */
  23004. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23005. /**
  23006. * A help function to create a joint
  23007. * @param otherImpostor A physics imposter used to create a joint
  23008. * @param jointType The type of joint
  23009. * @param jointData The data for the joint
  23010. * @returns The physics imposter
  23011. */
  23012. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23013. /**
  23014. * Add a joint to this impostor with a different impostor
  23015. * @param otherImpostor A physics imposter used to add a joint
  23016. * @param joint The joint to add
  23017. * @returns The physics imposter
  23018. */
  23019. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23020. /**
  23021. * Add an anchor to a cloth impostor
  23022. * @param otherImpostor rigid impostor to anchor to
  23023. * @param width ratio across width from 0 to 1
  23024. * @param height ratio up height from 0 to 1
  23025. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23026. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23027. * @returns impostor the soft imposter
  23028. */
  23029. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23030. /**
  23031. * Add a hook to a rope impostor
  23032. * @param otherImpostor rigid impostor to anchor to
  23033. * @param length ratio across rope from 0 to 1
  23034. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23035. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23036. * @returns impostor the rope imposter
  23037. */
  23038. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23039. /**
  23040. * Will keep this body still, in a sleep mode.
  23041. * @returns the physics imposter
  23042. */
  23043. sleep(): PhysicsImpostor;
  23044. /**
  23045. * Wake the body up.
  23046. * @returns The physics imposter
  23047. */
  23048. wakeUp(): PhysicsImpostor;
  23049. /**
  23050. * Clones the physics imposter
  23051. * @param newObject The physics imposter clones to this physics-enabled object
  23052. * @returns A nullable physics imposter
  23053. */
  23054. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23055. /**
  23056. * Disposes the physics imposter
  23057. */
  23058. dispose(): void;
  23059. /**
  23060. * Sets the delta position
  23061. * @param position The delta position amount
  23062. */
  23063. setDeltaPosition(position: Vector3): void;
  23064. /**
  23065. * Sets the delta rotation
  23066. * @param rotation The delta rotation amount
  23067. */
  23068. setDeltaRotation(rotation: Quaternion): void;
  23069. /**
  23070. * Gets the box size of the physics imposter and stores the result in the input parameter
  23071. * @param result Stores the box size
  23072. * @returns The physics imposter
  23073. */
  23074. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23075. /**
  23076. * Gets the radius of the physics imposter
  23077. * @returns Radius of the physics imposter
  23078. */
  23079. getRadius(): number;
  23080. /**
  23081. * Sync a bone with this impostor
  23082. * @param bone The bone to sync to the impostor.
  23083. * @param boneMesh The mesh that the bone is influencing.
  23084. * @param jointPivot The pivot of the joint / bone in local space.
  23085. * @param distToJoint Optional distance from the impostor to the joint.
  23086. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23087. */
  23088. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23089. /**
  23090. * Sync impostor to a bone
  23091. * @param bone The bone that the impostor will be synced to.
  23092. * @param boneMesh The mesh that the bone is influencing.
  23093. * @param jointPivot The pivot of the joint / bone in local space.
  23094. * @param distToJoint Optional distance from the impostor to the joint.
  23095. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23096. * @param boneAxis Optional vector3 axis the bone is aligned with
  23097. */
  23098. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23099. /**
  23100. * No-Imposter type
  23101. */
  23102. static NoImpostor: number;
  23103. /**
  23104. * Sphere-Imposter type
  23105. */
  23106. static SphereImpostor: number;
  23107. /**
  23108. * Box-Imposter type
  23109. */
  23110. static BoxImpostor: number;
  23111. /**
  23112. * Plane-Imposter type
  23113. */
  23114. static PlaneImpostor: number;
  23115. /**
  23116. * Mesh-imposter type
  23117. */
  23118. static MeshImpostor: number;
  23119. /**
  23120. * Capsule-Impostor type (Ammo.js plugin only)
  23121. */
  23122. static CapsuleImpostor: number;
  23123. /**
  23124. * Cylinder-Imposter type
  23125. */
  23126. static CylinderImpostor: number;
  23127. /**
  23128. * Particle-Imposter type
  23129. */
  23130. static ParticleImpostor: number;
  23131. /**
  23132. * Heightmap-Imposter type
  23133. */
  23134. static HeightmapImpostor: number;
  23135. /**
  23136. * ConvexHull-Impostor type (Ammo.js plugin only)
  23137. */
  23138. static ConvexHullImpostor: number;
  23139. /**
  23140. * Rope-Imposter type
  23141. */
  23142. static RopeImpostor: number;
  23143. /**
  23144. * Cloth-Imposter type
  23145. */
  23146. static ClothImpostor: number;
  23147. /**
  23148. * Softbody-Imposter type
  23149. */
  23150. static SoftbodyImpostor: number;
  23151. }
  23152. }
  23153. declare module BABYLON {
  23154. /**
  23155. * @hidden
  23156. **/
  23157. export class _CreationDataStorage {
  23158. closePath?: boolean;
  23159. closeArray?: boolean;
  23160. idx: number[];
  23161. dashSize: number;
  23162. gapSize: number;
  23163. path3D: Path3D;
  23164. pathArray: Vector3[][];
  23165. arc: number;
  23166. radius: number;
  23167. cap: number;
  23168. tessellation: number;
  23169. }
  23170. /**
  23171. * @hidden
  23172. **/ private class _InstanceDataStorage {
  23173. visibleInstances: any;
  23174. batchCache: _InstancesBatch;
  23175. instancesBufferSize: number;
  23176. instancesBuffer: Nullable<Buffer>;
  23177. instancesData: Float32Array;
  23178. overridenInstanceCount: number;
  23179. isFrozen: boolean;
  23180. previousBatch: Nullable<_InstancesBatch>;
  23181. hardwareInstancedRendering: boolean;
  23182. sideOrientation: number;
  23183. }
  23184. /**
  23185. * @hidden
  23186. **/
  23187. export class _InstancesBatch {
  23188. mustReturn: boolean;
  23189. visibleInstances: Nullable<InstancedMesh[]>[];
  23190. renderSelf: boolean[];
  23191. hardwareInstancedRendering: boolean[];
  23192. }
  23193. /**
  23194. * Class used to represent renderable models
  23195. */
  23196. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23197. /**
  23198. * Mesh side orientation : usually the external or front surface
  23199. */
  23200. static readonly FRONTSIDE: number;
  23201. /**
  23202. * Mesh side orientation : usually the internal or back surface
  23203. */
  23204. static readonly BACKSIDE: number;
  23205. /**
  23206. * Mesh side orientation : both internal and external or front and back surfaces
  23207. */
  23208. static readonly DOUBLESIDE: number;
  23209. /**
  23210. * Mesh side orientation : by default, `FRONTSIDE`
  23211. */
  23212. static readonly DEFAULTSIDE: number;
  23213. /**
  23214. * Mesh cap setting : no cap
  23215. */
  23216. static readonly NO_CAP: number;
  23217. /**
  23218. * Mesh cap setting : one cap at the beginning of the mesh
  23219. */
  23220. static readonly CAP_START: number;
  23221. /**
  23222. * Mesh cap setting : one cap at the end of the mesh
  23223. */
  23224. static readonly CAP_END: number;
  23225. /**
  23226. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23227. */
  23228. static readonly CAP_ALL: number;
  23229. /**
  23230. * Mesh pattern setting : no flip or rotate
  23231. */
  23232. static readonly NO_FLIP: number;
  23233. /**
  23234. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23235. */
  23236. static readonly FLIP_TILE: number;
  23237. /**
  23238. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23239. */
  23240. static readonly ROTATE_TILE: number;
  23241. /**
  23242. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23243. */
  23244. static readonly FLIP_ROW: number;
  23245. /**
  23246. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23247. */
  23248. static readonly ROTATE_ROW: number;
  23249. /**
  23250. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23251. */
  23252. static readonly FLIP_N_ROTATE_TILE: number;
  23253. /**
  23254. * Mesh pattern setting : rotate pattern and rotate
  23255. */
  23256. static readonly FLIP_N_ROTATE_ROW: number;
  23257. /**
  23258. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23259. */
  23260. static readonly CENTER: number;
  23261. /**
  23262. * Mesh tile positioning : part tiles on left
  23263. */
  23264. static readonly LEFT: number;
  23265. /**
  23266. * Mesh tile positioning : part tiles on right
  23267. */
  23268. static readonly RIGHT: number;
  23269. /**
  23270. * Mesh tile positioning : part tiles on top
  23271. */
  23272. static readonly TOP: number;
  23273. /**
  23274. * Mesh tile positioning : part tiles on bottom
  23275. */
  23276. static readonly BOTTOM: number;
  23277. /**
  23278. * Gets the default side orientation.
  23279. * @param orientation the orientation to value to attempt to get
  23280. * @returns the default orientation
  23281. * @hidden
  23282. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  23283. private _internalMeshDataInfo;
  23284. /**
  23285. * An event triggered before rendering the mesh
  23286. */
  23287. readonly onBeforeRenderObservable: Observable<Mesh>;
  23288. /**
  23289. * An event triggered before binding the mesh
  23290. */
  23291. readonly onBeforeBindObservable: Observable<Mesh>;
  23292. /**
  23293. * An event triggered after rendering the mesh
  23294. */
  23295. readonly onAfterRenderObservable: Observable<Mesh>;
  23296. /**
  23297. * An event triggered before drawing the mesh
  23298. */
  23299. readonly onBeforeDrawObservable: Observable<Mesh>;
  23300. private _onBeforeDrawObserver;
  23301. /**
  23302. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23303. */
  23304. onBeforeDraw: () => void;
  23305. readonly hasInstances: boolean;
  23306. /**
  23307. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23308. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23309. */
  23310. delayLoadState: number;
  23311. /**
  23312. * Gets the list of instances created from this mesh
  23313. * it is not supposed to be modified manually.
  23314. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23315. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23316. */
  23317. instances: InstancedMesh[];
  23318. /**
  23319. * Gets the file containing delay loading data for this mesh
  23320. */
  23321. delayLoadingFile: string;
  23322. /** @hidden */ private _binaryInfo: any;
  23323. /**
  23324. * User defined function used to change how LOD level selection is done
  23325. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23326. */
  23327. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23328. /**
  23329. * Gets or sets the morph target manager
  23330. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23331. */
  23332. morphTargetManager: Nullable<MorphTargetManager>;
  23333. /** @hidden */ private _creationDataStorage: Nullable<_CreationDataStorage>;
  23334. /** @hidden */ private _geometry: Nullable<Geometry>;
  23335. /** @hidden */ private _delayInfo: Array<string>;
  23336. /** @hidden */ private _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23337. /** @hidden */ private _instanceDataStorage: _InstanceDataStorage;
  23338. private _effectiveMaterial;
  23339. /** @hidden */ private _shouldGenerateFlatShading: boolean;
  23340. /** @hidden */ private _originalBuilderSideOrientation: number;
  23341. /**
  23342. * Use this property to change the original side orientation defined at construction time
  23343. */
  23344. overrideMaterialSideOrientation: Nullable<number>;
  23345. /**
  23346. * Gets the source mesh (the one used to clone this one from)
  23347. */
  23348. readonly source: Nullable<Mesh>;
  23349. /**
  23350. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23351. */
  23352. isUnIndexed: boolean;
  23353. /**
  23354. * @constructor
  23355. * @param name The value used by scene.getMeshByName() to do a lookup.
  23356. * @param scene The scene to add this mesh to.
  23357. * @param parent The parent of this mesh, if it has one
  23358. * @param source An optional Mesh from which geometry is shared, cloned.
  23359. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23360. * When false, achieved by calling a clone(), also passing False.
  23361. * This will make creation of children, recursive.
  23362. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23363. */
  23364. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23365. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23366. /**
  23367. * Gets the class name
  23368. * @returns the string "Mesh".
  23369. */
  23370. getClassName(): string;
  23371. /** @hidden */ protected readonly _isMesh: boolean;
  23372. /**
  23373. * Returns a description of this mesh
  23374. * @param fullDetails define if full details about this mesh must be used
  23375. * @returns a descriptive string representing this mesh
  23376. */
  23377. toString(fullDetails?: boolean): string;
  23378. /** @hidden */ private _unBindEffect(): void;
  23379. /**
  23380. * Gets a boolean indicating if this mesh has LOD
  23381. */
  23382. readonly hasLODLevels: boolean;
  23383. /**
  23384. * Gets the list of MeshLODLevel associated with the current mesh
  23385. * @returns an array of MeshLODLevel
  23386. */
  23387. getLODLevels(): MeshLODLevel[];
  23388. private _sortLODLevels;
  23389. /**
  23390. * Add a mesh as LOD level triggered at the given distance.
  23391. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23392. * @param distance The distance from the center of the object to show this level
  23393. * @param mesh The mesh to be added as LOD level (can be null)
  23394. * @return This mesh (for chaining)
  23395. */
  23396. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23397. /**
  23398. * Returns the LOD level mesh at the passed distance or null if not found.
  23399. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23400. * @param distance The distance from the center of the object to show this level
  23401. * @returns a Mesh or `null`
  23402. */
  23403. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23404. /**
  23405. * Remove a mesh from the LOD array
  23406. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23407. * @param mesh defines the mesh to be removed
  23408. * @return This mesh (for chaining)
  23409. */
  23410. removeLODLevel(mesh: Mesh): Mesh;
  23411. /**
  23412. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23413. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23414. * @param camera defines the camera to use to compute distance
  23415. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23416. * @return This mesh (for chaining)
  23417. */
  23418. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23419. /**
  23420. * Gets the mesh internal Geometry object
  23421. */
  23422. readonly geometry: Nullable<Geometry>;
  23423. /**
  23424. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23425. * @returns the total number of vertices
  23426. */
  23427. getTotalVertices(): number;
  23428. /**
  23429. * Returns the content of an associated vertex buffer
  23430. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23431. * - VertexBuffer.PositionKind
  23432. * - VertexBuffer.UVKind
  23433. * - VertexBuffer.UV2Kind
  23434. * - VertexBuffer.UV3Kind
  23435. * - VertexBuffer.UV4Kind
  23436. * - VertexBuffer.UV5Kind
  23437. * - VertexBuffer.UV6Kind
  23438. * - VertexBuffer.ColorKind
  23439. * - VertexBuffer.MatricesIndicesKind
  23440. * - VertexBuffer.MatricesIndicesExtraKind
  23441. * - VertexBuffer.MatricesWeightsKind
  23442. * - VertexBuffer.MatricesWeightsExtraKind
  23443. * @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
  23444. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23445. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23446. */
  23447. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23448. /**
  23449. * Returns the mesh VertexBuffer object from the requested `kind`
  23450. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23451. * - VertexBuffer.PositionKind
  23452. * - VertexBuffer.NormalKind
  23453. * - VertexBuffer.UVKind
  23454. * - VertexBuffer.UV2Kind
  23455. * - VertexBuffer.UV3Kind
  23456. * - VertexBuffer.UV4Kind
  23457. * - VertexBuffer.UV5Kind
  23458. * - VertexBuffer.UV6Kind
  23459. * - VertexBuffer.ColorKind
  23460. * - VertexBuffer.MatricesIndicesKind
  23461. * - VertexBuffer.MatricesIndicesExtraKind
  23462. * - VertexBuffer.MatricesWeightsKind
  23463. * - VertexBuffer.MatricesWeightsExtraKind
  23464. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23465. */
  23466. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23467. /**
  23468. * Tests if a specific vertex buffer is associated with this mesh
  23469. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23470. * - VertexBuffer.PositionKind
  23471. * - VertexBuffer.NormalKind
  23472. * - VertexBuffer.UVKind
  23473. * - VertexBuffer.UV2Kind
  23474. * - VertexBuffer.UV3Kind
  23475. * - VertexBuffer.UV4Kind
  23476. * - VertexBuffer.UV5Kind
  23477. * - VertexBuffer.UV6Kind
  23478. * - VertexBuffer.ColorKind
  23479. * - VertexBuffer.MatricesIndicesKind
  23480. * - VertexBuffer.MatricesIndicesExtraKind
  23481. * - VertexBuffer.MatricesWeightsKind
  23482. * - VertexBuffer.MatricesWeightsExtraKind
  23483. * @returns a boolean
  23484. */
  23485. isVerticesDataPresent(kind: string): boolean;
  23486. /**
  23487. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23488. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23489. * - VertexBuffer.PositionKind
  23490. * - VertexBuffer.UVKind
  23491. * - VertexBuffer.UV2Kind
  23492. * - VertexBuffer.UV3Kind
  23493. * - VertexBuffer.UV4Kind
  23494. * - VertexBuffer.UV5Kind
  23495. * - VertexBuffer.UV6Kind
  23496. * - VertexBuffer.ColorKind
  23497. * - VertexBuffer.MatricesIndicesKind
  23498. * - VertexBuffer.MatricesIndicesExtraKind
  23499. * - VertexBuffer.MatricesWeightsKind
  23500. * - VertexBuffer.MatricesWeightsExtraKind
  23501. * @returns a boolean
  23502. */
  23503. isVertexBufferUpdatable(kind: string): boolean;
  23504. /**
  23505. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23506. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23507. * - VertexBuffer.PositionKind
  23508. * - VertexBuffer.NormalKind
  23509. * - VertexBuffer.UVKind
  23510. * - VertexBuffer.UV2Kind
  23511. * - VertexBuffer.UV3Kind
  23512. * - VertexBuffer.UV4Kind
  23513. * - VertexBuffer.UV5Kind
  23514. * - VertexBuffer.UV6Kind
  23515. * - VertexBuffer.ColorKind
  23516. * - VertexBuffer.MatricesIndicesKind
  23517. * - VertexBuffer.MatricesIndicesExtraKind
  23518. * - VertexBuffer.MatricesWeightsKind
  23519. * - VertexBuffer.MatricesWeightsExtraKind
  23520. * @returns an array of strings
  23521. */
  23522. getVerticesDataKinds(): string[];
  23523. /**
  23524. * Returns a positive integer : the total number of indices in this mesh geometry.
  23525. * @returns the numner of indices or zero if the mesh has no geometry.
  23526. */
  23527. getTotalIndices(): number;
  23528. /**
  23529. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23530. * @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.
  23531. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23532. * @returns the indices array or an empty array if the mesh has no geometry
  23533. */
  23534. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23535. readonly isBlocked: boolean;
  23536. /**
  23537. * Determine if the current mesh is ready to be rendered
  23538. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23539. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23540. * @returns true if all associated assets are ready (material, textures, shaders)
  23541. */
  23542. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23543. /**
  23544. * 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.
  23545. */
  23546. readonly areNormalsFrozen: boolean;
  23547. /**
  23548. * 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.
  23549. * @returns the current mesh
  23550. */
  23551. freezeNormals(): Mesh;
  23552. /**
  23553. * 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
  23554. * @returns the current mesh
  23555. */
  23556. unfreezeNormals(): Mesh;
  23557. /**
  23558. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23559. */
  23560. overridenInstanceCount: number;
  23561. /** @hidden */ private _preActivate(): Mesh;
  23562. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): Mesh;
  23563. /** @hidden */ private _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23564. /**
  23565. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23566. * This means the mesh underlying bounding box and sphere are recomputed.
  23567. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23568. * @returns the current mesh
  23569. */
  23570. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23571. /** @hidden */ private _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23572. /**
  23573. * This function will subdivide the mesh into multiple submeshes
  23574. * @param count defines the expected number of submeshes
  23575. */
  23576. subdivide(count: number): void;
  23577. /**
  23578. * Copy a FloatArray into a specific associated vertex buffer
  23579. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23580. * - VertexBuffer.PositionKind
  23581. * - VertexBuffer.UVKind
  23582. * - VertexBuffer.UV2Kind
  23583. * - VertexBuffer.UV3Kind
  23584. * - VertexBuffer.UV4Kind
  23585. * - VertexBuffer.UV5Kind
  23586. * - VertexBuffer.UV6Kind
  23587. * - VertexBuffer.ColorKind
  23588. * - VertexBuffer.MatricesIndicesKind
  23589. * - VertexBuffer.MatricesIndicesExtraKind
  23590. * - VertexBuffer.MatricesWeightsKind
  23591. * - VertexBuffer.MatricesWeightsExtraKind
  23592. * @param data defines the data source
  23593. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23594. * @param stride defines the data stride size (can be null)
  23595. * @returns the current mesh
  23596. */
  23597. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23598. /**
  23599. * Flags an associated vertex buffer as updatable
  23600. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23601. * - VertexBuffer.PositionKind
  23602. * - VertexBuffer.UVKind
  23603. * - VertexBuffer.UV2Kind
  23604. * - VertexBuffer.UV3Kind
  23605. * - VertexBuffer.UV4Kind
  23606. * - VertexBuffer.UV5Kind
  23607. * - VertexBuffer.UV6Kind
  23608. * - VertexBuffer.ColorKind
  23609. * - VertexBuffer.MatricesIndicesKind
  23610. * - VertexBuffer.MatricesIndicesExtraKind
  23611. * - VertexBuffer.MatricesWeightsKind
  23612. * - VertexBuffer.MatricesWeightsExtraKind
  23613. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23614. */
  23615. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23616. /**
  23617. * Sets the mesh global Vertex Buffer
  23618. * @param buffer defines the buffer to use
  23619. * @returns the current mesh
  23620. */
  23621. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23622. /**
  23623. * Update a specific associated vertex buffer
  23624. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23625. * - VertexBuffer.PositionKind
  23626. * - VertexBuffer.UVKind
  23627. * - VertexBuffer.UV2Kind
  23628. * - VertexBuffer.UV3Kind
  23629. * - VertexBuffer.UV4Kind
  23630. * - VertexBuffer.UV5Kind
  23631. * - VertexBuffer.UV6Kind
  23632. * - VertexBuffer.ColorKind
  23633. * - VertexBuffer.MatricesIndicesKind
  23634. * - VertexBuffer.MatricesIndicesExtraKind
  23635. * - VertexBuffer.MatricesWeightsKind
  23636. * - VertexBuffer.MatricesWeightsExtraKind
  23637. * @param data defines the data source
  23638. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23639. * @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)
  23640. * @returns the current mesh
  23641. */
  23642. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23643. /**
  23644. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23645. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23646. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23647. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23648. * @returns the current mesh
  23649. */
  23650. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23651. /**
  23652. * Creates a un-shared specific occurence of the geometry for the mesh.
  23653. * @returns the current mesh
  23654. */
  23655. makeGeometryUnique(): Mesh;
  23656. /**
  23657. * Set the index buffer of this mesh
  23658. * @param indices defines the source data
  23659. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23660. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23661. * @returns the current mesh
  23662. */
  23663. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23664. /**
  23665. * Update the current index buffer
  23666. * @param indices defines the source data
  23667. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23668. * @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)
  23669. * @returns the current mesh
  23670. */
  23671. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23672. /**
  23673. * Invert the geometry to move from a right handed system to a left handed one.
  23674. * @returns the current mesh
  23675. */
  23676. toLeftHanded(): Mesh;
  23677. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23678. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23679. /**
  23680. * Registers for this mesh a javascript function called just before the rendering process
  23681. * @param func defines the function to call before rendering this mesh
  23682. * @returns the current mesh
  23683. */
  23684. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23685. /**
  23686. * Disposes a previously registered javascript function called before the rendering
  23687. * @param func defines the function to remove
  23688. * @returns the current mesh
  23689. */
  23690. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23691. /**
  23692. * Registers for this mesh a javascript function called just after the rendering is complete
  23693. * @param func defines the function to call after rendering this mesh
  23694. * @returns the current mesh
  23695. */
  23696. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23697. /**
  23698. * Disposes a previously registered javascript function called after the rendering.
  23699. * @param func defines the function to remove
  23700. * @returns the current mesh
  23701. */
  23702. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23703. /** @hidden */ private _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23704. /** @hidden */ private _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23705. /** @hidden */ private _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23706. /** @hidden */ private _rebuild(): void;
  23707. /** @hidden */ private _freeze(): void;
  23708. /** @hidden */ private _unFreeze(): void;
  23709. /**
  23710. * 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
  23711. * @param subMesh defines the subMesh to render
  23712. * @param enableAlphaMode defines if alpha mode can be changed
  23713. * @returns the current mesh
  23714. */
  23715. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23716. private _onBeforeDraw;
  23717. /**
  23718. * Renormalize the mesh and patch it up if there are no weights
  23719. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23720. * However in the case of zero weights then we set just a single influence to 1.
  23721. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23722. */
  23723. cleanMatrixWeights(): void;
  23724. private normalizeSkinFourWeights;
  23725. private normalizeSkinWeightsAndExtra;
  23726. /**
  23727. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23728. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23729. * the user know there was an issue with importing the mesh
  23730. * @returns a validation object with skinned, valid and report string
  23731. */
  23732. validateSkinning(): {
  23733. skinned: boolean;
  23734. valid: boolean;
  23735. report: string;
  23736. };
  23737. /** @hidden */ private _checkDelayState(): Mesh;
  23738. private _queueLoad;
  23739. /**
  23740. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23741. * A mesh is in the frustum if its bounding box intersects the frustum
  23742. * @param frustumPlanes defines the frustum to test
  23743. * @returns true if the mesh is in the frustum planes
  23744. */
  23745. isInFrustum(frustumPlanes: Plane[]): boolean;
  23746. /**
  23747. * Sets the mesh material by the material or multiMaterial `id` property
  23748. * @param id is a string identifying the material or the multiMaterial
  23749. * @returns the current mesh
  23750. */
  23751. setMaterialByID(id: string): Mesh;
  23752. /**
  23753. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23754. * @returns an array of IAnimatable
  23755. */
  23756. getAnimatables(): IAnimatable[];
  23757. /**
  23758. * Modifies the mesh geometry according to the passed transformation matrix.
  23759. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23760. * The mesh normals are modified using the same transformation.
  23761. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23762. * @param transform defines the transform matrix to use
  23763. * @see http://doc.babylonjs.com/resources/baking_transformations
  23764. * @returns the current mesh
  23765. */
  23766. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23767. /**
  23768. * Modifies the mesh geometry according to its own current World Matrix.
  23769. * The mesh World Matrix is then reset.
  23770. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23771. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23772. * @see http://doc.babylonjs.com/resources/baking_transformations
  23773. * @returns the current mesh
  23774. */
  23775. bakeCurrentTransformIntoVertices(): Mesh;
  23776. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  23777. /** @hidden */ private _resetPointsArrayCache(): Mesh;
  23778. /** @hidden */ private _generatePointsArray(): boolean;
  23779. /**
  23780. * Returns a new Mesh object generated from the current mesh properties.
  23781. * This method must not get confused with createInstance()
  23782. * @param name is a string, the name given to the new mesh
  23783. * @param newParent can be any Node object (default `null`)
  23784. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23785. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23786. * @returns a new mesh
  23787. */
  23788. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  23789. /**
  23790. * Releases resources associated with this mesh.
  23791. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23792. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23793. */
  23794. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23795. /**
  23796. * Modifies the mesh geometry according to a displacement map.
  23797. * 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.
  23798. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23799. * @param url is a string, the URL from the image file is to be downloaded.
  23800. * @param minHeight is the lower limit of the displacement.
  23801. * @param maxHeight is the upper limit of the displacement.
  23802. * @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.
  23803. * @param uvOffset is an optional vector2 used to offset UV.
  23804. * @param uvScale is an optional vector2 used to scale UV.
  23805. * @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.
  23806. * @returns the Mesh.
  23807. */
  23808. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23809. /**
  23810. * Modifies the mesh geometry according to a displacementMap buffer.
  23811. * 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.
  23812. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23813. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23814. * @param heightMapWidth is the width of the buffer image.
  23815. * @param heightMapHeight is the height of the buffer image.
  23816. * @param minHeight is the lower limit of the displacement.
  23817. * @param maxHeight is the upper limit of the displacement.
  23818. * @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.
  23819. * @param uvOffset is an optional vector2 used to offset UV.
  23820. * @param uvScale is an optional vector2 used to scale UV.
  23821. * @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.
  23822. * @returns the Mesh.
  23823. */
  23824. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23825. /**
  23826. * Modify the mesh to get a flat shading rendering.
  23827. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23828. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23829. * @returns current mesh
  23830. */
  23831. convertToFlatShadedMesh(): Mesh;
  23832. /**
  23833. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23834. * In other words, more vertices, no more indices and a single bigger VBO.
  23835. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23836. * @returns current mesh
  23837. */
  23838. convertToUnIndexedMesh(): Mesh;
  23839. /**
  23840. * Inverses facet orientations.
  23841. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23842. * @param flipNormals will also inverts the normals
  23843. * @returns current mesh
  23844. */
  23845. flipFaces(flipNormals?: boolean): Mesh;
  23846. /**
  23847. * Increase the number of facets and hence vertices in a mesh
  23848. * Vertex normals are interpolated from existing vertex normals
  23849. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23850. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23851. */
  23852. increaseVertices(numberPerEdge: number): void;
  23853. /**
  23854. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23855. * This will undo any application of covertToFlatShadedMesh
  23856. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23857. */
  23858. forceSharedVertices(): void;
  23859. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  23860. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  23861. /**
  23862. * Creates a new InstancedMesh object from the mesh model.
  23863. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23864. * @param name defines the name of the new instance
  23865. * @returns a new InstancedMesh
  23866. */
  23867. createInstance(name: string): InstancedMesh;
  23868. /**
  23869. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  23870. * After this call, all the mesh instances have the same submeshes than the current mesh.
  23871. * @returns the current mesh
  23872. */
  23873. synchronizeInstances(): Mesh;
  23874. /**
  23875. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  23876. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  23877. * This should be used together with the simplification to avoid disappearing triangles.
  23878. * @param successCallback an optional success callback to be called after the optimization finished.
  23879. * @returns the current mesh
  23880. */
  23881. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  23882. /**
  23883. * Serialize current mesh
  23884. * @param serializationObject defines the object which will receive the serialization data
  23885. */
  23886. serialize(serializationObject: any): void;
  23887. /** @hidden */ private _syncGeometryWithMorphTargetManager(): void;
  23888. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  23889. /**
  23890. * Returns a new Mesh object parsed from the source provided.
  23891. * @param parsedMesh is the source
  23892. * @param scene defines the hosting scene
  23893. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  23894. * @returns a new Mesh
  23895. */
  23896. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  23897. /**
  23898. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  23899. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23900. * @param name defines the name of the mesh to create
  23901. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  23902. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  23903. * @param closePath creates a seam between the first and the last points of each path of the path array
  23904. * @param offset is taken in account only if the `pathArray` is containing a single path
  23905. * @param scene defines the hosting scene
  23906. * @param updatable defines if the mesh must be flagged as updatable
  23907. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23908. * @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)
  23909. * @returns a new Mesh
  23910. */
  23911. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23912. /**
  23913. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  23914. * @param name defines the name of the mesh to create
  23915. * @param radius sets the radius size (float) of the polygon (default 0.5)
  23916. * @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
  23917. * @param scene defines the hosting scene
  23918. * @param updatable defines if the mesh must be flagged as updatable
  23919. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23920. * @returns a new Mesh
  23921. */
  23922. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23923. /**
  23924. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  23925. * @param name defines the name of the mesh to create
  23926. * @param size sets the size (float) of each box side (default 1)
  23927. * @param scene defines the hosting scene
  23928. * @param updatable defines if the mesh must be flagged as updatable
  23929. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23930. * @returns a new Mesh
  23931. */
  23932. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23933. /**
  23934. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  23935. * @param name defines the name of the mesh to create
  23936. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  23937. * @param diameter sets the diameter size (float) of the sphere (default 1)
  23938. * @param scene defines the hosting scene
  23939. * @param updatable defines if the mesh must be flagged as updatable
  23940. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23941. * @returns a new Mesh
  23942. */
  23943. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23944. /**
  23945. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  23946. * @param name defines the name of the mesh to create
  23947. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  23948. * @param diameter sets the diameter size (float) of the sphere (default 1)
  23949. * @param scene defines the hosting scene
  23950. * @returns a new Mesh
  23951. */
  23952. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  23953. /**
  23954. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  23955. * @param name defines the name of the mesh to create
  23956. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  23957. * @param diameterTop set the top cap diameter (floats, default 1)
  23958. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  23959. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  23960. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  23961. * @param scene defines the hosting scene
  23962. * @param updatable defines if the mesh must be flagged as updatable
  23963. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23964. * @returns a new Mesh
  23965. */
  23966. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  23967. /**
  23968. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  23969. * @param name defines the name of the mesh to create
  23970. * @param diameter sets the diameter size (float) of the torus (default 1)
  23971. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  23972. * @param tessellation sets the number of torus sides (postive integer, default 16)
  23973. * @param scene defines the hosting scene
  23974. * @param updatable defines if the mesh must be flagged as updatable
  23975. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23976. * @returns a new Mesh
  23977. */
  23978. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23979. /**
  23980. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  23981. * @param name defines the name of the mesh to create
  23982. * @param radius sets the global radius size (float) of the torus knot (default 2)
  23983. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  23984. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  23985. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  23986. * @param p the number of windings on X axis (positive integers, default 2)
  23987. * @param q the number of windings on Y axis (positive integers, default 3)
  23988. * @param scene defines the hosting scene
  23989. * @param updatable defines if the mesh must be flagged as updatable
  23990. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23991. * @returns a new Mesh
  23992. */
  23993. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23994. /**
  23995. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  23996. * @param name defines the name of the mesh to create
  23997. * @param points is an array successive Vector3
  23998. * @param scene defines the hosting scene
  23999. * @param updatable defines if the mesh must be flagged as updatable
  24000. * @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).
  24001. * @returns a new Mesh
  24002. */
  24003. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24004. /**
  24005. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24006. * @param name defines the name of the mesh to create
  24007. * @param points is an array successive Vector3
  24008. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24009. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24010. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24011. * @param scene defines the hosting scene
  24012. * @param updatable defines if the mesh must be flagged as updatable
  24013. * @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)
  24014. * @returns a new Mesh
  24015. */
  24016. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24017. /**
  24018. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24019. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24020. * 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.
  24021. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24022. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24023. * Remember you can only change the shape positions, not their number when updating a polygon.
  24024. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24025. * @param name defines the name of the mesh to create
  24026. * @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
  24027. * @param scene defines the hosting scene
  24028. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24029. * @param updatable defines if the mesh must be flagged as updatable
  24030. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24031. * @param earcutInjection can be used to inject your own earcut reference
  24032. * @returns a new Mesh
  24033. */
  24034. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24035. /**
  24036. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24037. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24038. * @param name defines the name of the mesh to create
  24039. * @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
  24040. * @param depth defines the height of extrusion
  24041. * @param scene defines the hosting scene
  24042. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24043. * @param updatable defines if the mesh must be flagged as updatable
  24044. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24045. * @param earcutInjection can be used to inject your own earcut reference
  24046. * @returns a new Mesh
  24047. */
  24048. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24049. /**
  24050. * Creates an extruded shape mesh.
  24051. * 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
  24052. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24053. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24054. * @param name defines the name of the mesh to create
  24055. * @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
  24056. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24057. * @param scale is the value to scale the shape
  24058. * @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
  24059. * @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
  24060. * @param scene defines the hosting scene
  24061. * @param updatable defines if the mesh must be flagged as updatable
  24062. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24063. * @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)
  24064. * @returns a new Mesh
  24065. */
  24066. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24067. /**
  24068. * Creates an custom extruded shape mesh.
  24069. * The custom extrusion is a parametric shape.
  24070. * It has no predefined shape. Its final shape will depend on the input parameters.
  24071. * Please consider using the same method from the MeshBuilder class instead
  24072. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24073. * @param name defines the name of the mesh to create
  24074. * @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
  24075. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24076. * @param scaleFunction is a custom Javascript function called on each path point
  24077. * @param rotationFunction is a custom Javascript function called on each path point
  24078. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24079. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24080. * @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
  24081. * @param scene defines the hosting scene
  24082. * @param updatable defines if the mesh must be flagged as updatable
  24083. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24084. * @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)
  24085. * @returns a new Mesh
  24086. */
  24087. 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;
  24088. /**
  24089. * Creates lathe mesh.
  24090. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24091. * Please consider using the same method from the MeshBuilder class instead
  24092. * @param name defines the name of the mesh to create
  24093. * @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
  24094. * @param radius is the radius value of the lathe
  24095. * @param tessellation is the side number of the lathe.
  24096. * @param scene defines the hosting scene
  24097. * @param updatable defines if the mesh must be flagged as updatable
  24098. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24099. * @returns a new Mesh
  24100. */
  24101. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24102. /**
  24103. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24104. * @param name defines the name of the mesh to create
  24105. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24106. * @param scene defines the hosting scene
  24107. * @param updatable defines if the mesh must be flagged as updatable
  24108. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24109. * @returns a new Mesh
  24110. */
  24111. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24112. /**
  24113. * Creates a ground mesh.
  24114. * Please consider using the same method from the MeshBuilder class instead
  24115. * @param name defines the name of the mesh to create
  24116. * @param width set the width of the ground
  24117. * @param height set the height of the ground
  24118. * @param subdivisions sets the number of subdivisions per side
  24119. * @param scene defines the hosting scene
  24120. * @param updatable defines if the mesh must be flagged as updatable
  24121. * @returns a new Mesh
  24122. */
  24123. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24124. /**
  24125. * Creates a tiled ground mesh.
  24126. * Please consider using the same method from the MeshBuilder class instead
  24127. * @param name defines the name of the mesh to create
  24128. * @param xmin set the ground minimum X coordinate
  24129. * @param zmin set the ground minimum Y coordinate
  24130. * @param xmax set the ground maximum X coordinate
  24131. * @param zmax set the ground maximum Z coordinate
  24132. * @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
  24133. * @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
  24134. * @param scene defines the hosting scene
  24135. * @param updatable defines if the mesh must be flagged as updatable
  24136. * @returns a new Mesh
  24137. */
  24138. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24139. w: number;
  24140. h: number;
  24141. }, precision: {
  24142. w: number;
  24143. h: number;
  24144. }, scene: Scene, updatable?: boolean): Mesh;
  24145. /**
  24146. * Creates a ground mesh from a height map.
  24147. * Please consider using the same method from the MeshBuilder class instead
  24148. * @see http://doc.babylonjs.com/babylon101/height_map
  24149. * @param name defines the name of the mesh to create
  24150. * @param url sets the URL of the height map image resource
  24151. * @param width set the ground width size
  24152. * @param height set the ground height size
  24153. * @param subdivisions sets the number of subdivision per side
  24154. * @param minHeight is the minimum altitude on the ground
  24155. * @param maxHeight is the maximum altitude on the ground
  24156. * @param scene defines the hosting scene
  24157. * @param updatable defines if the mesh must be flagged as updatable
  24158. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24159. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24160. * @returns a new Mesh
  24161. */
  24162. 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;
  24163. /**
  24164. * Creates a tube mesh.
  24165. * The tube is a parametric shape.
  24166. * It has no predefined shape. Its final shape will depend on the input parameters.
  24167. * Please consider using the same method from the MeshBuilder class instead
  24168. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24169. * @param name defines the name of the mesh to create
  24170. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24171. * @param radius sets the tube radius size
  24172. * @param tessellation is the number of sides on the tubular surface
  24173. * @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
  24174. * @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
  24175. * @param scene defines the hosting scene
  24176. * @param updatable defines if the mesh must be flagged as updatable
  24177. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24178. * @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)
  24179. * @returns a new Mesh
  24180. */
  24181. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24182. (i: number, distance: number): number;
  24183. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24184. /**
  24185. * Creates a polyhedron mesh.
  24186. * Please consider using the same method from the MeshBuilder class instead.
  24187. * * 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
  24188. * * The parameter `size` (positive float, default 1) sets the polygon size
  24189. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24190. * * 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`
  24191. * * 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
  24192. * * 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)`)
  24193. * * 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
  24194. * * 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
  24195. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24196. * * 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
  24197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24198. * @param name defines the name of the mesh to create
  24199. * @param options defines the options used to create the mesh
  24200. * @param scene defines the hosting scene
  24201. * @returns a new Mesh
  24202. */
  24203. static CreatePolyhedron(name: string, options: {
  24204. type?: number;
  24205. size?: number;
  24206. sizeX?: number;
  24207. sizeY?: number;
  24208. sizeZ?: number;
  24209. custom?: any;
  24210. faceUV?: Vector4[];
  24211. faceColors?: Color4[];
  24212. updatable?: boolean;
  24213. sideOrientation?: number;
  24214. }, scene: Scene): Mesh;
  24215. /**
  24216. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24217. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24218. * * 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`)
  24219. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24220. * * 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
  24221. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24222. * * 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
  24223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24224. * @param name defines the name of the mesh
  24225. * @param options defines the options used to create the mesh
  24226. * @param scene defines the hosting scene
  24227. * @returns a new Mesh
  24228. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24229. */
  24230. static CreateIcoSphere(name: string, options: {
  24231. radius?: number;
  24232. flat?: boolean;
  24233. subdivisions?: number;
  24234. sideOrientation?: number;
  24235. updatable?: boolean;
  24236. }, scene: Scene): Mesh;
  24237. /**
  24238. * Creates a decal mesh.
  24239. * Please consider using the same method from the MeshBuilder class instead.
  24240. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24241. * @param name defines the name of the mesh
  24242. * @param sourceMesh defines the mesh receiving the decal
  24243. * @param position sets the position of the decal in world coordinates
  24244. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24245. * @param size sets the decal scaling
  24246. * @param angle sets the angle to rotate the decal
  24247. * @returns a new Mesh
  24248. */
  24249. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24250. /**
  24251. * Prepare internal position array for software CPU skinning
  24252. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24253. */
  24254. setPositionsForCPUSkinning(): Float32Array;
  24255. /**
  24256. * Prepare internal normal array for software CPU skinning
  24257. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24258. */
  24259. setNormalsForCPUSkinning(): Float32Array;
  24260. /**
  24261. * Updates the vertex buffer by applying transformation from the bones
  24262. * @param skeleton defines the skeleton to apply to current mesh
  24263. * @returns the current mesh
  24264. */
  24265. applySkeleton(skeleton: Skeleton): Mesh;
  24266. /**
  24267. * 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
  24268. * @param meshes defines the list of meshes to scan
  24269. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24270. */
  24271. static MinMax(meshes: AbstractMesh[]): {
  24272. min: Vector3;
  24273. max: Vector3;
  24274. };
  24275. /**
  24276. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24277. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24278. * @returns a vector3
  24279. */
  24280. static Center(meshesOrMinMaxVector: {
  24281. min: Vector3;
  24282. max: Vector3;
  24283. } | AbstractMesh[]): Vector3;
  24284. /**
  24285. * Merge the array of meshes into a single mesh for performance reasons.
  24286. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24287. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24288. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24289. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24290. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24291. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24292. * @returns a new mesh
  24293. */
  24294. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24295. /** @hidden */
  24296. addInstance(instance: InstancedMesh): void;
  24297. /** @hidden */
  24298. removeInstance(instance: InstancedMesh): void;
  24299. }
  24300. }
  24301. declare module BABYLON {
  24302. /**
  24303. * This is the base class of all the camera used in the application.
  24304. * @see http://doc.babylonjs.com/features/cameras
  24305. */
  24306. export class Camera extends Node {
  24307. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24308. /**
  24309. * This is the default projection mode used by the cameras.
  24310. * It helps recreating a feeling of perspective and better appreciate depth.
  24311. * This is the best way to simulate real life cameras.
  24312. */
  24313. static readonly PERSPECTIVE_CAMERA: number;
  24314. /**
  24315. * This helps creating camera with an orthographic mode.
  24316. * 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.
  24317. */
  24318. static readonly ORTHOGRAPHIC_CAMERA: number;
  24319. /**
  24320. * This is the default FOV mode for perspective cameras.
  24321. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24322. */
  24323. static readonly FOVMODE_VERTICAL_FIXED: number;
  24324. /**
  24325. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24326. */
  24327. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24328. /**
  24329. * This specifies ther is no need for a camera rig.
  24330. * Basically only one eye is rendered corresponding to the camera.
  24331. */
  24332. static readonly RIG_MODE_NONE: number;
  24333. /**
  24334. * Simulates a camera Rig with one blue eye and one red eye.
  24335. * This can be use with 3d blue and red glasses.
  24336. */
  24337. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24338. /**
  24339. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24340. */
  24341. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24342. /**
  24343. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24344. */
  24345. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24346. /**
  24347. * Defines that both eyes of the camera will be rendered over under each other.
  24348. */
  24349. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24350. /**
  24351. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24352. */
  24353. static readonly RIG_MODE_VR: number;
  24354. /**
  24355. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24356. */
  24357. static readonly RIG_MODE_WEBVR: number;
  24358. /**
  24359. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24360. */
  24361. static readonly RIG_MODE_CUSTOM: number;
  24362. /**
  24363. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24364. */
  24365. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24366. /**
  24367. * Define the input manager associated with the camera.
  24368. */
  24369. inputs: CameraInputsManager<Camera>;
  24370. /** @hidden */ private _position: Vector3;
  24371. /**
  24372. * Define the current local position of the camera in the scene
  24373. */
  24374. position: Vector3;
  24375. /**
  24376. * The vector the camera should consider as up.
  24377. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24378. */
  24379. upVector: Vector3;
  24380. /**
  24381. * Define the current limit on the left side for an orthographic camera
  24382. * In scene unit
  24383. */
  24384. orthoLeft: Nullable<number>;
  24385. /**
  24386. * Define the current limit on the right side for an orthographic camera
  24387. * In scene unit
  24388. */
  24389. orthoRight: Nullable<number>;
  24390. /**
  24391. * Define the current limit on the bottom side for an orthographic camera
  24392. * In scene unit
  24393. */
  24394. orthoBottom: Nullable<number>;
  24395. /**
  24396. * Define the current limit on the top side for an orthographic camera
  24397. * In scene unit
  24398. */
  24399. orthoTop: Nullable<number>;
  24400. /**
  24401. * Field Of View is set in Radians. (default is 0.8)
  24402. */
  24403. fov: number;
  24404. /**
  24405. * Define the minimum distance the camera can see from.
  24406. * This is important to note that the depth buffer are not infinite and the closer it starts
  24407. * the more your scene might encounter depth fighting issue.
  24408. */
  24409. minZ: number;
  24410. /**
  24411. * Define the maximum distance the camera can see to.
  24412. * This is important to note that the depth buffer are not infinite and the further it end
  24413. * the more your scene might encounter depth fighting issue.
  24414. */
  24415. maxZ: number;
  24416. /**
  24417. * Define the default inertia of the camera.
  24418. * This helps giving a smooth feeling to the camera movement.
  24419. */
  24420. inertia: number;
  24421. /**
  24422. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24423. */
  24424. mode: number;
  24425. /**
  24426. * Define wether the camera is intermediate.
  24427. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24428. */
  24429. isIntermediate: boolean;
  24430. /**
  24431. * Define the viewport of the camera.
  24432. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24433. */
  24434. viewport: Viewport;
  24435. /**
  24436. * Restricts the camera to viewing objects with the same layerMask.
  24437. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24438. */
  24439. layerMask: number;
  24440. /**
  24441. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24442. */
  24443. fovMode: number;
  24444. /**
  24445. * Rig mode of the camera.
  24446. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24447. * This is normally controlled byt the camera themselves as internal use.
  24448. */
  24449. cameraRigMode: number;
  24450. /**
  24451. * Defines the distance between both "eyes" in case of a RIG
  24452. */
  24453. interaxialDistance: number;
  24454. /**
  24455. * Defines if stereoscopic rendering is done side by side or over under.
  24456. */
  24457. isStereoscopicSideBySide: boolean;
  24458. /**
  24459. * 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
  24460. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24461. * else in the scene. (Eg. security camera)
  24462. *
  24463. * 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)
  24464. */
  24465. customRenderTargets: RenderTargetTexture[];
  24466. /**
  24467. * When set, the camera will render to this render target instead of the default canvas
  24468. *
  24469. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24470. */
  24471. outputRenderTarget: Nullable<RenderTargetTexture>;
  24472. /**
  24473. * Observable triggered when the camera view matrix has changed.
  24474. */
  24475. onViewMatrixChangedObservable: Observable<Camera>;
  24476. /**
  24477. * Observable triggered when the camera Projection matrix has changed.
  24478. */
  24479. onProjectionMatrixChangedObservable: Observable<Camera>;
  24480. /**
  24481. * Observable triggered when the inputs have been processed.
  24482. */
  24483. onAfterCheckInputsObservable: Observable<Camera>;
  24484. /**
  24485. * Observable triggered when reset has been called and applied to the camera.
  24486. */
  24487. onRestoreStateObservable: Observable<Camera>;
  24488. /** @hidden */ private _cameraRigParams: any;
  24489. /** @hidden */ private _rigCameras: Camera[];
  24490. /** @hidden */ private _rigPostProcess: Nullable<PostProcess>;
  24491. protected _webvrViewMatrix: Matrix;
  24492. /** @hidden */ private _skipRendering: boolean;
  24493. /** @hidden */ private _projectionMatrix: Matrix;
  24494. /** @hidden */ private _postProcesses: Nullable<PostProcess>[];
  24495. /** @hidden */ private _activeMeshes: SmartArray<AbstractMesh>;
  24496. protected _globalPosition: Vector3;
  24497. /** @hidden */ private _computedViewMatrix: Matrix;
  24498. private _doNotComputeProjectionMatrix;
  24499. private _transformMatrix;
  24500. private _frustumPlanes;
  24501. private _refreshFrustumPlanes;
  24502. private _storedFov;
  24503. private _stateStored;
  24504. /**
  24505. * Instantiates a new camera object.
  24506. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24507. * @see http://doc.babylonjs.com/features/cameras
  24508. * @param name Defines the name of the camera in the scene
  24509. * @param position Defines the position of the camera
  24510. * @param scene Defines the scene the camera belongs too
  24511. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24512. */
  24513. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24514. /**
  24515. * Store current camera state (fov, position, etc..)
  24516. * @returns the camera
  24517. */
  24518. storeState(): Camera;
  24519. /**
  24520. * Restores the camera state values if it has been stored. You must call storeState() first
  24521. */
  24522. protected _restoreStateValues(): boolean;
  24523. /**
  24524. * Restored camera state. You must call storeState() first.
  24525. * @returns true if restored and false otherwise
  24526. */
  24527. restoreState(): boolean;
  24528. /**
  24529. * Gets the class name of the camera.
  24530. * @returns the class name
  24531. */
  24532. getClassName(): string;
  24533. /** @hidden */ protected readonly _isCamera: boolean;
  24534. /**
  24535. * Gets a string representation of the camera useful for debug purpose.
  24536. * @param fullDetails Defines that a more verboe level of logging is required
  24537. * @returns the string representation
  24538. */
  24539. toString(fullDetails?: boolean): string;
  24540. /**
  24541. * Gets the current world space position of the camera.
  24542. */
  24543. readonly globalPosition: Vector3;
  24544. /**
  24545. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24546. * @returns the active meshe list
  24547. */
  24548. getActiveMeshes(): SmartArray<AbstractMesh>;
  24549. /**
  24550. * Check wether a mesh is part of the current active mesh list of the camera
  24551. * @param mesh Defines the mesh to check
  24552. * @returns true if active, false otherwise
  24553. */
  24554. isActiveMesh(mesh: Mesh): boolean;
  24555. /**
  24556. * Is this camera ready to be used/rendered
  24557. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24558. * @return true if the camera is ready
  24559. */
  24560. isReady(completeCheck?: boolean): boolean;
  24561. /** @hidden */ private _initCache(): void;
  24562. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  24563. /** @hidden */ private _isSynchronized(): boolean;
  24564. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  24565. /** @hidden */ private _isSynchronizedProjectionMatrix(): boolean;
  24566. /**
  24567. * Attach the input controls to a specific dom element to get the input from.
  24568. * @param element Defines the element the controls should be listened from
  24569. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24570. */
  24571. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24572. /**
  24573. * Detach the current controls from the specified dom element.
  24574. * @param element Defines the element to stop listening the inputs from
  24575. */
  24576. detachControl(element: HTMLElement): void;
  24577. /**
  24578. * Update the camera state according to the different inputs gathered during the frame.
  24579. */
  24580. update(): void;
  24581. /** @hidden */ private _checkInputs(): void;
  24582. /** @hidden */
  24583. readonly rigCameras: Camera[];
  24584. /**
  24585. * Gets the post process used by the rig cameras
  24586. */
  24587. readonly rigPostProcess: Nullable<PostProcess>;
  24588. /**
  24589. * Internal, gets the first post proces.
  24590. * @returns the first post process to be run on this camera.
  24591. */ private _getFirstPostProcess(): Nullable<PostProcess>;
  24592. private _cascadePostProcessesToRigCams;
  24593. /**
  24594. * Attach a post process to the camera.
  24595. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24596. * @param postProcess The post process to attach to the camera
  24597. * @param insertAt The position of the post process in case several of them are in use in the scene
  24598. * @returns the position the post process has been inserted at
  24599. */
  24600. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24601. /**
  24602. * Detach a post process to the camera.
  24603. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24604. * @param postProcess The post process to detach from the camera
  24605. */
  24606. detachPostProcess(postProcess: PostProcess): void;
  24607. /**
  24608. * Gets the current world matrix of the camera
  24609. */
  24610. getWorldMatrix(): Matrix;
  24611. /** @hidden */ private _getViewMatrix(): Matrix;
  24612. /**
  24613. * Gets the current view matrix of the camera.
  24614. * @param force forces the camera to recompute the matrix without looking at the cached state
  24615. * @returns the view matrix
  24616. */
  24617. getViewMatrix(force?: boolean): Matrix;
  24618. /**
  24619. * Freeze the projection matrix.
  24620. * It will prevent the cache check of the camera projection compute and can speed up perf
  24621. * if no parameter of the camera are meant to change
  24622. * @param projection Defines manually a projection if necessary
  24623. */
  24624. freezeProjectionMatrix(projection?: Matrix): void;
  24625. /**
  24626. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24627. */
  24628. unfreezeProjectionMatrix(): void;
  24629. /**
  24630. * Gets the current projection matrix of the camera.
  24631. * @param force forces the camera to recompute the matrix without looking at the cached state
  24632. * @returns the projection matrix
  24633. */
  24634. getProjectionMatrix(force?: boolean): Matrix;
  24635. /**
  24636. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24637. * @returns a Matrix
  24638. */
  24639. getTransformationMatrix(): Matrix;
  24640. private _updateFrustumPlanes;
  24641. /**
  24642. * Checks if a cullable object (mesh...) is in the camera frustum
  24643. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24644. * @param target The object to check
  24645. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24646. * @returns true if the object is in frustum otherwise false
  24647. */
  24648. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24649. /**
  24650. * Checks if a cullable object (mesh...) is in the camera frustum
  24651. * Unlike isInFrustum this cheks the full bounding box
  24652. * @param target The object to check
  24653. * @returns true if the object is in frustum otherwise false
  24654. */
  24655. isCompletelyInFrustum(target: ICullable): boolean;
  24656. /**
  24657. * Gets a ray in the forward direction from the camera.
  24658. * @param length Defines the length of the ray to create
  24659. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24660. * @param origin Defines the start point of the ray which defaults to the camera position
  24661. * @returns the forward ray
  24662. */
  24663. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24664. /**
  24665. * Releases resources associated with this node.
  24666. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24667. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24668. */
  24669. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24670. /** @hidden */ private _isLeftCamera: boolean;
  24671. /**
  24672. * Gets the left camera of a rig setup in case of Rigged Camera
  24673. */
  24674. readonly isLeftCamera: boolean;
  24675. /** @hidden */ private _isRightCamera: boolean;
  24676. /**
  24677. * Gets the right camera of a rig setup in case of Rigged Camera
  24678. */
  24679. readonly isRightCamera: boolean;
  24680. /**
  24681. * Gets the left camera of a rig setup in case of Rigged Camera
  24682. */
  24683. readonly leftCamera: Nullable<FreeCamera>;
  24684. /**
  24685. * Gets the right camera of a rig setup in case of Rigged Camera
  24686. */
  24687. readonly rightCamera: Nullable<FreeCamera>;
  24688. /**
  24689. * Gets the left camera target of a rig setup in case of Rigged Camera
  24690. * @returns the target position
  24691. */
  24692. getLeftTarget(): Nullable<Vector3>;
  24693. /**
  24694. * Gets the right camera target of a rig setup in case of Rigged Camera
  24695. * @returns the target position
  24696. */
  24697. getRightTarget(): Nullable<Vector3>;
  24698. /**
  24699. * @hidden
  24700. */
  24701. setCameraRigMode(mode: number, rigParams: any): void;
  24702. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  24703. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24704. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  24705. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24706. /** @hidden */ private _getVRProjectionMatrix(): Matrix;
  24707. protected _updateCameraRotationMatrix(): void;
  24708. protected _updateWebVRCameraRotationMatrix(): void;
  24709. /**
  24710. * This function MUST be overwritten by the different WebVR cameras available.
  24711. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24712. * @hidden
  24713. */ private _getWebVRProjectionMatrix(): Matrix;
  24714. /**
  24715. * This function MUST be overwritten by the different WebVR cameras available.
  24716. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24717. * @hidden
  24718. */ private _getWebVRViewMatrix(): Matrix;
  24719. /** @hidden */
  24720. setCameraRigParameter(name: string, value: any): void;
  24721. /**
  24722. * needs to be overridden by children so sub has required properties to be copied
  24723. * @hidden
  24724. */
  24725. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24726. /**
  24727. * May need to be overridden by children
  24728. * @hidden
  24729. */ private _updateRigCameras(): void;
  24730. /** @hidden */ private _setupInputs(): void;
  24731. /**
  24732. * Serialiaze the camera setup to a json represention
  24733. * @returns the JSON representation
  24734. */
  24735. serialize(): any;
  24736. /**
  24737. * Clones the current camera.
  24738. * @param name The cloned camera name
  24739. * @returns the cloned camera
  24740. */
  24741. clone(name: string): Camera;
  24742. /**
  24743. * Gets the direction of the camera relative to a given local axis.
  24744. * @param localAxis Defines the reference axis to provide a relative direction.
  24745. * @return the direction
  24746. */
  24747. getDirection(localAxis: Vector3): Vector3;
  24748. /**
  24749. * Returns the current camera absolute rotation
  24750. */
  24751. readonly absoluteRotation: Quaternion;
  24752. /**
  24753. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24754. * @param localAxis Defines the reference axis to provide a relative direction.
  24755. * @param result Defines the vector to store the result in
  24756. */
  24757. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24758. /**
  24759. * Gets a camera constructor for a given camera type
  24760. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24761. * @param name The name of the camera the result will be able to instantiate
  24762. * @param scene The scene the result will construct the camera in
  24763. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24764. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24765. * @returns a factory method to construc the camera
  24766. */
  24767. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24768. /**
  24769. * Compute the world matrix of the camera.
  24770. * @returns the camera workd matrix
  24771. */
  24772. computeWorldMatrix(): Matrix;
  24773. /**
  24774. * Parse a JSON and creates the camera from the parsed information
  24775. * @param parsedCamera The JSON to parse
  24776. * @param scene The scene to instantiate the camera in
  24777. * @returns the newly constructed camera
  24778. */
  24779. static Parse(parsedCamera: any, scene: Scene): Camera;
  24780. }
  24781. }
  24782. declare module BABYLON {
  24783. /**
  24784. * Class containing static functions to help procedurally build meshes
  24785. */
  24786. export class DiscBuilder {
  24787. /**
  24788. * Creates a plane polygonal mesh. By default, this is a disc
  24789. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24790. * * 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
  24791. * * 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
  24792. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24793. * * 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
  24794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24795. * @param name defines the name of the mesh
  24796. * @param options defines the options used to create the mesh
  24797. * @param scene defines the hosting scene
  24798. * @returns the plane polygonal mesh
  24799. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24800. */
  24801. static CreateDisc(name: string, options: {
  24802. radius?: number;
  24803. tessellation?: number;
  24804. arc?: number;
  24805. updatable?: boolean;
  24806. sideOrientation?: number;
  24807. frontUVs?: Vector4;
  24808. backUVs?: Vector4;
  24809. }, scene?: Nullable<Scene>): Mesh;
  24810. }
  24811. }
  24812. declare module BABYLON {
  24813. /**
  24814. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24815. *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.
  24816. * The SPS is also a particle system. It provides some methods to manage the particles.
  24817. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24818. *
  24819. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24820. */
  24821. export class SolidParticleSystem implements IDisposable {
  24822. /**
  24823. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24824. * Example : var p = SPS.particles[i];
  24825. */
  24826. particles: SolidParticle[];
  24827. /**
  24828. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24829. */
  24830. nbParticles: number;
  24831. /**
  24832. * If the particles must ever face the camera (default false). Useful for planar particles.
  24833. */
  24834. billboard: boolean;
  24835. /**
  24836. * Recompute normals when adding a shape
  24837. */
  24838. recomputeNormals: boolean;
  24839. /**
  24840. * This a counter ofr your own usage. It's not set by any SPS functions.
  24841. */
  24842. counter: number;
  24843. /**
  24844. * The SPS name. This name is also given to the underlying mesh.
  24845. */
  24846. name: string;
  24847. /**
  24848. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24849. */
  24850. mesh: Mesh;
  24851. /**
  24852. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24853. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  24854. */
  24855. vars: any;
  24856. /**
  24857. * This array is populated when the SPS is set as 'pickable'.
  24858. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24859. * Each element of this array is an object `{idx: int, faceId: int}`.
  24860. * `idx` is the picked particle index in the `SPS.particles` array
  24861. * `faceId` is the picked face index counted within this particle.
  24862. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  24863. */
  24864. pickedParticles: {
  24865. idx: number;
  24866. faceId: number;
  24867. }[];
  24868. /**
  24869. * This array is populated when `enableDepthSort` is set to true.
  24870. * Each element of this array is an instance of the class DepthSortedParticle.
  24871. */
  24872. depthSortedParticles: DepthSortedParticle[];
  24873. /**
  24874. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24875. * @hidden
  24876. */ private _bSphereOnly: boolean;
  24877. /**
  24878. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24879. * @hidden
  24880. */ private _bSphereRadiusFactor: number;
  24881. private _scene;
  24882. private _positions;
  24883. private _indices;
  24884. private _normals;
  24885. private _colors;
  24886. private _uvs;
  24887. private _indices32;
  24888. private _positions32;
  24889. private _normals32;
  24890. private _fixedNormal32;
  24891. private _colors32;
  24892. private _uvs32;
  24893. private _index;
  24894. private _updatable;
  24895. private _pickable;
  24896. private _isVisibilityBoxLocked;
  24897. private _alwaysVisible;
  24898. private _depthSort;
  24899. private _shapeCounter;
  24900. private _copy;
  24901. private _color;
  24902. private _computeParticleColor;
  24903. private _computeParticleTexture;
  24904. private _computeParticleRotation;
  24905. private _computeParticleVertex;
  24906. private _computeBoundingBox;
  24907. private _depthSortParticles;
  24908. private _camera;
  24909. private _mustUnrotateFixedNormals;
  24910. private _particlesIntersect;
  24911. private _needs32Bits;
  24912. /**
  24913. * Creates a SPS (Solid Particle System) object.
  24914. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24915. * @param scene (Scene) is the scene in which the SPS is added.
  24916. * @param options defines the options of the sps e.g.
  24917. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24918. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24919. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24920. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24921. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24922. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24923. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24924. */
  24925. constructor(name: string, scene: Scene, options?: {
  24926. updatable?: boolean;
  24927. isPickable?: boolean;
  24928. enableDepthSort?: boolean;
  24929. particleIntersection?: boolean;
  24930. boundingSphereOnly?: boolean;
  24931. bSphereRadiusFactor?: number;
  24932. });
  24933. /**
  24934. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24935. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24936. * @returns the created mesh
  24937. */
  24938. buildMesh(): Mesh;
  24939. /**
  24940. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24941. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24942. * Thus the particles generated from `digest()` have their property `position` set yet.
  24943. * @param mesh ( Mesh ) is the mesh to be digested
  24944. * @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
  24945. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24946. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24947. * @returns the current SPS
  24948. */
  24949. digest(mesh: Mesh, options?: {
  24950. facetNb?: number;
  24951. number?: number;
  24952. delta?: number;
  24953. }): SolidParticleSystem;
  24954. private _unrotateFixedNormals;
  24955. private _resetCopy;
  24956. private _meshBuilder;
  24957. private _posToShape;
  24958. private _uvsToShapeUV;
  24959. private _addParticle;
  24960. /**
  24961. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24962. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  24963. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24964. * @param nb (positive integer) the number of particles to be created from this model
  24965. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24966. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24967. * @returns the number of shapes in the system
  24968. */
  24969. addShape(mesh: Mesh, nb: number, options?: {
  24970. positionFunction?: any;
  24971. vertexFunction?: any;
  24972. }): number;
  24973. private _rebuildParticle;
  24974. /**
  24975. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24976. * @returns the SPS.
  24977. */
  24978. rebuildMesh(): SolidParticleSystem;
  24979. /**
  24980. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24981. * This method calls `updateParticle()` for each particle of the SPS.
  24982. * For an animated SPS, it is usually called within the render loop.
  24983. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24984. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24985. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24986. * @returns the SPS.
  24987. */
  24988. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24989. /**
  24990. * Disposes the SPS.
  24991. */
  24992. dispose(): void;
  24993. /**
  24994. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24995. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24996. * @returns the SPS.
  24997. */
  24998. refreshVisibleSize(): SolidParticleSystem;
  24999. /**
  25000. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25001. * @param size the size (float) of the visibility box
  25002. * note : this doesn't lock the SPS mesh bounding box.
  25003. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25004. */
  25005. setVisibilityBox(size: number): void;
  25006. /**
  25007. * Gets whether the SPS as always visible or not
  25008. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25009. */
  25010. /**
  25011. * Sets the SPS as always visible or not
  25012. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25013. */
  25014. isAlwaysVisible: boolean;
  25015. /**
  25016. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25017. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25018. */
  25019. /**
  25020. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25021. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25022. */
  25023. isVisibilityBoxLocked: boolean;
  25024. /**
  25025. * Tells to `setParticles()` to compute the particle rotations or not.
  25026. * Default value : true. The SPS is faster when it's set to false.
  25027. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25028. */
  25029. /**
  25030. * Gets if `setParticles()` computes the particle rotations or not.
  25031. * Default value : true. The SPS is faster when it's set to false.
  25032. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25033. */
  25034. computeParticleRotation: boolean;
  25035. /**
  25036. * Tells to `setParticles()` to compute the particle colors or not.
  25037. * Default value : true. The SPS is faster when it's set to false.
  25038. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25039. */
  25040. /**
  25041. * Gets if `setParticles()` computes the particle colors or not.
  25042. * Default value : true. The SPS is faster when it's set to false.
  25043. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25044. */
  25045. computeParticleColor: boolean;
  25046. /**
  25047. * Gets if `setParticles()` computes the particle textures or not.
  25048. * Default value : true. The SPS is faster when it's set to false.
  25049. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25050. */
  25051. computeParticleTexture: boolean;
  25052. /**
  25053. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25054. * Default value : false. The SPS is faster when it's set to false.
  25055. * Note : the particle custom vertex positions aren't stored values.
  25056. */
  25057. /**
  25058. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25059. * Default value : false. The SPS is faster when it's set to false.
  25060. * Note : the particle custom vertex positions aren't stored values.
  25061. */
  25062. computeParticleVertex: boolean;
  25063. /**
  25064. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25065. */
  25066. /**
  25067. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25068. */
  25069. computeBoundingBox: boolean;
  25070. /**
  25071. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25072. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25073. * Default : `true`
  25074. */
  25075. /**
  25076. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25077. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25078. * Default : `true`
  25079. */
  25080. depthSortParticles: boolean;
  25081. /**
  25082. * This function does nothing. It may be overwritten to set all the particle first values.
  25083. * The SPS doesn't call this function, you may have to call it by your own.
  25084. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25085. */
  25086. initParticles(): void;
  25087. /**
  25088. * This function does nothing. It may be overwritten to recycle a particle.
  25089. * The SPS doesn't call this function, you may have to call it by your own.
  25090. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25091. * @param particle The particle to recycle
  25092. * @returns the recycled particle
  25093. */
  25094. recycleParticle(particle: SolidParticle): SolidParticle;
  25095. /**
  25096. * Updates a particle : this function should be overwritten by the user.
  25097. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25098. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25099. * @example : just set a particle position or velocity and recycle conditions
  25100. * @param particle The particle to update
  25101. * @returns the updated particle
  25102. */
  25103. updateParticle(particle: SolidParticle): SolidParticle;
  25104. /**
  25105. * Updates a vertex of a particle : it can be overwritten by the user.
  25106. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25107. * @param particle the current particle
  25108. * @param vertex the current index of the current particle
  25109. * @param pt the index of the current vertex in the particle shape
  25110. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25111. * @example : just set a vertex particle position
  25112. * @returns the updated vertex
  25113. */
  25114. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25115. /**
  25116. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25117. * This does nothing and may be overwritten by the user.
  25118. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25119. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25120. * @param update the boolean update value actually passed to setParticles()
  25121. */
  25122. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25123. /**
  25124. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25125. * This will be passed three parameters.
  25126. * This does nothing and may be overwritten by the user.
  25127. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25128. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25129. * @param update the boolean update value actually passed to setParticles()
  25130. */
  25131. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25132. }
  25133. }
  25134. declare module BABYLON {
  25135. /**
  25136. * Represents one particle of a solid particle system.
  25137. */
  25138. export class SolidParticle {
  25139. /**
  25140. * particle global index
  25141. */
  25142. idx: number;
  25143. /**
  25144. * The color of the particle
  25145. */
  25146. color: Nullable<Color4>;
  25147. /**
  25148. * The world space position of the particle.
  25149. */
  25150. position: Vector3;
  25151. /**
  25152. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25153. */
  25154. rotation: Vector3;
  25155. /**
  25156. * The world space rotation quaternion of the particle.
  25157. */
  25158. rotationQuaternion: Nullable<Quaternion>;
  25159. /**
  25160. * The scaling of the particle.
  25161. */
  25162. scaling: Vector3;
  25163. /**
  25164. * The uvs of the particle.
  25165. */
  25166. uvs: Vector4;
  25167. /**
  25168. * The current speed of the particle.
  25169. */
  25170. velocity: Vector3;
  25171. /**
  25172. * The pivot point in the particle local space.
  25173. */
  25174. pivot: Vector3;
  25175. /**
  25176. * Must the particle be translated from its pivot point in its local space ?
  25177. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25178. * Default : false
  25179. */
  25180. translateFromPivot: boolean;
  25181. /**
  25182. * Is the particle active or not ?
  25183. */
  25184. alive: boolean;
  25185. /**
  25186. * Is the particle visible or not ?
  25187. */
  25188. isVisible: boolean;
  25189. /**
  25190. * Index of this particle in the global "positions" array (Internal use)
  25191. * @hidden
  25192. */ private _pos: number;
  25193. /**
  25194. * @hidden Index of this particle in the global "indices" array (Internal use)
  25195. */ private _ind: number;
  25196. /**
  25197. * @hidden ModelShape of this particle (Internal use)
  25198. */ private _model: ModelShape;
  25199. /**
  25200. * ModelShape id of this particle
  25201. */
  25202. shapeId: number;
  25203. /**
  25204. * Index of the particle in its shape id
  25205. */
  25206. idxInShape: number;
  25207. /**
  25208. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25209. */ private _modelBoundingInfo: BoundingInfo;
  25210. /**
  25211. * @hidden Particle BoundingInfo object (Internal use)
  25212. */ private _boundingInfo: BoundingInfo;
  25213. /**
  25214. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25215. */ private _sps: SolidParticleSystem;
  25216. /**
  25217. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25218. */ private _stillInvisible: boolean;
  25219. /**
  25220. * @hidden Last computed particle rotation matrix
  25221. */ private _rotationMatrix: number[];
  25222. /**
  25223. * Parent particle Id, if any.
  25224. * Default null.
  25225. */
  25226. parentId: Nullable<number>;
  25227. /**
  25228. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25229. * The possible values are :
  25230. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25231. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25232. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25233. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25234. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25235. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25236. * */
  25237. cullingStrategy: number;
  25238. /**
  25239. * @hidden Internal global position in the SPS.
  25240. */ private _globalPosition: Vector3;
  25241. /**
  25242. * Creates a Solid Particle object.
  25243. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25244. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25245. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25246. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25247. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25248. * @param shapeId (integer) is the model shape identifier in the SPS.
  25249. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25250. * @param sps defines the sps it is associated to
  25251. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25252. */
  25253. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25254. /**
  25255. * Legacy support, changed scale to scaling
  25256. */
  25257. /**
  25258. * Legacy support, changed scale to scaling
  25259. */
  25260. scale: Vector3;
  25261. /**
  25262. * Legacy support, changed quaternion to rotationQuaternion
  25263. */
  25264. /**
  25265. * Legacy support, changed quaternion to rotationQuaternion
  25266. */
  25267. quaternion: Nullable<Quaternion>;
  25268. /**
  25269. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25270. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25271. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25272. * @returns true if it intersects
  25273. */
  25274. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25275. /**
  25276. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25277. * A particle is in the frustum if its bounding box intersects the frustum
  25278. * @param frustumPlanes defines the frustum to test
  25279. * @returns true if the particle is in the frustum planes
  25280. */
  25281. isInFrustum(frustumPlanes: Plane[]): boolean;
  25282. /**
  25283. * get the rotation matrix of the particle
  25284. * @hidden
  25285. */
  25286. getRotationMatrix(m: Matrix): void;
  25287. }
  25288. /**
  25289. * Represents the shape of the model used by one particle of a solid particle system.
  25290. * SPS internal tool, don't use it manually.
  25291. */
  25292. export class ModelShape {
  25293. /**
  25294. * The shape id
  25295. * @hidden
  25296. */
  25297. shapeID: number;
  25298. /**
  25299. * flat array of model positions (internal use)
  25300. * @hidden
  25301. */ private _shape: Vector3[];
  25302. /**
  25303. * flat array of model UVs (internal use)
  25304. * @hidden
  25305. */ private _shapeUV: number[];
  25306. /**
  25307. * length of the shape in the model indices array (internal use)
  25308. * @hidden
  25309. */ private _indicesLength: number;
  25310. /**
  25311. * Custom position function (internal use)
  25312. * @hidden
  25313. */ private _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25314. /**
  25315. * Custom vertex function (internal use)
  25316. * @hidden
  25317. */ private _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25318. /**
  25319. * 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.
  25320. * SPS internal tool, don't use it manually.
  25321. * @hidden
  25322. */
  25323. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  25324. }
  25325. /**
  25326. * Represents a Depth Sorted Particle in the solid particle system.
  25327. */
  25328. export class DepthSortedParticle {
  25329. /**
  25330. * Index of the particle in the "indices" array
  25331. */
  25332. ind: number;
  25333. /**
  25334. * Length of the particle shape in the "indices" array
  25335. */
  25336. indicesLength: number;
  25337. /**
  25338. * Squared distance from the particle to the camera
  25339. */
  25340. sqDistance: number;
  25341. }
  25342. }
  25343. declare module BABYLON {
  25344. /**
  25345. * @hidden
  25346. */
  25347. 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>>;
  25348. }
  25349. }
  25350. declare module BABYLON {
  25351. /** @hidden */ private class _FacetDataStorage {
  25352. facetPositions: Vector3[];
  25353. facetNormals: Vector3[];
  25354. facetPartitioning: number[][];
  25355. facetNb: number;
  25356. partitioningSubdivisions: number;
  25357. partitioningBBoxRatio: number;
  25358. facetDataEnabled: boolean;
  25359. facetParameters: any;
  25360. bbSize: Vector3;
  25361. subDiv: {
  25362. max: number;
  25363. X: number;
  25364. Y: number;
  25365. Z: number;
  25366. };
  25367. facetDepthSort: boolean;
  25368. facetDepthSortEnabled: boolean;
  25369. depthSortedIndices: IndicesArray;
  25370. depthSortedFacets: {
  25371. ind: number;
  25372. sqDistance: number;
  25373. }[];
  25374. facetDepthSortFunction: (f1: {
  25375. ind: number;
  25376. sqDistance: number;
  25377. }, f2: {
  25378. ind: number;
  25379. sqDistance: number;
  25380. }) => number;
  25381. facetDepthSortFrom: Vector3;
  25382. facetDepthSortOrigin: Vector3;
  25383. invertedMatrix: Matrix;
  25384. }
  25385. /**
  25386. * @hidden
  25387. **/ 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;
  25388. }
  25389. /**
  25390. * Class used to store all common mesh properties
  25391. */
  25392. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25393. /** No occlusion */
  25394. static OCCLUSION_TYPE_NONE: number;
  25395. /** Occlusion set to optimisitic */
  25396. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25397. /** Occlusion set to strict */
  25398. static OCCLUSION_TYPE_STRICT: number;
  25399. /** Use an accurante occlusion algorithm */
  25400. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25401. /** Use a conservative occlusion algorithm */
  25402. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25403. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25404. * Test order :
  25405. * Is the bounding sphere outside the frustum ?
  25406. * If not, are the bounding box vertices outside the frustum ?
  25407. * It not, then the cullable object is in the frustum.
  25408. */
  25409. static readonly CULLINGSTRATEGY_STANDARD: number;
  25410. /** Culling strategy : Bounding Sphere Only.
  25411. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25412. * It's also less accurate than the standard because some not visible objects can still be selected.
  25413. * Test : is the bounding sphere outside the frustum ?
  25414. * If not, then the cullable object is in the frustum.
  25415. */
  25416. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25417. /** Culling strategy : Optimistic Inclusion.
  25418. * This in an inclusion test first, then the standard exclusion test.
  25419. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25420. * 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.
  25421. * Anyway, it's as accurate as the standard strategy.
  25422. * Test :
  25423. * Is the cullable object bounding sphere center in the frustum ?
  25424. * If not, apply the default culling strategy.
  25425. */
  25426. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25427. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25428. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25429. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25430. * 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.
  25431. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25432. * Test :
  25433. * Is the cullable object bounding sphere center in the frustum ?
  25434. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25435. */
  25436. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25437. /**
  25438. * No billboard
  25439. */
  25440. static readonly BILLBOARDMODE_NONE: number;
  25441. /** Billboard on X axis */
  25442. static readonly BILLBOARDMODE_X: number;
  25443. /** Billboard on Y axis */
  25444. static readonly BILLBOARDMODE_Y: number;
  25445. /** Billboard on Z axis */
  25446. static readonly BILLBOARDMODE_Z: number;
  25447. /** Billboard on all axes */
  25448. static readonly BILLBOARDMODE_ALL: number;
  25449. /** Billboard on using position instead of orientation */
  25450. static readonly BILLBOARDMODE_USE_POSITION: number;
  25451. /** @hidden */ private _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25452. /**
  25453. * The culling strategy to use to check whether the mesh must be rendered or not.
  25454. * This value can be changed at any time and will be used on the next render mesh selection.
  25455. * The possible values are :
  25456. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25457. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25458. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25459. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25460. * Please read each static variable documentation to get details about the culling process.
  25461. * */
  25462. cullingStrategy: number;
  25463. /**
  25464. * Gets the number of facets in the mesh
  25465. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25466. */
  25467. readonly facetNb: number;
  25468. /**
  25469. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25470. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25471. */
  25472. partitioningSubdivisions: number;
  25473. /**
  25474. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25475. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25476. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25477. */
  25478. partitioningBBoxRatio: number;
  25479. /**
  25480. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25481. * Works only for updatable meshes.
  25482. * Doesn't work with multi-materials
  25483. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25484. */
  25485. mustDepthSortFacets: boolean;
  25486. /**
  25487. * The location (Vector3) where the facet depth sort must be computed from.
  25488. * By default, the active camera position.
  25489. * Used only when facet depth sort is enabled
  25490. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25491. */
  25492. facetDepthSortFrom: Vector3;
  25493. /**
  25494. * gets a boolean indicating if facetData is enabled
  25495. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25496. */
  25497. readonly isFacetDataEnabled: boolean;
  25498. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  25499. /**
  25500. * An event triggered when this mesh collides with another one
  25501. */
  25502. onCollideObservable: Observable<AbstractMesh>;
  25503. /** Set a function to call when this mesh collides with another one */
  25504. onCollide: () => void;
  25505. /**
  25506. * An event triggered when the collision's position changes
  25507. */
  25508. onCollisionPositionChangeObservable: Observable<Vector3>;
  25509. /** Set a function to call when the collision's position changes */
  25510. onCollisionPositionChange: () => void;
  25511. /**
  25512. * An event triggered when material is changed
  25513. */
  25514. onMaterialChangedObservable: Observable<AbstractMesh>;
  25515. /**
  25516. * Gets or sets the orientation for POV movement & rotation
  25517. */
  25518. definedFacingForward: boolean;
  25519. /** @hidden */ private _occlusionQuery: Nullable<WebGLQuery>;
  25520. /** @hidden */ private _renderingGroup: Nullable<RenderingGroup>;
  25521. /**
  25522. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25523. */
  25524. /**
  25525. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25526. */
  25527. visibility: number;
  25528. /** Gets or sets the alpha index used to sort transparent meshes
  25529. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25530. */
  25531. alphaIndex: number;
  25532. /**
  25533. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25534. */
  25535. isVisible: boolean;
  25536. /**
  25537. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25538. */
  25539. isPickable: boolean;
  25540. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25541. showSubMeshesBoundingBox: boolean;
  25542. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25543. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25544. */
  25545. isBlocker: boolean;
  25546. /**
  25547. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25548. */
  25549. enablePointerMoveEvents: boolean;
  25550. /**
  25551. * Specifies the rendering group id for this mesh (0 by default)
  25552. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25553. */
  25554. renderingGroupId: number;
  25555. private _material;
  25556. /** Gets or sets current material */
  25557. material: Nullable<Material>;
  25558. /**
  25559. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25560. * @see http://doc.babylonjs.com/babylon101/shadows
  25561. */
  25562. receiveShadows: boolean;
  25563. /** Defines color to use when rendering outline */
  25564. outlineColor: Color3;
  25565. /** Define width to use when rendering outline */
  25566. outlineWidth: number;
  25567. /** Defines color to use when rendering overlay */
  25568. overlayColor: Color3;
  25569. /** Defines alpha to use when rendering overlay */
  25570. overlayAlpha: number;
  25571. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25572. hasVertexAlpha: boolean;
  25573. /** 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) */
  25574. useVertexColors: boolean;
  25575. /**
  25576. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25577. */
  25578. computeBonesUsingShaders: boolean;
  25579. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25580. numBoneInfluencers: number;
  25581. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25582. applyFog: boolean;
  25583. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25584. useOctreeForRenderingSelection: boolean;
  25585. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25586. useOctreeForPicking: boolean;
  25587. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25588. useOctreeForCollisions: boolean;
  25589. /**
  25590. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25591. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25592. */
  25593. layerMask: number;
  25594. /**
  25595. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25596. */
  25597. alwaysSelectAsActiveMesh: boolean;
  25598. /**
  25599. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25600. */
  25601. doNotSyncBoundingInfo: boolean;
  25602. /**
  25603. * Gets or sets the current action manager
  25604. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25605. */
  25606. actionManager: Nullable<AbstractActionManager>;
  25607. private _meshCollisionData;
  25608. /**
  25609. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25610. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25611. */
  25612. ellipsoid: Vector3;
  25613. /**
  25614. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25615. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25616. */
  25617. ellipsoidOffset: Vector3;
  25618. /**
  25619. * Gets or sets a collision mask used to mask collisions (default is -1).
  25620. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25621. */
  25622. collisionMask: number;
  25623. /**
  25624. * Gets or sets the current collision group mask (-1 by default).
  25625. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25626. */
  25627. collisionGroup: number;
  25628. /**
  25629. * Defines edge width used when edgesRenderer is enabled
  25630. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25631. */
  25632. edgesWidth: number;
  25633. /**
  25634. * Defines edge color used when edgesRenderer is enabled
  25635. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25636. */
  25637. edgesColor: Color4;
  25638. /** @hidden */ private _edgesRenderer: Nullable<IEdgesRenderer>;
  25639. /** @hidden */ private _masterMesh: Nullable<AbstractMesh>;
  25640. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  25641. /** @hidden */ private _renderId: number;
  25642. /**
  25643. * Gets or sets the list of subMeshes
  25644. * @see http://doc.babylonjs.com/how_to/multi_materials
  25645. */
  25646. subMeshes: SubMesh[];
  25647. /** @hidden */ private _intersectionsInProgress: AbstractMesh[];
  25648. /** @hidden */ private _unIndexed: boolean;
  25649. /** @hidden */ private _lightSources: Light[];
  25650. /** Gets the list of lights affecting that mesh */
  25651. readonly lightSources: Light[];
  25652. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  25653. /** @hidden */ private _waitingData: {
  25654. lods: Nullable<any>;
  25655. actions: Nullable<any>;
  25656. freezeWorldMatrix: Nullable<boolean>;
  25657. };
  25658. /** @hidden */ private _bonesTransformMatrices: Nullable<Float32Array>;
  25659. /** @hidden */ private _transformMatrixTexture: Nullable<RawTexture>;
  25660. /**
  25661. * Gets or sets a skeleton to apply skining transformations
  25662. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25663. */
  25664. skeleton: Nullable<Skeleton>;
  25665. /**
  25666. * An event triggered when the mesh is rebuilt.
  25667. */
  25668. onRebuildObservable: Observable<AbstractMesh>;
  25669. /**
  25670. * Creates a new AbstractMesh
  25671. * @param name defines the name of the mesh
  25672. * @param scene defines the hosting scene
  25673. */
  25674. constructor(name: string, scene?: Nullable<Scene>);
  25675. /**
  25676. * Returns the string "AbstractMesh"
  25677. * @returns "AbstractMesh"
  25678. */
  25679. getClassName(): string;
  25680. /**
  25681. * Gets a string representation of the current mesh
  25682. * @param fullDetails defines a boolean indicating if full details must be included
  25683. * @returns a string representation of the current mesh
  25684. */
  25685. toString(fullDetails?: boolean): string;
  25686. /**
  25687. * @hidden
  25688. */
  25689. protected _getEffectiveParent(): Nullable<Node>;
  25690. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25691. /** @hidden */ private _rebuild(): void;
  25692. /** @hidden */ private _resyncLightSources(): void;
  25693. /** @hidden */ private _resyncLighSource(light: Light): void;
  25694. /** @hidden */ private _unBindEffect(): void;
  25695. /** @hidden */ private _removeLightSource(light: Light, dispose: boolean): void;
  25696. private _markSubMeshesAsDirty;
  25697. /** @hidden */ private _markSubMeshesAsLightDirty(dispose?: boolean): void;
  25698. /** @hidden */ private _markSubMeshesAsAttributesDirty(): void;
  25699. /** @hidden */ private _markSubMeshesAsMiscDirty(): void;
  25700. /**
  25701. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25702. */
  25703. scaling: Vector3;
  25704. /**
  25705. * Returns true if the mesh is blocked. Implemented by child classes
  25706. */
  25707. readonly isBlocked: boolean;
  25708. /**
  25709. * Returns the mesh itself by default. Implemented by child classes
  25710. * @param camera defines the camera to use to pick the right LOD level
  25711. * @returns the currentAbstractMesh
  25712. */
  25713. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25714. /**
  25715. * Returns 0 by default. Implemented by child classes
  25716. * @returns an integer
  25717. */
  25718. getTotalVertices(): number;
  25719. /**
  25720. * Returns a positive integer : the total number of indices in this mesh geometry.
  25721. * @returns the numner of indices or zero if the mesh has no geometry.
  25722. */
  25723. getTotalIndices(): number;
  25724. /**
  25725. * Returns null by default. Implemented by child classes
  25726. * @returns null
  25727. */
  25728. getIndices(): Nullable<IndicesArray>;
  25729. /**
  25730. * Returns the array of the requested vertex data kind. Implemented by child classes
  25731. * @param kind defines the vertex data kind to use
  25732. * @returns null
  25733. */
  25734. getVerticesData(kind: string): Nullable<FloatArray>;
  25735. /**
  25736. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25737. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25738. * Note that a new underlying VertexBuffer object is created each call.
  25739. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25740. * @param kind defines vertex data kind:
  25741. * * VertexBuffer.PositionKind
  25742. * * VertexBuffer.UVKind
  25743. * * VertexBuffer.UV2Kind
  25744. * * VertexBuffer.UV3Kind
  25745. * * VertexBuffer.UV4Kind
  25746. * * VertexBuffer.UV5Kind
  25747. * * VertexBuffer.UV6Kind
  25748. * * VertexBuffer.ColorKind
  25749. * * VertexBuffer.MatricesIndicesKind
  25750. * * VertexBuffer.MatricesIndicesExtraKind
  25751. * * VertexBuffer.MatricesWeightsKind
  25752. * * VertexBuffer.MatricesWeightsExtraKind
  25753. * @param data defines the data source
  25754. * @param updatable defines if the data must be flagged as updatable (or static)
  25755. * @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
  25756. * @returns the current mesh
  25757. */
  25758. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25759. /**
  25760. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25761. * If the mesh has no geometry, it is simply returned as it is.
  25762. * @param kind defines vertex data kind:
  25763. * * VertexBuffer.PositionKind
  25764. * * VertexBuffer.UVKind
  25765. * * VertexBuffer.UV2Kind
  25766. * * VertexBuffer.UV3Kind
  25767. * * VertexBuffer.UV4Kind
  25768. * * VertexBuffer.UV5Kind
  25769. * * VertexBuffer.UV6Kind
  25770. * * VertexBuffer.ColorKind
  25771. * * VertexBuffer.MatricesIndicesKind
  25772. * * VertexBuffer.MatricesIndicesExtraKind
  25773. * * VertexBuffer.MatricesWeightsKind
  25774. * * VertexBuffer.MatricesWeightsExtraKind
  25775. * @param data defines the data source
  25776. * @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
  25777. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25778. * @returns the current mesh
  25779. */
  25780. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25781. /**
  25782. * Sets the mesh indices,
  25783. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25784. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25785. * @param totalVertices Defines the total number of vertices
  25786. * @returns the current mesh
  25787. */
  25788. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25789. /**
  25790. * Gets a boolean indicating if specific vertex data is present
  25791. * @param kind defines the vertex data kind to use
  25792. * @returns true is data kind is present
  25793. */
  25794. isVerticesDataPresent(kind: string): boolean;
  25795. /**
  25796. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25797. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25798. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25799. * @returns a BoundingInfo
  25800. */
  25801. getBoundingInfo(): BoundingInfo;
  25802. /**
  25803. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25804. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25805. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25806. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25807. * @returns the current mesh
  25808. */
  25809. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25810. /**
  25811. * Overwrite the current bounding info
  25812. * @param boundingInfo defines the new bounding info
  25813. * @returns the current mesh
  25814. */
  25815. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25816. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25817. readonly useBones: boolean;
  25818. /** @hidden */ private _preActivate(): void;
  25819. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): void;
  25820. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  25821. /** @hidden */ private _postActivate(): void;
  25822. /** @hidden */ private _freeze(): void;
  25823. /** @hidden */ private _unFreeze(): void;
  25824. /**
  25825. * Gets the current world matrix
  25826. * @returns a Matrix
  25827. */
  25828. getWorldMatrix(): Matrix;
  25829. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  25830. /**
  25831. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25832. */
  25833. readonly isAnInstance: boolean;
  25834. /**
  25835. * Gets a boolean indicating if this mesh has instances
  25836. */
  25837. readonly hasInstances: boolean;
  25838. /**
  25839. * Perform relative position change from the point of view of behind the front of the mesh.
  25840. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25841. * Supports definition of mesh facing forward or backward
  25842. * @param amountRight defines the distance on the right axis
  25843. * @param amountUp defines the distance on the up axis
  25844. * @param amountForward defines the distance on the forward axis
  25845. * @returns the current mesh
  25846. */
  25847. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25848. /**
  25849. * Calculate relative position change from the point of view of behind the front of the mesh.
  25850. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25851. * Supports definition of mesh facing forward or backward
  25852. * @param amountRight defines the distance on the right axis
  25853. * @param amountUp defines the distance on the up axis
  25854. * @param amountForward defines the distance on the forward axis
  25855. * @returns the new displacement vector
  25856. */
  25857. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25858. /**
  25859. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25860. * Supports definition of mesh facing forward or backward
  25861. * @param flipBack defines the flip
  25862. * @param twirlClockwise defines the twirl
  25863. * @param tiltRight defines the tilt
  25864. * @returns the current mesh
  25865. */
  25866. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25867. /**
  25868. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25869. * Supports definition of mesh facing forward or backward.
  25870. * @param flipBack defines the flip
  25871. * @param twirlClockwise defines the twirl
  25872. * @param tiltRight defines the tilt
  25873. * @returns the new rotation vector
  25874. */
  25875. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25876. /**
  25877. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25878. * This means the mesh underlying bounding box and sphere are recomputed.
  25879. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25880. * @returns the current mesh
  25881. */
  25882. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25883. /** @hidden */ private _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25884. /** @hidden */ private _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25885. /** @hidden */ private _updateBoundingInfo(): AbstractMesh;
  25886. /** @hidden */ private _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25887. /** @hidden */
  25888. protected _afterComputeWorldMatrix(): void;
  25889. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  25890. /**
  25891. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25892. * A mesh is in the frustum if its bounding box intersects the frustum
  25893. * @param frustumPlanes defines the frustum to test
  25894. * @returns true if the mesh is in the frustum planes
  25895. */
  25896. isInFrustum(frustumPlanes: Plane[]): boolean;
  25897. /**
  25898. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25899. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25900. * @param frustumPlanes defines the frustum to test
  25901. * @returns true if the mesh is completely in the frustum planes
  25902. */
  25903. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25904. /**
  25905. * True if the mesh intersects another mesh or a SolidParticle object
  25906. * @param mesh defines a target mesh or SolidParticle to test
  25907. * @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)
  25908. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25909. * @returns true if there is an intersection
  25910. */
  25911. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25912. /**
  25913. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25914. * @param point defines the point to test
  25915. * @returns true if there is an intersection
  25916. */
  25917. intersectsPoint(point: Vector3): boolean;
  25918. /**
  25919. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25920. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25921. */
  25922. checkCollisions: boolean;
  25923. /**
  25924. * Gets Collider object used to compute collisions (not physics)
  25925. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25926. */
  25927. readonly collider: Nullable<Collider>;
  25928. /**
  25929. * Move the mesh using collision engine
  25930. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25931. * @param displacement defines the requested displacement vector
  25932. * @returns the current mesh
  25933. */
  25934. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25935. private _onCollisionPositionChange;
  25936. /** @hidden */ private _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25937. /** @hidden */ private _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25938. /** @hidden */ private _checkCollision(collider: Collider): AbstractMesh;
  25939. /** @hidden */ private _generatePointsArray(): boolean;
  25940. /**
  25941. * Checks if the passed Ray intersects with the mesh
  25942. * @param ray defines the ray to use
  25943. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25944. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25945. * @returns the picking info
  25946. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25947. */
  25948. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25949. /**
  25950. * Clones the current mesh
  25951. * @param name defines the mesh name
  25952. * @param newParent defines the new mesh parent
  25953. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25954. * @returns the new mesh
  25955. */
  25956. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25957. /**
  25958. * Disposes all the submeshes of the current meshnp
  25959. * @returns the current mesh
  25960. */
  25961. releaseSubMeshes(): AbstractMesh;
  25962. /**
  25963. * Releases resources associated with this abstract mesh.
  25964. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25965. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25966. */
  25967. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25968. /**
  25969. * Adds the passed mesh as a child to the current mesh
  25970. * @param mesh defines the child mesh
  25971. * @returns the current mesh
  25972. */
  25973. addChild(mesh: AbstractMesh): AbstractMesh;
  25974. /**
  25975. * Removes the passed mesh from the current mesh children list
  25976. * @param mesh defines the child mesh
  25977. * @returns the current mesh
  25978. */
  25979. removeChild(mesh: AbstractMesh): AbstractMesh;
  25980. /** @hidden */
  25981. private _initFacetData;
  25982. /**
  25983. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25984. * This method can be called within the render loop.
  25985. * 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
  25986. * @returns the current mesh
  25987. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25988. */
  25989. updateFacetData(): AbstractMesh;
  25990. /**
  25991. * Returns the facetLocalNormals array.
  25992. * The normals are expressed in the mesh local spac
  25993. * @returns an array of Vector3
  25994. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25995. */
  25996. getFacetLocalNormals(): Vector3[];
  25997. /**
  25998. * Returns the facetLocalPositions array.
  25999. * The facet positions are expressed in the mesh local space
  26000. * @returns an array of Vector3
  26001. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26002. */
  26003. getFacetLocalPositions(): Vector3[];
  26004. /**
  26005. * Returns the facetLocalPartioning array
  26006. * @returns an array of array of numbers
  26007. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26008. */
  26009. getFacetLocalPartitioning(): number[][];
  26010. /**
  26011. * Returns the i-th facet position in the world system.
  26012. * This method allocates a new Vector3 per call
  26013. * @param i defines the facet index
  26014. * @returns a new Vector3
  26015. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26016. */
  26017. getFacetPosition(i: number): Vector3;
  26018. /**
  26019. * Sets the reference Vector3 with the i-th facet position in the world system
  26020. * @param i defines the facet index
  26021. * @param ref defines the target vector
  26022. * @returns the current mesh
  26023. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26024. */
  26025. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26026. /**
  26027. * Returns the i-th facet normal in the world system.
  26028. * This method allocates a new Vector3 per call
  26029. * @param i defines the facet index
  26030. * @returns a new Vector3
  26031. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26032. */
  26033. getFacetNormal(i: number): Vector3;
  26034. /**
  26035. * Sets the reference Vector3 with the i-th facet normal in the world system
  26036. * @param i defines the facet index
  26037. * @param ref defines the target vector
  26038. * @returns the current mesh
  26039. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26040. */
  26041. getFacetNormalToRef(i: number, ref: Vector3): this;
  26042. /**
  26043. * 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)
  26044. * @param x defines x coordinate
  26045. * @param y defines y coordinate
  26046. * @param z defines z coordinate
  26047. * @returns the array of facet indexes
  26048. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26049. */
  26050. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26051. /**
  26052. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26053. * @param projected sets as the (x,y,z) world projection on the facet
  26054. * @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
  26055. * @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
  26056. * @param x defines x coordinate
  26057. * @param y defines y coordinate
  26058. * @param z defines z coordinate
  26059. * @returns the face index if found (or null instead)
  26060. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26061. */
  26062. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26063. /**
  26064. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26065. * @param projected sets as the (x,y,z) local projection on the facet
  26066. * @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
  26067. * @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
  26068. * @param x defines x coordinate
  26069. * @param y defines y coordinate
  26070. * @param z defines z coordinate
  26071. * @returns the face index if found (or null instead)
  26072. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26073. */
  26074. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26075. /**
  26076. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26077. * @returns the parameters
  26078. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26079. */
  26080. getFacetDataParameters(): any;
  26081. /**
  26082. * Disables the feature FacetData and frees the related memory
  26083. * @returns the current mesh
  26084. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26085. */
  26086. disableFacetData(): AbstractMesh;
  26087. /**
  26088. * Updates the AbstractMesh indices array
  26089. * @param indices defines the data source
  26090. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26091. * @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)
  26092. * @returns the current mesh
  26093. */
  26094. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26095. /**
  26096. * Creates new normals data for the mesh
  26097. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26098. * @returns the current mesh
  26099. */
  26100. createNormals(updatable: boolean): AbstractMesh;
  26101. /**
  26102. * Align the mesh with a normal
  26103. * @param normal defines the normal to use
  26104. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26105. * @returns the current mesh
  26106. */
  26107. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26108. /** @hidden */ private _checkOcclusionQuery(): boolean;
  26109. /**
  26110. * Disables the mesh edge rendering mode
  26111. * @returns the currentAbstractMesh
  26112. */
  26113. disableEdgesRendering(): AbstractMesh;
  26114. /**
  26115. * Enables the edge rendering mode on the mesh.
  26116. * This mode makes the mesh edges visible
  26117. * @param epsilon defines the maximal distance between two angles to detect a face
  26118. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26119. * @returns the currentAbstractMesh
  26120. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26121. */
  26122. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26123. }
  26124. }
  26125. declare module BABYLON {
  26126. /**
  26127. * Interface used to define ActionEvent
  26128. */
  26129. export interface IActionEvent {
  26130. /** The mesh or sprite that triggered the action */
  26131. source: any;
  26132. /** The X mouse cursor position at the time of the event */
  26133. pointerX: number;
  26134. /** The Y mouse cursor position at the time of the event */
  26135. pointerY: number;
  26136. /** The mesh that is currently pointed at (can be null) */
  26137. meshUnderPointer: Nullable<AbstractMesh>;
  26138. /** the original (browser) event that triggered the ActionEvent */
  26139. sourceEvent?: any;
  26140. /** additional data for the event */
  26141. additionalData?: any;
  26142. }
  26143. /**
  26144. * ActionEvent is the event being sent when an action is triggered.
  26145. */
  26146. export class ActionEvent implements IActionEvent {
  26147. /** The mesh or sprite that triggered the action */
  26148. source: any;
  26149. /** The X mouse cursor position at the time of the event */
  26150. pointerX: number;
  26151. /** The Y mouse cursor position at the time of the event */
  26152. pointerY: number;
  26153. /** The mesh that is currently pointed at (can be null) */
  26154. meshUnderPointer: Nullable<AbstractMesh>;
  26155. /** the original (browser) event that triggered the ActionEvent */
  26156. sourceEvent?: any;
  26157. /** additional data for the event */
  26158. additionalData?: any;
  26159. /**
  26160. * Creates a new ActionEvent
  26161. * @param source The mesh or sprite that triggered the action
  26162. * @param pointerX The X mouse cursor position at the time of the event
  26163. * @param pointerY The Y mouse cursor position at the time of the event
  26164. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26165. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26166. * @param additionalData additional data for the event
  26167. */
  26168. constructor(
  26169. /** The mesh or sprite that triggered the action */
  26170. source: any,
  26171. /** The X mouse cursor position at the time of the event */
  26172. pointerX: number,
  26173. /** The Y mouse cursor position at the time of the event */
  26174. pointerY: number,
  26175. /** The mesh that is currently pointed at (can be null) */
  26176. meshUnderPointer: Nullable<AbstractMesh>,
  26177. /** the original (browser) event that triggered the ActionEvent */
  26178. sourceEvent?: any,
  26179. /** additional data for the event */
  26180. additionalData?: any);
  26181. /**
  26182. * Helper function to auto-create an ActionEvent from a source mesh.
  26183. * @param source The source mesh that triggered the event
  26184. * @param evt The original (browser) event
  26185. * @param additionalData additional data for the event
  26186. * @returns the new ActionEvent
  26187. */
  26188. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26189. /**
  26190. * Helper function to auto-create an ActionEvent from a source sprite
  26191. * @param source The source sprite that triggered the event
  26192. * @param scene Scene associated with the sprite
  26193. * @param evt The original (browser) event
  26194. * @param additionalData additional data for the event
  26195. * @returns the new ActionEvent
  26196. */
  26197. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26198. /**
  26199. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26200. * @param scene the scene where the event occurred
  26201. * @param evt The original (browser) event
  26202. * @returns the new ActionEvent
  26203. */
  26204. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26205. /**
  26206. * Helper function to auto-create an ActionEvent from a primitive
  26207. * @param prim defines the target primitive
  26208. * @param pointerPos defines the pointer position
  26209. * @param evt The original (browser) event
  26210. * @param additionalData additional data for the event
  26211. * @returns the new ActionEvent
  26212. */
  26213. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26214. }
  26215. }
  26216. declare module BABYLON {
  26217. /**
  26218. * Abstract class used to decouple action Manager from scene and meshes.
  26219. * Do not instantiate.
  26220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26221. */
  26222. export abstract class AbstractActionManager implements IDisposable {
  26223. /** Gets the list of active triggers */
  26224. static Triggers: {
  26225. [key: string]: number;
  26226. };
  26227. /** Gets the cursor to use when hovering items */
  26228. hoverCursor: string;
  26229. /** Gets the list of actions */
  26230. actions: IAction[];
  26231. /**
  26232. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26233. */
  26234. isRecursive: boolean;
  26235. /**
  26236. * Releases all associated resources
  26237. */
  26238. abstract dispose(): void;
  26239. /**
  26240. * Does this action manager has pointer triggers
  26241. */
  26242. abstract readonly hasPointerTriggers: boolean;
  26243. /**
  26244. * Does this action manager has pick triggers
  26245. */
  26246. abstract readonly hasPickTriggers: boolean;
  26247. /**
  26248. * Process a specific trigger
  26249. * @param trigger defines the trigger to process
  26250. * @param evt defines the event details to be processed
  26251. */
  26252. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26253. /**
  26254. * Does this action manager handles actions of any of the given triggers
  26255. * @param triggers defines the triggers to be tested
  26256. * @return a boolean indicating whether one (or more) of the triggers is handled
  26257. */
  26258. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26259. /**
  26260. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26261. * speed.
  26262. * @param triggerA defines the trigger to be tested
  26263. * @param triggerB defines the trigger to be tested
  26264. * @return a boolean indicating whether one (or more) of the triggers is handled
  26265. */
  26266. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26267. /**
  26268. * Does this action manager handles actions of a given trigger
  26269. * @param trigger defines the trigger to be tested
  26270. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26271. * @return whether the trigger is handled
  26272. */
  26273. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26274. /**
  26275. * Serialize this manager to a JSON object
  26276. * @param name defines the property name to store this manager
  26277. * @returns a JSON representation of this manager
  26278. */
  26279. abstract serialize(name: string): any;
  26280. /**
  26281. * Registers an action to this action manager
  26282. * @param action defines the action to be registered
  26283. * @return the action amended (prepared) after registration
  26284. */
  26285. abstract registerAction(action: IAction): Nullable<IAction>;
  26286. /**
  26287. * Unregisters an action to this action manager
  26288. * @param action defines the action to be unregistered
  26289. * @return a boolean indicating whether the action has been unregistered
  26290. */
  26291. abstract unregisterAction(action: IAction): Boolean;
  26292. /**
  26293. * Does exist one action manager with at least one trigger
  26294. **/
  26295. static readonly HasTriggers: boolean;
  26296. /**
  26297. * Does exist one action manager with at least one pick trigger
  26298. **/
  26299. static readonly HasPickTriggers: boolean;
  26300. /**
  26301. * Does exist one action manager that handles actions of a given trigger
  26302. * @param trigger defines the trigger to be tested
  26303. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26304. **/
  26305. static HasSpecificTrigger(trigger: number): boolean;
  26306. }
  26307. }
  26308. declare module BABYLON {
  26309. /**
  26310. * Defines how a node can be built from a string name.
  26311. */
  26312. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26313. /**
  26314. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26315. */
  26316. export class Node implements IBehaviorAware<Node> {
  26317. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26318. private static _NodeConstructors;
  26319. /**
  26320. * Add a new node constructor
  26321. * @param type defines the type name of the node to construct
  26322. * @param constructorFunc defines the constructor function
  26323. */
  26324. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26325. /**
  26326. * Returns a node constructor based on type name
  26327. * @param type defines the type name
  26328. * @param name defines the new node name
  26329. * @param scene defines the hosting scene
  26330. * @param options defines optional options to transmit to constructors
  26331. * @returns the new constructor or null
  26332. */
  26333. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26334. /**
  26335. * Gets or sets the name of the node
  26336. */
  26337. name: string;
  26338. /**
  26339. * Gets or sets the id of the node
  26340. */
  26341. id: string;
  26342. /**
  26343. * Gets or sets the unique id of the node
  26344. */
  26345. uniqueId: number;
  26346. /**
  26347. * Gets or sets a string used to store user defined state for the node
  26348. */
  26349. state: string;
  26350. /**
  26351. * Gets or sets an object used to store user defined information for the node
  26352. */
  26353. metadata: any;
  26354. /**
  26355. * For internal use only. Please do not use.
  26356. */
  26357. reservedDataStore: any;
  26358. /**
  26359. * List of inspectable custom properties (used by the Inspector)
  26360. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26361. */
  26362. inspectableCustomProperties: IInspectable[];
  26363. /**
  26364. * Gets or sets a boolean used to define if the node must be serialized
  26365. */
  26366. doNotSerialize: boolean;
  26367. /** @hidden */ private _isDisposed: boolean;
  26368. /**
  26369. * Gets a list of Animations associated with the node
  26370. */
  26371. animations: Animation[];
  26372. protected _ranges: {
  26373. [name: string]: Nullable<AnimationRange>;
  26374. };
  26375. /**
  26376. * Callback raised when the node is ready to be used
  26377. */
  26378. onReady: Nullable<(node: Node) => void>;
  26379. private _isEnabled;
  26380. private _isParentEnabled;
  26381. private _isReady;
  26382. /** @hidden */ private _currentRenderId: number;
  26383. private _parentUpdateId;
  26384. /** @hidden */ private _childUpdateId: number;
  26385. /** @hidden */ private _waitingParentId: Nullable<string>;
  26386. /** @hidden */ private _scene: Scene;
  26387. /** @hidden */ private _cache: any;
  26388. private _parentNode;
  26389. private _children;
  26390. /** @hidden */ private _worldMatrix: Matrix;
  26391. /** @hidden */ private _worldMatrixDeterminant: number;
  26392. /** @hidden */ private _worldMatrixDeterminantIsDirty: boolean;
  26393. /** @hidden */
  26394. private _sceneRootNodesIndex;
  26395. /**
  26396. * Gets a boolean indicating if the node has been disposed
  26397. * @returns true if the node was disposed
  26398. */
  26399. isDisposed(): boolean;
  26400. /**
  26401. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26402. * @see https://doc.babylonjs.com/how_to/parenting
  26403. */
  26404. parent: Nullable<Node>;
  26405. private addToSceneRootNodes;
  26406. private removeFromSceneRootNodes;
  26407. private _animationPropertiesOverride;
  26408. /**
  26409. * Gets or sets the animation properties override
  26410. */
  26411. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26412. /**
  26413. * Gets a string idenfifying the name of the class
  26414. * @returns "Node" string
  26415. */
  26416. getClassName(): string;
  26417. /** @hidden */ protected readonly _isNode: boolean;
  26418. /**
  26419. * An event triggered when the mesh is disposed
  26420. */
  26421. onDisposeObservable: Observable<Node>;
  26422. private _onDisposeObserver;
  26423. /**
  26424. * Sets a callback that will be raised when the node will be disposed
  26425. */
  26426. onDispose: () => void;
  26427. /**
  26428. * Creates a new Node
  26429. * @param name the name and id to be given to this node
  26430. * @param scene the scene this node will be added to
  26431. * @param addToRootNodes the node will be added to scene.rootNodes
  26432. */
  26433. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26434. /**
  26435. * Gets the scene of the node
  26436. * @returns a scene
  26437. */
  26438. getScene(): Scene;
  26439. /**
  26440. * Gets the engine of the node
  26441. * @returns a Engine
  26442. */
  26443. getEngine(): Engine;
  26444. private _behaviors;
  26445. /**
  26446. * Attach a behavior to the node
  26447. * @see http://doc.babylonjs.com/features/behaviour
  26448. * @param behavior defines the behavior to attach
  26449. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26450. * @returns the current Node
  26451. */
  26452. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26453. /**
  26454. * Remove an attached behavior
  26455. * @see http://doc.babylonjs.com/features/behaviour
  26456. * @param behavior defines the behavior to attach
  26457. * @returns the current Node
  26458. */
  26459. removeBehavior(behavior: Behavior<Node>): Node;
  26460. /**
  26461. * Gets the list of attached behaviors
  26462. * @see http://doc.babylonjs.com/features/behaviour
  26463. */
  26464. readonly behaviors: Behavior<Node>[];
  26465. /**
  26466. * Gets an attached behavior by name
  26467. * @param name defines the name of the behavior to look for
  26468. * @see http://doc.babylonjs.com/features/behaviour
  26469. * @returns null if behavior was not found else the requested behavior
  26470. */
  26471. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26472. /**
  26473. * Returns the latest update of the World matrix
  26474. * @returns a Matrix
  26475. */
  26476. getWorldMatrix(): Matrix;
  26477. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  26478. /**
  26479. * Returns directly the latest state of the mesh World matrix.
  26480. * A Matrix is returned.
  26481. */
  26482. readonly worldMatrixFromCache: Matrix;
  26483. /** @hidden */ private _initCache(): void;
  26484. /** @hidden */
  26485. updateCache(force?: boolean): void;
  26486. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26487. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  26488. /** @hidden */ private _isSynchronized(): boolean;
  26489. /** @hidden */ private _markSyncedWithParent(): void;
  26490. /** @hidden */
  26491. isSynchronizedWithParent(): boolean;
  26492. /** @hidden */
  26493. isSynchronized(): boolean;
  26494. /**
  26495. * Is this node ready to be used/rendered
  26496. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26497. * @return true if the node is ready
  26498. */
  26499. isReady(completeCheck?: boolean): boolean;
  26500. /**
  26501. * Is this node enabled?
  26502. * 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
  26503. * @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
  26504. * @return whether this node (and its parent) is enabled
  26505. */
  26506. isEnabled(checkAncestors?: boolean): boolean;
  26507. /** @hidden */
  26508. protected _syncParentEnabledState(): void;
  26509. /**
  26510. * Set the enabled state of this node
  26511. * @param value defines the new enabled state
  26512. */
  26513. setEnabled(value: boolean): void;
  26514. /**
  26515. * Is this node a descendant of the given node?
  26516. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26517. * @param ancestor defines the parent node to inspect
  26518. * @returns a boolean indicating if this node is a descendant of the given node
  26519. */
  26520. isDescendantOf(ancestor: Node): boolean;
  26521. /** @hidden */ private _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26522. /**
  26523. * Will return all nodes that have this node as ascendant
  26524. * @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
  26525. * @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
  26526. * @return all children nodes of all types
  26527. */
  26528. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26529. /**
  26530. * Get all child-meshes of this node
  26531. * @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)
  26532. * @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
  26533. * @returns an array of AbstractMesh
  26534. */
  26535. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26536. /**
  26537. * Get all direct children of this node
  26538. * @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
  26539. * @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)
  26540. * @returns an array of Node
  26541. */
  26542. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26543. /** @hidden */ private _setReady(state: boolean): void;
  26544. /**
  26545. * Get an animation by name
  26546. * @param name defines the name of the animation to look for
  26547. * @returns null if not found else the requested animation
  26548. */
  26549. getAnimationByName(name: string): Nullable<Animation>;
  26550. /**
  26551. * Creates an animation range for this node
  26552. * @param name defines the name of the range
  26553. * @param from defines the starting key
  26554. * @param to defines the end key
  26555. */
  26556. createAnimationRange(name: string, from: number, to: number): void;
  26557. /**
  26558. * Delete a specific animation range
  26559. * @param name defines the name of the range to delete
  26560. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26561. */
  26562. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26563. /**
  26564. * Get an animation range by name
  26565. * @param name defines the name of the animation range to look for
  26566. * @returns null if not found else the requested animation range
  26567. */
  26568. getAnimationRange(name: string): Nullable<AnimationRange>;
  26569. /**
  26570. * Gets the list of all animation ranges defined on this node
  26571. * @returns an array
  26572. */
  26573. getAnimationRanges(): Nullable<AnimationRange>[];
  26574. /**
  26575. * Will start the animation sequence
  26576. * @param name defines the range frames for animation sequence
  26577. * @param loop defines if the animation should loop (false by default)
  26578. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26579. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26580. * @returns the object created for this animation. If range does not exist, it will return null
  26581. */
  26582. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26583. /**
  26584. * Serialize animation ranges into a JSON compatible object
  26585. * @returns serialization object
  26586. */
  26587. serializeAnimationRanges(): any;
  26588. /**
  26589. * Computes the world matrix of the node
  26590. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26591. * @returns the world matrix
  26592. */
  26593. computeWorldMatrix(force?: boolean): Matrix;
  26594. /**
  26595. * Releases resources associated with this node.
  26596. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26597. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26598. */
  26599. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26600. /**
  26601. * Parse animation range data from a serialization object and store them into a given node
  26602. * @param node defines where to store the animation ranges
  26603. * @param parsedNode defines the serialization object to read data from
  26604. * @param scene defines the hosting scene
  26605. */
  26606. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26607. /**
  26608. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26609. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26610. * @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
  26611. * @returns the new bounding vectors
  26612. */
  26613. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26614. min: Vector3;
  26615. max: Vector3;
  26616. };
  26617. }
  26618. }
  26619. declare module BABYLON {
  26620. /**
  26621. * @hidden
  26622. */
  26623. export class _IAnimationState {
  26624. key: number;
  26625. repeatCount: number;
  26626. workValue?: any;
  26627. loopMode?: number;
  26628. offsetValue?: any;
  26629. highLimitValue?: any;
  26630. }
  26631. /**
  26632. * Class used to store any kind of animation
  26633. */
  26634. export class Animation {
  26635. /**Name of the animation */
  26636. name: string;
  26637. /**Property to animate */
  26638. targetProperty: string;
  26639. /**The frames per second of the animation */
  26640. framePerSecond: number;
  26641. /**The data type of the animation */
  26642. dataType: number;
  26643. /**The loop mode of the animation */
  26644. loopMode?: number | undefined;
  26645. /**Specifies if blending should be enabled */
  26646. enableBlending?: boolean | undefined;
  26647. /**
  26648. * Use matrix interpolation instead of using direct key value when animating matrices
  26649. */
  26650. static AllowMatricesInterpolation: boolean;
  26651. /**
  26652. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26653. */
  26654. static AllowMatrixDecomposeForInterpolation: boolean;
  26655. /**
  26656. * Stores the key frames of the animation
  26657. */
  26658. private _keys;
  26659. /**
  26660. * Stores the easing function of the animation
  26661. */
  26662. private _easingFunction;
  26663. /**
  26664. * @hidden Internal use only
  26665. */ private _runtimeAnimations: RuntimeAnimation[];
  26666. /**
  26667. * The set of event that will be linked to this animation
  26668. */
  26669. private _events;
  26670. /**
  26671. * Stores an array of target property paths
  26672. */
  26673. targetPropertyPath: string[];
  26674. /**
  26675. * Stores the blending speed of the animation
  26676. */
  26677. blendingSpeed: number;
  26678. /**
  26679. * Stores the animation ranges for the animation
  26680. */
  26681. private _ranges;
  26682. /**
  26683. * @hidden Internal use
  26684. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26685. /**
  26686. * Sets up an animation
  26687. * @param property The property to animate
  26688. * @param animationType The animation type to apply
  26689. * @param framePerSecond The frames per second of the animation
  26690. * @param easingFunction The easing function used in the animation
  26691. * @returns The created animation
  26692. */
  26693. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26694. /**
  26695. * Create and start an animation on a node
  26696. * @param name defines the name of the global animation that will be run on all nodes
  26697. * @param node defines the root node where the animation will take place
  26698. * @param targetProperty defines property to animate
  26699. * @param framePerSecond defines the number of frame per second yo use
  26700. * @param totalFrame defines the number of frames in total
  26701. * @param from defines the initial value
  26702. * @param to defines the final value
  26703. * @param loopMode defines which loop mode you want to use (off by default)
  26704. * @param easingFunction defines the easing function to use (linear by default)
  26705. * @param onAnimationEnd defines the callback to call when animation end
  26706. * @returns the animatable created for this animation
  26707. */
  26708. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26709. /**
  26710. * Create and start an animation on a node and its descendants
  26711. * @param name defines the name of the global animation that will be run on all nodes
  26712. * @param node defines the root node where the animation will take place
  26713. * @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
  26714. * @param targetProperty defines property to animate
  26715. * @param framePerSecond defines the number of frame per second to use
  26716. * @param totalFrame defines the number of frames in total
  26717. * @param from defines the initial value
  26718. * @param to defines the final value
  26719. * @param loopMode defines which loop mode you want to use (off by default)
  26720. * @param easingFunction defines the easing function to use (linear by default)
  26721. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26722. * @returns the list of animatables created for all nodes
  26723. * @example https://www.babylonjs-playground.com/#MH0VLI
  26724. */
  26725. 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[]>;
  26726. /**
  26727. * Creates a new animation, merges it with the existing animations and starts it
  26728. * @param name Name of the animation
  26729. * @param node Node which contains the scene that begins the animations
  26730. * @param targetProperty Specifies which property to animate
  26731. * @param framePerSecond The frames per second of the animation
  26732. * @param totalFrame The total number of frames
  26733. * @param from The frame at the beginning of the animation
  26734. * @param to The frame at the end of the animation
  26735. * @param loopMode Specifies the loop mode of the animation
  26736. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26737. * @param onAnimationEnd Callback to run once the animation is complete
  26738. * @returns Nullable animation
  26739. */
  26740. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26741. /**
  26742. * Transition property of an host to the target Value
  26743. * @param property The property to transition
  26744. * @param targetValue The target Value of the property
  26745. * @param host The object where the property to animate belongs
  26746. * @param scene Scene used to run the animation
  26747. * @param frameRate Framerate (in frame/s) to use
  26748. * @param transition The transition type we want to use
  26749. * @param duration The duration of the animation, in milliseconds
  26750. * @param onAnimationEnd Callback trigger at the end of the animation
  26751. * @returns Nullable animation
  26752. */
  26753. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26754. /**
  26755. * Return the array of runtime animations currently using this animation
  26756. */
  26757. readonly runtimeAnimations: RuntimeAnimation[];
  26758. /**
  26759. * Specifies if any of the runtime animations are currently running
  26760. */
  26761. readonly hasRunningRuntimeAnimations: boolean;
  26762. /**
  26763. * Initializes the animation
  26764. * @param name Name of the animation
  26765. * @param targetProperty Property to animate
  26766. * @param framePerSecond The frames per second of the animation
  26767. * @param dataType The data type of the animation
  26768. * @param loopMode The loop mode of the animation
  26769. * @param enableBlending Specifies if blending should be enabled
  26770. */
  26771. constructor(
  26772. /**Name of the animation */
  26773. name: string,
  26774. /**Property to animate */
  26775. targetProperty: string,
  26776. /**The frames per second of the animation */
  26777. framePerSecond: number,
  26778. /**The data type of the animation */
  26779. dataType: number,
  26780. /**The loop mode of the animation */
  26781. loopMode?: number | undefined,
  26782. /**Specifies if blending should be enabled */
  26783. enableBlending?: boolean | undefined);
  26784. /**
  26785. * Converts the animation to a string
  26786. * @param fullDetails support for multiple levels of logging within scene loading
  26787. * @returns String form of the animation
  26788. */
  26789. toString(fullDetails?: boolean): string;
  26790. /**
  26791. * Add an event to this animation
  26792. * @param event Event to add
  26793. */
  26794. addEvent(event: AnimationEvent): void;
  26795. /**
  26796. * Remove all events found at the given frame
  26797. * @param frame The frame to remove events from
  26798. */
  26799. removeEvents(frame: number): void;
  26800. /**
  26801. * Retrieves all the events from the animation
  26802. * @returns Events from the animation
  26803. */
  26804. getEvents(): AnimationEvent[];
  26805. /**
  26806. * Creates an animation range
  26807. * @param name Name of the animation range
  26808. * @param from Starting frame of the animation range
  26809. * @param to Ending frame of the animation
  26810. */
  26811. createRange(name: string, from: number, to: number): void;
  26812. /**
  26813. * Deletes an animation range by name
  26814. * @param name Name of the animation range to delete
  26815. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26816. */
  26817. deleteRange(name: string, deleteFrames?: boolean): void;
  26818. /**
  26819. * Gets the animation range by name, or null if not defined
  26820. * @param name Name of the animation range
  26821. * @returns Nullable animation range
  26822. */
  26823. getRange(name: string): Nullable<AnimationRange>;
  26824. /**
  26825. * Gets the key frames from the animation
  26826. * @returns The key frames of the animation
  26827. */
  26828. getKeys(): Array<IAnimationKey>;
  26829. /**
  26830. * Gets the highest frame rate of the animation
  26831. * @returns Highest frame rate of the animation
  26832. */
  26833. getHighestFrame(): number;
  26834. /**
  26835. * Gets the easing function of the animation
  26836. * @returns Easing function of the animation
  26837. */
  26838. getEasingFunction(): IEasingFunction;
  26839. /**
  26840. * Sets the easing function of the animation
  26841. * @param easingFunction A custom mathematical formula for animation
  26842. */
  26843. setEasingFunction(easingFunction: EasingFunction): void;
  26844. /**
  26845. * Interpolates a scalar linearly
  26846. * @param startValue Start value of the animation curve
  26847. * @param endValue End value of the animation curve
  26848. * @param gradient Scalar amount to interpolate
  26849. * @returns Interpolated scalar value
  26850. */
  26851. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26852. /**
  26853. * Interpolates a scalar cubically
  26854. * @param startValue Start value of the animation curve
  26855. * @param outTangent End tangent of the animation
  26856. * @param endValue End value of the animation curve
  26857. * @param inTangent Start tangent of the animation curve
  26858. * @param gradient Scalar amount to interpolate
  26859. * @returns Interpolated scalar value
  26860. */
  26861. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26862. /**
  26863. * Interpolates a quaternion using a spherical linear interpolation
  26864. * @param startValue Start value of the animation curve
  26865. * @param endValue End value of the animation curve
  26866. * @param gradient Scalar amount to interpolate
  26867. * @returns Interpolated quaternion value
  26868. */
  26869. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26870. /**
  26871. * Interpolates a quaternion cubically
  26872. * @param startValue Start value of the animation curve
  26873. * @param outTangent End tangent of the animation curve
  26874. * @param endValue End value of the animation curve
  26875. * @param inTangent Start tangent of the animation curve
  26876. * @param gradient Scalar amount to interpolate
  26877. * @returns Interpolated quaternion value
  26878. */
  26879. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26880. /**
  26881. * Interpolates a Vector3 linearl
  26882. * @param startValue Start value of the animation curve
  26883. * @param endValue End value of the animation curve
  26884. * @param gradient Scalar amount to interpolate
  26885. * @returns Interpolated scalar value
  26886. */
  26887. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26888. /**
  26889. * Interpolates a Vector3 cubically
  26890. * @param startValue Start value of the animation curve
  26891. * @param outTangent End tangent of the animation
  26892. * @param endValue End value of the animation curve
  26893. * @param inTangent Start tangent of the animation curve
  26894. * @param gradient Scalar amount to interpolate
  26895. * @returns InterpolatedVector3 value
  26896. */
  26897. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26898. /**
  26899. * Interpolates a Vector2 linearly
  26900. * @param startValue Start value of the animation curve
  26901. * @param endValue End value of the animation curve
  26902. * @param gradient Scalar amount to interpolate
  26903. * @returns Interpolated Vector2 value
  26904. */
  26905. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26906. /**
  26907. * Interpolates a Vector2 cubically
  26908. * @param startValue Start value of the animation curve
  26909. * @param outTangent End tangent of the animation
  26910. * @param endValue End value of the animation curve
  26911. * @param inTangent Start tangent of the animation curve
  26912. * @param gradient Scalar amount to interpolate
  26913. * @returns Interpolated Vector2 value
  26914. */
  26915. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26916. /**
  26917. * Interpolates a size linearly
  26918. * @param startValue Start value of the animation curve
  26919. * @param endValue End value of the animation curve
  26920. * @param gradient Scalar amount to interpolate
  26921. * @returns Interpolated Size value
  26922. */
  26923. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26924. /**
  26925. * Interpolates a Color3 linearly
  26926. * @param startValue Start value of the animation curve
  26927. * @param endValue End value of the animation curve
  26928. * @param gradient Scalar amount to interpolate
  26929. * @returns Interpolated Color3 value
  26930. */
  26931. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26932. /**
  26933. * @hidden Internal use only
  26934. */ private _getKeyValue(value: any): any;
  26935. /**
  26936. * @hidden Internal use only
  26937. */ private _interpolate(currentFrame: number, state: _IAnimationState): any;
  26938. /**
  26939. * Defines the function to use to interpolate matrices
  26940. * @param startValue defines the start matrix
  26941. * @param endValue defines the end matrix
  26942. * @param gradient defines the gradient between both matrices
  26943. * @param result defines an optional target matrix where to store the interpolation
  26944. * @returns the interpolated matrix
  26945. */
  26946. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26947. /**
  26948. * Makes a copy of the animation
  26949. * @returns Cloned animation
  26950. */
  26951. clone(): Animation;
  26952. /**
  26953. * Sets the key frames of the animation
  26954. * @param values The animation key frames to set
  26955. */
  26956. setKeys(values: Array<IAnimationKey>): void;
  26957. /**
  26958. * Serializes the animation to an object
  26959. * @returns Serialized object
  26960. */
  26961. serialize(): any;
  26962. /**
  26963. * Float animation type
  26964. */
  26965. private static _ANIMATIONTYPE_FLOAT;
  26966. /**
  26967. * Vector3 animation type
  26968. */
  26969. private static _ANIMATIONTYPE_VECTOR3;
  26970. /**
  26971. * Quaternion animation type
  26972. */
  26973. private static _ANIMATIONTYPE_QUATERNION;
  26974. /**
  26975. * Matrix animation type
  26976. */
  26977. private static _ANIMATIONTYPE_MATRIX;
  26978. /**
  26979. * Color3 animation type
  26980. */
  26981. private static _ANIMATIONTYPE_COLOR3;
  26982. /**
  26983. * Vector2 animation type
  26984. */
  26985. private static _ANIMATIONTYPE_VECTOR2;
  26986. /**
  26987. * Size animation type
  26988. */
  26989. private static _ANIMATIONTYPE_SIZE;
  26990. /**
  26991. * Relative Loop Mode
  26992. */
  26993. private static _ANIMATIONLOOPMODE_RELATIVE;
  26994. /**
  26995. * Cycle Loop Mode
  26996. */
  26997. private static _ANIMATIONLOOPMODE_CYCLE;
  26998. /**
  26999. * Constant Loop Mode
  27000. */
  27001. private static _ANIMATIONLOOPMODE_CONSTANT;
  27002. /**
  27003. * Get the float animation type
  27004. */
  27005. static readonly ANIMATIONTYPE_FLOAT: number;
  27006. /**
  27007. * Get the Vector3 animation type
  27008. */
  27009. static readonly ANIMATIONTYPE_VECTOR3: number;
  27010. /**
  27011. * Get the Vector2 animation type
  27012. */
  27013. static readonly ANIMATIONTYPE_VECTOR2: number;
  27014. /**
  27015. * Get the Size animation type
  27016. */
  27017. static readonly ANIMATIONTYPE_SIZE: number;
  27018. /**
  27019. * Get the Quaternion animation type
  27020. */
  27021. static readonly ANIMATIONTYPE_QUATERNION: number;
  27022. /**
  27023. * Get the Matrix animation type
  27024. */
  27025. static readonly ANIMATIONTYPE_MATRIX: number;
  27026. /**
  27027. * Get the Color3 animation type
  27028. */
  27029. static readonly ANIMATIONTYPE_COLOR3: number;
  27030. /**
  27031. * Get the Relative Loop Mode
  27032. */
  27033. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27034. /**
  27035. * Get the Cycle Loop Mode
  27036. */
  27037. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27038. /**
  27039. * Get the Constant Loop Mode
  27040. */
  27041. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27042. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  27043. /**
  27044. * Parses an animation object and creates an animation
  27045. * @param parsedAnimation Parsed animation object
  27046. * @returns Animation object
  27047. */
  27048. static Parse(parsedAnimation: any): Animation;
  27049. /**
  27050. * Appends the serialized animations from the source animations
  27051. * @param source Source containing the animations
  27052. * @param destination Target to store the animations
  27053. */
  27054. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27055. }
  27056. }
  27057. declare module BABYLON {
  27058. /**
  27059. * Interface containing an array of animations
  27060. */
  27061. export interface IAnimatable {
  27062. /**
  27063. * Array of animations
  27064. */
  27065. animations: Nullable<Array<Animation>>;
  27066. }
  27067. }
  27068. declare module BABYLON {
  27069. /**
  27070. * This represents all the required information to add a fresnel effect on a material:
  27071. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27072. */
  27073. export class FresnelParameters {
  27074. private _isEnabled;
  27075. /**
  27076. * Define if the fresnel effect is enable or not.
  27077. */
  27078. isEnabled: boolean;
  27079. /**
  27080. * Define the color used on edges (grazing angle)
  27081. */
  27082. leftColor: Color3;
  27083. /**
  27084. * Define the color used on center
  27085. */
  27086. rightColor: Color3;
  27087. /**
  27088. * Define bias applied to computed fresnel term
  27089. */
  27090. bias: number;
  27091. /**
  27092. * Defined the power exponent applied to fresnel term
  27093. */
  27094. power: number;
  27095. /**
  27096. * Clones the current fresnel and its valuues
  27097. * @returns a clone fresnel configuration
  27098. */
  27099. clone(): FresnelParameters;
  27100. /**
  27101. * Serializes the current fresnel parameters to a JSON representation.
  27102. * @return the JSON serialization
  27103. */
  27104. serialize(): any;
  27105. /**
  27106. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27107. * @param parsedFresnelParameters Define the JSON representation
  27108. * @returns the parsed parameters
  27109. */
  27110. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27111. }
  27112. }
  27113. declare module BABYLON {
  27114. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27115. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27116. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27117. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27118. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27119. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27120. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27121. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27122. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27123. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27124. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27125. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27126. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27127. /**
  27128. * Decorator used to define property that can be serialized as reference to a camera
  27129. * @param sourceName defines the name of the property to decorate
  27130. */
  27131. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27132. /**
  27133. * Class used to help serialization objects
  27134. */
  27135. export class SerializationHelper {
  27136. /** @hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27137. /** @hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27138. /** @hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27139. /** @hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27140. /**
  27141. * Appends the serialized animations from the source animations
  27142. * @param source Source containing the animations
  27143. * @param destination Target to store the animations
  27144. */
  27145. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27146. /**
  27147. * Static function used to serialized a specific entity
  27148. * @param entity defines the entity to serialize
  27149. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27150. * @returns a JSON compatible object representing the serialization of the entity
  27151. */
  27152. static Serialize<T>(entity: T, serializationObject?: any): any;
  27153. /**
  27154. * Creates a new entity from a serialization data object
  27155. * @param creationFunction defines a function used to instanciated the new entity
  27156. * @param source defines the source serialization data
  27157. * @param scene defines the hosting scene
  27158. * @param rootUrl defines the root url for resources
  27159. * @returns a new entity
  27160. */
  27161. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27162. /**
  27163. * Clones an object
  27164. * @param creationFunction defines the function used to instanciate the new object
  27165. * @param source defines the source object
  27166. * @returns the cloned object
  27167. */
  27168. static Clone<T>(creationFunction: () => T, source: T): T;
  27169. /**
  27170. * Instanciates a new object based on a source one (some data will be shared between both object)
  27171. * @param creationFunction defines the function used to instanciate the new object
  27172. * @param source defines the source object
  27173. * @returns the new object
  27174. */
  27175. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27176. }
  27177. }
  27178. declare module BABYLON {
  27179. /**
  27180. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27181. */
  27182. export interface CubeMapInfo {
  27183. /**
  27184. * The pixel array for the front face.
  27185. * This is stored in format, left to right, up to down format.
  27186. */
  27187. front: Nullable<ArrayBufferView>;
  27188. /**
  27189. * The pixel array for the back face.
  27190. * This is stored in format, left to right, up to down format.
  27191. */
  27192. back: Nullable<ArrayBufferView>;
  27193. /**
  27194. * The pixel array for the left face.
  27195. * This is stored in format, left to right, up to down format.
  27196. */
  27197. left: Nullable<ArrayBufferView>;
  27198. /**
  27199. * The pixel array for the right face.
  27200. * This is stored in format, left to right, up to down format.
  27201. */
  27202. right: Nullable<ArrayBufferView>;
  27203. /**
  27204. * The pixel array for the up face.
  27205. * This is stored in format, left to right, up to down format.
  27206. */
  27207. up: Nullable<ArrayBufferView>;
  27208. /**
  27209. * The pixel array for the down face.
  27210. * This is stored in format, left to right, up to down format.
  27211. */
  27212. down: Nullable<ArrayBufferView>;
  27213. /**
  27214. * The size of the cubemap stored.
  27215. *
  27216. * Each faces will be size * size pixels.
  27217. */
  27218. size: number;
  27219. /**
  27220. * The format of the texture.
  27221. *
  27222. * RGBA, RGB.
  27223. */
  27224. format: number;
  27225. /**
  27226. * The type of the texture data.
  27227. *
  27228. * UNSIGNED_INT, FLOAT.
  27229. */
  27230. type: number;
  27231. /**
  27232. * Specifies whether the texture is in gamma space.
  27233. */
  27234. gammaSpace: boolean;
  27235. }
  27236. /**
  27237. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27238. */
  27239. export class PanoramaToCubeMapTools {
  27240. private static FACE_FRONT;
  27241. private static FACE_BACK;
  27242. private static FACE_RIGHT;
  27243. private static FACE_LEFT;
  27244. private static FACE_DOWN;
  27245. private static FACE_UP;
  27246. /**
  27247. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27248. *
  27249. * @param float32Array The source data.
  27250. * @param inputWidth The width of the input panorama.
  27251. * @param inputHeight The height of the input panorama.
  27252. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27253. * @return The cubemap data
  27254. */
  27255. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27256. private static CreateCubemapTexture;
  27257. private static CalcProjectionSpherical;
  27258. }
  27259. }
  27260. declare module BABYLON {
  27261. /**
  27262. * Helper class dealing with the extraction of spherical polynomial dataArray
  27263. * from a cube map.
  27264. */
  27265. export class CubeMapToSphericalPolynomialTools {
  27266. private static FileFaces;
  27267. /**
  27268. * Converts a texture to the according Spherical Polynomial data.
  27269. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27270. *
  27271. * @param texture The texture to extract the information from.
  27272. * @return The Spherical Polynomial data.
  27273. */
  27274. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27275. /**
  27276. * Converts a cubemap to the according Spherical Polynomial data.
  27277. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27278. *
  27279. * @param cubeInfo The Cube map to extract the information from.
  27280. * @return The Spherical Polynomial data.
  27281. */
  27282. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27283. }
  27284. }
  27285. declare module BABYLON {
  27286. /**
  27287. * Class used to manipulate GUIDs
  27288. */
  27289. export class GUID {
  27290. /**
  27291. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27292. * Be aware Math.random() could cause collisions, but:
  27293. * "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"
  27294. * @returns a pseudo random id
  27295. */
  27296. static RandomId(): string;
  27297. }
  27298. }
  27299. declare module BABYLON {
  27300. /**
  27301. * Base class of all the textures in babylon.
  27302. * It groups all the common properties the materials, post process, lights... might need
  27303. * in order to make a correct use of the texture.
  27304. */
  27305. export class BaseTexture implements IAnimatable {
  27306. /**
  27307. * Default anisotropic filtering level for the application.
  27308. * It is set to 4 as a good tradeoff between perf and quality.
  27309. */
  27310. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27311. /**
  27312. * Gets or sets the unique id of the texture
  27313. */
  27314. uniqueId: number;
  27315. /**
  27316. * Define the name of the texture.
  27317. */
  27318. name: string;
  27319. /**
  27320. * Gets or sets an object used to store user defined information.
  27321. */
  27322. metadata: any;
  27323. /**
  27324. * For internal use only. Please do not use.
  27325. */
  27326. reservedDataStore: any;
  27327. private _hasAlpha;
  27328. /**
  27329. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27330. */
  27331. hasAlpha: boolean;
  27332. /**
  27333. * Defines if the alpha value should be determined via the rgb values.
  27334. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27335. */
  27336. getAlphaFromRGB: boolean;
  27337. /**
  27338. * Intensity or strength of the texture.
  27339. * It is commonly used by materials to fine tune the intensity of the texture
  27340. */
  27341. level: number;
  27342. /**
  27343. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27344. * This is part of the texture as textures usually maps to one uv set.
  27345. */
  27346. coordinatesIndex: number;
  27347. private _coordinatesMode;
  27348. /**
  27349. * How a texture is mapped.
  27350. *
  27351. * | Value | Type | Description |
  27352. * | ----- | ----------------------------------- | ----------- |
  27353. * | 0 | EXPLICIT_MODE | |
  27354. * | 1 | SPHERICAL_MODE | |
  27355. * | 2 | PLANAR_MODE | |
  27356. * | 3 | CUBIC_MODE | |
  27357. * | 4 | PROJECTION_MODE | |
  27358. * | 5 | SKYBOX_MODE | |
  27359. * | 6 | INVCUBIC_MODE | |
  27360. * | 7 | EQUIRECTANGULAR_MODE | |
  27361. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27362. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27363. */
  27364. coordinatesMode: number;
  27365. /**
  27366. * | Value | Type | Description |
  27367. * | ----- | ------------------ | ----------- |
  27368. * | 0 | CLAMP_ADDRESSMODE | |
  27369. * | 1 | WRAP_ADDRESSMODE | |
  27370. * | 2 | MIRROR_ADDRESSMODE | |
  27371. */
  27372. wrapU: number;
  27373. /**
  27374. * | Value | Type | Description |
  27375. * | ----- | ------------------ | ----------- |
  27376. * | 0 | CLAMP_ADDRESSMODE | |
  27377. * | 1 | WRAP_ADDRESSMODE | |
  27378. * | 2 | MIRROR_ADDRESSMODE | |
  27379. */
  27380. wrapV: number;
  27381. /**
  27382. * | Value | Type | Description |
  27383. * | ----- | ------------------ | ----------- |
  27384. * | 0 | CLAMP_ADDRESSMODE | |
  27385. * | 1 | WRAP_ADDRESSMODE | |
  27386. * | 2 | MIRROR_ADDRESSMODE | |
  27387. */
  27388. wrapR: number;
  27389. /**
  27390. * With compliant hardware and browser (supporting anisotropic filtering)
  27391. * this defines the level of anisotropic filtering in the texture.
  27392. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27393. */
  27394. anisotropicFilteringLevel: number;
  27395. /**
  27396. * Define if the texture is a cube texture or if false a 2d texture.
  27397. */
  27398. isCube: boolean;
  27399. /**
  27400. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27401. */
  27402. is3D: boolean;
  27403. /**
  27404. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27405. * HDR texture are usually stored in linear space.
  27406. * This only impacts the PBR and Background materials
  27407. */
  27408. gammaSpace: boolean;
  27409. /**
  27410. * Gets or sets whether or not the texture contains RGBD data.
  27411. */
  27412. isRGBD: boolean;
  27413. /**
  27414. * Is Z inverted in the texture (useful in a cube texture).
  27415. */
  27416. invertZ: boolean;
  27417. /**
  27418. * Are mip maps generated for this texture or not.
  27419. */
  27420. readonly noMipmap: boolean;
  27421. /**
  27422. * @hidden
  27423. */
  27424. lodLevelInAlpha: boolean;
  27425. /**
  27426. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27427. */
  27428. lodGenerationOffset: number;
  27429. /**
  27430. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27431. */
  27432. lodGenerationScale: number;
  27433. /**
  27434. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27435. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27436. * average roughness values.
  27437. */
  27438. linearSpecularLOD: boolean;
  27439. /**
  27440. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27441. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27442. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27443. */
  27444. irradianceTexture: Nullable<BaseTexture>;
  27445. /**
  27446. * Define if the texture is a render target.
  27447. */
  27448. isRenderTarget: boolean;
  27449. /**
  27450. * Define the unique id of the texture in the scene.
  27451. */
  27452. readonly uid: string;
  27453. /**
  27454. * Return a string representation of the texture.
  27455. * @returns the texture as a string
  27456. */
  27457. toString(): string;
  27458. /**
  27459. * Get the class name of the texture.
  27460. * @returns "BaseTexture"
  27461. */
  27462. getClassName(): string;
  27463. /**
  27464. * Define the list of animation attached to the texture.
  27465. */
  27466. animations: Animation[];
  27467. /**
  27468. * An event triggered when the texture is disposed.
  27469. */
  27470. onDisposeObservable: Observable<BaseTexture>;
  27471. private _onDisposeObserver;
  27472. /**
  27473. * Callback triggered when the texture has been disposed.
  27474. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27475. */
  27476. onDispose: () => void;
  27477. /**
  27478. * Define the current state of the loading sequence when in delayed load mode.
  27479. */
  27480. delayLoadState: number;
  27481. private _scene;
  27482. /** @hidden */ private _texture: Nullable<InternalTexture>;
  27483. private _uid;
  27484. /**
  27485. * Define if the texture is preventinga material to render or not.
  27486. * If not and the texture is not ready, the engine will use a default black texture instead.
  27487. */
  27488. readonly isBlocking: boolean;
  27489. /**
  27490. * Instantiates a new BaseTexture.
  27491. * Base class of all the textures in babylon.
  27492. * It groups all the common properties the materials, post process, lights... might need
  27493. * in order to make a correct use of the texture.
  27494. * @param scene Define the scene the texture blongs to
  27495. */
  27496. constructor(scene: Nullable<Scene>);
  27497. /**
  27498. * Get the scene the texture belongs to.
  27499. * @returns the scene or null if undefined
  27500. */
  27501. getScene(): Nullable<Scene>;
  27502. /**
  27503. * Get the texture transform matrix used to offset tile the texture for istance.
  27504. * @returns the transformation matrix
  27505. */
  27506. getTextureMatrix(): Matrix;
  27507. /**
  27508. * Get the texture reflection matrix used to rotate/transform the reflection.
  27509. * @returns the reflection matrix
  27510. */
  27511. getReflectionTextureMatrix(): Matrix;
  27512. /**
  27513. * Get the underlying lower level texture from Babylon.
  27514. * @returns the insternal texture
  27515. */
  27516. getInternalTexture(): Nullable<InternalTexture>;
  27517. /**
  27518. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27519. * @returns true if ready or not blocking
  27520. */
  27521. isReadyOrNotBlocking(): boolean;
  27522. /**
  27523. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27524. * @returns true if fully ready
  27525. */
  27526. isReady(): boolean;
  27527. private _cachedSize;
  27528. /**
  27529. * Get the size of the texture.
  27530. * @returns the texture size.
  27531. */
  27532. getSize(): ISize;
  27533. /**
  27534. * Get the base size of the texture.
  27535. * It can be different from the size if the texture has been resized for POT for instance
  27536. * @returns the base size
  27537. */
  27538. getBaseSize(): ISize;
  27539. /**
  27540. * Update the sampling mode of the texture.
  27541. * Default is Trilinear mode.
  27542. *
  27543. * | Value | Type | Description |
  27544. * | ----- | ------------------ | ----------- |
  27545. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27546. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27547. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27548. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27549. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27550. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27551. * | 7 | NEAREST_LINEAR | |
  27552. * | 8 | NEAREST_NEAREST | |
  27553. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27554. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27555. * | 11 | LINEAR_LINEAR | |
  27556. * | 12 | LINEAR_NEAREST | |
  27557. *
  27558. * > _mag_: magnification filter (close to the viewer)
  27559. * > _min_: minification filter (far from the viewer)
  27560. * > _mip_: filter used between mip map levels
  27561. *@param samplingMode Define the new sampling mode of the texture
  27562. */
  27563. updateSamplingMode(samplingMode: number): void;
  27564. /**
  27565. * Scales the texture if is `canRescale()`
  27566. * @param ratio the resize factor we want to use to rescale
  27567. */
  27568. scale(ratio: number): void;
  27569. /**
  27570. * Get if the texture can rescale.
  27571. */
  27572. readonly canRescale: boolean;
  27573. /** @hidden */ private _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27574. /** @hidden */ private _rebuild(): void;
  27575. /**
  27576. * Triggers the load sequence in delayed load mode.
  27577. */
  27578. delayLoad(): void;
  27579. /**
  27580. * Clones the texture.
  27581. * @returns the cloned texture
  27582. */
  27583. clone(): Nullable<BaseTexture>;
  27584. /**
  27585. * Get the texture underlying type (INT, FLOAT...)
  27586. */
  27587. readonly textureType: number;
  27588. /**
  27589. * Get the texture underlying format (RGB, RGBA...)
  27590. */
  27591. readonly textureFormat: number;
  27592. /**
  27593. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27594. * This will returns an RGBA array buffer containing either in values (0-255) or
  27595. * float values (0-1) depending of the underlying buffer type.
  27596. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27597. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27598. * @param buffer defines a user defined buffer to fill with data (can be null)
  27599. * @returns The Array buffer containing the pixels data.
  27600. */
  27601. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27602. /**
  27603. * Release and destroy the underlying lower level texture aka internalTexture.
  27604. */
  27605. releaseInternalTexture(): void;
  27606. /**
  27607. * Get the polynomial representation of the texture data.
  27608. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27609. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27610. */
  27611. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27612. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  27613. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  27614. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  27615. /**
  27616. * Dispose the texture and release its associated resources.
  27617. */
  27618. dispose(): void;
  27619. /**
  27620. * Serialize the texture into a JSON representation that can be parsed later on.
  27621. * @returns the JSON representation of the texture
  27622. */
  27623. serialize(): any;
  27624. /**
  27625. * Helper function to be called back once a list of texture contains only ready textures.
  27626. * @param textures Define the list of textures to wait for
  27627. * @param callback Define the callback triggered once the entire list will be ready
  27628. */
  27629. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27630. }
  27631. }
  27632. declare module BABYLON {
  27633. /**
  27634. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  27635. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  27636. */
  27637. export class EffectFallbacks {
  27638. private _defines;
  27639. private _currentRank;
  27640. private _maxRank;
  27641. private _mesh;
  27642. /**
  27643. * Removes the fallback from the bound mesh.
  27644. */
  27645. unBindMesh(): void;
  27646. /**
  27647. * Adds a fallback on the specified property.
  27648. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  27649. * @param define The name of the define in the shader
  27650. */
  27651. addFallback(rank: number, define: string): void;
  27652. /**
  27653. * Sets the mesh to use CPU skinning when needing to fallback.
  27654. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  27655. * @param mesh The mesh to use the fallbacks.
  27656. */
  27657. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  27658. /**
  27659. * Checks to see if more fallbacks are still availible.
  27660. */
  27661. readonly hasMoreFallbacks: boolean;
  27662. /**
  27663. * Removes the defines that should be removed when falling back.
  27664. * @param currentDefines defines the current define statements for the shader.
  27665. * @param effect defines the current effect we try to compile
  27666. * @returns The resulting defines with defines of the current rank removed.
  27667. */
  27668. reduce(currentDefines: string, effect: Effect): string;
  27669. }
  27670. /**
  27671. * Options to be used when creating an effect.
  27672. */
  27673. export class EffectCreationOptions {
  27674. /**
  27675. * Atrributes that will be used in the shader.
  27676. */
  27677. attributes: string[];
  27678. /**
  27679. * Uniform varible names that will be set in the shader.
  27680. */
  27681. uniformsNames: string[];
  27682. /**
  27683. * Uniform buffer varible names that will be set in the shader.
  27684. */
  27685. uniformBuffersNames: string[];
  27686. /**
  27687. * Sampler texture variable names that will be set in the shader.
  27688. */
  27689. samplers: string[];
  27690. /**
  27691. * Define statements that will be set in the shader.
  27692. */
  27693. defines: any;
  27694. /**
  27695. * Possible fallbacks for this effect to improve performance when needed.
  27696. */
  27697. fallbacks: Nullable<EffectFallbacks>;
  27698. /**
  27699. * Callback that will be called when the shader is compiled.
  27700. */
  27701. onCompiled: Nullable<(effect: Effect) => void>;
  27702. /**
  27703. * Callback that will be called if an error occurs during shader compilation.
  27704. */
  27705. onError: Nullable<(effect: Effect, errors: string) => void>;
  27706. /**
  27707. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27708. */
  27709. indexParameters: any;
  27710. /**
  27711. * Max number of lights that can be used in the shader.
  27712. */
  27713. maxSimultaneousLights: number;
  27714. /**
  27715. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  27716. */
  27717. transformFeedbackVaryings: Nullable<string[]>;
  27718. }
  27719. /**
  27720. * Effect containing vertex and fragment shader that can be executed on an object.
  27721. */
  27722. export class Effect implements IDisposable {
  27723. /**
  27724. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27725. */
  27726. static ShadersRepository: string;
  27727. /**
  27728. * Name of the effect.
  27729. */
  27730. name: any;
  27731. /**
  27732. * String container all the define statements that should be set on the shader.
  27733. */
  27734. defines: string;
  27735. /**
  27736. * Callback that will be called when the shader is compiled.
  27737. */
  27738. onCompiled: Nullable<(effect: Effect) => void>;
  27739. /**
  27740. * Callback that will be called if an error occurs during shader compilation.
  27741. */
  27742. onError: Nullable<(effect: Effect, errors: string) => void>;
  27743. /**
  27744. * Callback that will be called when effect is bound.
  27745. */
  27746. onBind: Nullable<(effect: Effect) => void>;
  27747. /**
  27748. * Unique ID of the effect.
  27749. */
  27750. uniqueId: number;
  27751. /**
  27752. * Observable that will be called when the shader is compiled.
  27753. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  27754. */
  27755. onCompileObservable: Observable<Effect>;
  27756. /**
  27757. * Observable that will be called if an error occurs during shader compilation.
  27758. */
  27759. onErrorObservable: Observable<Effect>;
  27760. /** @hidden */ private _onBindObservable: Nullable<Observable<Effect>>;
  27761. /**
  27762. * Observable that will be called when effect is bound.
  27763. */
  27764. readonly onBindObservable: Observable<Effect>;
  27765. /** @hidden */ private _bonesComputationForcedToCPU: boolean;
  27766. private static _uniqueIdSeed;
  27767. private _engine;
  27768. private _uniformBuffersNames;
  27769. private _uniformsNames;
  27770. private _samplerList;
  27771. private _samplers;
  27772. private _isReady;
  27773. private _compilationError;
  27774. private _attributesNames;
  27775. private _attributes;
  27776. private _uniforms;
  27777. /**
  27778. * Key for the effect.
  27779. * @hidden
  27780. */ private _key: string;
  27781. private _indexParameters;
  27782. private _fallbacks;
  27783. private _vertexSourceCode;
  27784. private _fragmentSourceCode;
  27785. private _vertexSourceCodeOverride;
  27786. private _fragmentSourceCodeOverride;
  27787. private _transformFeedbackVaryings;
  27788. /**
  27789. * Compiled shader to webGL program.
  27790. * @hidden
  27791. */ private _pipelineContext: Nullable<IPipelineContext>;
  27792. private _valueCache;
  27793. private static _baseCache;
  27794. /**
  27795. * Instantiates an effect.
  27796. * An effect can be used to create/manage/execute vertex and fragment shaders.
  27797. * @param baseName Name of the effect.
  27798. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  27799. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  27800. * @param samplers List of sampler variables that will be passed to the shader.
  27801. * @param engine Engine to be used to render the effect
  27802. * @param defines Define statements to be added to the shader.
  27803. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  27804. * @param onCompiled Callback that will be called when the shader is compiled.
  27805. * @param onError Callback that will be called if an error occurs during shader compilation.
  27806. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27807. */
  27808. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | BaseEngine, samplers?: Nullable<string[]>, engine?: BaseEngine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  27809. private _useFinalCode;
  27810. /**
  27811. * Unique key for this effect
  27812. */
  27813. readonly key: string;
  27814. /**
  27815. * If the effect has been compiled and prepared.
  27816. * @returns if the effect is compiled and prepared.
  27817. */
  27818. isReady(): boolean;
  27819. private _isReadyInternal;
  27820. /**
  27821. * The engine the effect was initialized with.
  27822. * @returns the engine.
  27823. */
  27824. getEngine(): Engine;
  27825. /**
  27826. * The pipeline context for this effect
  27827. * @returns the associated pipeline context
  27828. */
  27829. getPipelineContext(): Nullable<IPipelineContext>;
  27830. /**
  27831. * The set of names of attribute variables for the shader.
  27832. * @returns An array of attribute names.
  27833. */
  27834. getAttributesNames(): string[];
  27835. /**
  27836. * Returns the attribute at the given index.
  27837. * @param index The index of the attribute.
  27838. * @returns The location of the attribute.
  27839. */
  27840. getAttributeLocation(index: number): number;
  27841. /**
  27842. * Returns the attribute based on the name of the variable.
  27843. * @param name of the attribute to look up.
  27844. * @returns the attribute location.
  27845. */
  27846. getAttributeLocationByName(name: string): number;
  27847. /**
  27848. * The number of attributes.
  27849. * @returns the numnber of attributes.
  27850. */
  27851. getAttributesCount(): number;
  27852. /**
  27853. * Gets the index of a uniform variable.
  27854. * @param uniformName of the uniform to look up.
  27855. * @returns the index.
  27856. */
  27857. getUniformIndex(uniformName: string): number;
  27858. /**
  27859. * Returns the attribute based on the name of the variable.
  27860. * @param uniformName of the uniform to look up.
  27861. * @returns the location of the uniform.
  27862. */
  27863. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  27864. /**
  27865. * Returns an array of sampler variable names
  27866. * @returns The array of sampler variable neames.
  27867. */
  27868. getSamplers(): string[];
  27869. /**
  27870. * The error from the last compilation.
  27871. * @returns the error string.
  27872. */
  27873. getCompilationError(): string;
  27874. /**
  27875. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  27876. * @param func The callback to be used.
  27877. */
  27878. executeWhenCompiled(func: (effect: Effect) => void): void;
  27879. private _checkIsReady;
  27880. /** @hidden */ private _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  27881. /** @hidden */ private _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  27882. /** @hidden */ private _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  27883. /**
  27884. * Recompiles the webGL program
  27885. * @param vertexSourceCode The source code for the vertex shader.
  27886. * @param fragmentSourceCode The source code for the fragment shader.
  27887. * @param onCompiled Callback called when completed.
  27888. * @param onError Callback called on error.
  27889. * @hidden
  27890. */ private _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  27891. /**
  27892. * Prepares the effect
  27893. * @hidden
  27894. */ private _prepareEffect(): void;
  27895. private _processCompilationErrors;
  27896. /**
  27897. * Checks if the effect is supported. (Must be called after compilation)
  27898. */
  27899. readonly isSupported: boolean;
  27900. /**
  27901. * Binds a texture to the engine to be used as output of the shader.
  27902. * @param channel Name of the output variable.
  27903. * @param texture Texture to bind.
  27904. * @hidden
  27905. */ private _bindTexture(channel: string, texture: InternalTexture): void;
  27906. /**
  27907. * Sets a texture on the engine to be used in the shader.
  27908. * @param channel Name of the sampler variable.
  27909. * @param texture Texture to set.
  27910. */
  27911. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  27912. /**
  27913. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  27914. * @param channel Name of the sampler variable.
  27915. * @param texture Texture to set.
  27916. */
  27917. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  27918. /**
  27919. * Sets an array of textures on the engine to be used in the shader.
  27920. * @param channel Name of the variable.
  27921. * @param textures Textures to set.
  27922. */
  27923. setTextureArray(channel: string, textures: BaseTexture[]): void;
  27924. /**
  27925. * 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)
  27926. * @param channel Name of the sampler variable.
  27927. * @param postProcess Post process to get the input texture from.
  27928. */
  27929. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  27930. /**
  27931. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  27932. * 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)
  27933. * @param channel Name of the sampler variable.
  27934. * @param postProcess Post process to get the output texture from.
  27935. */
  27936. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  27937. /** @hidden */ private _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  27938. /** @hidden */ private _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  27939. /** @hidden */ private _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  27940. /** @hidden */ private _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  27941. /**
  27942. * Binds a buffer to a uniform.
  27943. * @param buffer Buffer to bind.
  27944. * @param name Name of the uniform variable to bind to.
  27945. */
  27946. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  27947. /**
  27948. * Binds block to a uniform.
  27949. * @param blockName Name of the block to bind.
  27950. * @param index Index to bind.
  27951. */
  27952. bindUniformBlock(blockName: string, index: number): void;
  27953. /**
  27954. * Sets an interger value on a uniform variable.
  27955. * @param uniformName Name of the variable.
  27956. * @param value Value to be set.
  27957. * @returns this effect.
  27958. */
  27959. setInt(uniformName: string, value: number): Effect;
  27960. /**
  27961. * Sets an int array on a uniform variable.
  27962. * @param uniformName Name of the variable.
  27963. * @param array array to be set.
  27964. * @returns this effect.
  27965. */
  27966. setIntArray(uniformName: string, array: Int32Array): Effect;
  27967. /**
  27968. * 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)
  27969. * @param uniformName Name of the variable.
  27970. * @param array array to be set.
  27971. * @returns this effect.
  27972. */
  27973. setIntArray2(uniformName: string, array: Int32Array): Effect;
  27974. /**
  27975. * 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)
  27976. * @param uniformName Name of the variable.
  27977. * @param array array to be set.
  27978. * @returns this effect.
  27979. */
  27980. setIntArray3(uniformName: string, array: Int32Array): Effect;
  27981. /**
  27982. * 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)
  27983. * @param uniformName Name of the variable.
  27984. * @param array array to be set.
  27985. * @returns this effect.
  27986. */
  27987. setIntArray4(uniformName: string, array: Int32Array): Effect;
  27988. /**
  27989. * Sets an float array on a uniform variable.
  27990. * @param uniformName Name of the variable.
  27991. * @param array array to be set.
  27992. * @returns this effect.
  27993. */
  27994. setFloatArray(uniformName: string, array: Float32Array): Effect;
  27995. /**
  27996. * 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)
  27997. * @param uniformName Name of the variable.
  27998. * @param array array to be set.
  27999. * @returns this effect.
  28000. */
  28001. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28002. /**
  28003. * 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)
  28004. * @param uniformName Name of the variable.
  28005. * @param array array to be set.
  28006. * @returns this effect.
  28007. */
  28008. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28009. /**
  28010. * 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)
  28011. * @param uniformName Name of the variable.
  28012. * @param array array to be set.
  28013. * @returns this effect.
  28014. */
  28015. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28016. /**
  28017. * Sets an array on a uniform variable.
  28018. * @param uniformName Name of the variable.
  28019. * @param array array to be set.
  28020. * @returns this effect.
  28021. */
  28022. setArray(uniformName: string, array: number[]): Effect;
  28023. /**
  28024. * 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)
  28025. * @param uniformName Name of the variable.
  28026. * @param array array to be set.
  28027. * @returns this effect.
  28028. */
  28029. setArray2(uniformName: string, array: number[]): Effect;
  28030. /**
  28031. * 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)
  28032. * @param uniformName Name of the variable.
  28033. * @param array array to be set.
  28034. * @returns this effect.
  28035. */
  28036. setArray3(uniformName: string, array: number[]): Effect;
  28037. /**
  28038. * 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)
  28039. * @param uniformName Name of the variable.
  28040. * @param array array to be set.
  28041. * @returns this effect.
  28042. */
  28043. setArray4(uniformName: string, array: number[]): Effect;
  28044. /**
  28045. * Sets matrices on a uniform variable.
  28046. * @param uniformName Name of the variable.
  28047. * @param matrices matrices to be set.
  28048. * @returns this effect.
  28049. */
  28050. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28051. /**
  28052. * Sets matrix on a uniform variable.
  28053. * @param uniformName Name of the variable.
  28054. * @param matrix matrix to be set.
  28055. * @returns this effect.
  28056. */
  28057. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28058. /**
  28059. * 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)
  28060. * @param uniformName Name of the variable.
  28061. * @param matrix matrix to be set.
  28062. * @returns this effect.
  28063. */
  28064. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28065. /**
  28066. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28067. * @param uniformName Name of the variable.
  28068. * @param matrix matrix to be set.
  28069. * @returns this effect.
  28070. */
  28071. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28072. /**
  28073. * Sets a float on a uniform variable.
  28074. * @param uniformName Name of the variable.
  28075. * @param value value to be set.
  28076. * @returns this effect.
  28077. */
  28078. setFloat(uniformName: string, value: number): Effect;
  28079. /**
  28080. * Sets a boolean on a uniform variable.
  28081. * @param uniformName Name of the variable.
  28082. * @param bool value to be set.
  28083. * @returns this effect.
  28084. */
  28085. setBool(uniformName: string, bool: boolean): Effect;
  28086. /**
  28087. * Sets a Vector2 on a uniform variable.
  28088. * @param uniformName Name of the variable.
  28089. * @param vector2 vector2 to be set.
  28090. * @returns this effect.
  28091. */
  28092. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28093. /**
  28094. * Sets a float2 on a uniform variable.
  28095. * @param uniformName Name of the variable.
  28096. * @param x First float in float2.
  28097. * @param y Second float in float2.
  28098. * @returns this effect.
  28099. */
  28100. setFloat2(uniformName: string, x: number, y: number): Effect;
  28101. /**
  28102. * Sets a Vector3 on a uniform variable.
  28103. * @param uniformName Name of the variable.
  28104. * @param vector3 Value to be set.
  28105. * @returns this effect.
  28106. */
  28107. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28108. /**
  28109. * Sets a float3 on a uniform variable.
  28110. * @param uniformName Name of the variable.
  28111. * @param x First float in float3.
  28112. * @param y Second float in float3.
  28113. * @param z Third float in float3.
  28114. * @returns this effect.
  28115. */
  28116. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28117. /**
  28118. * Sets a Vector4 on a uniform variable.
  28119. * @param uniformName Name of the variable.
  28120. * @param vector4 Value to be set.
  28121. * @returns this effect.
  28122. */
  28123. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28124. /**
  28125. * Sets a float4 on a uniform variable.
  28126. * @param uniformName Name of the variable.
  28127. * @param x First float in float4.
  28128. * @param y Second float in float4.
  28129. * @param z Third float in float4.
  28130. * @param w Fourth float in float4.
  28131. * @returns this effect.
  28132. */
  28133. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28134. /**
  28135. * Sets a Color3 on a uniform variable.
  28136. * @param uniformName Name of the variable.
  28137. * @param color3 Value to be set.
  28138. * @returns this effect.
  28139. */
  28140. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28141. /**
  28142. * Sets a Color4 on a uniform variable.
  28143. * @param uniformName Name of the variable.
  28144. * @param color3 Value to be set.
  28145. * @param alpha Alpha value to be set.
  28146. * @returns this effect.
  28147. */
  28148. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28149. /**
  28150. * Sets a Color4 on a uniform variable
  28151. * @param uniformName defines the name of the variable
  28152. * @param color4 defines the value to be set
  28153. * @returns this effect.
  28154. */
  28155. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28156. /** Release all associated resources */
  28157. dispose(): void;
  28158. /**
  28159. * This function will add a new shader to the shader store
  28160. * @param name the name of the shader
  28161. * @param pixelShader optional pixel shader content
  28162. * @param vertexShader optional vertex shader content
  28163. */
  28164. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28165. /**
  28166. * Store of each shader (The can be looked up using effect.key)
  28167. */
  28168. static ShadersStore: {
  28169. [key: string]: string;
  28170. };
  28171. /**
  28172. * Store of each included file for a shader (The can be looked up using effect.key)
  28173. */
  28174. static IncludesShadersStore: {
  28175. [key: string]: string;
  28176. };
  28177. /**
  28178. * Resets the cache of effects.
  28179. */
  28180. static ResetCache(): void;
  28181. }
  28182. }
  28183. declare module BABYLON {
  28184. /**
  28185. * Class used to describe the capabilities of the engine relatively to the current browser
  28186. */
  28187. export class EngineCapabilities {
  28188. /** Maximum textures units per fragment shader */
  28189. maxTexturesImageUnits: number;
  28190. /** Maximum texture units per vertex shader */
  28191. maxVertexTextureImageUnits: number;
  28192. /** Maximum textures units in the entire pipeline */
  28193. maxCombinedTexturesImageUnits: number;
  28194. /** Maximum texture size */
  28195. maxTextureSize: number;
  28196. /** Maximum cube texture size */
  28197. maxCubemapTextureSize: number;
  28198. /** Maximum render texture size */
  28199. maxRenderTextureSize: number;
  28200. /** Maximum number of vertex attributes */
  28201. maxVertexAttribs: number;
  28202. /** Maximum number of varyings */
  28203. maxVaryingVectors: number;
  28204. /** Maximum number of uniforms per vertex shader */
  28205. maxVertexUniformVectors: number;
  28206. /** Maximum number of uniforms per fragment shader */
  28207. maxFragmentUniformVectors: number;
  28208. /** Defines if standard derivates (dx/dy) are supported */
  28209. standardDerivatives: boolean;
  28210. /** Defines if s3tc texture compression is supported */
  28211. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28212. /** Defines if pvrtc texture compression is supported */
  28213. pvrtc: any;
  28214. /** Defines if etc1 texture compression is supported */
  28215. etc1: any;
  28216. /** Defines if etc2 texture compression is supported */
  28217. etc2: any;
  28218. /** Defines if astc texture compression is supported */
  28219. astc: any;
  28220. /** Defines if float textures are supported */
  28221. textureFloat: boolean;
  28222. /** Defines if vertex array objects are supported */
  28223. vertexArrayObject: boolean;
  28224. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28225. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28226. /** Gets the maximum level of anisotropy supported */
  28227. maxAnisotropy: number;
  28228. /** Defines if instancing is supported */
  28229. instancedArrays: boolean;
  28230. /** Defines if 32 bits indices are supported */
  28231. uintIndices: boolean;
  28232. /** Defines if high precision shaders are supported */
  28233. highPrecisionShaderSupported: boolean;
  28234. /** Defines if depth reading in the fragment shader is supported */
  28235. fragmentDepthSupported: boolean;
  28236. /** Defines if float texture linear filtering is supported*/
  28237. textureFloatLinearFiltering: boolean;
  28238. /** Defines if rendering to float textures is supported */
  28239. textureFloatRender: boolean;
  28240. /** Defines if half float textures are supported*/
  28241. textureHalfFloat: boolean;
  28242. /** Defines if half float texture linear filtering is supported*/
  28243. textureHalfFloatLinearFiltering: boolean;
  28244. /** Defines if rendering to half float textures is supported */
  28245. textureHalfFloatRender: boolean;
  28246. /** Defines if textureLOD shader command is supported */
  28247. textureLOD: boolean;
  28248. /** Defines if draw buffers extension is supported */
  28249. drawBuffersExtension: boolean;
  28250. /** Defines if depth textures are supported */
  28251. depthTextureExtension: boolean;
  28252. /** Defines if float color buffer are supported */
  28253. colorBufferFloat: boolean;
  28254. /** Gets disjoint timer query extension (null if not supported) */
  28255. timerQuery: EXT_disjoint_timer_query;
  28256. /** Defines if timestamp can be used with timer query */
  28257. canUseTimestampForTimerQuery: boolean;
  28258. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28259. multiview: any;
  28260. /** Function used to let the system compiles shaders in background */
  28261. parallelShaderCompile: {
  28262. COMPLETION_STATUS_KHR: number;
  28263. };
  28264. /** Max number of texture samples for MSAA */
  28265. maxMSAASamples: number;
  28266. /** Defines if the blend min max extension is supported */
  28267. blendMinMax: boolean;
  28268. }
  28269. }
  28270. declare module BABYLON {
  28271. /**
  28272. * This class is used to track a performance counter which is number based.
  28273. * The user has access to many properties which give statistics of different nature.
  28274. *
  28275. * The implementer can track two kinds of Performance Counter: time and count.
  28276. * 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.
  28277. * 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.
  28278. */
  28279. export class PerfCounter {
  28280. /**
  28281. * Gets or sets a global boolean to turn on and off all the counters
  28282. */
  28283. static Enabled: boolean;
  28284. /**
  28285. * Returns the smallest value ever
  28286. */
  28287. readonly min: number;
  28288. /**
  28289. * Returns the biggest value ever
  28290. */
  28291. readonly max: number;
  28292. /**
  28293. * Returns the average value since the performance counter is running
  28294. */
  28295. readonly average: number;
  28296. /**
  28297. * Returns the average value of the last second the counter was monitored
  28298. */
  28299. readonly lastSecAverage: number;
  28300. /**
  28301. * Returns the current value
  28302. */
  28303. readonly current: number;
  28304. /**
  28305. * Gets the accumulated total
  28306. */
  28307. readonly total: number;
  28308. /**
  28309. * Gets the total value count
  28310. */
  28311. readonly count: number;
  28312. /**
  28313. * Creates a new counter
  28314. */
  28315. constructor();
  28316. /**
  28317. * Call this method to start monitoring a new frame.
  28318. * 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.
  28319. */
  28320. fetchNewFrame(): void;
  28321. /**
  28322. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  28323. * @param newCount the count value to add to the monitored count
  28324. * @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.
  28325. */
  28326. addCount(newCount: number, fetchResult: boolean): void;
  28327. /**
  28328. * Start monitoring this performance counter
  28329. */
  28330. beginMonitoring(): void;
  28331. /**
  28332. * Compute the time lapsed since the previous beginMonitoring() call.
  28333. * @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
  28334. */
  28335. endMonitoring(newFrame?: boolean): void;
  28336. private _fetchResult;
  28337. private _startMonitoringTime;
  28338. private _min;
  28339. private _max;
  28340. private _average;
  28341. private _current;
  28342. private _totalValueCount;
  28343. private _totalAccumulated;
  28344. private _lastSecAverage;
  28345. private _lastSecAccumulated;
  28346. private _lastSecTime;
  28347. private _lastSecValueCount;
  28348. }
  28349. }
  28350. declare module BABYLON {
  28351. /** @hidden */
  28352. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28353. attributeProcessor(attribute: string): string;
  28354. varyingProcessor(varying: string, isFragment: boolean): string;
  28355. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28356. }
  28357. }
  28358. declare module BABYLON {
  28359. /** @hidden */
  28360. export class WebGLDataBuffer extends DataBuffer {
  28361. private _buffer;
  28362. constructor(resource: WebGLBuffer);
  28363. readonly underlyingResource: any;
  28364. }
  28365. }
  28366. declare module BABYLON {
  28367. /** @hidden */
  28368. export class WebGLPipelineContext implements IPipelineContext {
  28369. engine: BaseEngine;
  28370. program: Nullable<WebGLProgram>;
  28371. context?: WebGLRenderingContext;
  28372. vertexShader?: WebGLShader;
  28373. fragmentShader?: WebGLShader;
  28374. isParallelCompiled: boolean;
  28375. onCompiled?: () => void;
  28376. transformFeedback?: WebGLTransformFeedback | null;
  28377. readonly isAsync: boolean;
  28378. readonly isReady: boolean; private _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  28379. }
  28380. }
  28381. declare module BABYLON {
  28382. /**
  28383. * Interface for attribute information associated with buffer instanciation
  28384. */
  28385. export class InstancingAttributeInfo {
  28386. /**
  28387. * Index/offset of the attribute in the vertex shader
  28388. */
  28389. index: number;
  28390. /**
  28391. * size of the attribute, 1, 2, 3 or 4
  28392. */
  28393. attributeSize: number;
  28394. /**
  28395. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28396. * default is FLOAT
  28397. */
  28398. attribyteType: number;
  28399. /**
  28400. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28401. */
  28402. normalized: boolean;
  28403. /**
  28404. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28405. */
  28406. offset: number;
  28407. /**
  28408. * Name of the GLSL attribute, for debugging purpose only
  28409. */
  28410. attributeName: string;
  28411. }
  28412. }
  28413. declare module BABYLON {
  28414. /**
  28415. * Settings for finer control over video usage
  28416. */
  28417. export interface VideoTextureSettings {
  28418. /**
  28419. * Applies `autoplay` to video, if specified
  28420. */
  28421. autoPlay?: boolean;
  28422. /**
  28423. * Applies `loop` to video, if specified
  28424. */
  28425. loop?: boolean;
  28426. /**
  28427. * Automatically updates internal texture from video at every frame in the render loop
  28428. */
  28429. autoUpdateTexture: boolean;
  28430. /**
  28431. * Image src displayed during the video loading or until the user interacts with the video.
  28432. */
  28433. poster?: string;
  28434. }
  28435. /**
  28436. * If you want to display a video in your scene, this is the special texture for that.
  28437. * This special texture works similar to other textures, with the exception of a few parameters.
  28438. * @see https://doc.babylonjs.com/how_to/video_texture
  28439. */
  28440. export class VideoTexture extends Texture {
  28441. /**
  28442. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  28443. */
  28444. readonly autoUpdateTexture: boolean;
  28445. /**
  28446. * The video instance used by the texture internally
  28447. */
  28448. readonly video: HTMLVideoElement;
  28449. private _onUserActionRequestedObservable;
  28450. /**
  28451. * Event triggerd when a dom action is required by the user to play the video.
  28452. * This happens due to recent changes in browser policies preventing video to auto start.
  28453. */
  28454. readonly onUserActionRequestedObservable: Observable<Texture>;
  28455. private _generateMipMaps;
  28456. private _engine;
  28457. private _stillImageCaptured;
  28458. private _displayingPosterTexture;
  28459. private _settings;
  28460. private _createInternalTextureOnEvent;
  28461. private _frameId;
  28462. /**
  28463. * Creates a video texture.
  28464. * If you want to display a video in your scene, this is the special texture for that.
  28465. * This special texture works similar to other textures, with the exception of a few parameters.
  28466. * @see https://doc.babylonjs.com/how_to/video_texture
  28467. * @param name optional name, will detect from video source, if not defined
  28468. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28469. * @param scene is obviously the current scene.
  28470. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28471. * @param invertY is false by default but can be used to invert video on Y axis
  28472. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28473. * @param settings allows finer control over video usage
  28474. */
  28475. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28476. private _getName;
  28477. private _getVideo;
  28478. private _createInternalTexture;
  28479. private reset;
  28480. /**
  28481. * @hidden Internal method to initiate `update`.
  28482. */ private _rebuild(): void;
  28483. /**
  28484. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28485. */
  28486. update(): void;
  28487. /**
  28488. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28489. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28490. */
  28491. updateTexture(isVisible: boolean): void;
  28492. protected _updateInternalTexture: () => void;
  28493. /**
  28494. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28495. * @param url New url.
  28496. */
  28497. updateURL(url: string): void;
  28498. /**
  28499. * Dispose the texture and release its associated resources.
  28500. */
  28501. dispose(): void;
  28502. /**
  28503. * Creates a video texture straight from a stream.
  28504. * @param scene Define the scene the texture should be created in
  28505. * @param stream Define the stream the texture should be created from
  28506. * @returns The created video texture as a promise
  28507. */
  28508. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28509. /**
  28510. * Creates a video texture straight from your WebCam video feed.
  28511. * @param scene Define the scene the texture should be created in
  28512. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28513. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28514. * @returns The created video texture as a promise
  28515. */
  28516. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28517. minWidth: number;
  28518. maxWidth: number;
  28519. minHeight: number;
  28520. maxHeight: number;
  28521. deviceId: string;
  28522. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28523. /**
  28524. * Creates a video texture straight from your WebCam video feed.
  28525. * @param scene Define the scene the texture should be created in
  28526. * @param onReady Define a callback to triggered once the texture will be ready
  28527. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28528. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28529. */
  28530. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28531. minWidth: number;
  28532. maxWidth: number;
  28533. minHeight: number;
  28534. maxHeight: number;
  28535. deviceId: string;
  28536. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  28537. }
  28538. }
  28539. declare module BABYLON {
  28540. /**
  28541. * Defines the interface used by objects containing a viewport (like a camera)
  28542. */
  28543. interface IViewportOwnerLike {
  28544. /**
  28545. * Gets or sets the viewport
  28546. */
  28547. viewport: IViewportLike;
  28548. }
  28549. /**
  28550. * Defines the interface used by objects working like Scene
  28551. * @hidden
  28552. */
  28553. interface ISceneLike { private _addPendingData(data: any): void; private _removePendingData(data: any): void;
  28554. offlineProvider: IOfflineProvider;
  28555. }
  28556. /** Interface defining initialization parameters for Engine class */
  28557. export interface EngineOptions extends WebGLContextAttributes {
  28558. /**
  28559. * Defines if the engine should no exceed a specified device ratio
  28560. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28561. */
  28562. limitDeviceRatio?: number;
  28563. /**
  28564. * Defines if webvr should be enabled automatically
  28565. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28566. */
  28567. autoEnableWebVR?: boolean;
  28568. /**
  28569. * Defines if webgl2 should be turned off even if supported
  28570. * @see http://doc.babylonjs.com/features/webgl2
  28571. */
  28572. disableWebGL2Support?: boolean;
  28573. /**
  28574. * Defines if webaudio should be initialized as well
  28575. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28576. */
  28577. audioEngine?: boolean;
  28578. /**
  28579. * Defines if animations should run using a deterministic lock step
  28580. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28581. */
  28582. deterministicLockstep?: boolean;
  28583. /** Defines the maximum steps to use with deterministic lock step mode */
  28584. lockstepMaxSteps?: number;
  28585. /**
  28586. * Defines that engine should ignore context lost events
  28587. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28588. */
  28589. doNotHandleContextLost?: boolean;
  28590. /**
  28591. * Defines that engine should ignore modifying touch action attribute and style
  28592. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28593. */
  28594. doNotHandleTouchAction?: boolean;
  28595. /**
  28596. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28597. */
  28598. useHighPrecisionFloats?: boolean;
  28599. }
  28600. /**
  28601. * The base engine class (root of all engines)
  28602. */
  28603. export class BaseEngine {
  28604. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28605. static ExceptionList: ({
  28606. key: string;
  28607. capture: string;
  28608. captureConstraint: number;
  28609. targets: string[];
  28610. } | {
  28611. key: string;
  28612. capture: null;
  28613. captureConstraint: null;
  28614. targets: string[];
  28615. })[];
  28616. /** @hidden */ private static _TextureLoaders: IInternalTextureLoader[];
  28617. /**
  28618. * Returns the current npm package of the sdk
  28619. */
  28620. static readonly NpmPackage: string;
  28621. /**
  28622. * Returns the current version of the framework
  28623. */
  28624. static readonly Version: string;
  28625. /**
  28626. * Returns a string describing the current engine
  28627. */
  28628. readonly description: string;
  28629. /**
  28630. * Gets or sets the epsilon value used by collision engine
  28631. */
  28632. static CollisionsEpsilon: number;
  28633. /**
  28634. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28635. */
  28636. static ShadersRepository: string;
  28637. /** @hidden */ private _shaderProcessor: IShaderProcessor;
  28638. /**
  28639. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28640. */
  28641. forcePOTTextures: boolean;
  28642. /**
  28643. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28644. */
  28645. isFullscreen: boolean;
  28646. /**
  28647. * Gets a boolean indicating if the pointer is currently locked
  28648. */
  28649. isPointerLock: boolean;
  28650. /**
  28651. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28652. */
  28653. cullBackFaces: boolean;
  28654. /**
  28655. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28656. */
  28657. renderEvenInBackground: boolean;
  28658. /**
  28659. * Gets or sets a boolean indicating that cache can be kept between frames
  28660. */
  28661. preventCacheWipeBetweenFrames: boolean;
  28662. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28663. validateShaderPrograms: boolean;
  28664. /**
  28665. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28666. */
  28667. disableUniformBuffers: boolean;
  28668. /** @hidden */ private _uniformBuffers: UniformBuffer[];
  28669. /**
  28670. * Gets a boolean indicating that the engine supports uniform buffers
  28671. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28672. */
  28673. readonly supportsUniformBuffers: boolean;
  28674. /** @hidden */ private _gl: WebGLRenderingContext;
  28675. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  28676. protected _windowIsBackground: boolean;
  28677. protected _webGLVersion: number;
  28678. protected _highPrecisionShadersAllowed: boolean;
  28679. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  28680. /**
  28681. * Gets a boolean indicating that only power of 2 textures are supported
  28682. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28683. */
  28684. readonly needPOTTextures: boolean;
  28685. /** @hidden */ private _badOS: boolean;
  28686. /** @hidden */ private _badDesktopOS: boolean;
  28687. private _hardwareScalingLevel;
  28688. /** @hidden */ private _caps: EngineCapabilities;
  28689. private _isStencilEnable;
  28690. protected _colorWrite: boolean;
  28691. /** @hidden */ private _drawCalls: PerfCounter;
  28692. private _glVersion;
  28693. private _glRenderer;
  28694. private _glVendor;
  28695. private _videoTextureSupported;
  28696. protected _renderingQueueLaunched: boolean;
  28697. protected _activeRenderLoops: (() => void)[];
  28698. private _deterministicLockstep;
  28699. private _lockstepMaxSteps;
  28700. /**
  28701. * Observable signaled when a context lost event is raised
  28702. */
  28703. onContextLostObservable: Observable<BaseEngine>;
  28704. /**
  28705. * Observable signaled when a context restored event is raised
  28706. */
  28707. onContextRestoredObservable: Observable<BaseEngine>;
  28708. private _onContextLost;
  28709. private _onContextRestored;
  28710. protected _contextWasLost: boolean;
  28711. /** @hidden */ private _doNotHandleContextLost: boolean;
  28712. /**
  28713. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28714. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28715. */
  28716. doNotHandleContextLost: boolean;
  28717. /**
  28718. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28719. */
  28720. disableVertexArrayObjects: boolean;
  28721. /** @hidden */
  28722. protected _depthCullingState: _DepthCullingState;
  28723. /** @hidden */
  28724. protected _stencilState: _StencilState;
  28725. /** @hidden */
  28726. protected _alphaState: _AlphaState;
  28727. /** @hidden */
  28728. protected _alphaMode: number;
  28729. /** @hidden */
  28730. protected _alphaEquation: number;
  28731. /** @hidden */ private _internalTexturesCache: InternalTexture[];
  28732. /** @hidden */
  28733. protected _activeChannel: number;
  28734. private _currentTextureChannel;
  28735. /** @hidden */
  28736. protected _boundTexturesCache: {
  28737. [key: string]: Nullable<InternalTexture>;
  28738. };
  28739. /** @hidden */
  28740. protected _currentEffect: Nullable<Effect>;
  28741. /** @hidden */
  28742. protected _currentProgram: Nullable<WebGLProgram>;
  28743. private _compiledEffects;
  28744. private _vertexAttribArraysEnabled;
  28745. /** @hidden */
  28746. protected _cachedViewport: Nullable<IViewportLike>;
  28747. private _cachedVertexArrayObject;
  28748. /** @hidden */
  28749. protected _cachedVertexBuffers: any;
  28750. /** @hidden */
  28751. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28752. /** @hidden */
  28753. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28754. /** @hidden */ private _currentRenderTarget: Nullable<InternalTexture>;
  28755. private _uintIndicesCurrentlySet;
  28756. private _currentBoundBuffer;
  28757. /** @hidden */
  28758. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28759. private _currentBufferPointers;
  28760. private _currentInstanceLocations;
  28761. private _currentInstanceBuffers;
  28762. private _textureUnits;
  28763. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  28764. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  28765. /** @hidden */ private _bindedRenderFunction: any;
  28766. private _vaoRecordInProgress;
  28767. private _mustWipeVertexAttributes;
  28768. private _emptyTexture;
  28769. private _emptyCubeTexture;
  28770. private _emptyTexture3D;
  28771. /** @hidden */ private _frameHandler: number;
  28772. private _nextFreeTextureSlots;
  28773. private _maxSimultaneousTextures;
  28774. private _activeRequests;
  28775. private _texturesSupported;
  28776. /** @hidden */ private _textureFormatInUse: Nullable<string>;
  28777. protected readonly _supportsHardwareTextureRescaling: boolean;
  28778. /**
  28779. * Gets the list of texture formats supported
  28780. */
  28781. readonly texturesSupported: Array<string>;
  28782. /**
  28783. * Gets the list of texture formats in use
  28784. */
  28785. readonly textureFormatInUse: Nullable<string>;
  28786. /**
  28787. * Gets the current viewport
  28788. */
  28789. readonly currentViewport: Nullable<IViewportLike>;
  28790. /**
  28791. * Gets the default empty texture
  28792. */
  28793. readonly emptyTexture: InternalTexture;
  28794. /**
  28795. * Gets the default empty 3D texture
  28796. */
  28797. readonly emptyTexture3D: InternalTexture;
  28798. /**
  28799. * Gets the default empty cube texture
  28800. */
  28801. readonly emptyCubeTexture: InternalTexture;
  28802. /**
  28803. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28804. */
  28805. readonly premultipliedAlpha: boolean;
  28806. /**
  28807. * Creates a new engine
  28808. * @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
  28809. * @param antialias defines enable antialiasing (default: false)
  28810. * @param options defines further options to be sent to the getContext() function
  28811. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28812. */
  28813. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28814. private _disableTouchAction;
  28815. private _rebuildInternalTextures;
  28816. private _rebuildEffects;
  28817. /**
  28818. * Gets a boolean indicating if all created effects are ready
  28819. * @returns true if all effects are ready
  28820. */
  28821. areAllEffectsReady(): boolean;
  28822. protected _rebuildBuffers(): void;
  28823. private _initGLContext;
  28824. /**
  28825. * Gets version of the current webGL context
  28826. */
  28827. readonly webGLVersion: number;
  28828. /**
  28829. * Gets a string idenfifying the name of the class
  28830. * @returns "Engine" string
  28831. */
  28832. getClassName(): string;
  28833. /**
  28834. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28835. */
  28836. readonly isStencilEnable: boolean;
  28837. /** @hidden */ private _prepareWorkingCanvas(): void;
  28838. /**
  28839. * Reset the texture cache to empty state
  28840. */
  28841. resetTextureCache(): void;
  28842. /**
  28843. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28844. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28845. * @returns true if engine is in deterministic lock step mode
  28846. */
  28847. isDeterministicLockStep(): boolean;
  28848. /**
  28849. * Gets the max steps when engine is running in deterministic lock step
  28850. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28851. * @returns the max steps
  28852. */
  28853. getLockstepMaxSteps(): number;
  28854. /**
  28855. * Gets an object containing information about the current webGL context
  28856. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28857. */
  28858. getGlInfo(): {
  28859. vendor: string;
  28860. renderer: string;
  28861. version: string;
  28862. };
  28863. /**
  28864. * Gets current aspect ratio
  28865. * @param viewportOwner defines the camera to use to get the aspect ratio
  28866. * @param useScreen defines if screen size must be used (or the current render target if any)
  28867. * @returns a number defining the aspect ratio
  28868. */
  28869. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  28870. /**
  28871. * Gets current screen aspect ratio
  28872. * @returns a number defining the aspect ratio
  28873. */
  28874. getScreenAspectRatio(): number;
  28875. /**
  28876. * Gets the current render width
  28877. * @param useScreen defines if screen size must be used (or the current render target if any)
  28878. * @returns a number defining the current render width
  28879. */
  28880. getRenderWidth(useScreen?: boolean): number;
  28881. /**
  28882. * Gets the current render height
  28883. * @param useScreen defines if screen size must be used (or the current render target if any)
  28884. * @returns a number defining the current render height
  28885. */
  28886. getRenderHeight(useScreen?: boolean): number;
  28887. /**
  28888. * Gets the HTML canvas attached with the current webGL context
  28889. * @returns a HTML canvas
  28890. */
  28891. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28892. /**
  28893. * Gets host window
  28894. * @returns the host window object
  28895. */
  28896. getHostWindow(): Window;
  28897. /**
  28898. * Gets host document
  28899. * @returns the host document object
  28900. */
  28901. getHostDocument(): Document;
  28902. /**
  28903. * Gets the client rect of the HTML canvas attached with the current webGL context
  28904. * @returns a client rectanglee
  28905. */
  28906. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28907. /**
  28908. * Defines the hardware scaling level.
  28909. * By default the hardware scaling level is computed from the window device ratio.
  28910. * 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.
  28911. * @param level defines the level to use
  28912. */
  28913. setHardwareScalingLevel(level: number): void;
  28914. /**
  28915. * Gets the current hardware scaling level.
  28916. * By default the hardware scaling level is computed from the window device ratio.
  28917. * 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.
  28918. * @returns a number indicating the current hardware scaling level
  28919. */
  28920. getHardwareScalingLevel(): number;
  28921. /**
  28922. * Gets the list of loaded textures
  28923. * @returns an array containing all loaded textures
  28924. */
  28925. getLoadedTexturesCache(): InternalTexture[];
  28926. /**
  28927. * Gets the object containing all engine capabilities
  28928. * @returns the EngineCapabilities object
  28929. */
  28930. getCaps(): EngineCapabilities;
  28931. /**
  28932. * Gets the current depth function
  28933. * @returns a number defining the depth function
  28934. */
  28935. getDepthFunction(): Nullable<number>;
  28936. /**
  28937. * Sets the current depth function
  28938. * @param depthFunc defines the function to use
  28939. */
  28940. setDepthFunction(depthFunc: number): void;
  28941. /**
  28942. * Sets the current depth function to GREATER
  28943. */
  28944. setDepthFunctionToGreater(): void;
  28945. /**
  28946. * Sets the current depth function to GEQUAL
  28947. */
  28948. setDepthFunctionToGreaterOrEqual(): void;
  28949. /**
  28950. * Sets the current depth function to LESS
  28951. */
  28952. setDepthFunctionToLess(): void;
  28953. private _cachedStencilBuffer;
  28954. private _cachedStencilFunction;
  28955. private _cachedStencilMask;
  28956. private _cachedStencilOperationPass;
  28957. private _cachedStencilOperationFail;
  28958. private _cachedStencilOperationDepthFail;
  28959. private _cachedStencilReference;
  28960. /**
  28961. * Caches the the state of the stencil buffer
  28962. */
  28963. cacheStencilState(): void;
  28964. /**
  28965. * Restores the state of the stencil buffer
  28966. */
  28967. restoreStencilState(): void;
  28968. /**
  28969. * Sets the current depth function to LEQUAL
  28970. */
  28971. setDepthFunctionToLessOrEqual(): void;
  28972. /**
  28973. * Gets a boolean indicating if stencil buffer is enabled
  28974. * @returns the current stencil buffer state
  28975. */
  28976. getStencilBuffer(): boolean;
  28977. /**
  28978. * Enable or disable the stencil buffer
  28979. * @param enable defines if the stencil buffer must be enabled or disabled
  28980. */
  28981. setStencilBuffer(enable: boolean): void;
  28982. /**
  28983. * Gets the current stencil mask
  28984. * @returns a number defining the new stencil mask to use
  28985. */
  28986. getStencilMask(): number;
  28987. /**
  28988. * Sets the current stencil mask
  28989. * @param mask defines the new stencil mask to use
  28990. */
  28991. setStencilMask(mask: number): void;
  28992. /**
  28993. * Gets the current stencil function
  28994. * @returns a number defining the stencil function to use
  28995. */
  28996. getStencilFunction(): number;
  28997. /**
  28998. * Gets the current stencil reference value
  28999. * @returns a number defining the stencil reference value to use
  29000. */
  29001. getStencilFunctionReference(): number;
  29002. /**
  29003. * Gets the current stencil mask
  29004. * @returns a number defining the stencil mask to use
  29005. */
  29006. getStencilFunctionMask(): number;
  29007. /**
  29008. * Sets the current stencil function
  29009. * @param stencilFunc defines the new stencil function to use
  29010. */
  29011. setStencilFunction(stencilFunc: number): void;
  29012. /**
  29013. * Sets the current stencil reference
  29014. * @param reference defines the new stencil reference to use
  29015. */
  29016. setStencilFunctionReference(reference: number): void;
  29017. /**
  29018. * Sets the current stencil mask
  29019. * @param mask defines the new stencil mask to use
  29020. */
  29021. setStencilFunctionMask(mask: number): void;
  29022. /**
  29023. * Gets the current stencil operation when stencil fails
  29024. * @returns a number defining stencil operation to use when stencil fails
  29025. */
  29026. getStencilOperationFail(): number;
  29027. /**
  29028. * Gets the current stencil operation when depth fails
  29029. * @returns a number defining stencil operation to use when depth fails
  29030. */
  29031. getStencilOperationDepthFail(): number;
  29032. /**
  29033. * Gets the current stencil operation when stencil passes
  29034. * @returns a number defining stencil operation to use when stencil passes
  29035. */
  29036. getStencilOperationPass(): number;
  29037. /**
  29038. * Sets the stencil operation to use when stencil fails
  29039. * @param operation defines the stencil operation to use when stencil fails
  29040. */
  29041. setStencilOperationFail(operation: number): void;
  29042. /**
  29043. * Sets the stencil operation to use when depth fails
  29044. * @param operation defines the stencil operation to use when depth fails
  29045. */
  29046. setStencilOperationDepthFail(operation: number): void;
  29047. /**
  29048. * Sets the stencil operation to use when stencil passes
  29049. * @param operation defines the stencil operation to use when stencil passes
  29050. */
  29051. setStencilOperationPass(operation: number): void;
  29052. /**
  29053. * Sets a boolean indicating if the dithering state is enabled or disabled
  29054. * @param value defines the dithering state
  29055. */
  29056. setDitheringState(value: boolean): void;
  29057. /**
  29058. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  29059. * @param value defines the rasterizer state
  29060. */
  29061. setRasterizerState(value: boolean): void;
  29062. /**
  29063. * stop executing a render loop function and remove it from the execution array
  29064. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29065. */
  29066. stopRenderLoop(renderFunction?: () => void): void;
  29067. /** @hidden */ private _renderLoop(): void;
  29068. /**
  29069. * Can be used to override the current requestAnimationFrame requester.
  29070. * @hidden
  29071. */
  29072. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  29073. /**
  29074. * Register and execute a render loop. The engine can have more than one render function
  29075. * @param renderFunction defines the function to continuously execute
  29076. */
  29077. runRenderLoop(renderFunction: () => void): void;
  29078. /**
  29079. * Clear the current render buffer or the current render target (if any is set up)
  29080. * @param color defines the color to use
  29081. * @param backBuffer defines if the back buffer must be cleared
  29082. * @param depth defines if the depth buffer must be cleared
  29083. * @param stencil defines if the stencil buffer must be cleared
  29084. */
  29085. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29086. /**
  29087. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29088. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29089. * @param y defines the y-coordinate of the corner of the clear rectangle
  29090. * @param width defines the width of the clear rectangle
  29091. * @param height defines the height of the clear rectangle
  29092. * @param clearColor defines the clear color
  29093. */
  29094. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  29095. /**
  29096. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29097. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29098. * @param y defines the y-coordinate of the corner of the clear rectangle
  29099. * @param width defines the width of the clear rectangle
  29100. * @param height defines the height of the clear rectangle
  29101. */
  29102. enableScissor(x: number, y: number, width: number, height: number): void;
  29103. /**
  29104. * Disable previously set scissor test rectangle
  29105. */
  29106. disableScissor(): void;
  29107. private _viewportCached;
  29108. /** @hidden */ private _viewport(x: number, y: number, width: number, height: number): void;
  29109. /**
  29110. * Set the WebGL's viewport
  29111. * @param viewport defines the viewport element to be used
  29112. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29113. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29114. */
  29115. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  29116. /**
  29117. * Directly set the WebGL Viewport
  29118. * @param x defines the x coordinate of the viewport (in screen space)
  29119. * @param y defines the y coordinate of the viewport (in screen space)
  29120. * @param width defines the width of the viewport (in screen space)
  29121. * @param height defines the height of the viewport (in screen space)
  29122. * @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
  29123. */
  29124. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  29125. /**
  29126. * Begin a new frame
  29127. */
  29128. beginFrame(): void;
  29129. /**
  29130. * Enf the current frame
  29131. */
  29132. endFrame(): void;
  29133. /**
  29134. * Resize the view according to the canvas' size
  29135. */
  29136. resize(): void;
  29137. /**
  29138. * Force a specific size of the canvas
  29139. * @param width defines the new canvas' width
  29140. * @param height defines the new canvas' height
  29141. */
  29142. setSize(width: number, height: number): void;
  29143. /**
  29144. * Binds the frame buffer to the specified texture.
  29145. * @param texture The texture to render to or null for the default canvas
  29146. * @param faceIndex The face of the texture to render to in case of cube texture
  29147. * @param requiredWidth The width of the target to render to
  29148. * @param requiredHeight The height of the target to render to
  29149. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29150. * @param depthStencilTexture The depth stencil texture to use to render
  29151. * @param lodLevel defines le lod level to bind to the frame buffer
  29152. */
  29153. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29154. /** @hidden */ private _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29155. /**
  29156. * Unbind the current render target texture from the webGL context
  29157. * @param texture defines the render target texture to unbind
  29158. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29159. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29160. */
  29161. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29162. /**
  29163. * Force the mipmap generation for the given render target texture
  29164. * @param texture defines the render target texture to use
  29165. */
  29166. generateMipMapsForCubemap(texture: InternalTexture): void;
  29167. /**
  29168. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29169. */
  29170. flushFramebuffer(): void;
  29171. /**
  29172. * Unbind the current render target and bind the default framebuffer
  29173. */
  29174. restoreDefaultFramebuffer(): void;
  29175. /**
  29176. * Create an uniform buffer
  29177. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29178. * @param elements defines the content of the uniform buffer
  29179. * @returns the webGL uniform buffer
  29180. */
  29181. createUniformBuffer(elements: FloatArray): DataBuffer;
  29182. /**
  29183. * Create a dynamic uniform buffer
  29184. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29185. * @param elements defines the content of the uniform buffer
  29186. * @returns the webGL uniform buffer
  29187. */
  29188. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  29189. /**
  29190. * Update an existing uniform buffer
  29191. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29192. * @param uniformBuffer defines the target uniform buffer
  29193. * @param elements defines the content to update
  29194. * @param offset defines the offset in the uniform buffer where update should start
  29195. * @param count defines the size of the data to update
  29196. */
  29197. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  29198. private _resetVertexBufferBinding;
  29199. /**
  29200. * Creates a vertex buffer
  29201. * @param data the data for the vertex buffer
  29202. * @returns the new WebGL static buffer
  29203. */
  29204. createVertexBuffer(data: DataArray): DataBuffer;
  29205. private _createVertexBuffer;
  29206. /**
  29207. * Creates a dynamic vertex buffer
  29208. * @param data the data for the dynamic vertex buffer
  29209. * @returns the new WebGL dynamic buffer
  29210. */
  29211. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29212. /**
  29213. * Update a dynamic index buffer
  29214. * @param indexBuffer defines the target index buffer
  29215. * @param indices defines the data to update
  29216. * @param offset defines the offset in the target index buffer where update should start
  29217. */
  29218. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  29219. /**
  29220. * Updates a dynamic vertex buffer.
  29221. * @param vertexBuffer the vertex buffer to update
  29222. * @param data the data used to update the vertex buffer
  29223. * @param byteOffset the byte offset of the data
  29224. * @param byteLength the byte length of the data
  29225. */
  29226. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29227. private _resetIndexBufferBinding;
  29228. /**
  29229. * Creates a new index buffer
  29230. * @param indices defines the content of the index buffer
  29231. * @param updatable defines if the index buffer must be updatable
  29232. * @returns a new webGL buffer
  29233. */
  29234. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29235. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  29236. /**
  29237. * Bind a webGL buffer to the webGL context
  29238. * @param buffer defines the buffer to bind
  29239. */
  29240. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29241. /**
  29242. * Bind an uniform buffer to the current webGL context
  29243. * @param buffer defines the buffer to bind
  29244. */
  29245. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  29246. /**
  29247. * Bind a buffer to the current webGL context at a given location
  29248. * @param buffer defines the buffer to bind
  29249. * @param location defines the index where to bind the buffer
  29250. */
  29251. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  29252. /**
  29253. * Bind a specific block at a given index in a specific shader program
  29254. * @param pipelineContext defines the pipeline context to use
  29255. * @param blockName defines the block name
  29256. * @param index defines the index where to bind the block
  29257. */
  29258. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  29259. private bindIndexBuffer;
  29260. private bindBuffer;
  29261. /**
  29262. * update the bound buffer with the given data
  29263. * @param data defines the data to update
  29264. */
  29265. updateArrayBuffer(data: Float32Array): void;
  29266. private _vertexAttribPointer;
  29267. private _bindIndexBufferWithCache;
  29268. private _bindVertexBuffersAttributes;
  29269. /**
  29270. * Records a vertex array object
  29271. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29272. * @param vertexBuffers defines the list of vertex buffers to store
  29273. * @param indexBuffer defines the index buffer to store
  29274. * @param effect defines the effect to store
  29275. * @returns the new vertex array object
  29276. */
  29277. recordVertexArrayObject(vertexBuffers: {
  29278. [key: string]: VertexBuffer;
  29279. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29280. /**
  29281. * Bind a specific vertex array object
  29282. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29283. * @param vertexArrayObject defines the vertex array object to bind
  29284. * @param indexBuffer defines the index buffer to bind
  29285. */
  29286. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29287. /**
  29288. * Bind webGl buffers directly to the webGL context
  29289. * @param vertexBuffer defines the vertex buffer to bind
  29290. * @param indexBuffer defines the index buffer to bind
  29291. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29292. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29293. * @param effect defines the effect associated with the vertex buffer
  29294. */
  29295. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29296. private _unbindVertexArrayObject;
  29297. /**
  29298. * Bind a list of vertex buffers to the webGL context
  29299. * @param vertexBuffers defines the list of vertex buffers to bind
  29300. * @param indexBuffer defines the index buffer to bind
  29301. * @param effect defines the effect associated with the vertex buffers
  29302. */
  29303. bindBuffers(vertexBuffers: {
  29304. [key: string]: Nullable<VertexBuffer>;
  29305. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29306. /**
  29307. * Unbind all instance attributes
  29308. */
  29309. unbindInstanceAttributes(): void;
  29310. /**
  29311. * Release and free the memory of a vertex array object
  29312. * @param vao defines the vertex array object to delete
  29313. */
  29314. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29315. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  29316. protected _deleteBuffer(buffer: DataBuffer): void;
  29317. /**
  29318. * Creates a webGL buffer to use with instanciation
  29319. * @param capacity defines the size of the buffer
  29320. * @returns the webGL buffer
  29321. */
  29322. createInstancesBuffer(capacity: number): DataBuffer;
  29323. /**
  29324. * Delete a webGL buffer used with instanciation
  29325. * @param buffer defines the webGL buffer to delete
  29326. */
  29327. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29328. /**
  29329. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29330. * @param instancesBuffer defines the webGL buffer to update and bind
  29331. * @param data defines the data to store in the buffer
  29332. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29333. */
  29334. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29335. /**
  29336. * Apply all cached states (depth, culling, stencil and alpha)
  29337. */
  29338. applyStates(): void;
  29339. /**
  29340. * Send a draw order
  29341. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29342. * @param indexStart defines the starting index
  29343. * @param indexCount defines the number of index to draw
  29344. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29345. */
  29346. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29347. /**
  29348. * Draw a list of points
  29349. * @param verticesStart defines the index of first vertex to draw
  29350. * @param verticesCount defines the count of vertices to draw
  29351. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29352. */
  29353. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29354. /**
  29355. * Draw a list of unindexed primitives
  29356. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29357. * @param verticesStart defines the index of first vertex to draw
  29358. * @param verticesCount defines the count of vertices to draw
  29359. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29360. */
  29361. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29362. /**
  29363. * Draw a list of indexed primitives
  29364. * @param fillMode defines the primitive to use
  29365. * @param indexStart defines the starting index
  29366. * @param indexCount defines the number of index to draw
  29367. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29368. */
  29369. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29370. /**
  29371. * Draw a list of unindexed primitives
  29372. * @param fillMode defines the primitive to use
  29373. * @param verticesStart defines the index of first vertex to draw
  29374. * @param verticesCount defines the count of vertices to draw
  29375. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29376. */
  29377. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29378. private _drawMode;
  29379. /** @hidden */ private _releaseEffect(effect: Effect): void;
  29380. /** @hidden */ private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29381. /**
  29382. * Create a new effect (used to store vertex/fragment shaders)
  29383. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29384. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29385. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29386. * @param samplers defines an array of string used to represent textures
  29387. * @param defines defines the string containing the defines to use to compile the shaders
  29388. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29389. * @param onCompiled defines a function to call when the effect creation is successful
  29390. * @param onError defines a function to call when the effect creation has failed
  29391. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29392. * @returns the new Effect
  29393. */
  29394. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | BaseEngine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29395. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  29396. private _compileShader;
  29397. private _compileRawShader;
  29398. /**
  29399. * Directly creates a webGL program
  29400. * @param pipelineContext defines the pipeline context to attach to
  29401. * @param vertexCode defines the vertex shader code to use
  29402. * @param fragmentCode defines the fragment shader code to use
  29403. * @param context defines the webGL context to use (if not set, the current one will be used)
  29404. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29405. * @returns the new webGL program
  29406. */
  29407. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29408. /**
  29409. * Creates a webGL program
  29410. * @param pipelineContext defines the pipeline context to attach to
  29411. * @param vertexCode defines the vertex shader code to use
  29412. * @param fragmentCode defines the fragment shader code to use
  29413. * @param defines defines the string containing the defines to use to compile the shaders
  29414. * @param context defines the webGL context to use (if not set, the current one will be used)
  29415. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29416. * @returns the new webGL program
  29417. */
  29418. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29419. /**
  29420. * Creates a new pipeline context
  29421. * @returns the new pipeline
  29422. */
  29423. createPipelineContext(): IPipelineContext;
  29424. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29425. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  29426. /** @hidden */ private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29427. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29428. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29429. /**
  29430. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29431. * @param pipelineContext defines the pipeline context to use
  29432. * @param uniformsNames defines the list of uniform names
  29433. * @returns an array of webGL uniform locations
  29434. */
  29435. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29436. /**
  29437. * Gets the lsit of active attributes for a given webGL program
  29438. * @param pipelineContext defines the pipeline context to use
  29439. * @param attributesNames defines the list of attribute names to get
  29440. * @returns an array of indices indicating the offset of each attribute
  29441. */
  29442. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29443. /**
  29444. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29445. * @param effect defines the effect to activate
  29446. */
  29447. enableEffect(effect: Nullable<Effect>): void;
  29448. /**
  29449. * Set the value of an uniform to an array of int32
  29450. * @param uniform defines the webGL uniform location where to store the value
  29451. * @param array defines the array of int32 to store
  29452. */
  29453. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29454. /**
  29455. * Set the value of an uniform to an array of int32 (stored as vec2)
  29456. * @param uniform defines the webGL uniform location where to store the value
  29457. * @param array defines the array of int32 to store
  29458. */
  29459. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29460. /**
  29461. * Set the value of an uniform to an array of int32 (stored as vec3)
  29462. * @param uniform defines the webGL uniform location where to store the value
  29463. * @param array defines the array of int32 to store
  29464. */
  29465. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29466. /**
  29467. * Set the value of an uniform to an array of int32 (stored as vec4)
  29468. * @param uniform defines the webGL uniform location where to store the value
  29469. * @param array defines the array of int32 to store
  29470. */
  29471. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29472. /**
  29473. * Set the value of an uniform to an array of float32
  29474. * @param uniform defines the webGL uniform location where to store the value
  29475. * @param array defines the array of float32 to store
  29476. */
  29477. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29478. /**
  29479. * Set the value of an uniform to an array of float32 (stored as vec2)
  29480. * @param uniform defines the webGL uniform location where to store the value
  29481. * @param array defines the array of float32 to store
  29482. */
  29483. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29484. /**
  29485. * Set the value of an uniform to an array of float32 (stored as vec3)
  29486. * @param uniform defines the webGL uniform location where to store the value
  29487. * @param array defines the array of float32 to store
  29488. */
  29489. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29490. /**
  29491. * Set the value of an uniform to an array of float32 (stored as vec4)
  29492. * @param uniform defines the webGL uniform location where to store the value
  29493. * @param array defines the array of float32 to store
  29494. */
  29495. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29496. /**
  29497. * Set the value of an uniform to an array of number
  29498. * @param uniform defines the webGL uniform location where to store the value
  29499. * @param array defines the array of number to store
  29500. */
  29501. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29502. /**
  29503. * Set the value of an uniform to an array of number (stored as vec2)
  29504. * @param uniform defines the webGL uniform location where to store the value
  29505. * @param array defines the array of number to store
  29506. */
  29507. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29508. /**
  29509. * Set the value of an uniform to an array of number (stored as vec3)
  29510. * @param uniform defines the webGL uniform location where to store the value
  29511. * @param array defines the array of number to store
  29512. */
  29513. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29514. /**
  29515. * Set the value of an uniform to an array of number (stored as vec4)
  29516. * @param uniform defines the webGL uniform location where to store the value
  29517. * @param array defines the array of number to store
  29518. */
  29519. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29520. /**
  29521. * Set the value of an uniform to an array of float32 (stored as matrices)
  29522. * @param uniform defines the webGL uniform location where to store the value
  29523. * @param matrices defines the array of float32 to store
  29524. */
  29525. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29526. /**
  29527. * Set the value of an uniform to a matrix (3x3)
  29528. * @param uniform defines the webGL uniform location where to store the value
  29529. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29530. */
  29531. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29532. /**
  29533. * Set the value of an uniform to a matrix (2x2)
  29534. * @param uniform defines the webGL uniform location where to store the value
  29535. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29536. */
  29537. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29538. /**
  29539. * Set the value of an uniform to a number (int)
  29540. * @param uniform defines the webGL uniform location where to store the value
  29541. * @param value defines the int number to store
  29542. */
  29543. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29544. /**
  29545. * Set the value of an uniform to a number (float)
  29546. * @param uniform defines the webGL uniform location where to store the value
  29547. * @param value defines the float number to store
  29548. */
  29549. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29550. /**
  29551. * Set the value of an uniform to a vec2
  29552. * @param uniform defines the webGL uniform location where to store the value
  29553. * @param x defines the 1st component of the value
  29554. * @param y defines the 2nd component of the value
  29555. */
  29556. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29557. /**
  29558. * Set the value of an uniform to a vec3
  29559. * @param uniform defines the webGL uniform location where to store the value
  29560. * @param x defines the 1st component of the value
  29561. * @param y defines the 2nd component of the value
  29562. * @param z defines the 3rd component of the value
  29563. */
  29564. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29565. /**
  29566. * Set the value of an uniform to a boolean
  29567. * @param uniform defines the webGL uniform location where to store the value
  29568. * @param bool defines the boolean to store
  29569. */
  29570. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29571. /**
  29572. * Set the value of an uniform to a vec4
  29573. * @param uniform defines the webGL uniform location where to store the value
  29574. * @param x defines the 1st component of the value
  29575. * @param y defines the 2nd component of the value
  29576. * @param z defines the 3rd component of the value
  29577. * @param w defines the 4th component of the value
  29578. */
  29579. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29580. /**
  29581. * Sets a Color4 on a uniform variable
  29582. * @param uniform defines the uniform location
  29583. * @param color4 defines the value to be set
  29584. */
  29585. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  29586. /**
  29587. * Set various states to the webGL context
  29588. * @param culling defines backface culling state
  29589. * @param zOffset defines the value to apply to zOffset (0 by default)
  29590. * @param force defines if states must be applied even if cache is up to date
  29591. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29592. */
  29593. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29594. /**
  29595. * Set the z offset to apply to current rendering
  29596. * @param value defines the offset to apply
  29597. */
  29598. setZOffset(value: number): void;
  29599. /**
  29600. * Gets the current value of the zOffset
  29601. * @returns the current zOffset state
  29602. */
  29603. getZOffset(): number;
  29604. /**
  29605. * Enable or disable depth buffering
  29606. * @param enable defines the state to set
  29607. */
  29608. setDepthBuffer(enable: boolean): void;
  29609. /**
  29610. * Gets a boolean indicating if depth writing is enabled
  29611. * @returns the current depth writing state
  29612. */
  29613. getDepthWrite(): boolean;
  29614. /**
  29615. * Enable or disable depth writing
  29616. * @param enable defines the state to set
  29617. */
  29618. setDepthWrite(enable: boolean): void;
  29619. /**
  29620. * Enable or disable color writing
  29621. * @param enable defines the state to set
  29622. */
  29623. setColorWrite(enable: boolean): void;
  29624. /**
  29625. * Gets a boolean indicating if color writing is enabled
  29626. * @returns the current color writing state
  29627. */
  29628. getColorWrite(): boolean;
  29629. /**
  29630. * Sets alpha constants used by some alpha blending modes
  29631. * @param r defines the red component
  29632. * @param g defines the green component
  29633. * @param b defines the blue component
  29634. * @param a defines the alpha component
  29635. */
  29636. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29637. /**
  29638. * Sets the current alpha mode
  29639. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29640. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29641. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29642. */
  29643. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29644. /**
  29645. * Gets the current alpha mode
  29646. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29647. * @returns the current alpha mode
  29648. */
  29649. getAlphaMode(): number;
  29650. /**
  29651. * Sets the current alpha equation
  29652. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  29653. */
  29654. setAlphaEquation(equation: number): void;
  29655. /**
  29656. * Gets the current alpha equation.
  29657. * @returns the current alpha equation
  29658. */
  29659. getAlphaEquation(): number;
  29660. /**
  29661. * Clears the list of texture accessible through engine.
  29662. * This can help preventing texture load conflict due to name collision.
  29663. */
  29664. clearInternalTexturesCache(): void;
  29665. /**
  29666. * Force the entire cache to be cleared
  29667. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29668. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29669. */
  29670. wipeCaches(bruteForce?: boolean): void;
  29671. /**
  29672. * Set the compressed texture format to use, based on the formats you have, and the formats
  29673. * supported by the hardware / browser.
  29674. *
  29675. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29676. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29677. * to API arguments needed to compressed textures. This puts the burden on the container
  29678. * generator to house the arcane code for determining these for current & future formats.
  29679. *
  29680. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29681. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29682. *
  29683. * Note: The result of this call is not taken into account when a texture is base64.
  29684. *
  29685. * @param formatsAvailable defines the list of those format families you have created
  29686. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29687. *
  29688. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29689. * @returns The extension selected.
  29690. */
  29691. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29692. /** @hidden */ private _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29693. min: number;
  29694. mag: number;
  29695. };
  29696. /** @hidden */ private _createTexture(): WebGLTexture;
  29697. /**
  29698. * Usually called from Texture.ts.
  29699. * Passed information to create a WebGLTexture
  29700. * @param urlArg defines a value which contains one of the following:
  29701. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29702. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29703. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29704. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29705. * @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)
  29706. * @param scene needed for loading to the correct scene
  29707. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29708. * @param onLoad optional callback to be called upon successful completion
  29709. * @param onError optional callback to be called upon failure
  29710. * @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
  29711. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29712. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29713. * @param forcedExtension defines the extension to use to pick the right loader
  29714. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29715. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29716. */
  29717. 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>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  29718. /**
  29719. * @hidden
  29720. */ private _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  29721. private _unpackFlipYCached;
  29722. /**
  29723. * In case you are sharing the context with other applications, it might
  29724. * be interested to not cache the unpack flip y state to ensure a consistent
  29725. * value would be set.
  29726. */
  29727. enableUnpackFlipYCached: boolean;
  29728. /** @hidden */ private _unpackFlipY(value: boolean): void;
  29729. /** @hidden */ private _getUnpackAlignement(): number;
  29730. /**
  29731. * Creates a dynamic texture
  29732. * @param width defines the width of the texture
  29733. * @param height defines the height of the texture
  29734. * @param generateMipMaps defines if the engine should generate the mip levels
  29735. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29736. * @returns the dynamic texture inside an InternalTexture
  29737. */
  29738. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29739. /**
  29740. * Update the sampling mode of a given texture
  29741. * @param samplingMode defines the required sampling mode
  29742. * @param texture defines the texture to update
  29743. */
  29744. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29745. /**
  29746. * Update the content of a dynamic texture
  29747. * @param texture defines the texture to update
  29748. * @param canvas defines the canvas containing the source
  29749. * @param invertY defines if data must be stored with Y axis inverted
  29750. * @param premulAlpha defines if alpha is stored as premultiplied
  29751. * @param format defines the format of the data
  29752. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29753. */
  29754. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29755. /**
  29756. * Update a video texture
  29757. * @param texture defines the texture to update
  29758. * @param video defines the video element to use
  29759. * @param invertY defines if data must be stored with Y axis inverted
  29760. */
  29761. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29762. /**
  29763. * Updates a depth texture Comparison Mode and Function.
  29764. * If the comparison Function is equal to 0, the mode will be set to none.
  29765. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29766. * @param texture The texture to set the comparison function for
  29767. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29768. */
  29769. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29770. /** @hidden */ private _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29771. width: number;
  29772. height: number;
  29773. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29774. /**
  29775. * Creates a depth stencil texture.
  29776. * This is only available in WebGL 2 or with the depth texture extension available.
  29777. * @param size The size of face edge in the texture.
  29778. * @param options The options defining the texture.
  29779. * @returns The texture
  29780. */
  29781. createDepthStencilTexture(size: number | {
  29782. width: number;
  29783. height: number;
  29784. }, options: DepthTextureCreationOptions): InternalTexture;
  29785. /**
  29786. * Creates a depth stencil texture.
  29787. * This is only available in WebGL 2 or with the depth texture extension available.
  29788. * @param size The size of face edge in the texture.
  29789. * @param options The options defining the texture.
  29790. * @returns The texture
  29791. */
  29792. private _createDepthStencilTexture;
  29793. /**
  29794. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29795. * @param renderTarget The render target to set the frame buffer for
  29796. */
  29797. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29798. /**
  29799. * Creates a new render target texture
  29800. * @param size defines the size of the texture
  29801. * @param options defines the options used to create the texture
  29802. * @returns a new render target texture stored in an InternalTexture
  29803. */
  29804. createRenderTargetTexture(size: number | {
  29805. width: number;
  29806. height: number;
  29807. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29808. /** @hidden */ private _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29809. /**
  29810. * Updates the sample count of a render target texture
  29811. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29812. * @param texture defines the texture to update
  29813. * @param samples defines the sample count to set
  29814. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29815. */
  29816. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29817. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29818. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29819. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29820. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29821. /**
  29822. * @hidden
  29823. */ private _setCubeMapTextureParams(loadMipmap: boolean): void;
  29824. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  29825. private _prepareWebGLTexture;
  29826. /** @hidden */ private _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29827. /** @hidden */ private _releaseFramebufferObjects(texture: InternalTexture): void;
  29828. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  29829. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  29830. protected _setProgram(program: WebGLProgram): void;
  29831. protected _boundUniforms: {
  29832. [key: number]: WebGLUniformLocation;
  29833. };
  29834. /**
  29835. * Binds an effect to the webGL context
  29836. * @param effect defines the effect to bind
  29837. */
  29838. bindSamplers(effect: Effect): void;
  29839. private _activateCurrentTexture;
  29840. /** @hidden */ private _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29841. /** @hidden */ private _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29842. /**
  29843. * Sets a texture to the webGL context from a postprocess
  29844. * @param channel defines the channel to use
  29845. * @param postProcess defines the source postprocess
  29846. */
  29847. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29848. /**
  29849. * Binds the output of the passed in post process to the texture channel specified
  29850. * @param channel The channel the texture should be bound to
  29851. * @param postProcess The post process which's output should be bound
  29852. */
  29853. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29854. /**
  29855. * Unbind all textures from the webGL context
  29856. */
  29857. unbindAllTextures(): void;
  29858. /**
  29859. * Sets a texture to the according uniform.
  29860. * @param channel The texture channel
  29861. * @param uniform The uniform to set
  29862. * @param texture The texture to apply
  29863. */
  29864. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29865. /**
  29866. * Sets a depth stencil texture from a render target to the according uniform.
  29867. * @param channel The texture channel
  29868. * @param uniform The uniform to set
  29869. * @param texture The render target texture containing the depth stencil texture to apply
  29870. */
  29871. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29872. private _bindSamplerUniformToChannel;
  29873. private _getTextureWrapMode;
  29874. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  29875. /**
  29876. * Sets an array of texture to the webGL context
  29877. * @param channel defines the channel where the texture array must be set
  29878. * @param uniform defines the associated uniform location
  29879. * @param textures defines the array of textures to bind
  29880. */
  29881. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29882. /** @hidden */ private _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29883. private _setTextureParameterFloat;
  29884. private _setTextureParameterInteger;
  29885. /**
  29886. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29887. * @param x defines the x coordinate of the rectangle where pixels must be read
  29888. * @param y defines the y coordinate of the rectangle where pixels must be read
  29889. * @param width defines the width of the rectangle where pixels must be read
  29890. * @param height defines the height of the rectangle where pixels must be read
  29891. * @returns a Uint8Array containing RGBA colors
  29892. */
  29893. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29894. /**
  29895. * Unbind all vertex attributes from the webGL context
  29896. */
  29897. unbindAllAttributes(): void;
  29898. /**
  29899. * 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
  29900. */
  29901. releaseEffects(): void;
  29902. /**
  29903. * Dispose and release all associated resources
  29904. */
  29905. dispose(): void;
  29906. /**
  29907. * Attach a new callback raised when context lost event is fired
  29908. * @param callback defines the callback to call
  29909. */
  29910. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29911. /**
  29912. * Attach a new callback raised when context restored event is fired
  29913. * @param callback defines the callback to call
  29914. */
  29915. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29916. /**
  29917. * Gets the source code of the vertex shader associated with a specific webGL program
  29918. * @param program defines the program to use
  29919. * @returns a string containing the source code of the vertex shader associated with the program
  29920. */
  29921. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29922. /**
  29923. * Gets the source code of the fragment shader associated with a specific webGL program
  29924. * @param program defines the program to use
  29925. * @returns a string containing the source code of the fragment shader associated with the program
  29926. */
  29927. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29928. /**
  29929. * Get the current error code of the webGL context
  29930. * @returns the error code
  29931. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29932. */
  29933. getError(): number;
  29934. private _canRenderToFloatFramebuffer;
  29935. private _canRenderToHalfFloatFramebuffer;
  29936. private _canRenderToFramebuffer;
  29937. /** @hidden */ private _getWebGLTextureType(type: number): number;
  29938. /** @hidden */ private _getInternalFormat(format: number): number;
  29939. /** @hidden */ private _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29940. /** @hidden */ private _getRGBAMultiSampleBufferFormat(type: number): number;
  29941. /** @hidden */ private _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  29942. /** @hidden */ private _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29943. /**
  29944. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29945. * @returns true if the engine can be created
  29946. * @ignorenaming
  29947. */
  29948. static isSupported(): boolean;
  29949. /**
  29950. * Find the next highest power of two.
  29951. * @param x Number to start search from.
  29952. * @return Next highest power of two.
  29953. */
  29954. static CeilingPOT(x: number): number;
  29955. /**
  29956. * Find the next lowest power of two.
  29957. * @param x Number to start search from.
  29958. * @return Next lowest power of two.
  29959. */
  29960. static FloorPOT(x: number): number;
  29961. /**
  29962. * Find the nearest power of two.
  29963. * @param x Number to start search from.
  29964. * @return Next nearest power of two.
  29965. */
  29966. static NearestPOT(x: number): number;
  29967. /**
  29968. * Get the closest exponent of two
  29969. * @param value defines the value to approximate
  29970. * @param max defines the maximum value to return
  29971. * @param mode defines how to define the closest value
  29972. * @returns closest exponent of two of the given value
  29973. */
  29974. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  29975. /**
  29976. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  29977. * @param func - the function to be called
  29978. * @param requester - the object that will request the next frame. Falls back to window.
  29979. * @returns frame number
  29980. */
  29981. static QueueNewFrame(func: () => void, requester?: any): number;
  29982. /**
  29983. * Ask the browser to promote the current element to pointerlock mode
  29984. * @param element defines the DOM element to promote
  29985. */ private static _RequestPointerlock(element: HTMLElement): void;
  29986. /**
  29987. * Asks the browser to exit pointerlock mode
  29988. */ private static _ExitPointerlock(): void;
  29989. /**
  29990. * Ask the browser to promote the current element to fullscreen rendering mode
  29991. * @param element defines the DOM element to promote
  29992. */ private static _RequestFullscreen(element: HTMLElement): void;
  29993. /**
  29994. * Asks the browser to exit fullscreen mode
  29995. */ private static _ExitFullscreen(): void;
  29996. }
  29997. }
  29998. declare module BABYLON {
  29999. /**
  30000. * Class used to store data associated with WebGL texture data for the engine
  30001. * This class should not be used directly
  30002. */
  30003. export class InternalTexture {
  30004. /** @hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  30005. /**
  30006. * The source of the texture data is unknown
  30007. */
  30008. static DATASOURCE_UNKNOWN: number;
  30009. /**
  30010. * Texture data comes from an URL
  30011. */
  30012. static DATASOURCE_URL: number;
  30013. /**
  30014. * Texture data is only used for temporary storage
  30015. */
  30016. static DATASOURCE_TEMP: number;
  30017. /**
  30018. * Texture data comes from raw data (ArrayBuffer)
  30019. */
  30020. static DATASOURCE_RAW: number;
  30021. /**
  30022. * Texture content is dynamic (video or dynamic texture)
  30023. */
  30024. static DATASOURCE_DYNAMIC: number;
  30025. /**
  30026. * Texture content is generated by rendering to it
  30027. */
  30028. static DATASOURCE_RENDERTARGET: number;
  30029. /**
  30030. * Texture content is part of a multi render target process
  30031. */
  30032. static DATASOURCE_MULTIRENDERTARGET: number;
  30033. /**
  30034. * Texture data comes from a cube data file
  30035. */
  30036. static DATASOURCE_CUBE: number;
  30037. /**
  30038. * Texture data comes from a raw cube data
  30039. */
  30040. static DATASOURCE_CUBERAW: number;
  30041. /**
  30042. * Texture data come from a prefiltered cube data file
  30043. */
  30044. static DATASOURCE_CUBEPREFILTERED: number;
  30045. /**
  30046. * Texture content is raw 3D data
  30047. */
  30048. static DATASOURCE_RAW3D: number;
  30049. /**
  30050. * Texture content is a depth texture
  30051. */
  30052. static DATASOURCE_DEPTHTEXTURE: number;
  30053. /**
  30054. * Texture data comes from a raw cube data encoded with RGBD
  30055. */
  30056. static DATASOURCE_CUBERAW_RGBD: number;
  30057. /**
  30058. * Defines if the texture is ready
  30059. */
  30060. isReady: boolean;
  30061. /**
  30062. * Defines if the texture is a cube texture
  30063. */
  30064. isCube: boolean;
  30065. /**
  30066. * Defines if the texture contains 3D data
  30067. */
  30068. is3D: boolean;
  30069. /**
  30070. * Defines if the texture contains multiview data
  30071. */
  30072. isMultiview: boolean;
  30073. /**
  30074. * Gets the URL used to load this texture
  30075. */
  30076. url: string;
  30077. /**
  30078. * Gets the sampling mode of the texture
  30079. */
  30080. samplingMode: number;
  30081. /**
  30082. * Gets a boolean indicating if the texture needs mipmaps generation
  30083. */
  30084. generateMipMaps: boolean;
  30085. /**
  30086. * Gets the number of samples used by the texture (WebGL2+ only)
  30087. */
  30088. samples: number;
  30089. /**
  30090. * Gets the type of the texture (int, float...)
  30091. */
  30092. type: number;
  30093. /**
  30094. * Gets the format of the texture (RGB, RGBA...)
  30095. */
  30096. format: number;
  30097. /**
  30098. * Observable called when the texture is loaded
  30099. */
  30100. onLoadedObservable: Observable<InternalTexture>;
  30101. /**
  30102. * Gets the width of the texture
  30103. */
  30104. width: number;
  30105. /**
  30106. * Gets the height of the texture
  30107. */
  30108. height: number;
  30109. /**
  30110. * Gets the depth of the texture
  30111. */
  30112. depth: number;
  30113. /**
  30114. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  30115. */
  30116. baseWidth: number;
  30117. /**
  30118. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  30119. */
  30120. baseHeight: number;
  30121. /**
  30122. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  30123. */
  30124. baseDepth: number;
  30125. /**
  30126. * Gets a boolean indicating if the texture is inverted on Y axis
  30127. */
  30128. invertY: boolean;
  30129. /** @hidden */ private _invertVScale: boolean;
  30130. /** @hidden */ private _associatedChannel: number;
  30131. /** @hidden */ private _dataSource: number;
  30132. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  30133. /** @hidden */ private _bufferView: Nullable<ArrayBufferView>;
  30134. /** @hidden */ private _bufferViewArray: Nullable<ArrayBufferView[]>;
  30135. /** @hidden */ private _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  30136. /** @hidden */ private _size: number;
  30137. /** @hidden */ private _extension: string;
  30138. /** @hidden */ private _files: Nullable<string[]>;
  30139. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  30140. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  30141. /** @hidden */ private _framebuffer: Nullable<WebGLFramebuffer>;
  30142. /** @hidden */ private _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  30143. /** @hidden */ private _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  30144. /** @hidden */ private _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  30145. /** @hidden */ private _attachments: Nullable<number[]>;
  30146. /** @hidden */ private _cachedCoordinatesMode: Nullable<number>;
  30147. /** @hidden */ private _cachedWrapU: Nullable<number>;
  30148. /** @hidden */ private _cachedWrapV: Nullable<number>;
  30149. /** @hidden */ private _cachedWrapR: Nullable<number>;
  30150. /** @hidden */ private _cachedAnisotropicFilteringLevel: Nullable<number>;
  30151. /** @hidden */ private _isDisabled: boolean;
  30152. /** @hidden */ private _compression: Nullable<string>;
  30153. /** @hidden */ private _generateStencilBuffer: boolean;
  30154. /** @hidden */ private _generateDepthBuffer: boolean;
  30155. /** @hidden */ private _comparisonFunction: number;
  30156. /** @hidden */ private _sphericalPolynomial: Nullable<SphericalPolynomial>;
  30157. /** @hidden */ private _lodGenerationScale: number;
  30158. /** @hidden */ private _lodGenerationOffset: number;
  30159. /** @hidden */ private _colorTextureArray: Nullable<WebGLTexture>;
  30160. /** @hidden */ private _depthStencilTextureArray: Nullable<WebGLTexture>;
  30161. /** @hidden */ private _lodTextureHigh: Nullable<BaseTexture>;
  30162. /** @hidden */ private _lodTextureMid: Nullable<BaseTexture>;
  30163. /** @hidden */ private _lodTextureLow: Nullable<BaseTexture>;
  30164. /** @hidden */ private _isRGBD: boolean;
  30165. /** @hidden */ private _linearSpecularLOD: boolean;
  30166. /** @hidden */ private _irradianceTexture: Nullable<BaseTexture>;
  30167. /** @hidden */ private _webGLTexture: Nullable<WebGLTexture>;
  30168. /** @hidden */ private _references: number;
  30169. private _engine;
  30170. /**
  30171. * Gets the Engine the texture belongs to.
  30172. * @returns The babylon engine
  30173. */
  30174. getEngine(): BaseEngine;
  30175. /**
  30176. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  30177. */
  30178. readonly dataSource: number;
  30179. /**
  30180. * Creates a new InternalTexture
  30181. * @param engine defines the engine to use
  30182. * @param dataSource defines the type of data that will be used
  30183. * @param delayAllocation if the texture allocation should be delayed (default: false)
  30184. */
  30185. constructor(engine: BaseEngine, dataSource: number, delayAllocation?: boolean);
  30186. /**
  30187. * Increments the number of references (ie. the number of Texture that point to it)
  30188. */
  30189. incrementReferences(): void;
  30190. /**
  30191. * Change the size of the texture (not the size of the content)
  30192. * @param width defines the new width
  30193. * @param height defines the new height
  30194. * @param depth defines the new depth (1 by default)
  30195. */
  30196. updateSize(width: int, height: int, depth?: int): void;
  30197. /** @hidden */ private _rebuild(): void;
  30198. /** @hidden */ private _swapAndDie(target: InternalTexture): void;
  30199. /**
  30200. * Dispose the current allocated resources
  30201. */
  30202. dispose(): void;
  30203. }
  30204. }
  30205. declare module BABYLON {
  30206. /**
  30207. * Class used to work with sound analyzer using fast fourier transform (FFT)
  30208. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30209. */
  30210. export class Analyser {
  30211. /**
  30212. * Gets or sets the smoothing
  30213. * @ignorenaming
  30214. */
  30215. SMOOTHING: number;
  30216. /**
  30217. * Gets or sets the FFT table size
  30218. * @ignorenaming
  30219. */
  30220. FFT_SIZE: number;
  30221. /**
  30222. * Gets or sets the bar graph amplitude
  30223. * @ignorenaming
  30224. */
  30225. BARGRAPHAMPLITUDE: number;
  30226. /**
  30227. * Gets or sets the position of the debug canvas
  30228. * @ignorenaming
  30229. */
  30230. DEBUGCANVASPOS: {
  30231. x: number;
  30232. y: number;
  30233. };
  30234. /**
  30235. * Gets or sets the debug canvas size
  30236. * @ignorenaming
  30237. */
  30238. DEBUGCANVASSIZE: {
  30239. width: number;
  30240. height: number;
  30241. };
  30242. private _byteFreqs;
  30243. private _byteTime;
  30244. private _floatFreqs;
  30245. private _webAudioAnalyser;
  30246. private _debugCanvas;
  30247. private _debugCanvasContext;
  30248. private _scene;
  30249. private _registerFunc;
  30250. private _audioEngine;
  30251. /**
  30252. * Creates a new analyser
  30253. * @param scene defines hosting scene
  30254. */
  30255. constructor(scene: Scene);
  30256. /**
  30257. * Get the number of data values you will have to play with for the visualization
  30258. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  30259. * @returns a number
  30260. */
  30261. getFrequencyBinCount(): number;
  30262. /**
  30263. * Gets the current frequency data as a byte array
  30264. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30265. * @returns a Uint8Array
  30266. */
  30267. getByteFrequencyData(): Uint8Array;
  30268. /**
  30269. * Gets the current waveform as a byte array
  30270. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  30271. * @returns a Uint8Array
  30272. */
  30273. getByteTimeDomainData(): Uint8Array;
  30274. /**
  30275. * Gets the current frequency data as a float array
  30276. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30277. * @returns a Float32Array
  30278. */
  30279. getFloatFrequencyData(): Float32Array;
  30280. /**
  30281. * Renders the debug canvas
  30282. */
  30283. drawDebugCanvas(): void;
  30284. /**
  30285. * Stops rendering the debug canvas and removes it
  30286. */
  30287. stopDebugCanvas(): void;
  30288. /**
  30289. * Connects two audio nodes
  30290. * @param inputAudioNode defines first node to connect
  30291. * @param outputAudioNode defines second node to connect
  30292. */
  30293. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30294. /**
  30295. * Releases all associated resources
  30296. */
  30297. dispose(): void;
  30298. }
  30299. }
  30300. declare module BABYLON {
  30301. /**
  30302. * This represents an audio engine and it is responsible
  30303. * to play, synchronize and analyse sounds throughout the application.
  30304. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30305. */
  30306. export interface IAudioEngine extends IDisposable {
  30307. /**
  30308. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30309. */
  30310. readonly canUseWebAudio: boolean;
  30311. /**
  30312. * Gets the current AudioContext if available.
  30313. */
  30314. readonly audioContext: Nullable<AudioContext>;
  30315. /**
  30316. * The master gain node defines the global audio volume of your audio engine.
  30317. */
  30318. readonly masterGain: GainNode;
  30319. /**
  30320. * Gets whether or not mp3 are supported by your browser.
  30321. */
  30322. readonly isMP3supported: boolean;
  30323. /**
  30324. * Gets whether or not ogg are supported by your browser.
  30325. */
  30326. readonly isOGGsupported: boolean;
  30327. /**
  30328. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30329. * @ignoreNaming
  30330. */
  30331. WarnedWebAudioUnsupported: boolean;
  30332. /**
  30333. * Defines if the audio engine relies on a custom unlocked button.
  30334. * In this case, the embedded button will not be displayed.
  30335. */
  30336. useCustomUnlockedButton: boolean;
  30337. /**
  30338. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30339. */
  30340. readonly unlocked: boolean;
  30341. /**
  30342. * Event raised when audio has been unlocked on the browser.
  30343. */
  30344. onAudioUnlockedObservable: Observable<AudioEngine>;
  30345. /**
  30346. * Event raised when audio has been locked on the browser.
  30347. */
  30348. onAudioLockedObservable: Observable<AudioEngine>;
  30349. /**
  30350. * Flags the audio engine in Locked state.
  30351. * This happens due to new browser policies preventing audio to autoplay.
  30352. */
  30353. lock(): void;
  30354. /**
  30355. * Unlocks the audio engine once a user action has been done on the dom.
  30356. * This is helpful to resume play once browser policies have been satisfied.
  30357. */
  30358. unlock(): void;
  30359. }
  30360. /**
  30361. * This represents the default audio engine used in babylon.
  30362. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30364. */
  30365. export class AudioEngine implements IAudioEngine {
  30366. private _audioContext;
  30367. private _audioContextInitialized;
  30368. private _muteButton;
  30369. private _hostElement;
  30370. /**
  30371. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30372. */
  30373. canUseWebAudio: boolean;
  30374. /**
  30375. * The master gain node defines the global audio volume of your audio engine.
  30376. */
  30377. masterGain: GainNode;
  30378. /**
  30379. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30380. * @ignoreNaming
  30381. */
  30382. WarnedWebAudioUnsupported: boolean;
  30383. /**
  30384. * Gets whether or not mp3 are supported by your browser.
  30385. */
  30386. isMP3supported: boolean;
  30387. /**
  30388. * Gets whether or not ogg are supported by your browser.
  30389. */
  30390. isOGGsupported: boolean;
  30391. /**
  30392. * Gets whether audio has been unlocked on the device.
  30393. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30394. * a user interaction has happened.
  30395. */
  30396. unlocked: boolean;
  30397. /**
  30398. * Defines if the audio engine relies on a custom unlocked button.
  30399. * In this case, the embedded button will not be displayed.
  30400. */
  30401. useCustomUnlockedButton: boolean;
  30402. /**
  30403. * Event raised when audio has been unlocked on the browser.
  30404. */
  30405. onAudioUnlockedObservable: Observable<AudioEngine>;
  30406. /**
  30407. * Event raised when audio has been locked on the browser.
  30408. */
  30409. onAudioLockedObservable: Observable<AudioEngine>;
  30410. /**
  30411. * Gets the current AudioContext if available.
  30412. */
  30413. readonly audioContext: Nullable<AudioContext>;
  30414. private _connectedAnalyser;
  30415. /**
  30416. * Instantiates a new audio engine.
  30417. *
  30418. * There should be only one per page as some browsers restrict the number
  30419. * of audio contexts you can create.
  30420. * @param hostElement defines the host element where to display the mute icon if necessary
  30421. */
  30422. constructor(hostElement?: Nullable<HTMLElement>);
  30423. /**
  30424. * Flags the audio engine in Locked state.
  30425. * This happens due to new browser policies preventing audio to autoplay.
  30426. */
  30427. lock(): void;
  30428. /**
  30429. * Unlocks the audio engine once a user action has been done on the dom.
  30430. * This is helpful to resume play once browser policies have been satisfied.
  30431. */
  30432. unlock(): void;
  30433. private _resumeAudioContext;
  30434. private _initializeAudioContext;
  30435. private _tryToRun;
  30436. private _triggerRunningState;
  30437. private _triggerSuspendedState;
  30438. private _displayMuteButton;
  30439. private _moveButtonToTopLeft;
  30440. private _onResize;
  30441. private _hideMuteButton;
  30442. /**
  30443. * Destroy and release the resources associated with the audio ccontext.
  30444. */
  30445. dispose(): void;
  30446. /**
  30447. * Gets the global volume sets on the master gain.
  30448. * @returns the global volume if set or -1 otherwise
  30449. */
  30450. getGlobalVolume(): number;
  30451. /**
  30452. * Sets the global volume of your experience (sets on the master gain).
  30453. * @param newVolume Defines the new global volume of the application
  30454. */
  30455. setGlobalVolume(newVolume: number): void;
  30456. /**
  30457. * Connect the audio engine to an audio analyser allowing some amazing
  30458. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30459. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30460. * @param analyser The analyser to connect to the engine
  30461. */
  30462. connectToAnalyser(analyser: Analyser): void;
  30463. }
  30464. }
  30465. declare module BABYLON {
  30466. /**
  30467. * Interface used to present a loading screen while loading a scene
  30468. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30469. */
  30470. export interface ILoadingScreen {
  30471. /**
  30472. * Function called to display the loading screen
  30473. */
  30474. displayLoadingUI: () => void;
  30475. /**
  30476. * Function called to hide the loading screen
  30477. */
  30478. hideLoadingUI: () => void;
  30479. /**
  30480. * Gets or sets the color to use for the background
  30481. */
  30482. loadingUIBackgroundColor: string;
  30483. /**
  30484. * Gets or sets the text to display while loading
  30485. */
  30486. loadingUIText: string;
  30487. }
  30488. /**
  30489. * Class used for the default loading screen
  30490. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30491. */
  30492. export class DefaultLoadingScreen implements ILoadingScreen {
  30493. private _renderingCanvas;
  30494. private _loadingText;
  30495. private _loadingDivBackgroundColor;
  30496. private _loadingDiv;
  30497. private _loadingTextDiv;
  30498. /** Gets or sets the logo url to use for the default loading screen */
  30499. static DefaultLogoUrl: string;
  30500. /** Gets or sets the spinner url to use for the default loading screen */
  30501. static DefaultSpinnerUrl: string;
  30502. /**
  30503. * Creates a new default loading screen
  30504. * @param _renderingCanvas defines the canvas used to render the scene
  30505. * @param _loadingText defines the default text to display
  30506. * @param _loadingDivBackgroundColor defines the default background color
  30507. */
  30508. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30509. /**
  30510. * Function called to display the loading screen
  30511. */
  30512. displayLoadingUI(): void;
  30513. /**
  30514. * Function called to hide the loading screen
  30515. */
  30516. hideLoadingUI(): void;
  30517. /**
  30518. * Gets or sets the text to display while loading
  30519. */
  30520. loadingUIText: string;
  30521. /**
  30522. * Gets or sets the color to use for the background
  30523. */
  30524. loadingUIBackgroundColor: string;
  30525. private _resizeLoadingUI;
  30526. }
  30527. }
  30528. declare module BABYLON {
  30529. /**
  30530. * Interface for any object that can request an animation frame
  30531. */
  30532. export interface ICustomAnimationFrameRequester {
  30533. /**
  30534. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30535. */
  30536. renderFunction?: Function;
  30537. /**
  30538. * Called to request the next frame to render to
  30539. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30540. */
  30541. requestAnimationFrame: Function;
  30542. /**
  30543. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30544. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30545. */
  30546. requestID?: number;
  30547. }
  30548. }
  30549. declare module BABYLON {
  30550. /**
  30551. * Interface for performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30552. */
  30553. export interface IPerformanceMonitor {
  30554. /**
  30555. * Enables contributions to the sliding window sample set
  30556. */
  30557. enable(): void;
  30558. /**
  30559. * Disables contributions to the sliding window sample set
  30560. * Samples will not be interpolated over the disabled period
  30561. */
  30562. disable(): void;
  30563. /**
  30564. * Samples current frame
  30565. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30566. */
  30567. sampleFrame(timeMs?: number): void;
  30568. /**
  30569. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30570. */
  30571. averageFrameTime: number;
  30572. /**
  30573. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30574. */
  30575. averageFrameTimeVariance: number;
  30576. /**
  30577. * Returns the frame time of the most recent frame
  30578. */
  30579. instantaneousFrameTime: number;
  30580. /**
  30581. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30582. */
  30583. averageFPS: number;
  30584. /**
  30585. * Returns the average framerate in frames per second using the most recent frame time
  30586. */
  30587. instantaneousFPS: number;
  30588. }
  30589. }
  30590. declare module BABYLON {
  30591. /**
  30592. * Defines the interface used by display changed events
  30593. */
  30594. export interface IDisplayChangedEventArgs {
  30595. /** Gets the vrDisplay object (if any) */
  30596. vrDisplay: Nullable<any>;
  30597. /** Gets a boolean indicating if webVR is supported */
  30598. vrSupported: boolean;
  30599. }
  30600. /**
  30601. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30602. */
  30603. export class Engine extends BaseEngine {
  30604. /**
  30605. * Returns the current npm package of the sdk
  30606. */
  30607. static readonly NpmPackage: string;
  30608. /**
  30609. * Returns the current version of the framework
  30610. */
  30611. static readonly Version: string;
  30612. /** Gets the list of created engines */
  30613. static readonly Instances: Engine[];
  30614. /**
  30615. * Gets the latest created engine
  30616. */
  30617. static readonly LastCreatedEngine: Nullable<Engine>;
  30618. /**
  30619. * Gets the latest created scene
  30620. */
  30621. static readonly LastCreatedScene: Nullable<Scene>;
  30622. /**
  30623. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30624. * @param flag defines which part of the materials must be marked as dirty
  30625. * @param predicate defines a predicate used to filter which materials should be affected
  30626. */
  30627. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30628. /**
  30629. * Factory used to create the performance monitor
  30630. * @returns a new PerformanceMonitor
  30631. */
  30632. static DefaultPerformanceMonitorFactory(): IPerformanceMonitor;
  30633. /**
  30634. * Method called to create the default loading screen.
  30635. * This can be overriden in your own app.
  30636. * @param canvas The rendering canvas element
  30637. * @returns The loading screen
  30638. */
  30639. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30640. /**
  30641. * Method called to create the default rescale post process on each engine.
  30642. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30643. /**
  30644. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30645. **/
  30646. enableOfflineSupport: boolean;
  30647. /**
  30648. * 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)
  30649. **/
  30650. disableManifestCheck: boolean;
  30651. /**
  30652. * Gets the list of created scenes
  30653. */
  30654. scenes: Scene[];
  30655. /**
  30656. * Event raised when a new scene is created
  30657. */
  30658. onNewSceneAddedObservable: Observable<Scene>;
  30659. /**
  30660. * Gets the list of created postprocesses
  30661. */
  30662. postProcesses: PostProcess[];
  30663. /**
  30664. * Observable event triggered each time the rendering canvas is resized
  30665. */
  30666. onResizeObservable: Observable<Engine>;
  30667. /**
  30668. * Observable event triggered each time the canvas loses focus
  30669. */
  30670. onCanvasBlurObservable: Observable<Engine>;
  30671. /**
  30672. * Observable event triggered each time the canvas gains focus
  30673. */
  30674. onCanvasFocusObservable: Observable<Engine>;
  30675. /**
  30676. * Observable event triggered each time the canvas receives pointerout event
  30677. */
  30678. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30679. /**
  30680. * Observable event triggered before each texture is initialized
  30681. */
  30682. onBeforeTextureInitObservable: Observable<Texture>;
  30683. /**
  30684. * Observable raised when the engine begins a new frame
  30685. */
  30686. onBeginFrameObservable: Observable<Engine>;
  30687. /**
  30688. * If set, will be used to request the next animation frame for the render loop
  30689. */
  30690. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30691. /**
  30692. * Observable raised when the engine ends the current frame
  30693. */
  30694. onEndFrameObservable: Observable<Engine>;
  30695. /**
  30696. * Observable raised when the engine is about to compile a shader
  30697. */
  30698. onBeforeShaderCompilationObservable: Observable<Engine>;
  30699. /**
  30700. * Observable raised when the engine has jsut compiled a shader
  30701. */
  30702. onAfterShaderCompilationObservable: Observable<Engine>;
  30703. /**
  30704. * Gets the audio engine
  30705. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30706. * @ignorenaming
  30707. */
  30708. static audioEngine: IAudioEngine;
  30709. /**
  30710. * Default AudioEngine factory responsible of creating the Audio Engine.
  30711. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30712. */
  30713. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30714. /**
  30715. * Default offline support factory responsible of creating a tool used to store data locally.
  30716. * By default, this will create a Database object if the workload has been embedded.
  30717. */
  30718. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30719. private _loadingScreen;
  30720. private _pointerLockRequested;
  30721. private _dummyFramebuffer;
  30722. private _rescalePostProcess;
  30723. protected readonly _supportsHardwareTextureRescaling: boolean;
  30724. private _fps;
  30725. private _deltaTime;
  30726. /**
  30727. * Turn this value on if you want to pause FPS computation when in background
  30728. */
  30729. disablePerformanceMonitorInBackground: boolean;
  30730. private _performanceMonitor;
  30731. /**
  30732. * Gets the performance monitor attached to this engine
  30733. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30734. */
  30735. readonly performanceMonitor: IPerformanceMonitor;
  30736. private _onFocus;
  30737. private _onBlur;
  30738. private _onCanvasPointerOut;
  30739. private _onCanvasBlur;
  30740. private _onCanvasFocus;
  30741. private _onFullscreenChange;
  30742. private _onPointerLockChange;
  30743. /**
  30744. * Creates a new engine
  30745. * @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
  30746. * @param antialias defines enable antialiasing (default: false)
  30747. * @param options defines further options to be sent to the getContext() function
  30748. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30749. */
  30750. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30751. /**
  30752. * Initializes a webVR display and starts listening to display change events
  30753. * The onVRDisplayChangedObservable will be notified upon these changes
  30754. * @returns The onVRDisplayChangedObservable
  30755. */
  30756. initWebVR(): Observable<IDisplayChangedEventArgs>;
  30757. /** @hidden */ private _prepareVRComponent(): void;
  30758. /** @hidden */ private _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  30759. /** @hidden */ private _submitVRFrame(): void;
  30760. /**
  30761. * Call this function to leave webVR mode
  30762. * Will do nothing if webVR is not supported or if there is no webVR device
  30763. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30764. */
  30765. disableVR(): void;
  30766. /**
  30767. * Gets a boolean indicating that the system is in VR mode and is presenting
  30768. * @returns true if VR mode is engaged
  30769. */
  30770. isVRPresenting(): boolean;
  30771. /** @hidden */ private _requestVRFrame(): void;
  30772. protected _rebuildBuffers(): void; private _renderLoop(): void;
  30773. /**
  30774. * Toggle full screen mode
  30775. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30776. */
  30777. switchFullscreen(requestPointerLock: boolean): void;
  30778. /**
  30779. * Enters full screen mode
  30780. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30781. */
  30782. enterFullscreen(requestPointerLock: boolean): void;
  30783. /**
  30784. * Exits full screen mode
  30785. */
  30786. exitFullscreen(): void;
  30787. /**
  30788. * Enters Pointerlock mode
  30789. */
  30790. enterPointerlock(): void;
  30791. /**
  30792. * Exits Pointerlock mode
  30793. */
  30794. exitPointerlock(): void;
  30795. /**
  30796. * Begin a new frame
  30797. */
  30798. beginFrame(): void;
  30799. /**
  30800. * Enf the current frame
  30801. */
  30802. endFrame(): void;
  30803. resize(): void;
  30804. /**
  30805. * Force a specific size of the canvas
  30806. * @param width defines the new canvas' width
  30807. * @param height defines the new canvas' height
  30808. */
  30809. setSize(width: number, height: number): void; private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30810. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30811. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram; private _releaseTexture(texture: InternalTexture): void;
  30812. /**
  30813. * @hidden
  30814. * Rescales a texture
  30815. * @param source input texutre
  30816. * @param destination destination texture
  30817. * @param scene scene to use to render the resize
  30818. * @param internalFormat format to use when resizing
  30819. * @param onComplete callback to be called when resize has completed
  30820. */ private _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30821. /**
  30822. * Gets the current framerate
  30823. * @returns a number representing the framerate
  30824. */
  30825. getFps(): number;
  30826. /**
  30827. * Gets the time spent between current and previous frame
  30828. * @returns a number representing the delta time in ms
  30829. */
  30830. getDeltaTime(): number;
  30831. private _measureFps;
  30832. /** @hidden */ private _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  30833. dispose(): void;
  30834. /**
  30835. * Display the loading screen
  30836. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30837. */
  30838. displayLoadingUI(): void;
  30839. /**
  30840. * Hide the loading screen
  30841. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30842. */
  30843. hideLoadingUI(): void;
  30844. /**
  30845. * Gets the current loading screen object
  30846. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30847. */
  30848. /**
  30849. * Sets the current loading screen object
  30850. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30851. */
  30852. loadingScreen: ILoadingScreen;
  30853. /**
  30854. * Sets the current loading screen text
  30855. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30856. */
  30857. loadingUIText: string;
  30858. /**
  30859. * Sets the current loading screen background color
  30860. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30861. */
  30862. loadingUIBackgroundColor: string;
  30863. }
  30864. }
  30865. declare module BABYLON {
  30866. /**
  30867. * The engine store class is responsible to hold all the instances of Engine and Scene created
  30868. * during the life time of the application.
  30869. */
  30870. export class EngineStore {
  30871. /** Gets the list of created engines */
  30872. static Instances: Engine[];
  30873. /** @hidden */ private static _LastCreatedScene: Nullable<Scene>;
  30874. /**
  30875. * Gets the latest created engine
  30876. */
  30877. static readonly LastCreatedEngine: Nullable<Engine>;
  30878. /**
  30879. * Gets the latest created scene
  30880. */
  30881. static readonly LastCreatedScene: Nullable<Scene>;
  30882. /**
  30883. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30884. * @ignorenaming
  30885. */
  30886. static UseFallbackTexture: boolean;
  30887. /**
  30888. * Texture content used if a texture cannot loaded
  30889. * @ignorenaming
  30890. */
  30891. static FallbackTexture: string;
  30892. }
  30893. }
  30894. declare module BABYLON {
  30895. /**
  30896. * Helper class that provides a small promise polyfill
  30897. */
  30898. export class PromisePolyfill {
  30899. /**
  30900. * Static function used to check if the polyfill is required
  30901. * If this is the case then the function will inject the polyfill to window.Promise
  30902. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  30903. */
  30904. static Apply(force?: boolean): void;
  30905. }
  30906. }
  30907. declare module BABYLON {
  30908. /**
  30909. * Interface for screenshot methods with describe argument called `size` as object with options
  30910. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  30911. */
  30912. export interface IScreenshotSize {
  30913. /**
  30914. * number in pixels for canvas height
  30915. */
  30916. height?: number;
  30917. /**
  30918. * multiplier allowing render at a higher or lower resolution
  30919. * If value is defined then height and width will be ignored and taken from camera
  30920. */
  30921. precision?: number;
  30922. /**
  30923. * number in pixels for canvas width
  30924. */
  30925. width?: number;
  30926. }
  30927. }
  30928. declare module BABYLON {
  30929. interface IColor4Like {
  30930. r: float;
  30931. g: float;
  30932. b: float;
  30933. a: float;
  30934. }
  30935. /**
  30936. * Class containing a set of static utilities functions
  30937. */
  30938. export class Tools {
  30939. /**
  30940. * Gets or sets the base URL to use to load assets
  30941. */
  30942. static BaseUrl: string;
  30943. /**
  30944. * Enable/Disable Custom HTTP Request Headers globally.
  30945. * default = false
  30946. * @see CustomRequestHeaders
  30947. */
  30948. static UseCustomRequestHeaders: boolean;
  30949. /**
  30950. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30951. * i.e. when loading files, where the server/service expects an Authorization header
  30952. */
  30953. static CustomRequestHeaders: {
  30954. [key: string]: string;
  30955. };
  30956. /**
  30957. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30958. */
  30959. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30960. /**
  30961. * Default behaviour for cors in the application.
  30962. * It can be a string if the expected behavior is identical in the entire app.
  30963. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30964. */
  30965. static CorsBehavior: string | ((url: string | string[]) => string);
  30966. /**
  30967. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30968. * @ignorenaming
  30969. */
  30970. static UseFallbackTexture: boolean;
  30971. /**
  30972. * Use this object to register external classes like custom textures or material
  30973. * to allow the laoders to instantiate them
  30974. */
  30975. static RegisteredExternalClasses: {
  30976. [key: string]: Object;
  30977. };
  30978. /**
  30979. * Texture content used if a texture cannot loaded
  30980. * @ignorenaming
  30981. */
  30982. static fallbackTexture: string;
  30983. /**
  30984. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30985. * @param u defines the coordinate on X axis
  30986. * @param v defines the coordinate on Y axis
  30987. * @param width defines the width of the source data
  30988. * @param height defines the height of the source data
  30989. * @param pixels defines the source byte array
  30990. * @param color defines the output color
  30991. */
  30992. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  30993. /**
  30994. * Interpolates between a and b via alpha
  30995. * @param a The lower value (returned when alpha = 0)
  30996. * @param b The upper value (returned when alpha = 1)
  30997. * @param alpha The interpolation-factor
  30998. * @return The mixed value
  30999. */
  31000. static Mix(a: number, b: number, alpha: number): number;
  31001. /**
  31002. * Tries to instantiate a new object from a given class name
  31003. * @param className defines the class name to instantiate
  31004. * @returns the new object or null if the system was not able to do the instantiation
  31005. */
  31006. static Instantiate(className: string): any;
  31007. /**
  31008. * Provides a slice function that will work even on IE
  31009. * @param data defines the array to slice
  31010. * @param start defines the start of the data (optional)
  31011. * @param end defines the end of the data (optional)
  31012. * @returns the new sliced array
  31013. */
  31014. static Slice<T>(data: T, start?: number, end?: number): T;
  31015. /**
  31016. * Polyfill for setImmediate
  31017. * @param action defines the action to execute after the current execution block
  31018. */
  31019. static SetImmediate(action: () => void): void;
  31020. /**
  31021. * Function indicating if a number is an exponent of 2
  31022. * @param value defines the value to test
  31023. * @returns true if the value is an exponent of 2
  31024. */
  31025. static IsExponentOfTwo(value: number): boolean;
  31026. private static _tmpFloatArray;
  31027. /**
  31028. * Returns the nearest 32-bit single precision float representation of a Number
  31029. * @param value A Number. If the parameter is of a different type, it will get converted
  31030. * to a number or to NaN if it cannot be converted
  31031. * @returns number
  31032. */
  31033. static FloatRound(value: number): number;
  31034. /**
  31035. * Extracts the filename from a path
  31036. * @param path defines the path to use
  31037. * @returns the filename
  31038. */
  31039. static GetFilename(path: string): string;
  31040. /**
  31041. * Extracts the "folder" part of a path (everything before the filename).
  31042. * @param uri The URI to extract the info from
  31043. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31044. * @returns The "folder" part of the path
  31045. */
  31046. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31047. /**
  31048. * Extracts text content from a DOM element hierarchy
  31049. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31050. */
  31051. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31052. /**
  31053. * Convert an angle in radians to degrees
  31054. * @param angle defines the angle to convert
  31055. * @returns the angle in degrees
  31056. */
  31057. static ToDegrees(angle: number): number;
  31058. /**
  31059. * Convert an angle in degrees to radians
  31060. * @param angle defines the angle to convert
  31061. * @returns the angle in radians
  31062. */
  31063. static ToRadians(angle: number): number;
  31064. /**
  31065. * Encode a buffer to a base64 string
  31066. * @param buffer defines the buffer to encode
  31067. * @returns the encoded string
  31068. */
  31069. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31070. /**
  31071. * Returns an array if obj is not an array
  31072. * @param obj defines the object to evaluate as an array
  31073. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31074. * @returns either obj directly if obj is an array or a new array containing obj
  31075. */
  31076. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31077. /**
  31078. * Gets the pointer prefix to use
  31079. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31080. */
  31081. static GetPointerPrefix(): string;
  31082. /**
  31083. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31084. * @param url define the url we are trying
  31085. * @param element define the dom element where to configure the cors policy
  31086. */
  31087. static SetCorsBehavior(url: string | string[], element: {
  31088. crossOrigin: string | null;
  31089. }): void;
  31090. /**
  31091. * Removes unwanted characters from an url
  31092. * @param url defines the url to clean
  31093. * @returns the cleaned url
  31094. */
  31095. static CleanUrl(url: string): string;
  31096. /**
  31097. * Gets or sets a function used to pre-process url before using them to load assets
  31098. */
  31099. static PreprocessUrl: (url: string) => string;
  31100. /**
  31101. * Loads an image as an HTMLImageElement.
  31102. * @param input url string, ArrayBuffer, or Blob to load
  31103. * @param onLoad callback called when the image successfully loads
  31104. * @param onError callback called when the image fails to load
  31105. * @param offlineProvider offline provider for caching
  31106. * @returns the HTMLImageElement of the loaded image
  31107. */
  31108. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31109. /**
  31110. * Loads a file
  31111. * @param url url string, ArrayBuffer, or Blob to load
  31112. * @param onSuccess callback called when the file successfully loads
  31113. * @param onProgress callback called while file is loading (if the server supports this mode)
  31114. * @param offlineProvider defines the offline provider for caching
  31115. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31116. * @param onError callback called when the file fails to load
  31117. * @returns a file request object
  31118. */
  31119. 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;
  31120. /**
  31121. * Loads a file from a url
  31122. * @param url the file url to load
  31123. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31124. */
  31125. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31126. /**
  31127. * Load a script (identified by an url). When the url returns, the
  31128. * content of this file is added into a new script element, attached to the DOM (body element)
  31129. * @param scriptUrl defines the url of the script to laod
  31130. * @param onSuccess defines the callback called when the script is loaded
  31131. * @param onError defines the callback to call if an error occurs
  31132. * @param scriptId defines the id of the script element
  31133. */
  31134. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31135. /**
  31136. * Load an asynchronous script (identified by an url). When the url returns, the
  31137. * content of this file is added into a new script element, attached to the DOM (body element)
  31138. * @param scriptUrl defines the url of the script to laod
  31139. * @param scriptId defines the id of the script element
  31140. * @returns a promise request object
  31141. */
  31142. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31143. /**
  31144. * Loads a file from a blob
  31145. * @param fileToLoad defines the blob to use
  31146. * @param callback defines the callback to call when data is loaded
  31147. * @param progressCallback defines the callback to call during loading process
  31148. * @returns a file request object
  31149. */
  31150. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31151. /**
  31152. * Loads a file
  31153. * @param fileToLoad defines the file to load
  31154. * @param callback defines the callback to call when data is loaded
  31155. * @param progressCallBack defines the callback to call during loading process
  31156. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31157. * @returns a file request object
  31158. */
  31159. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31160. /**
  31161. * Creates a data url from a given string content
  31162. * @param content defines the content to convert
  31163. * @returns the new data url link
  31164. */
  31165. static FileAsURL(content: string): string;
  31166. /**
  31167. * Format the given number to a specific decimal format
  31168. * @param value defines the number to format
  31169. * @param decimals defines the number of decimals to use
  31170. * @returns the formatted string
  31171. */
  31172. static Format(value: number, decimals?: number): string;
  31173. /**
  31174. * Tries to copy an object by duplicating every property
  31175. * @param source defines the source object
  31176. * @param destination defines the target object
  31177. * @param doNotCopyList defines a list of properties to avoid
  31178. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31179. */
  31180. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31181. /**
  31182. * Gets a boolean indicating if the given object has no own property
  31183. * @param obj defines the object to test
  31184. * @returns true if object has no own property
  31185. */
  31186. static IsEmpty(obj: any): boolean;
  31187. /**
  31188. * Function used to register events at window level
  31189. * @param windowElement defines the Window object to use
  31190. * @param events defines the events to register
  31191. */
  31192. static RegisterTopRootEvents(windowElement: Window, events: {
  31193. name: string;
  31194. handler: Nullable<(e: FocusEvent) => any>;
  31195. }[]): void;
  31196. /**
  31197. * Function used to unregister events from window level
  31198. * @param windowElement defines the Window object to use
  31199. * @param events defines the events to unregister
  31200. */
  31201. static UnregisterTopRootEvents(windowElement: Window, events: {
  31202. name: string;
  31203. handler: Nullable<(e: FocusEvent) => any>;
  31204. }[]): void;
  31205. /**
  31206. * @ignore
  31207. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  31208. /**
  31209. * Dumps the current bound framebuffer
  31210. * @param width defines the rendering width
  31211. * @param height defines the rendering height
  31212. * @param engine defines the hosting engine
  31213. * @param successCallback defines the callback triggered once the data are available
  31214. * @param mimeType defines the mime type of the result
  31215. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31216. */
  31217. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31218. /**
  31219. * Converts the canvas data to blob.
  31220. * This acts as a polyfill for browsers not supporting the to blob function.
  31221. * @param canvas Defines the canvas to extract the data from
  31222. * @param successCallback Defines the callback triggered once the data are available
  31223. * @param mimeType Defines the mime type of the result
  31224. */
  31225. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31226. /**
  31227. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31228. * @param successCallback defines the callback triggered once the data are available
  31229. * @param mimeType defines the mime type of the result
  31230. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31231. */
  31232. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31233. /**
  31234. * Downloads a blob in the browser
  31235. * @param blob defines the blob to download
  31236. * @param fileName defines the name of the downloaded file
  31237. */
  31238. static Download(blob: Blob, fileName: string): void;
  31239. /**
  31240. * Captures a screenshot of the current rendering
  31241. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31242. * @param engine defines the rendering engine
  31243. * @param camera defines the source camera
  31244. * @param size This parameter can be set to a single number or to an object with the
  31245. * following (optional) properties: precision, width, height. If a single number is passed,
  31246. * it will be used for both width and height. If an object is passed, the screenshot size
  31247. * will be derived from the parameters. The precision property is a multiplier allowing
  31248. * rendering at a higher or lower resolution
  31249. * @param successCallback defines the callback receives a single parameter which contains the
  31250. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31251. * src parameter of an <img> to display it
  31252. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31253. * Check your browser for supported MIME types
  31254. */
  31255. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  31256. /**
  31257. * Captures a screenshot of the current rendering
  31258. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31259. * @param engine defines the rendering engine
  31260. * @param camera defines the source camera
  31261. * @param size This parameter can be set to a single number or to an object with the
  31262. * following (optional) properties: precision, width, height. If a single number is passed,
  31263. * it will be used for both width and height. If an object is passed, the screenshot size
  31264. * will be derived from the parameters. The precision property is a multiplier allowing
  31265. * rendering at a higher or lower resolution
  31266. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31267. * Check your browser for supported MIME types
  31268. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31269. * to the src parameter of an <img> to display it
  31270. */
  31271. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  31272. /**
  31273. * Generates an image screenshot from the specified camera.
  31274. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31275. * @param engine The engine to use for rendering
  31276. * @param camera The camera to use for rendering
  31277. * @param size This parameter can be set to a single number or to an object with the
  31278. * following (optional) properties: precision, width, height. If a single number is passed,
  31279. * it will be used for both width and height. If an object is passed, the screenshot size
  31280. * will be derived from the parameters. The precision property is a multiplier allowing
  31281. * rendering at a higher or lower resolution
  31282. * @param successCallback The callback receives a single parameter which contains the
  31283. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31284. * src parameter of an <img> to display it
  31285. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31286. * Check your browser for supported MIME types
  31287. * @param samples Texture samples (default: 1)
  31288. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31289. * @param fileName A name for for the downloaded file.
  31290. */
  31291. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31292. /**
  31293. * Generates an image screenshot from the specified camera.
  31294. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31295. * @param engine The engine to use for rendering
  31296. * @param camera The camera to use for rendering
  31297. * @param size This parameter can be set to a single number or to an object with the
  31298. * following (optional) properties: precision, width, height. If a single number is passed,
  31299. * it will be used for both width and height. If an object is passed, the screenshot size
  31300. * will be derived from the parameters. The precision property is a multiplier allowing
  31301. * rendering at a higher or lower resolution
  31302. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31303. * Check your browser for supported MIME types
  31304. * @param samples Texture samples (default: 1)
  31305. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31306. * @param fileName A name for for the downloaded file.
  31307. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31308. * to the src parameter of an <img> to display it
  31309. */
  31310. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  31311. /**
  31312. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31313. * Be aware Math.random() could cause collisions, but:
  31314. * "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"
  31315. * @returns a pseudo random id
  31316. */
  31317. static RandomId(): string;
  31318. /**
  31319. * Test if the given uri is a base64 string
  31320. * @param uri The uri to test
  31321. * @return True if the uri is a base64 string or false otherwise
  31322. */
  31323. static IsBase64(uri: string): boolean;
  31324. /**
  31325. * Decode the given base64 uri.
  31326. * @param uri The uri to decode
  31327. * @return The decoded base64 data.
  31328. */
  31329. static DecodeBase64(uri: string): ArrayBuffer;
  31330. /**
  31331. * Gets the absolute url.
  31332. * @param url the input url
  31333. * @return the absolute url
  31334. */
  31335. static GetAbsoluteUrl(url: string): string;
  31336. /**
  31337. * No log
  31338. */
  31339. static readonly NoneLogLevel: number;
  31340. /**
  31341. * Only message logs
  31342. */
  31343. static readonly MessageLogLevel: number;
  31344. /**
  31345. * Only warning logs
  31346. */
  31347. static readonly WarningLogLevel: number;
  31348. /**
  31349. * Only error logs
  31350. */
  31351. static readonly ErrorLogLevel: number;
  31352. /**
  31353. * All logs
  31354. */
  31355. static readonly AllLogLevel: number;
  31356. /**
  31357. * Gets a value indicating the number of loading errors
  31358. * @ignorenaming
  31359. */
  31360. static readonly errorsCount: number;
  31361. /**
  31362. * Callback called when a new log is added
  31363. */
  31364. static OnNewCacheEntry: (entry: string) => void;
  31365. /**
  31366. * Log a message to the console
  31367. * @param message defines the message to log
  31368. */
  31369. static Log(message: string): void;
  31370. /**
  31371. * Write a warning message to the console
  31372. * @param message defines the message to log
  31373. */
  31374. static Warn(message: string): void;
  31375. /**
  31376. * Write an error message to the console
  31377. * @param message defines the message to log
  31378. */
  31379. static Error(message: string): void;
  31380. /**
  31381. * Gets current log cache (list of logs)
  31382. */
  31383. static readonly LogCache: string;
  31384. /**
  31385. * Clears the log cache
  31386. */
  31387. static ClearLogCache(): void;
  31388. /**
  31389. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31390. */
  31391. static LogLevels: number;
  31392. /**
  31393. * Checks if the window object exists
  31394. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31395. */
  31396. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31397. /**
  31398. * No performance log
  31399. */
  31400. static readonly PerformanceNoneLogLevel: number;
  31401. /**
  31402. * Use user marks to log performance
  31403. */
  31404. static readonly PerformanceUserMarkLogLevel: number;
  31405. /**
  31406. * Log performance to the console
  31407. */
  31408. static readonly PerformanceConsoleLogLevel: number;
  31409. private static _performance;
  31410. /**
  31411. * Sets the current performance log level
  31412. */
  31413. static PerformanceLogLevel: number;
  31414. private static _StartPerformanceCounterDisabled;
  31415. private static _EndPerformanceCounterDisabled;
  31416. private static _StartUserMark;
  31417. private static _EndUserMark;
  31418. private static _StartPerformanceConsole;
  31419. private static _EndPerformanceConsole;
  31420. /**
  31421. * Starts a performance counter
  31422. */
  31423. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31424. /**
  31425. * Ends a specific performance coutner
  31426. */
  31427. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31428. /**
  31429. * Gets either window.performance.now() if supported or Date.now() else
  31430. */
  31431. static readonly Now: number;
  31432. /**
  31433. * This method will return the name of the class used to create the instance of the given object.
  31434. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31435. * @param object the object to get the class name from
  31436. * @param isType defines if the object is actually a type
  31437. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31438. */
  31439. static GetClassName(object: any, isType?: boolean): string;
  31440. /**
  31441. * Gets the first element of an array satisfying a given predicate
  31442. * @param array defines the array to browse
  31443. * @param predicate defines the predicate to use
  31444. * @returns null if not found or the element
  31445. */
  31446. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31447. /**
  31448. * This method will return the name of the full name of the class, including its owning module (if any).
  31449. * 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).
  31450. * @param object the object to get the class name from
  31451. * @param isType defines if the object is actually a type
  31452. * @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.
  31453. * @ignorenaming
  31454. */
  31455. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31456. /**
  31457. * Returns a promise that resolves after the given amount of time.
  31458. * @param delay Number of milliseconds to delay
  31459. * @returns Promise that resolves after the given amount of time
  31460. */
  31461. static DelayAsync(delay: number): Promise<void>;
  31462. }
  31463. /**
  31464. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31465. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31466. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31467. * @param name The name of the class, case should be preserved
  31468. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31469. */
  31470. export function className(name: string, module?: string): (target: Object) => void;
  31471. /**
  31472. * An implementation of a loop for asynchronous functions.
  31473. */
  31474. export class AsyncLoop {
  31475. /**
  31476. * Defines the number of iterations for the loop
  31477. */
  31478. iterations: number;
  31479. /**
  31480. * Defines the current index of the loop.
  31481. */
  31482. index: number;
  31483. private _done;
  31484. private _fn;
  31485. private _successCallback;
  31486. /**
  31487. * Constructor.
  31488. * @param iterations the number of iterations.
  31489. * @param func the function to run each iteration
  31490. * @param successCallback the callback that will be called upon succesful execution
  31491. * @param offset starting offset.
  31492. */
  31493. constructor(
  31494. /**
  31495. * Defines the number of iterations for the loop
  31496. */
  31497. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31498. /**
  31499. * Execute the next iteration. Must be called after the last iteration was finished.
  31500. */
  31501. executeNext(): void;
  31502. /**
  31503. * Break the loop and run the success callback.
  31504. */
  31505. breakLoop(): void;
  31506. /**
  31507. * Create and run an async loop.
  31508. * @param iterations the number of iterations.
  31509. * @param fn the function to run each iteration
  31510. * @param successCallback the callback that will be called upon succesful execution
  31511. * @param offset starting offset.
  31512. * @returns the created async loop object
  31513. */
  31514. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31515. /**
  31516. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31517. * @param iterations total number of iterations
  31518. * @param syncedIterations number of synchronous iterations in each async iteration.
  31519. * @param fn the function to call each iteration.
  31520. * @param callback a success call back that will be called when iterating stops.
  31521. * @param breakFunction a break condition (optional)
  31522. * @param timeout timeout settings for the setTimeout function. default - 0.
  31523. * @returns the created async loop object
  31524. */
  31525. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31526. }
  31527. }
  31528. declare module BABYLON {
  31529. /**
  31530. * This class implement a typical dictionary using a string as key and the generic type T as value.
  31531. * The underlying implementation relies on an associative array to ensure the best performances.
  31532. * The value can be anything including 'null' but except 'undefined'
  31533. */
  31534. export class StringDictionary<T> {
  31535. /**
  31536. * This will clear this dictionary and copy the content from the 'source' one.
  31537. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  31538. * @param source the dictionary to take the content from and copy to this dictionary
  31539. */
  31540. copyFrom(source: StringDictionary<T>): void;
  31541. /**
  31542. * Get a value based from its key
  31543. * @param key the given key to get the matching value from
  31544. * @return the value if found, otherwise undefined is returned
  31545. */
  31546. get(key: string): T | undefined;
  31547. /**
  31548. * Get a value from its key or add it if it doesn't exist.
  31549. * This method will ensure you that a given key/data will be present in the dictionary.
  31550. * @param key the given key to get the matching value from
  31551. * @param factory the factory that will create the value if the key is not present in the dictionary.
  31552. * The factory will only be invoked if there's no data for the given key.
  31553. * @return the value corresponding to the key.
  31554. */
  31555. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  31556. /**
  31557. * Get a value from its key if present in the dictionary otherwise add it
  31558. * @param key the key to get the value from
  31559. * @param val if there's no such key/value pair in the dictionary add it with this value
  31560. * @return the value corresponding to the key
  31561. */
  31562. getOrAdd(key: string, val: T): T;
  31563. /**
  31564. * Check if there's a given key in the dictionary
  31565. * @param key the key to check for
  31566. * @return true if the key is present, false otherwise
  31567. */
  31568. contains(key: string): boolean;
  31569. /**
  31570. * Add a new key and its corresponding value
  31571. * @param key the key to add
  31572. * @param value the value corresponding to the key
  31573. * @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
  31574. */
  31575. add(key: string, value: T): boolean;
  31576. /**
  31577. * Update a specific value associated to a key
  31578. * @param key defines the key to use
  31579. * @param value defines the value to store
  31580. * @returns true if the value was updated (or false if the key was not found)
  31581. */
  31582. set(key: string, value: T): boolean;
  31583. /**
  31584. * Get the element of the given key and remove it from the dictionary
  31585. * @param key defines the key to search
  31586. * @returns the value associated with the key or null if not found
  31587. */
  31588. getAndRemove(key: string): Nullable<T>;
  31589. /**
  31590. * Remove a key/value from the dictionary.
  31591. * @param key the key to remove
  31592. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  31593. */
  31594. remove(key: string): boolean;
  31595. /**
  31596. * Clear the whole content of the dictionary
  31597. */
  31598. clear(): void;
  31599. /**
  31600. * Gets the current count
  31601. */
  31602. readonly count: number;
  31603. /**
  31604. * Execute a callback on each key/val of the dictionary.
  31605. * Note that you can remove any element in this dictionary in the callback implementation
  31606. * @param callback the callback to execute on a given key/value pair
  31607. */
  31608. forEach(callback: (key: string, val: T) => void): void;
  31609. /**
  31610. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  31611. * If the callback returns null or undefined the method will iterate to the next key/value pair
  31612. * Note that you can remove any element in this dictionary in the callback implementation
  31613. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  31614. * @returns the first item
  31615. */
  31616. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  31617. private _count;
  31618. private _data;
  31619. }
  31620. }
  31621. declare module BABYLON {
  31622. /** @hidden */
  31623. export interface ICollisionCoordinator {
  31624. createCollider(): Collider;
  31625. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31626. init(scene: Scene): void;
  31627. }
  31628. /** @hidden */
  31629. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31630. private _scene;
  31631. private _scaledPosition;
  31632. private _scaledVelocity;
  31633. private _finalPosition;
  31634. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31635. createCollider(): Collider;
  31636. init(scene: Scene): void;
  31637. private _collideWithWorld;
  31638. }
  31639. }
  31640. declare module BABYLON {
  31641. /**
  31642. * Class used to manage all inputs for the scene.
  31643. */
  31644. export class InputManager {
  31645. /** The distance in pixel that you have to move to prevent some events */
  31646. static DragMovementThreshold: number;
  31647. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31648. static LongPressDelay: number;
  31649. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31650. static DoubleClickDelay: number;
  31651. /** If you need to check double click without raising a single click at first click, enable this flag */
  31652. static ExclusiveDoubleClickMode: boolean;
  31653. private _wheelEventName;
  31654. private _onPointerMove;
  31655. private _onPointerDown;
  31656. private _onPointerUp;
  31657. private _initClickEvent;
  31658. private _initActionManager;
  31659. private _delayedSimpleClick;
  31660. private _delayedSimpleClickTimeout;
  31661. private _previousDelayedSimpleClickTimeout;
  31662. private _meshPickProceed;
  31663. private _previousButtonPressed;
  31664. private _currentPickResult;
  31665. private _previousPickResult;
  31666. private _totalPointersPressed;
  31667. private _doubleClickOccured;
  31668. private _pointerOverMesh;
  31669. private _pickedDownMesh;
  31670. private _pickedUpMesh;
  31671. private _pointerX;
  31672. private _pointerY;
  31673. private _unTranslatedPointerX;
  31674. private _unTranslatedPointerY;
  31675. private _startingPointerPosition;
  31676. private _previousStartingPointerPosition;
  31677. private _startingPointerTime;
  31678. private _previousStartingPointerTime;
  31679. private _pointerCaptures;
  31680. private _onKeyDown;
  31681. private _onKeyUp;
  31682. private _onCanvasFocusObserver;
  31683. private _onCanvasBlurObserver;
  31684. private _scene;
  31685. /**
  31686. * Creates a new InputManager
  31687. * @param scene defines the hosting scene
  31688. */
  31689. constructor(scene: Scene);
  31690. /**
  31691. * Gets the mesh that is currently under the pointer
  31692. */
  31693. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31694. /**
  31695. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31696. */
  31697. readonly unTranslatedPointer: Vector2;
  31698. /**
  31699. * Gets or sets the current on-screen X position of the pointer
  31700. */
  31701. pointerX: number;
  31702. /**
  31703. * Gets or sets the current on-screen Y position of the pointer
  31704. */
  31705. pointerY: number;
  31706. private _updatePointerPosition;
  31707. private _processPointerMove;
  31708. private _setRayOnPointerInfo;
  31709. private _checkPrePointerObservable;
  31710. /**
  31711. * Use this method to simulate a pointer move on a mesh
  31712. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31713. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31714. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31715. */
  31716. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31717. /**
  31718. * Use this method to simulate a pointer down on a mesh
  31719. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31720. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31721. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31722. */
  31723. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31724. private _processPointerDown;
  31725. /** @hidden */ private _isPointerSwiping(): boolean;
  31726. /**
  31727. * Use this method to simulate a pointer up on a mesh
  31728. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31729. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31730. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31731. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31732. */
  31733. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31734. private _processPointerUp;
  31735. /**
  31736. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31737. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31738. * @returns true if the pointer was captured
  31739. */
  31740. isPointerCaptured(pointerId?: number): boolean;
  31741. /**
  31742. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31743. * @param attachUp defines if you want to attach events to pointerup
  31744. * @param attachDown defines if you want to attach events to pointerdown
  31745. * @param attachMove defines if you want to attach events to pointermove
  31746. */
  31747. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31748. /**
  31749. * Detaches all event handlers
  31750. */
  31751. detachControl(): void;
  31752. /**
  31753. * Force the value of meshUnderPointer
  31754. * @param mesh defines the mesh to use
  31755. */
  31756. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31757. /**
  31758. * Gets the mesh under the pointer
  31759. * @returns a Mesh or null if no mesh is under the pointer
  31760. */
  31761. getPointerOverMesh(): Nullable<AbstractMesh>;
  31762. }
  31763. }
  31764. declare module BABYLON {
  31765. /**
  31766. * Helper class used to generate session unique ID
  31767. */
  31768. export class UniqueIdGenerator {
  31769. private static _UniqueIdCounter;
  31770. /**
  31771. * Gets an unique (relatively to the current scene) Id
  31772. */
  31773. static readonly UniqueId: number;
  31774. }
  31775. }
  31776. declare module BABYLON {
  31777. /**
  31778. * This class defines the direct association between an animation and a target
  31779. */
  31780. export class TargetedAnimation {
  31781. /**
  31782. * Animation to perform
  31783. */
  31784. animation: Animation;
  31785. /**
  31786. * Target to animate
  31787. */
  31788. target: any;
  31789. /**
  31790. * Serialize the object
  31791. * @returns the JSON object representing the current entity
  31792. */
  31793. serialize(): any;
  31794. }
  31795. /**
  31796. * Use this class to create coordinated animations on multiple targets
  31797. */
  31798. export class AnimationGroup implements IDisposable {
  31799. /** The name of the animation group */
  31800. name: string;
  31801. private _scene;
  31802. private _targetedAnimations;
  31803. private _animatables;
  31804. private _from;
  31805. private _to;
  31806. private _isStarted;
  31807. private _isPaused;
  31808. private _speedRatio;
  31809. private _loopAnimation;
  31810. /**
  31811. * Gets or sets the unique id of the node
  31812. */
  31813. uniqueId: number;
  31814. /**
  31815. * This observable will notify when one animation have ended
  31816. */
  31817. onAnimationEndObservable: Observable<TargetedAnimation>;
  31818. /**
  31819. * Observer raised when one animation loops
  31820. */
  31821. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31822. /**
  31823. * This observable will notify when all animations have ended.
  31824. */
  31825. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31826. /**
  31827. * This observable will notify when all animations have paused.
  31828. */
  31829. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31830. /**
  31831. * This observable will notify when all animations are playing.
  31832. */
  31833. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31834. /**
  31835. * Gets the first frame
  31836. */
  31837. readonly from: number;
  31838. /**
  31839. * Gets the last frame
  31840. */
  31841. readonly to: number;
  31842. /**
  31843. * Define if the animations are started
  31844. */
  31845. readonly isStarted: boolean;
  31846. /**
  31847. * Gets a value indicating that the current group is playing
  31848. */
  31849. readonly isPlaying: boolean;
  31850. /**
  31851. * Gets or sets the speed ratio to use for all animations
  31852. */
  31853. /**
  31854. * Gets or sets the speed ratio to use for all animations
  31855. */
  31856. speedRatio: number;
  31857. /**
  31858. * Gets or sets if all animations should loop or not
  31859. */
  31860. loopAnimation: boolean;
  31861. /**
  31862. * Gets the targeted animations for this animation group
  31863. */
  31864. readonly targetedAnimations: Array<TargetedAnimation>;
  31865. /**
  31866. * returning the list of animatables controlled by this animation group.
  31867. */
  31868. readonly animatables: Array<Animatable>;
  31869. /**
  31870. * Instantiates a new Animation Group.
  31871. * This helps managing several animations at once.
  31872. * @see http://doc.babylonjs.com/how_to/group
  31873. * @param name Defines the name of the group
  31874. * @param scene Defines the scene the group belongs to
  31875. */
  31876. constructor(
  31877. /** The name of the animation group */
  31878. name: string, scene?: Nullable<Scene>);
  31879. /**
  31880. * Add an animation (with its target) in the group
  31881. * @param animation defines the animation we want to add
  31882. * @param target defines the target of the animation
  31883. * @returns the TargetedAnimation object
  31884. */
  31885. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31886. /**
  31887. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31888. * It can add constant keys at begin or end
  31889. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31890. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31891. * @returns the animation group
  31892. */
  31893. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31894. /**
  31895. * Start all animations on given targets
  31896. * @param loop defines if animations must loop
  31897. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31898. * @param from defines the from key (optional)
  31899. * @param to defines the to key (optional)
  31900. * @returns the current animation group
  31901. */
  31902. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31903. /**
  31904. * Pause all animations
  31905. * @returns the animation group
  31906. */
  31907. pause(): AnimationGroup;
  31908. /**
  31909. * Play all animations to initial state
  31910. * This function will start() the animations if they were not started or will restart() them if they were paused
  31911. * @param loop defines if animations must loop
  31912. * @returns the animation group
  31913. */
  31914. play(loop?: boolean): AnimationGroup;
  31915. /**
  31916. * Reset all animations to initial state
  31917. * @returns the animation group
  31918. */
  31919. reset(): AnimationGroup;
  31920. /**
  31921. * Restart animations from key 0
  31922. * @returns the animation group
  31923. */
  31924. restart(): AnimationGroup;
  31925. /**
  31926. * Stop all animations
  31927. * @returns the animation group
  31928. */
  31929. stop(): AnimationGroup;
  31930. /**
  31931. * Set animation weight for all animatables
  31932. * @param weight defines the weight to use
  31933. * @return the animationGroup
  31934. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31935. */
  31936. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31937. /**
  31938. * Synchronize and normalize all animatables with a source animatable
  31939. * @param root defines the root animatable to synchronize with
  31940. * @return the animationGroup
  31941. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31942. */
  31943. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31944. /**
  31945. * Goes to a specific frame in this animation group
  31946. * @param frame the frame number to go to
  31947. * @return the animationGroup
  31948. */
  31949. goToFrame(frame: number): AnimationGroup;
  31950. /**
  31951. * Dispose all associated resources
  31952. */
  31953. dispose(): void;
  31954. private _checkAnimationGroupEnded;
  31955. /**
  31956. * Clone the current animation group and returns a copy
  31957. * @param newName defines the name of the new group
  31958. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31959. * @returns the new aniamtion group
  31960. */
  31961. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31962. /**
  31963. * Serializes the animationGroup to an object
  31964. * @returns Serialized object
  31965. */
  31966. serialize(): any;
  31967. /**
  31968. * Returns a new AnimationGroup object parsed from the source provided.
  31969. * @param parsedAnimationGroup defines the source
  31970. * @param scene defines the scene that will receive the animationGroup
  31971. * @returns a new AnimationGroup
  31972. */
  31973. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31974. /**
  31975. * Returns the string "AnimationGroup"
  31976. * @returns "AnimationGroup"
  31977. */
  31978. getClassName(): string;
  31979. /**
  31980. * Creates a detailled string about the object
  31981. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31982. * @returns a string representing the object
  31983. */
  31984. toString(fullDetails?: boolean): string;
  31985. }
  31986. }
  31987. declare module BABYLON {
  31988. /**
  31989. * Define an interface for all classes that will hold resources
  31990. */
  31991. export interface IDisposable {
  31992. /**
  31993. * Releases all held resources
  31994. */
  31995. dispose(): void;
  31996. }
  31997. /** Interface defining initialization parameters for Scene class */
  31998. export interface SceneOptions {
  31999. /**
  32000. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32001. * It will improve performance when the number of geometries becomes important.
  32002. */
  32003. useGeometryUniqueIdsMap?: boolean;
  32004. /**
  32005. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32006. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32007. */
  32008. useMaterialMeshMap?: boolean;
  32009. /**
  32010. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32011. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32012. */
  32013. useClonedMeshhMap?: boolean;
  32014. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32015. virtual?: boolean;
  32016. }
  32017. /**
  32018. * Represents a scene to be rendered by the engine.
  32019. * @see http://doc.babylonjs.com/features/scene
  32020. */
  32021. export class Scene extends AbstractScene implements IAnimatable {
  32022. /** The fog is deactivated */
  32023. static readonly FOGMODE_NONE: number;
  32024. /** The fog density is following an exponential function */
  32025. static readonly FOGMODE_EXP: number;
  32026. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32027. static readonly FOGMODE_EXP2: number;
  32028. /** The fog density is following a linear function. */
  32029. static readonly FOGMODE_LINEAR: number;
  32030. /**
  32031. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32032. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32033. */
  32034. static MinDeltaTime: number;
  32035. /**
  32036. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32037. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32038. */
  32039. static MaxDeltaTime: number;
  32040. /**
  32041. * Factory used to create the default material.
  32042. * @param name The name of the material to create
  32043. * @param scene The scene to create the material for
  32044. * @returns The default material
  32045. */
  32046. static DefaultMaterialFactory(scene: Scene): Material;
  32047. /**
  32048. * Factory used to create the a collision coordinator.
  32049. * @returns The collision coordinator
  32050. */
  32051. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32052. /** @hidden */ private _inputManager: InputManager;
  32053. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32054. cameraToUseForPointers: Nullable<Camera>;
  32055. /** @hidden */ protected readonly _isScene: boolean;
  32056. /**
  32057. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32058. */
  32059. autoClear: boolean;
  32060. /**
  32061. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32062. */
  32063. autoClearDepthAndStencil: boolean;
  32064. /**
  32065. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32066. */
  32067. clearColor: Color4;
  32068. /**
  32069. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32070. */
  32071. ambientColor: Color3;
  32072. /**
  32073. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32074. * It should only be one of the following (if not the default embedded one):
  32075. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32076. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32077. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32078. * The material properties need to be setup according to the type of texture in use.
  32079. */
  32080. environmentBRDFTexture: BaseTexture;
  32081. /** @hidden */
  32082. protected _environmentTexture: Nullable<BaseTexture>;
  32083. /**
  32084. * Texture used in all pbr material as the reflection texture.
  32085. * As in the majority of the scene they are the same (exception for multi room and so on),
  32086. * this is easier to reference from here than from all the materials.
  32087. */
  32088. /**
  32089. * Texture used in all pbr material as the reflection texture.
  32090. * As in the majority of the scene they are the same (exception for multi room and so on),
  32091. * this is easier to set here than in all the materials.
  32092. */
  32093. environmentTexture: Nullable<BaseTexture>;
  32094. /** @hidden */
  32095. protected _environmentIntensity: number;
  32096. /**
  32097. * Intensity of the environment in all pbr material.
  32098. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32099. * As in the majority of the scene they are the same (exception for multi room and so on),
  32100. * this is easier to reference from here than from all the materials.
  32101. */
  32102. /**
  32103. * Intensity of the environment in all pbr material.
  32104. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32105. * As in the majority of the scene they are the same (exception for multi room and so on),
  32106. * this is easier to set here than in all the materials.
  32107. */
  32108. environmentIntensity: number;
  32109. /** @hidden */
  32110. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32111. /**
  32112. * Default image processing configuration used either in the rendering
  32113. * Forward main pass or through the imageProcessingPostProcess if present.
  32114. * As in the majority of the scene they are the same (exception for multi camera),
  32115. * this is easier to reference from here than from all the materials and post process.
  32116. *
  32117. * No setter as we it is a shared configuration, you can set the values instead.
  32118. */
  32119. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32120. private _forceWireframe;
  32121. /**
  32122. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32123. */
  32124. forceWireframe: boolean;
  32125. private _forcePointsCloud;
  32126. /**
  32127. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32128. */
  32129. forcePointsCloud: boolean;
  32130. /**
  32131. * Gets or sets the active clipplane 1
  32132. */
  32133. clipPlane: Nullable<Plane>;
  32134. /**
  32135. * Gets or sets the active clipplane 2
  32136. */
  32137. clipPlane2: Nullable<Plane>;
  32138. /**
  32139. * Gets or sets the active clipplane 3
  32140. */
  32141. clipPlane3: Nullable<Plane>;
  32142. /**
  32143. * Gets or sets the active clipplane 4
  32144. */
  32145. clipPlane4: Nullable<Plane>;
  32146. /**
  32147. * Gets or sets a boolean indicating if animations are enabled
  32148. */
  32149. animationsEnabled: boolean;
  32150. private _animationPropertiesOverride;
  32151. /**
  32152. * Gets or sets the animation properties override
  32153. */
  32154. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32155. /**
  32156. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32157. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32158. */
  32159. useConstantAnimationDeltaTime: boolean;
  32160. /**
  32161. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32162. * Please note that it requires to run a ray cast through the scene on every frame
  32163. */
  32164. constantlyUpdateMeshUnderPointer: boolean;
  32165. /**
  32166. * Defines the HTML cursor to use when hovering over interactive elements
  32167. */
  32168. hoverCursor: string;
  32169. /**
  32170. * Defines the HTML default cursor to use (empty by default)
  32171. */
  32172. defaultCursor: string;
  32173. /**
  32174. * This is used to call preventDefault() on pointer down
  32175. * in order to block unwanted artifacts like system double clicks
  32176. */
  32177. preventDefaultOnPointerDown: boolean;
  32178. /**
  32179. * This is used to call preventDefault() on pointer up
  32180. * in order to block unwanted artifacts like system double clicks
  32181. */
  32182. preventDefaultOnPointerUp: boolean;
  32183. /**
  32184. * Gets or sets user defined metadata
  32185. */
  32186. metadata: any;
  32187. /**
  32188. * For internal use only. Please do not use.
  32189. */
  32190. reservedDataStore: any;
  32191. /**
  32192. * Gets the name of the plugin used to load this scene (null by default)
  32193. */
  32194. loadingPluginName: string;
  32195. /**
  32196. * Use this array to add regular expressions used to disable offline support for specific urls
  32197. */
  32198. disableOfflineSupportExceptionRules: RegExp[];
  32199. /**
  32200. * An event triggered when the scene is disposed.
  32201. */
  32202. onDisposeObservable: Observable<Scene>;
  32203. private _onDisposeObserver;
  32204. /** Sets a function to be executed when this scene is disposed. */
  32205. onDispose: () => void;
  32206. /**
  32207. * An event triggered before rendering the scene (right after animations and physics)
  32208. */
  32209. onBeforeRenderObservable: Observable<Scene>;
  32210. private _onBeforeRenderObserver;
  32211. /** Sets a function to be executed before rendering this scene */
  32212. beforeRender: Nullable<() => void>;
  32213. /**
  32214. * An event triggered after rendering the scene
  32215. */
  32216. onAfterRenderObservable: Observable<Scene>;
  32217. /**
  32218. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32219. */
  32220. onAfterRenderCameraObservable: Observable<Camera>;
  32221. private _onAfterRenderObserver;
  32222. /** Sets a function to be executed after rendering this scene */
  32223. afterRender: Nullable<() => void>;
  32224. /**
  32225. * An event triggered before animating the scene
  32226. */
  32227. onBeforeAnimationsObservable: Observable<Scene>;
  32228. /**
  32229. * An event triggered after animations processing
  32230. */
  32231. onAfterAnimationsObservable: Observable<Scene>;
  32232. /**
  32233. * An event triggered before draw calls are ready to be sent
  32234. */
  32235. onBeforeDrawPhaseObservable: Observable<Scene>;
  32236. /**
  32237. * An event triggered after draw calls have been sent
  32238. */
  32239. onAfterDrawPhaseObservable: Observable<Scene>;
  32240. /**
  32241. * An event triggered when the scene is ready
  32242. */
  32243. onReadyObservable: Observable<Scene>;
  32244. /**
  32245. * An event triggered before rendering a camera
  32246. */
  32247. onBeforeCameraRenderObservable: Observable<Camera>;
  32248. private _onBeforeCameraRenderObserver;
  32249. /** Sets a function to be executed before rendering a camera*/
  32250. beforeCameraRender: () => void;
  32251. /**
  32252. * An event triggered after rendering a camera
  32253. */
  32254. onAfterCameraRenderObservable: Observable<Camera>;
  32255. private _onAfterCameraRenderObserver;
  32256. /** Sets a function to be executed after rendering a camera*/
  32257. afterCameraRender: () => void;
  32258. /**
  32259. * An event triggered when active meshes evaluation is about to start
  32260. */
  32261. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32262. /**
  32263. * An event triggered when active meshes evaluation is done
  32264. */
  32265. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32266. /**
  32267. * An event triggered when particles rendering is about to start
  32268. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32269. */
  32270. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32271. /**
  32272. * An event triggered when particles rendering is done
  32273. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32274. */
  32275. onAfterParticlesRenderingObservable: Observable<Scene>;
  32276. /**
  32277. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32278. */
  32279. onDataLoadedObservable: Observable<Scene>;
  32280. /**
  32281. * An event triggered when a camera is created
  32282. */
  32283. onNewCameraAddedObservable: Observable<Camera>;
  32284. /**
  32285. * An event triggered when a camera is removed
  32286. */
  32287. onCameraRemovedObservable: Observable<Camera>;
  32288. /**
  32289. * An event triggered when a light is created
  32290. */
  32291. onNewLightAddedObservable: Observable<Light>;
  32292. /**
  32293. * An event triggered when a light is removed
  32294. */
  32295. onLightRemovedObservable: Observable<Light>;
  32296. /**
  32297. * An event triggered when a geometry is created
  32298. */
  32299. onNewGeometryAddedObservable: Observable<Geometry>;
  32300. /**
  32301. * An event triggered when a geometry is removed
  32302. */
  32303. onGeometryRemovedObservable: Observable<Geometry>;
  32304. /**
  32305. * An event triggered when a transform node is created
  32306. */
  32307. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32308. /**
  32309. * An event triggered when a transform node is removed
  32310. */
  32311. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32312. /**
  32313. * An event triggered when a mesh is created
  32314. */
  32315. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32316. /**
  32317. * An event triggered when a mesh is removed
  32318. */
  32319. onMeshRemovedObservable: Observable<AbstractMesh>;
  32320. /**
  32321. * An event triggered when a skeleton is created
  32322. */
  32323. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32324. /**
  32325. * An event triggered when a skeleton is removed
  32326. */
  32327. onSkeletonRemovedObservable: Observable<Skeleton>;
  32328. /**
  32329. * An event triggered when a material is created
  32330. */
  32331. onNewMaterialAddedObservable: Observable<Material>;
  32332. /**
  32333. * An event triggered when a material is removed
  32334. */
  32335. onMaterialRemovedObservable: Observable<Material>;
  32336. /**
  32337. * An event triggered when a texture is created
  32338. */
  32339. onNewTextureAddedObservable: Observable<BaseTexture>;
  32340. /**
  32341. * An event triggered when a texture is removed
  32342. */
  32343. onTextureRemovedObservable: Observable<BaseTexture>;
  32344. /**
  32345. * An event triggered when render targets are about to be rendered
  32346. * Can happen multiple times per frame.
  32347. */
  32348. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32349. /**
  32350. * An event triggered when render targets were rendered.
  32351. * Can happen multiple times per frame.
  32352. */
  32353. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32354. /**
  32355. * An event triggered before calculating deterministic simulation step
  32356. */
  32357. onBeforeStepObservable: Observable<Scene>;
  32358. /**
  32359. * An event triggered after calculating deterministic simulation step
  32360. */
  32361. onAfterStepObservable: Observable<Scene>;
  32362. /**
  32363. * An event triggered when the activeCamera property is updated
  32364. */
  32365. onActiveCameraChanged: Observable<Scene>;
  32366. /**
  32367. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32368. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32369. * 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)
  32370. */
  32371. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32372. /**
  32373. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32374. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32375. * 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)
  32376. */
  32377. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32378. /**
  32379. * This Observable will when a mesh has been imported into the scene.
  32380. */
  32381. onMeshImportedObservable: Observable<AbstractMesh>;
  32382. /**
  32383. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32384. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32385. */
  32386. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32387. /** @hidden */ private _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32388. /**
  32389. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32390. */
  32391. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32392. /**
  32393. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32394. */
  32395. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32396. /**
  32397. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32398. */
  32399. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32400. /** Callback called when a pointer move is detected */
  32401. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32402. /** Callback called when a pointer down is detected */
  32403. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32404. /** Callback called when a pointer up is detected */
  32405. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32406. /** Callback called when a pointer pick is detected */
  32407. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32408. /**
  32409. * 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).
  32410. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32411. */
  32412. onPrePointerObservable: Observable<PointerInfoPre>;
  32413. /**
  32414. * Observable event triggered each time an input event is received from the rendering canvas
  32415. */
  32416. onPointerObservable: Observable<PointerInfo>;
  32417. /**
  32418. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32419. */
  32420. readonly unTranslatedPointer: Vector2;
  32421. /**
  32422. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32423. */
  32424. static DragMovementThreshold: number;
  32425. /**
  32426. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32427. */
  32428. static LongPressDelay: number;
  32429. /**
  32430. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32431. */
  32432. static DoubleClickDelay: number;
  32433. /** If you need to check double click without raising a single click at first click, enable this flag */
  32434. static ExclusiveDoubleClickMode: boolean;
  32435. /** @hidden */ private _mirroredCameraPosition: Nullable<Vector3>;
  32436. /**
  32437. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32438. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32439. */
  32440. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32441. /**
  32442. * Observable event triggered each time an keyboard event is received from the hosting window
  32443. */
  32444. onKeyboardObservable: Observable<KeyboardInfo>;
  32445. private _useRightHandedSystem;
  32446. /**
  32447. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32448. */
  32449. useRightHandedSystem: boolean;
  32450. private _timeAccumulator;
  32451. private _currentStepId;
  32452. private _currentInternalStep;
  32453. /**
  32454. * Sets the step Id used by deterministic lock step
  32455. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32456. * @param newStepId defines the step Id
  32457. */
  32458. setStepId(newStepId: number): void;
  32459. /**
  32460. * Gets the step Id used by deterministic lock step
  32461. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32462. * @returns the step Id
  32463. */
  32464. getStepId(): number;
  32465. /**
  32466. * Gets the internal step used by deterministic lock step
  32467. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32468. * @returns the internal step
  32469. */
  32470. getInternalStep(): number;
  32471. private _fogEnabled;
  32472. /**
  32473. * Gets or sets a boolean indicating if fog is enabled on this scene
  32474. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32475. * (Default is true)
  32476. */
  32477. fogEnabled: boolean;
  32478. private _fogMode;
  32479. /**
  32480. * Gets or sets the fog mode to use
  32481. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32482. * | mode | value |
  32483. * | --- | --- |
  32484. * | FOGMODE_NONE | 0 |
  32485. * | FOGMODE_EXP | 1 |
  32486. * | FOGMODE_EXP2 | 2 |
  32487. * | FOGMODE_LINEAR | 3 |
  32488. */
  32489. fogMode: number;
  32490. /**
  32491. * Gets or sets the fog color to use
  32492. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32493. * (Default is Color3(0.2, 0.2, 0.3))
  32494. */
  32495. fogColor: Color3;
  32496. /**
  32497. * Gets or sets the fog density to use
  32498. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32499. * (Default is 0.1)
  32500. */
  32501. fogDensity: number;
  32502. /**
  32503. * Gets or sets the fog start distance to use
  32504. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32505. * (Default is 0)
  32506. */
  32507. fogStart: number;
  32508. /**
  32509. * Gets or sets the fog end distance to use
  32510. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32511. * (Default is 1000)
  32512. */
  32513. fogEnd: number;
  32514. private _shadowsEnabled;
  32515. /**
  32516. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32517. */
  32518. shadowsEnabled: boolean;
  32519. private _lightsEnabled;
  32520. /**
  32521. * Gets or sets a boolean indicating if lights are enabled on this scene
  32522. */
  32523. lightsEnabled: boolean;
  32524. /** All of the active cameras added to this scene. */
  32525. activeCameras: Camera[];
  32526. /** @hidden */ private _activeCamera: Nullable<Camera>;
  32527. /** Gets or sets the current active camera */
  32528. activeCamera: Nullable<Camera>;
  32529. private _defaultMaterial;
  32530. /** The default material used on meshes when no material is affected */
  32531. /** The default material used on meshes when no material is affected */
  32532. defaultMaterial: Material;
  32533. private _texturesEnabled;
  32534. /**
  32535. * Gets or sets a boolean indicating if textures are enabled on this scene
  32536. */
  32537. texturesEnabled: boolean;
  32538. /**
  32539. * Gets or sets a boolean indicating if particles are enabled on this scene
  32540. */
  32541. particlesEnabled: boolean;
  32542. /**
  32543. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32544. */
  32545. spritesEnabled: boolean;
  32546. private _skeletonsEnabled;
  32547. /**
  32548. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32549. */
  32550. skeletonsEnabled: boolean;
  32551. /**
  32552. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32553. */
  32554. lensFlaresEnabled: boolean;
  32555. /**
  32556. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32557. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32558. */
  32559. collisionsEnabled: boolean;
  32560. private _collisionCoordinator;
  32561. /** @hidden */
  32562. readonly collisionCoordinator: ICollisionCoordinator;
  32563. /**
  32564. * Defines the gravity applied to this scene (used only for collisions)
  32565. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32566. */
  32567. gravity: Vector3;
  32568. /**
  32569. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32570. */
  32571. postProcessesEnabled: boolean;
  32572. /**
  32573. * The list of postprocesses added to the scene
  32574. */
  32575. postProcesses: PostProcess[];
  32576. /**
  32577. * Gets the current postprocess manager
  32578. */
  32579. postProcessManager: PostProcessManager;
  32580. /**
  32581. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32582. */
  32583. renderTargetsEnabled: boolean;
  32584. /**
  32585. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32586. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32587. */
  32588. dumpNextRenderTargets: boolean;
  32589. /**
  32590. * The list of user defined render targets added to the scene
  32591. */
  32592. customRenderTargets: RenderTargetTexture[];
  32593. /**
  32594. * Defines if texture loading must be delayed
  32595. * If true, textures will only be loaded when they need to be rendered
  32596. */
  32597. useDelayedTextureLoading: boolean;
  32598. /**
  32599. * Gets the list of meshes imported to the scene through SceneLoader
  32600. */
  32601. importedMeshesFiles: String[];
  32602. /**
  32603. * Gets or sets a boolean indicating if probes are enabled on this scene
  32604. */
  32605. probesEnabled: boolean;
  32606. /**
  32607. * Gets or sets the current offline provider to use to store scene data
  32608. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32609. */
  32610. offlineProvider: IOfflineProvider;
  32611. /**
  32612. * Gets or sets the action manager associated with the scene
  32613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32614. */
  32615. actionManager: AbstractActionManager;
  32616. private _meshesForIntersections;
  32617. /**
  32618. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32619. */
  32620. proceduralTexturesEnabled: boolean;
  32621. private _engine;
  32622. private _totalVertices;
  32623. /** @hidden */ private _activeIndices: PerfCounter;
  32624. /** @hidden */ private _activeParticles: PerfCounter;
  32625. /** @hidden */ private _activeBones: PerfCounter;
  32626. private _animationRatio;
  32627. /** @hidden */ private _animationTimeLast: number;
  32628. /** @hidden */ private _animationTime: number;
  32629. /**
  32630. * Gets or sets a general scale for animation speed
  32631. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32632. */
  32633. animationTimeScale: number;
  32634. /** @hidden */ private _cachedMaterial: Nullable<Material>;
  32635. /** @hidden */ private _cachedEffect: Nullable<Effect>;
  32636. /** @hidden */ private _cachedVisibility: Nullable<number>;
  32637. private _renderId;
  32638. private _frameId;
  32639. private _executeWhenReadyTimeoutId;
  32640. private _intermediateRendering;
  32641. private _viewUpdateFlag;
  32642. private _projectionUpdateFlag;
  32643. /** @hidden */ private _toBeDisposed: Nullable<IDisposable>[];
  32644. private _activeRequests;
  32645. /** @hidden */ private _pendingData: any[];
  32646. private _isDisposed;
  32647. /**
  32648. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32649. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32650. */
  32651. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32652. private _activeMeshes;
  32653. private _processedMaterials;
  32654. private _renderTargets;
  32655. /** @hidden */ private _activeParticleSystems: SmartArray<IParticleSystem>;
  32656. private _activeSkeletons;
  32657. private _softwareSkinnedMeshes;
  32658. private _renderingManager;
  32659. /** @hidden */ private _activeAnimatables: Animatable[];
  32660. private _transformMatrix;
  32661. private _sceneUbo;
  32662. /** @hidden */ private _viewMatrix: Matrix;
  32663. private _projectionMatrix;
  32664. /** @hidden */ private _forcedViewPosition: Nullable<Vector3>;
  32665. /** @hidden */ private _frustumPlanes: Plane[];
  32666. /**
  32667. * Gets the list of frustum planes (built from the active camera)
  32668. */
  32669. readonly frustumPlanes: Plane[];
  32670. /**
  32671. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32672. * This is useful if there are more lights that the maximum simulteanous authorized
  32673. */
  32674. requireLightSorting: boolean;
  32675. /** @hidden */
  32676. readonly useMaterialMeshMap: boolean;
  32677. /** @hidden */
  32678. readonly useClonedMeshhMap: boolean;
  32679. private _externalData;
  32680. private _uid;
  32681. /**
  32682. * @hidden
  32683. * Backing store of defined scene components.
  32684. */ private _components: ISceneComponent[];
  32685. /**
  32686. * @hidden
  32687. * Backing store of defined scene components.
  32688. */ private _serializableComponents: ISceneSerializableComponent[];
  32689. /**
  32690. * List of components to register on the next registration step.
  32691. */
  32692. private _transientComponents;
  32693. /**
  32694. * Registers the transient components if needed.
  32695. */
  32696. private _registerTransientComponents;
  32697. /**
  32698. * @hidden
  32699. * Add a component to the scene.
  32700. * Note that the ccomponent could be registered on th next frame if this is called after
  32701. * the register component stage.
  32702. * @param component Defines the component to add to the scene
  32703. */ private _addComponent(component: ISceneComponent): void;
  32704. /**
  32705. * @hidden
  32706. * Gets a component from the scene.
  32707. * @param name defines the name of the component to retrieve
  32708. * @returns the component or null if not present
  32709. */ private _getComponent(name: string): Nullable<ISceneComponent>;
  32710. /**
  32711. * @hidden
  32712. * Defines the actions happening before camera updates.
  32713. */ private _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32714. /**
  32715. * @hidden
  32716. * Defines the actions happening before clear the canvas.
  32717. */ private _beforeClearStage: Stage<SimpleStageAction>;
  32718. /**
  32719. * @hidden
  32720. * Defines the actions when collecting render targets for the frame.
  32721. */ private _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32722. /**
  32723. * @hidden
  32724. * Defines the actions happening for one camera in the frame.
  32725. */ private _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32726. /**
  32727. * @hidden
  32728. * Defines the actions happening during the per mesh ready checks.
  32729. */ private _isReadyForMeshStage: Stage<MeshStageAction>;
  32730. /**
  32731. * @hidden
  32732. * Defines the actions happening before evaluate active mesh checks.
  32733. */ private _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32734. /**
  32735. * @hidden
  32736. * Defines the actions happening during the evaluate sub mesh checks.
  32737. */ private _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32738. /**
  32739. * @hidden
  32740. * Defines the actions happening during the active mesh stage.
  32741. */ private _activeMeshStage: Stage<ActiveMeshStageAction>;
  32742. /**
  32743. * @hidden
  32744. * Defines the actions happening during the per camera render target step.
  32745. */ private _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32746. /**
  32747. * @hidden
  32748. * Defines the actions happening just before the active camera is drawing.
  32749. */ private _beforeCameraDrawStage: Stage<CameraStageAction>;
  32750. /**
  32751. * @hidden
  32752. * Defines the actions happening just before a render target is drawing.
  32753. */ private _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32754. /**
  32755. * @hidden
  32756. * Defines the actions happening just before a rendering group is drawing.
  32757. */ private _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32758. /**
  32759. * @hidden
  32760. * Defines the actions happening just before a mesh is drawing.
  32761. */ private _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32762. /**
  32763. * @hidden
  32764. * Defines the actions happening just after a mesh has been drawn.
  32765. */ private _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32766. /**
  32767. * @hidden
  32768. * Defines the actions happening just after a rendering group has been drawn.
  32769. */ private _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32770. /**
  32771. * @hidden
  32772. * Defines the actions happening just after the active camera has been drawn.
  32773. */ private _afterCameraDrawStage: Stage<CameraStageAction>;
  32774. /**
  32775. * @hidden
  32776. * Defines the actions happening just after a render target has been drawn.
  32777. */ private _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32778. /**
  32779. * @hidden
  32780. * Defines the actions happening just after rendering all cameras and computing intersections.
  32781. */ private _afterRenderStage: Stage<SimpleStageAction>;
  32782. /**
  32783. * @hidden
  32784. * Defines the actions happening when a pointer move event happens.
  32785. */ private _pointerMoveStage: Stage<PointerMoveStageAction>;
  32786. /**
  32787. * @hidden
  32788. * Defines the actions happening when a pointer down event happens.
  32789. */ private _pointerDownStage: Stage<PointerUpDownStageAction>;
  32790. /**
  32791. * @hidden
  32792. * Defines the actions happening when a pointer up event happens.
  32793. */ private _pointerUpStage: Stage<PointerUpDownStageAction>;
  32794. /**
  32795. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32796. */
  32797. private geometriesByUniqueId;
  32798. /**
  32799. * Creates a new Scene
  32800. * @param engine defines the engine to use to render this scene
  32801. * @param options defines the scene options
  32802. */
  32803. constructor(engine: Engine, options?: SceneOptions);
  32804. /**
  32805. * Gets a string idenfifying the name of the class
  32806. * @returns "Scene" string
  32807. */
  32808. getClassName(): string;
  32809. private _defaultMeshCandidates;
  32810. /**
  32811. * @hidden
  32812. */ private _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32813. private _defaultSubMeshCandidates;
  32814. /**
  32815. * @hidden
  32816. */ private _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32817. /**
  32818. * Sets the default candidate providers for the scene.
  32819. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32820. * and getCollidingSubMeshCandidates to their default function
  32821. */
  32822. setDefaultCandidateProviders(): void;
  32823. /**
  32824. * Gets the mesh that is currently under the pointer
  32825. */
  32826. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32827. /**
  32828. * Gets or sets the current on-screen X position of the pointer
  32829. */
  32830. pointerX: number;
  32831. /**
  32832. * Gets or sets the current on-screen Y position of the pointer
  32833. */
  32834. pointerY: number;
  32835. /**
  32836. * Gets the cached material (ie. the latest rendered one)
  32837. * @returns the cached material
  32838. */
  32839. getCachedMaterial(): Nullable<Material>;
  32840. /**
  32841. * Gets the cached effect (ie. the latest rendered one)
  32842. * @returns the cached effect
  32843. */
  32844. getCachedEffect(): Nullable<Effect>;
  32845. /**
  32846. * Gets the cached visibility state (ie. the latest rendered one)
  32847. * @returns the cached visibility state
  32848. */
  32849. getCachedVisibility(): Nullable<number>;
  32850. /**
  32851. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32852. * @param material defines the current material
  32853. * @param effect defines the current effect
  32854. * @param visibility defines the current visibility state
  32855. * @returns true if one parameter is not cached
  32856. */
  32857. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32858. /**
  32859. * Gets the engine associated with the scene
  32860. * @returns an Engine
  32861. */
  32862. getEngine(): Engine;
  32863. /**
  32864. * Gets the total number of vertices rendered per frame
  32865. * @returns the total number of vertices rendered per frame
  32866. */
  32867. getTotalVertices(): number;
  32868. /**
  32869. * Gets the performance counter for total vertices
  32870. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32871. */
  32872. readonly totalVerticesPerfCounter: PerfCounter;
  32873. /**
  32874. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32875. * @returns the total number of active indices rendered per frame
  32876. */
  32877. getActiveIndices(): number;
  32878. /**
  32879. * Gets the performance counter for active indices
  32880. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32881. */
  32882. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32883. /**
  32884. * Gets the total number of active particles rendered per frame
  32885. * @returns the total number of active particles rendered per frame
  32886. */
  32887. getActiveParticles(): number;
  32888. /**
  32889. * Gets the performance counter for active particles
  32890. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32891. */
  32892. readonly activeParticlesPerfCounter: PerfCounter;
  32893. /**
  32894. * Gets the total number of active bones rendered per frame
  32895. * @returns the total number of active bones rendered per frame
  32896. */
  32897. getActiveBones(): number;
  32898. /**
  32899. * Gets the performance counter for active bones
  32900. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32901. */
  32902. readonly activeBonesPerfCounter: PerfCounter;
  32903. /**
  32904. * Gets the array of active meshes
  32905. * @returns an array of AbstractMesh
  32906. */
  32907. getActiveMeshes(): SmartArray<AbstractMesh>;
  32908. /**
  32909. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32910. * @returns a number
  32911. */
  32912. getAnimationRatio(): number;
  32913. /**
  32914. * Gets an unique Id for the current render phase
  32915. * @returns a number
  32916. */
  32917. getRenderId(): number;
  32918. /**
  32919. * Gets an unique Id for the current frame
  32920. * @returns a number
  32921. */
  32922. getFrameId(): number;
  32923. /** Call this function if you want to manually increment the render Id*/
  32924. incrementRenderId(): void;
  32925. private _createUbo;
  32926. /**
  32927. * Use this method to simulate a pointer move on a mesh
  32928. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32929. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32930. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32931. * @returns the current scene
  32932. */
  32933. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32934. /**
  32935. * Use this method to simulate a pointer down on a mesh
  32936. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32937. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32938. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32939. * @returns the current scene
  32940. */
  32941. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32942. /**
  32943. * Use this method to simulate a pointer up on a mesh
  32944. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32945. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32946. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32947. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32948. * @returns the current scene
  32949. */
  32950. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32951. /**
  32952. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32953. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32954. * @returns true if the pointer was captured
  32955. */
  32956. isPointerCaptured(pointerId?: number): boolean;
  32957. /**
  32958. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32959. * @param attachUp defines if you want to attach events to pointerup
  32960. * @param attachDown defines if you want to attach events to pointerdown
  32961. * @param attachMove defines if you want to attach events to pointermove
  32962. */
  32963. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32964. /** Detaches all event handlers*/
  32965. detachControl(): void;
  32966. /**
  32967. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32968. * Delay loaded resources are not taking in account
  32969. * @return true if all required resources are ready
  32970. */
  32971. isReady(): boolean;
  32972. /** Resets all cached information relative to material (including effect and visibility) */
  32973. resetCachedMaterial(): void;
  32974. /**
  32975. * Registers a function to be called before every frame render
  32976. * @param func defines the function to register
  32977. */
  32978. registerBeforeRender(func: () => void): void;
  32979. /**
  32980. * Unregisters a function called before every frame render
  32981. * @param func defines the function to unregister
  32982. */
  32983. unregisterBeforeRender(func: () => void): void;
  32984. /**
  32985. * Registers a function to be called after every frame render
  32986. * @param func defines the function to register
  32987. */
  32988. registerAfterRender(func: () => void): void;
  32989. /**
  32990. * Unregisters a function called after every frame render
  32991. * @param func defines the function to unregister
  32992. */
  32993. unregisterAfterRender(func: () => void): void;
  32994. private _executeOnceBeforeRender;
  32995. /**
  32996. * The provided function will run before render once and will be disposed afterwards.
  32997. * A timeout delay can be provided so that the function will be executed in N ms.
  32998. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32999. * @param func The function to be executed.
  33000. * @param timeout optional delay in ms
  33001. */
  33002. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33003. /** @hidden */ private _addPendingData(data: any): void;
  33004. /** @hidden */ private _removePendingData(data: any): void;
  33005. /**
  33006. * Returns the number of items waiting to be loaded
  33007. * @returns the number of items waiting to be loaded
  33008. */
  33009. getWaitingItemsCount(): number;
  33010. /**
  33011. * Returns a boolean indicating if the scene is still loading data
  33012. */
  33013. readonly isLoading: boolean;
  33014. /**
  33015. * Registers a function to be executed when the scene is ready
  33016. * @param {Function} func - the function to be executed
  33017. */
  33018. executeWhenReady(func: () => void): void;
  33019. /**
  33020. * Returns a promise that resolves when the scene is ready
  33021. * @returns A promise that resolves when the scene is ready
  33022. */
  33023. whenReadyAsync(): Promise<void>;
  33024. /** @hidden */ private _checkIsReady(): void;
  33025. /**
  33026. * Gets all animatable attached to the scene
  33027. */
  33028. readonly animatables: Animatable[];
  33029. /**
  33030. * Resets the last animation time frame.
  33031. * Useful to override when animations start running when loading a scene for the first time.
  33032. */
  33033. resetLastAnimationTimeFrame(): void;
  33034. /**
  33035. * Gets the current view matrix
  33036. * @returns a Matrix
  33037. */
  33038. getViewMatrix(): Matrix;
  33039. /**
  33040. * Gets the current projection matrix
  33041. * @returns a Matrix
  33042. */
  33043. getProjectionMatrix(): Matrix;
  33044. /**
  33045. * Gets the current transform matrix
  33046. * @returns a Matrix made of View * Projection
  33047. */
  33048. getTransformMatrix(): Matrix;
  33049. /**
  33050. * Sets the current transform matrix
  33051. * @param viewL defines the View matrix to use
  33052. * @param projectionL defines the Projection matrix to use
  33053. * @param viewR defines the right View matrix to use (if provided)
  33054. * @param projectionR defines the right Projection matrix to use (if provided)
  33055. */
  33056. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33057. /**
  33058. * Gets the uniform buffer used to store scene data
  33059. * @returns a UniformBuffer
  33060. */
  33061. getSceneUniformBuffer(): UniformBuffer;
  33062. /**
  33063. * Gets an unique (relatively to the current scene) Id
  33064. * @returns an unique number for the scene
  33065. */
  33066. getUniqueId(): number;
  33067. /**
  33068. * Add a mesh to the list of scene's meshes
  33069. * @param newMesh defines the mesh to add
  33070. * @param recursive if all child meshes should also be added to the scene
  33071. */
  33072. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33073. /**
  33074. * Remove a mesh for the list of scene's meshes
  33075. * @param toRemove defines the mesh to remove
  33076. * @param recursive if all child meshes should also be removed from the scene
  33077. * @returns the index where the mesh was in the mesh list
  33078. */
  33079. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33080. /**
  33081. * Add a transform node to the list of scene's transform nodes
  33082. * @param newTransformNode defines the transform node to add
  33083. */
  33084. addTransformNode(newTransformNode: TransformNode): void;
  33085. /**
  33086. * Remove a transform node for the list of scene's transform nodes
  33087. * @param toRemove defines the transform node to remove
  33088. * @returns the index where the transform node was in the transform node list
  33089. */
  33090. removeTransformNode(toRemove: TransformNode): number;
  33091. /**
  33092. * Remove a skeleton for the list of scene's skeletons
  33093. * @param toRemove defines the skeleton to remove
  33094. * @returns the index where the skeleton was in the skeleton list
  33095. */
  33096. removeSkeleton(toRemove: Skeleton): number;
  33097. /**
  33098. * Remove a morph target for the list of scene's morph targets
  33099. * @param toRemove defines the morph target to remove
  33100. * @returns the index where the morph target was in the morph target list
  33101. */
  33102. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33103. /**
  33104. * Remove a light for the list of scene's lights
  33105. * @param toRemove defines the light to remove
  33106. * @returns the index where the light was in the light list
  33107. */
  33108. removeLight(toRemove: Light): number;
  33109. /**
  33110. * Remove a camera for the list of scene's cameras
  33111. * @param toRemove defines the camera to remove
  33112. * @returns the index where the camera was in the camera list
  33113. */
  33114. removeCamera(toRemove: Camera): number;
  33115. /**
  33116. * Remove a particle system for the list of scene's particle systems
  33117. * @param toRemove defines the particle system to remove
  33118. * @returns the index where the particle system was in the particle system list
  33119. */
  33120. removeParticleSystem(toRemove: IParticleSystem): number;
  33121. /**
  33122. * Remove a animation for the list of scene's animations
  33123. * @param toRemove defines the animation to remove
  33124. * @returns the index where the animation was in the animation list
  33125. */
  33126. removeAnimation(toRemove: Animation): number;
  33127. /**
  33128. * Will stop the animation of the given target
  33129. * @param target - the target
  33130. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33131. * @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)
  33132. */
  33133. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33134. /**
  33135. * Removes the given animation group from this scene.
  33136. * @param toRemove The animation group to remove
  33137. * @returns The index of the removed animation group
  33138. */
  33139. removeAnimationGroup(toRemove: AnimationGroup): number;
  33140. /**
  33141. * Removes the given multi-material from this scene.
  33142. * @param toRemove The multi-material to remove
  33143. * @returns The index of the removed multi-material
  33144. */
  33145. removeMultiMaterial(toRemove: MultiMaterial): number;
  33146. /**
  33147. * Removes the given material from this scene.
  33148. * @param toRemove The material to remove
  33149. * @returns The index of the removed material
  33150. */
  33151. removeMaterial(toRemove: Material): number;
  33152. /**
  33153. * Removes the given action manager from this scene.
  33154. * @param toRemove The action manager to remove
  33155. * @returns The index of the removed action manager
  33156. */
  33157. removeActionManager(toRemove: AbstractActionManager): number;
  33158. /**
  33159. * Removes the given texture from this scene.
  33160. * @param toRemove The texture to remove
  33161. * @returns The index of the removed texture
  33162. */
  33163. removeTexture(toRemove: BaseTexture): number;
  33164. /**
  33165. * Adds the given light to this scene
  33166. * @param newLight The light to add
  33167. */
  33168. addLight(newLight: Light): void;
  33169. /**
  33170. * Sorts the list list based on light priorities
  33171. */
  33172. sortLightsByPriority(): void;
  33173. /**
  33174. * Adds the given camera to this scene
  33175. * @param newCamera The camera to add
  33176. */
  33177. addCamera(newCamera: Camera): void;
  33178. /**
  33179. * Adds the given skeleton to this scene
  33180. * @param newSkeleton The skeleton to add
  33181. */
  33182. addSkeleton(newSkeleton: Skeleton): void;
  33183. /**
  33184. * Adds the given particle system to this scene
  33185. * @param newParticleSystem The particle system to add
  33186. */
  33187. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33188. /**
  33189. * Adds the given animation to this scene
  33190. * @param newAnimation The animation to add
  33191. */
  33192. addAnimation(newAnimation: Animation): void;
  33193. /**
  33194. * Adds the given animation group to this scene.
  33195. * @param newAnimationGroup The animation group to add
  33196. */
  33197. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33198. /**
  33199. * Adds the given multi-material to this scene
  33200. * @param newMultiMaterial The multi-material to add
  33201. */
  33202. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33203. /**
  33204. * Adds the given material to this scene
  33205. * @param newMaterial The material to add
  33206. */
  33207. addMaterial(newMaterial: Material): void;
  33208. /**
  33209. * Adds the given morph target to this scene
  33210. * @param newMorphTargetManager The morph target to add
  33211. */
  33212. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33213. /**
  33214. * Adds the given geometry to this scene
  33215. * @param newGeometry The geometry to add
  33216. */
  33217. addGeometry(newGeometry: Geometry): void;
  33218. /**
  33219. * Adds the given action manager to this scene
  33220. * @param newActionManager The action manager to add
  33221. */
  33222. addActionManager(newActionManager: AbstractActionManager): void;
  33223. /**
  33224. * Adds the given texture to this scene.
  33225. * @param newTexture The texture to add
  33226. */
  33227. addTexture(newTexture: BaseTexture): void;
  33228. /**
  33229. * Switch active camera
  33230. * @param newCamera defines the new active camera
  33231. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33232. */
  33233. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33234. /**
  33235. * sets the active camera of the scene using its ID
  33236. * @param id defines the camera's ID
  33237. * @return the new active camera or null if none found.
  33238. */
  33239. setActiveCameraByID(id: string): Nullable<Camera>;
  33240. /**
  33241. * sets the active camera of the scene using its name
  33242. * @param name defines the camera's name
  33243. * @returns the new active camera or null if none found.
  33244. */
  33245. setActiveCameraByName(name: string): Nullable<Camera>;
  33246. /**
  33247. * get an animation group using its name
  33248. * @param name defines the material's name
  33249. * @return the animation group or null if none found.
  33250. */
  33251. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33252. /**
  33253. * Get a material using its unique id
  33254. * @param uniqueId defines the material's unique id
  33255. * @return the material or null if none found.
  33256. */
  33257. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33258. /**
  33259. * get a material using its id
  33260. * @param id defines the material's ID
  33261. * @return the material or null if none found.
  33262. */
  33263. getMaterialByID(id: string): Nullable<Material>;
  33264. /**
  33265. * Gets a the last added material using a given id
  33266. * @param id defines the material's ID
  33267. * @return the last material with the given id or null if none found.
  33268. */
  33269. getLastMaterialByID(id: string): Nullable<Material>;
  33270. /**
  33271. * Gets a material using its name
  33272. * @param name defines the material's name
  33273. * @return the material or null if none found.
  33274. */
  33275. getMaterialByName(name: string): Nullable<Material>;
  33276. /**
  33277. * Get a texture using its unique id
  33278. * @param uniqueId defines the texture's unique id
  33279. * @return the texture or null if none found.
  33280. */
  33281. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  33282. /**
  33283. * Gets a camera using its id
  33284. * @param id defines the id to look for
  33285. * @returns the camera or null if not found
  33286. */
  33287. getCameraByID(id: string): Nullable<Camera>;
  33288. /**
  33289. * Gets a camera using its unique id
  33290. * @param uniqueId defines the unique id to look for
  33291. * @returns the camera or null if not found
  33292. */
  33293. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33294. /**
  33295. * Gets a camera using its name
  33296. * @param name defines the camera's name
  33297. * @return the camera or null if none found.
  33298. */
  33299. getCameraByName(name: string): Nullable<Camera>;
  33300. /**
  33301. * Gets a bone using its id
  33302. * @param id defines the bone's id
  33303. * @return the bone or null if not found
  33304. */
  33305. getBoneByID(id: string): Nullable<Bone>;
  33306. /**
  33307. * Gets a bone using its id
  33308. * @param name defines the bone's name
  33309. * @return the bone or null if not found
  33310. */
  33311. getBoneByName(name: string): Nullable<Bone>;
  33312. /**
  33313. * Gets a light node using its name
  33314. * @param name defines the the light's name
  33315. * @return the light or null if none found.
  33316. */
  33317. getLightByName(name: string): Nullable<Light>;
  33318. /**
  33319. * Gets a light node using its id
  33320. * @param id defines the light's id
  33321. * @return the light or null if none found.
  33322. */
  33323. getLightByID(id: string): Nullable<Light>;
  33324. /**
  33325. * Gets a light node using its scene-generated unique ID
  33326. * @param uniqueId defines the light's unique id
  33327. * @return the light or null if none found.
  33328. */
  33329. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33330. /**
  33331. * Gets a particle system by id
  33332. * @param id defines the particle system id
  33333. * @return the corresponding system or null if none found
  33334. */
  33335. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33336. /**
  33337. * Gets a geometry using its ID
  33338. * @param id defines the geometry's id
  33339. * @return the geometry or null if none found.
  33340. */
  33341. getGeometryByID(id: string): Nullable<Geometry>;
  33342. private _getGeometryByUniqueID;
  33343. /**
  33344. * Add a new geometry to this scene
  33345. * @param geometry defines the geometry to be added to the scene.
  33346. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33347. * @return a boolean defining if the geometry was added or not
  33348. */
  33349. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33350. /**
  33351. * Removes an existing geometry
  33352. * @param geometry defines the geometry to be removed from the scene
  33353. * @return a boolean defining if the geometry was removed or not
  33354. */
  33355. removeGeometry(geometry: Geometry): boolean;
  33356. /**
  33357. * Gets the list of geometries attached to the scene
  33358. * @returns an array of Geometry
  33359. */
  33360. getGeometries(): Geometry[];
  33361. /**
  33362. * Gets the first added mesh found of a given ID
  33363. * @param id defines the id to search for
  33364. * @return the mesh found or null if not found at all
  33365. */
  33366. getMeshByID(id: string): Nullable<AbstractMesh>;
  33367. /**
  33368. * Gets a list of meshes using their id
  33369. * @param id defines the id to search for
  33370. * @returns a list of meshes
  33371. */
  33372. getMeshesByID(id: string): Array<AbstractMesh>;
  33373. /**
  33374. * Gets the first added transform node found of a given ID
  33375. * @param id defines the id to search for
  33376. * @return the found transform node or null if not found at all.
  33377. */
  33378. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33379. /**
  33380. * Gets a transform node with its auto-generated unique id
  33381. * @param uniqueId efines the unique id to search for
  33382. * @return the found transform node or null if not found at all.
  33383. */
  33384. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33385. /**
  33386. * Gets a list of transform nodes using their id
  33387. * @param id defines the id to search for
  33388. * @returns a list of transform nodes
  33389. */
  33390. getTransformNodesByID(id: string): Array<TransformNode>;
  33391. /**
  33392. * Gets a mesh with its auto-generated unique id
  33393. * @param uniqueId defines the unique id to search for
  33394. * @return the found mesh or null if not found at all.
  33395. */
  33396. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33397. /**
  33398. * Gets a the last added mesh using a given id
  33399. * @param id defines the id to search for
  33400. * @return the found mesh or null if not found at all.
  33401. */
  33402. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33403. /**
  33404. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33405. * @param id defines the id to search for
  33406. * @return the found node or null if not found at all
  33407. */
  33408. getLastEntryByID(id: string): Nullable<Node>;
  33409. /**
  33410. * Gets a node (Mesh, Camera, Light) using a given id
  33411. * @param id defines the id to search for
  33412. * @return the found node or null if not found at all
  33413. */
  33414. getNodeByID(id: string): Nullable<Node>;
  33415. /**
  33416. * Gets a node (Mesh, Camera, Light) using a given name
  33417. * @param name defines the name to search for
  33418. * @return the found node or null if not found at all.
  33419. */
  33420. getNodeByName(name: string): Nullable<Node>;
  33421. /**
  33422. * Gets a mesh using a given name
  33423. * @param name defines the name to search for
  33424. * @return the found mesh or null if not found at all.
  33425. */
  33426. getMeshByName(name: string): Nullable<AbstractMesh>;
  33427. /**
  33428. * Gets a transform node using a given name
  33429. * @param name defines the name to search for
  33430. * @return the found transform node or null if not found at all.
  33431. */
  33432. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33433. /**
  33434. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33435. * @param id defines the id to search for
  33436. * @return the found skeleton or null if not found at all.
  33437. */
  33438. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33439. /**
  33440. * Gets a skeleton using a given auto generated unique id
  33441. * @param uniqueId defines the unique id to search for
  33442. * @return the found skeleton or null if not found at all.
  33443. */
  33444. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33445. /**
  33446. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33447. * @param id defines the id to search for
  33448. * @return the found skeleton or null if not found at all.
  33449. */
  33450. getSkeletonById(id: string): Nullable<Skeleton>;
  33451. /**
  33452. * Gets a skeleton using a given name
  33453. * @param name defines the name to search for
  33454. * @return the found skeleton or null if not found at all.
  33455. */
  33456. getSkeletonByName(name: string): Nullable<Skeleton>;
  33457. /**
  33458. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33459. * @param id defines the id to search for
  33460. * @return the found morph target manager or null if not found at all.
  33461. */
  33462. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33463. /**
  33464. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33465. * @param id defines the id to search for
  33466. * @return the found morph target or null if not found at all.
  33467. */
  33468. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33469. /**
  33470. * Gets a boolean indicating if the given mesh is active
  33471. * @param mesh defines the mesh to look for
  33472. * @returns true if the mesh is in the active list
  33473. */
  33474. isActiveMesh(mesh: AbstractMesh): boolean;
  33475. /**
  33476. * Return a unique id as a string which can serve as an identifier for the scene
  33477. */
  33478. readonly uid: string;
  33479. /**
  33480. * Add an externaly attached data from its key.
  33481. * This method call will fail and return false, if such key already exists.
  33482. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33483. * @param key the unique key that identifies the data
  33484. * @param data the data object to associate to the key for this Engine instance
  33485. * @return true if no such key were already present and the data was added successfully, false otherwise
  33486. */
  33487. addExternalData<T>(key: string, data: T): boolean;
  33488. /**
  33489. * Get an externaly attached data from its key
  33490. * @param key the unique key that identifies the data
  33491. * @return the associated data, if present (can be null), or undefined if not present
  33492. */
  33493. getExternalData<T>(key: string): Nullable<T>;
  33494. /**
  33495. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33496. * @param key the unique key that identifies the data
  33497. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33498. * @return the associated data, can be null if the factory returned null.
  33499. */
  33500. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33501. /**
  33502. * Remove an externaly attached data from the Engine instance
  33503. * @param key the unique key that identifies the data
  33504. * @return true if the data was successfully removed, false if it doesn't exist
  33505. */
  33506. removeExternalData(key: string): boolean;
  33507. private _evaluateSubMesh;
  33508. /**
  33509. * Clear the processed materials smart array preventing retention point in material dispose.
  33510. */
  33511. freeProcessedMaterials(): void;
  33512. private _preventFreeActiveMeshesAndRenderingGroups;
  33513. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33514. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33515. * when disposing several meshes in a row or a hierarchy of meshes.
  33516. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33517. */
  33518. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33519. /**
  33520. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33521. */
  33522. freeActiveMeshes(): void;
  33523. /**
  33524. * Clear the info related to rendering groups preventing retention points during dispose.
  33525. */
  33526. freeRenderingGroups(): void;
  33527. /** @hidden */ private _isInIntermediateRendering(): boolean;
  33528. /**
  33529. * Lambda returning the list of potentially active meshes.
  33530. */
  33531. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33532. /**
  33533. * Lambda returning the list of potentially active sub meshes.
  33534. */
  33535. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33536. /**
  33537. * Lambda returning the list of potentially intersecting sub meshes.
  33538. */
  33539. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33540. /**
  33541. * Lambda returning the list of potentially colliding sub meshes.
  33542. */
  33543. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33544. private _activeMeshesFrozen;
  33545. /**
  33546. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33547. * @returns the current scene
  33548. */
  33549. freezeActiveMeshes(): Scene;
  33550. /**
  33551. * Use this function to restart evaluating active meshes on every frame
  33552. * @returns the current scene
  33553. */
  33554. unfreezeActiveMeshes(): Scene;
  33555. private _evaluateActiveMeshes;
  33556. private _activeMesh;
  33557. /**
  33558. * Update the transform matrix to update from the current active camera
  33559. * @param force defines a boolean used to force the update even if cache is up to date
  33560. */
  33561. updateTransformMatrix(force?: boolean): void;
  33562. private _bindFrameBuffer;
  33563. /** @hidden */ private _allowPostProcessClearColor: boolean;
  33564. /** @hidden */ private _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33565. private _processSubCameras;
  33566. private _checkIntersections;
  33567. /** @hidden */ private _advancePhysicsEngineStep(step: number): void;
  33568. /**
  33569. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33570. */
  33571. getDeterministicFrameTime: () => number;
  33572. /** @hidden */ private _animate(): void;
  33573. /** Execute all animations (for a frame) */
  33574. animate(): void;
  33575. /**
  33576. * Render the scene
  33577. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33578. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33579. */
  33580. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33581. /**
  33582. * Freeze all materials
  33583. * A frozen material will not be updatable but should be faster to render
  33584. */
  33585. freezeMaterials(): void;
  33586. /**
  33587. * Unfreeze all materials
  33588. * A frozen material will not be updatable but should be faster to render
  33589. */
  33590. unfreezeMaterials(): void;
  33591. /**
  33592. * Releases all held ressources
  33593. */
  33594. dispose(): void;
  33595. /**
  33596. * Gets if the scene is already disposed
  33597. */
  33598. readonly isDisposed: boolean;
  33599. /**
  33600. * Call this function to reduce memory footprint of the scene.
  33601. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33602. */
  33603. clearCachedVertexData(): void;
  33604. /**
  33605. * This function will remove the local cached buffer data from texture.
  33606. * It will save memory but will prevent the texture from being rebuilt
  33607. */
  33608. cleanCachedTextureBuffer(): void;
  33609. /**
  33610. * Get the world extend vectors with an optional filter
  33611. *
  33612. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33613. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33614. */
  33615. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33616. min: Vector3;
  33617. max: Vector3;
  33618. };
  33619. /**
  33620. * Creates a ray that can be used to pick in the scene
  33621. * @param x defines the x coordinate of the origin (on-screen)
  33622. * @param y defines the y coordinate of the origin (on-screen)
  33623. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33624. * @param camera defines the camera to use for the picking
  33625. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33626. * @returns a Ray
  33627. */
  33628. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33629. /**
  33630. * Creates a ray that can be used to pick in the scene
  33631. * @param x defines the x coordinate of the origin (on-screen)
  33632. * @param y defines the y coordinate of the origin (on-screen)
  33633. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33634. * @param result defines the ray where to store the picking ray
  33635. * @param camera defines the camera to use for the picking
  33636. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33637. * @returns the current scene
  33638. */
  33639. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33640. /**
  33641. * Creates a ray that can be used to pick in the scene
  33642. * @param x defines the x coordinate of the origin (on-screen)
  33643. * @param y defines the y coordinate of the origin (on-screen)
  33644. * @param camera defines the camera to use for the picking
  33645. * @returns a Ray
  33646. */
  33647. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33648. /**
  33649. * Creates a ray that can be used to pick in the scene
  33650. * @param x defines the x coordinate of the origin (on-screen)
  33651. * @param y defines the y coordinate of the origin (on-screen)
  33652. * @param result defines the ray where to store the picking ray
  33653. * @param camera defines the camera to use for the picking
  33654. * @returns the current scene
  33655. */
  33656. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33657. /** Launch a ray to try to pick a mesh in the scene
  33658. * @param x position on screen
  33659. * @param y position on screen
  33660. * @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
  33661. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33662. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33663. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33664. * @returns a PickingInfo
  33665. */
  33666. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33667. /** Use the given ray to pick a mesh in the scene
  33668. * @param ray The ray to use to pick meshes
  33669. * @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
  33670. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33671. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33672. * @returns a PickingInfo
  33673. */
  33674. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33675. /**
  33676. * Launch a ray to try to pick a mesh in the scene
  33677. * @param x X position on screen
  33678. * @param y Y position on screen
  33679. * @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
  33680. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33681. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33682. * @returns an array of PickingInfo
  33683. */
  33684. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33685. /**
  33686. * Launch a ray to try to pick a mesh in the scene
  33687. * @param ray Ray to use
  33688. * @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
  33689. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33690. * @returns an array of PickingInfo
  33691. */
  33692. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33693. /**
  33694. * Force the value of meshUnderPointer
  33695. * @param mesh defines the mesh to use
  33696. */
  33697. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33698. /**
  33699. * Gets the mesh under the pointer
  33700. * @returns a Mesh or null if no mesh is under the pointer
  33701. */
  33702. getPointerOverMesh(): Nullable<AbstractMesh>;
  33703. /** @hidden */ private _rebuildGeometries(): void;
  33704. /** @hidden */ private _rebuildTextures(): void;
  33705. private _getByTags;
  33706. /**
  33707. * Get a list of meshes by tags
  33708. * @param tagsQuery defines the tags query to use
  33709. * @param forEach defines a predicate used to filter results
  33710. * @returns an array of Mesh
  33711. */
  33712. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33713. /**
  33714. * Get a list of cameras by tags
  33715. * @param tagsQuery defines the tags query to use
  33716. * @param forEach defines a predicate used to filter results
  33717. * @returns an array of Camera
  33718. */
  33719. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33720. /**
  33721. * Get a list of lights by tags
  33722. * @param tagsQuery defines the tags query to use
  33723. * @param forEach defines a predicate used to filter results
  33724. * @returns an array of Light
  33725. */
  33726. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33727. /**
  33728. * Get a list of materials by tags
  33729. * @param tagsQuery defines the tags query to use
  33730. * @param forEach defines a predicate used to filter results
  33731. * @returns an array of Material
  33732. */
  33733. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33734. /**
  33735. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33736. * This allowed control for front to back rendering or reversly depending of the special needs.
  33737. *
  33738. * @param renderingGroupId The rendering group id corresponding to its index
  33739. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33740. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33741. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33742. */
  33743. 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;
  33744. /**
  33745. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33746. *
  33747. * @param renderingGroupId The rendering group id corresponding to its index
  33748. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33749. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33750. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33751. */
  33752. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33753. /**
  33754. * Gets the current auto clear configuration for one rendering group of the rendering
  33755. * manager.
  33756. * @param index the rendering group index to get the information for
  33757. * @returns The auto clear setup for the requested rendering group
  33758. */
  33759. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33760. private _blockMaterialDirtyMechanism;
  33761. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33762. blockMaterialDirtyMechanism: boolean;
  33763. /**
  33764. * Will flag all materials as dirty to trigger new shader compilation
  33765. * @param flag defines the flag used to specify which material part must be marked as dirty
  33766. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33767. */
  33768. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33769. /** @hidden */ private _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  33770. /** @hidden */ private _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33771. }
  33772. }
  33773. declare module BABYLON {
  33774. /**
  33775. * Set of assets to keep when moving a scene into an asset container.
  33776. */
  33777. export class KeepAssets extends AbstractScene {
  33778. }
  33779. /**
  33780. * Container with a set of assets that can be added or removed from a scene.
  33781. */
  33782. export class AssetContainer extends AbstractScene {
  33783. /**
  33784. * The scene the AssetContainer belongs to.
  33785. */
  33786. scene: Scene;
  33787. /**
  33788. * Instantiates an AssetContainer.
  33789. * @param scene The scene the AssetContainer belongs to.
  33790. */
  33791. constructor(scene: Scene);
  33792. /**
  33793. * Adds all the assets from the container to the scene.
  33794. */
  33795. addAllToScene(): void;
  33796. /**
  33797. * Removes all the assets in the container from the scene
  33798. */
  33799. removeAllFromScene(): void;
  33800. /**
  33801. * Disposes all the assets in the container
  33802. */
  33803. dispose(): void;
  33804. private _moveAssets;
  33805. /**
  33806. * Removes all the assets contained in the scene and adds them to the container.
  33807. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33808. */
  33809. moveAllFromScene(keepAssets?: KeepAssets): void;
  33810. /**
  33811. * 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.
  33812. * @returns the root mesh
  33813. */
  33814. createRootMesh(): Mesh;
  33815. }
  33816. }
  33817. declare module BABYLON {
  33818. /**
  33819. * Defines how the parser contract is defined.
  33820. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33821. */
  33822. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33823. /**
  33824. * Defines how the individual parser contract is defined.
  33825. * These parser can parse an individual asset
  33826. */
  33827. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33828. /**
  33829. * Base class of the scene acting as a container for the different elements composing a scene.
  33830. * This class is dynamically extended by the different components of the scene increasing
  33831. * flexibility and reducing coupling
  33832. */
  33833. export abstract class AbstractScene {
  33834. /**
  33835. * Stores the list of available parsers in the application.
  33836. */
  33837. private static _BabylonFileParsers;
  33838. /**
  33839. * Stores the list of available individual parsers in the application.
  33840. */
  33841. private static _IndividualBabylonFileParsers;
  33842. /**
  33843. * Adds a parser in the list of available ones
  33844. * @param name Defines the name of the parser
  33845. * @param parser Defines the parser to add
  33846. */
  33847. static AddParser(name: string, parser: BabylonFileParser): void;
  33848. /**
  33849. * Gets a general parser from the list of avaialble ones
  33850. * @param name Defines the name of the parser
  33851. * @returns the requested parser or null
  33852. */
  33853. static GetParser(name: string): Nullable<BabylonFileParser>;
  33854. /**
  33855. * Adds n individual parser in the list of available ones
  33856. * @param name Defines the name of the parser
  33857. * @param parser Defines the parser to add
  33858. */
  33859. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33860. /**
  33861. * Gets an individual parser from the list of avaialble ones
  33862. * @param name Defines the name of the parser
  33863. * @returns the requested parser or null
  33864. */
  33865. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33866. /**
  33867. * Parser json data and populate both a scene and its associated container object
  33868. * @param jsonData Defines the data to parse
  33869. * @param scene Defines the scene to parse the data for
  33870. * @param container Defines the container attached to the parsing sequence
  33871. * @param rootUrl Defines the root url of the data
  33872. */
  33873. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33874. /**
  33875. * Gets the list of root nodes (ie. nodes with no parent)
  33876. */
  33877. rootNodes: Node[];
  33878. /** All of the cameras added to this scene
  33879. * @see http://doc.babylonjs.com/babylon101/cameras
  33880. */
  33881. cameras: Camera[];
  33882. /**
  33883. * All of the lights added to this scene
  33884. * @see http://doc.babylonjs.com/babylon101/lights
  33885. */
  33886. lights: Light[];
  33887. /**
  33888. * All of the (abstract) meshes added to this scene
  33889. */
  33890. meshes: AbstractMesh[];
  33891. /**
  33892. * The list of skeletons added to the scene
  33893. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33894. */
  33895. skeletons: Skeleton[];
  33896. /**
  33897. * All of the particle systems added to this scene
  33898. * @see http://doc.babylonjs.com/babylon101/particles
  33899. */
  33900. particleSystems: IParticleSystem[];
  33901. /**
  33902. * Gets a list of Animations associated with the scene
  33903. */
  33904. animations: Animation[];
  33905. /**
  33906. * All of the animation groups added to this scene
  33907. * @see http://doc.babylonjs.com/how_to/group
  33908. */
  33909. animationGroups: AnimationGroup[];
  33910. /**
  33911. * All of the multi-materials added to this scene
  33912. * @see http://doc.babylonjs.com/how_to/multi_materials
  33913. */
  33914. multiMaterials: MultiMaterial[];
  33915. /**
  33916. * All of the materials added to this scene
  33917. * In the context of a Scene, it is not supposed to be modified manually.
  33918. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33919. * Note also that the order of the Material wihin the array is not significant and might change.
  33920. * @see http://doc.babylonjs.com/babylon101/materials
  33921. */
  33922. materials: Material[];
  33923. /**
  33924. * The list of morph target managers added to the scene
  33925. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33926. */
  33927. morphTargetManagers: MorphTargetManager[];
  33928. /**
  33929. * The list of geometries used in the scene.
  33930. */
  33931. geometries: Geometry[];
  33932. /**
  33933. * All of the tranform nodes added to this scene
  33934. * In the context of a Scene, it is not supposed to be modified manually.
  33935. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33936. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33937. * @see http://doc.babylonjs.com/how_to/transformnode
  33938. */
  33939. transformNodes: TransformNode[];
  33940. /**
  33941. * ActionManagers available on the scene.
  33942. */
  33943. actionManagers: AbstractActionManager[];
  33944. /**
  33945. * Textures to keep.
  33946. */
  33947. textures: BaseTexture[];
  33948. /**
  33949. * Environment texture for the scene
  33950. */
  33951. environmentTexture: Nullable<BaseTexture>;
  33952. }
  33953. }
  33954. declare module BABYLON {
  33955. /**
  33956. * Interface used to define options for Sound class
  33957. */
  33958. export interface ISoundOptions {
  33959. /**
  33960. * Does the sound autoplay once loaded.
  33961. */
  33962. autoplay?: boolean;
  33963. /**
  33964. * Does the sound loop after it finishes playing once.
  33965. */
  33966. loop?: boolean;
  33967. /**
  33968. * Sound's volume
  33969. */
  33970. volume?: number;
  33971. /**
  33972. * Is it a spatial sound?
  33973. */
  33974. spatialSound?: boolean;
  33975. /**
  33976. * Maximum distance to hear that sound
  33977. */
  33978. maxDistance?: number;
  33979. /**
  33980. * Uses user defined attenuation function
  33981. */
  33982. useCustomAttenuation?: boolean;
  33983. /**
  33984. * Define the roll off factor of spatial sounds.
  33985. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33986. */
  33987. rolloffFactor?: number;
  33988. /**
  33989. * Define the reference distance the sound should be heard perfectly.
  33990. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33991. */
  33992. refDistance?: number;
  33993. /**
  33994. * Define the distance attenuation model the sound will follow.
  33995. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33996. */
  33997. distanceModel?: string;
  33998. /**
  33999. * Defines the playback speed (1 by default)
  34000. */
  34001. playbackRate?: number;
  34002. /**
  34003. * Defines if the sound is from a streaming source
  34004. */
  34005. streaming?: boolean;
  34006. /**
  34007. * Defines an optional length (in seconds) inside the sound file
  34008. */
  34009. length?: number;
  34010. /**
  34011. * Defines an optional offset (in seconds) inside the sound file
  34012. */
  34013. offset?: number;
  34014. /**
  34015. * If true, URLs will not be required to state the audio file codec to use.
  34016. */
  34017. skipCodecCheck?: boolean;
  34018. }
  34019. /**
  34020. * Defines a sound that can be played in the application.
  34021. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34022. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34023. */
  34024. export class Sound {
  34025. /**
  34026. * The name of the sound in the scene.
  34027. */
  34028. name: string;
  34029. /**
  34030. * Does the sound autoplay once loaded.
  34031. */
  34032. autoplay: boolean;
  34033. /**
  34034. * Does the sound loop after it finishes playing once.
  34035. */
  34036. loop: boolean;
  34037. /**
  34038. * Does the sound use a custom attenuation curve to simulate the falloff
  34039. * happening when the source gets further away from the camera.
  34040. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34041. */
  34042. useCustomAttenuation: boolean;
  34043. /**
  34044. * The sound track id this sound belongs to.
  34045. */
  34046. soundTrackId: number;
  34047. /**
  34048. * Is this sound currently played.
  34049. */
  34050. isPlaying: boolean;
  34051. /**
  34052. * Is this sound currently paused.
  34053. */
  34054. isPaused: boolean;
  34055. /**
  34056. * Does this sound enables spatial sound.
  34057. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34058. */
  34059. spatialSound: boolean;
  34060. /**
  34061. * Define the reference distance the sound should be heard perfectly.
  34062. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34063. */
  34064. refDistance: number;
  34065. /**
  34066. * Define the roll off factor of spatial sounds.
  34067. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34068. */
  34069. rolloffFactor: number;
  34070. /**
  34071. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34072. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34073. */
  34074. maxDistance: number;
  34075. /**
  34076. * Define the distance attenuation model the sound will follow.
  34077. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34078. */
  34079. distanceModel: string;
  34080. /**
  34081. * @hidden
  34082. * Back Compat
  34083. **/
  34084. onended: () => any;
  34085. /**
  34086. * Observable event when the current playing sound finishes.
  34087. */
  34088. onEndedObservable: Observable<Sound>;
  34089. private _panningModel;
  34090. private _playbackRate;
  34091. private _streaming;
  34092. private _startTime;
  34093. private _startOffset;
  34094. private _position;
  34095. /** @hidden */ private _positionInEmitterSpace: boolean;
  34096. private _localDirection;
  34097. private _volume;
  34098. private _isReadyToPlay;
  34099. private _isDirectional;
  34100. private _readyToPlayCallback;
  34101. private _audioBuffer;
  34102. private _soundSource;
  34103. private _streamingSource;
  34104. private _soundPanner;
  34105. private _soundGain;
  34106. private _inputAudioNode;
  34107. private _outputAudioNode;
  34108. private _coneInnerAngle;
  34109. private _coneOuterAngle;
  34110. private _coneOuterGain;
  34111. private _scene;
  34112. private _connectedTransformNode;
  34113. private _customAttenuationFunction;
  34114. private _registerFunc;
  34115. private _isOutputConnected;
  34116. private _htmlAudioElement;
  34117. private _urlType;
  34118. private _length?;
  34119. private _offset?;
  34120. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  34121. /**
  34122. * Create a sound and attach it to a scene
  34123. * @param name Name of your sound
  34124. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34125. * @param scene defines the scene the sound belongs to
  34126. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34127. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34128. */
  34129. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34130. /**
  34131. * Release the sound and its associated resources
  34132. */
  34133. dispose(): void;
  34134. /**
  34135. * Gets if the sounds is ready to be played or not.
  34136. * @returns true if ready, otherwise false
  34137. */
  34138. isReady(): boolean;
  34139. private _soundLoaded;
  34140. /**
  34141. * Sets the data of the sound from an audiobuffer
  34142. * @param audioBuffer The audioBuffer containing the data
  34143. */
  34144. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34145. /**
  34146. * Updates the current sounds options such as maxdistance, loop...
  34147. * @param options A JSON object containing values named as the object properties
  34148. */
  34149. updateOptions(options: ISoundOptions): void;
  34150. private _createSpatialParameters;
  34151. private _updateSpatialParameters;
  34152. /**
  34153. * Switch the panning model to HRTF:
  34154. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34155. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34156. */
  34157. switchPanningModelToHRTF(): void;
  34158. /**
  34159. * Switch the panning model to Equal Power:
  34160. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34161. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34162. */
  34163. switchPanningModelToEqualPower(): void;
  34164. private _switchPanningModel;
  34165. /**
  34166. * Connect this sound to a sound track audio node like gain...
  34167. * @param soundTrackAudioNode the sound track audio node to connect to
  34168. */
  34169. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34170. /**
  34171. * Transform this sound into a directional source
  34172. * @param coneInnerAngle Size of the inner cone in degree
  34173. * @param coneOuterAngle Size of the outer cone in degree
  34174. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34175. */
  34176. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34177. /**
  34178. * Gets or sets the inner angle for the directional cone.
  34179. */
  34180. /**
  34181. * Gets or sets the inner angle for the directional cone.
  34182. */
  34183. directionalConeInnerAngle: number;
  34184. /**
  34185. * Gets or sets the outer angle for the directional cone.
  34186. */
  34187. /**
  34188. * Gets or sets the outer angle for the directional cone.
  34189. */
  34190. directionalConeOuterAngle: number;
  34191. /**
  34192. * Sets the position of the emitter if spatial sound is enabled
  34193. * @param newPosition Defines the new posisiton
  34194. */
  34195. setPosition(newPosition: Vector3): void;
  34196. /**
  34197. * Sets the local direction of the emitter if spatial sound is enabled
  34198. * @param newLocalDirection Defines the new local direction
  34199. */
  34200. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34201. private _updateDirection;
  34202. /** @hidden */
  34203. updateDistanceFromListener(): void;
  34204. /**
  34205. * Sets a new custom attenuation function for the sound.
  34206. * @param callback Defines the function used for the attenuation
  34207. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34208. */
  34209. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34210. /**
  34211. * Play the sound
  34212. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34213. * @param offset (optional) Start the sound at a specific time in seconds
  34214. * @param length (optional) Sound duration (in seconds)
  34215. */
  34216. play(time?: number, offset?: number, length?: number): void;
  34217. private _onended;
  34218. /**
  34219. * Stop the sound
  34220. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34221. */
  34222. stop(time?: number): void;
  34223. /**
  34224. * Put the sound in pause
  34225. */
  34226. pause(): void;
  34227. /**
  34228. * Sets a dedicated volume for this sounds
  34229. * @param newVolume Define the new volume of the sound
  34230. * @param time Define time for gradual change to new volume
  34231. */
  34232. setVolume(newVolume: number, time?: number): void;
  34233. /**
  34234. * Set the sound play back rate
  34235. * @param newPlaybackRate Define the playback rate the sound should be played at
  34236. */
  34237. setPlaybackRate(newPlaybackRate: number): void;
  34238. /**
  34239. * Gets the volume of the sound.
  34240. * @returns the volume of the sound
  34241. */
  34242. getVolume(): number;
  34243. /**
  34244. * Attach the sound to a dedicated mesh
  34245. * @param transformNode The transform node to connect the sound with
  34246. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34247. */
  34248. attachToMesh(transformNode: TransformNode): void;
  34249. /**
  34250. * Detach the sound from the previously attached mesh
  34251. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34252. */
  34253. detachFromMesh(): void;
  34254. private _onRegisterAfterWorldMatrixUpdate;
  34255. /**
  34256. * Clone the current sound in the scene.
  34257. * @returns the new sound clone
  34258. */
  34259. clone(): Nullable<Sound>;
  34260. /**
  34261. * Gets the current underlying audio buffer containing the data
  34262. * @returns the audio buffer
  34263. */
  34264. getAudioBuffer(): Nullable<AudioBuffer>;
  34265. /**
  34266. * Serializes the Sound in a JSON representation
  34267. * @returns the JSON representation of the sound
  34268. */
  34269. serialize(): any;
  34270. /**
  34271. * Parse a JSON representation of a sound to innstantiate in a given scene
  34272. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34273. * @param scene Define the scene the new parsed sound should be created in
  34274. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34275. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34276. * @returns the newly parsed sound
  34277. */
  34278. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34279. }
  34280. }
  34281. declare module BABYLON {
  34282. /**
  34283. * This defines an action helpful to play a defined sound on a triggered action.
  34284. */
  34285. export class PlaySoundAction extends Action {
  34286. private _sound;
  34287. /**
  34288. * Instantiate the action
  34289. * @param triggerOptions defines the trigger options
  34290. * @param sound defines the sound to play
  34291. * @param condition defines the trigger related conditions
  34292. */
  34293. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34294. /** @hidden */ private _prepare(): void;
  34295. /**
  34296. * Execute the action and play the sound.
  34297. */
  34298. execute(): void;
  34299. /**
  34300. * Serializes the actions and its related information.
  34301. * @param parent defines the object to serialize in
  34302. * @returns the serialized object
  34303. */
  34304. serialize(parent: any): any;
  34305. }
  34306. /**
  34307. * This defines an action helpful to stop a defined sound on a triggered action.
  34308. */
  34309. export class StopSoundAction extends Action {
  34310. private _sound;
  34311. /**
  34312. * Instantiate the action
  34313. * @param triggerOptions defines the trigger options
  34314. * @param sound defines the sound to stop
  34315. * @param condition defines the trigger related conditions
  34316. */
  34317. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34318. /** @hidden */ private _prepare(): void;
  34319. /**
  34320. * Execute the action and stop the sound.
  34321. */
  34322. execute(): void;
  34323. /**
  34324. * Serializes the actions and its related information.
  34325. * @param parent defines the object to serialize in
  34326. * @returns the serialized object
  34327. */
  34328. serialize(parent: any): any;
  34329. }
  34330. }
  34331. declare module BABYLON {
  34332. /**
  34333. * This defines an action responsible to change the value of a property
  34334. * by interpolating between its current value and the newly set one once triggered.
  34335. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34336. */
  34337. export class InterpolateValueAction extends Action {
  34338. /**
  34339. * Defines the path of the property where the value should be interpolated
  34340. */
  34341. propertyPath: string;
  34342. /**
  34343. * Defines the target value at the end of the interpolation.
  34344. */
  34345. value: any;
  34346. /**
  34347. * Defines the time it will take for the property to interpolate to the value.
  34348. */
  34349. duration: number;
  34350. /**
  34351. * Defines if the other scene animations should be stopped when the action has been triggered
  34352. */
  34353. stopOtherAnimations?: boolean;
  34354. /**
  34355. * Defines a callback raised once the interpolation animation has been done.
  34356. */
  34357. onInterpolationDone?: () => void;
  34358. /**
  34359. * Observable triggered once the interpolation animation has been done.
  34360. */
  34361. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34362. private _target;
  34363. private _effectiveTarget;
  34364. private _property;
  34365. /**
  34366. * Instantiate the action
  34367. * @param triggerOptions defines the trigger options
  34368. * @param target defines the object containing the value to interpolate
  34369. * @param propertyPath defines the path to the property in the target object
  34370. * @param value defines the target value at the end of the interpolation
  34371. * @param duration deines the time it will take for the property to interpolate to the value.
  34372. * @param condition defines the trigger related conditions
  34373. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34374. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34375. */
  34376. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34377. /** @hidden */ private _prepare(): void;
  34378. /**
  34379. * Execute the action starts the value interpolation.
  34380. */
  34381. execute(): void;
  34382. /**
  34383. * Serializes the actions and its related information.
  34384. * @param parent defines the object to serialize in
  34385. * @returns the serialized object
  34386. */
  34387. serialize(parent: any): any;
  34388. }
  34389. }
  34390. declare module BABYLON {
  34391. /**
  34392. * Options allowed during the creation of a sound track.
  34393. */
  34394. export interface ISoundTrackOptions {
  34395. /**
  34396. * The volume the sound track should take during creation
  34397. */
  34398. volume?: number;
  34399. /**
  34400. * Define if the sound track is the main sound track of the scene
  34401. */
  34402. mainTrack?: boolean;
  34403. }
  34404. /**
  34405. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34406. * It will be also used in a future release to apply effects on a specific track.
  34407. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34408. */
  34409. export class SoundTrack {
  34410. /**
  34411. * The unique identifier of the sound track in the scene.
  34412. */
  34413. id: number;
  34414. /**
  34415. * The list of sounds included in the sound track.
  34416. */
  34417. soundCollection: Array<Sound>;
  34418. private _outputAudioNode;
  34419. private _scene;
  34420. private _isMainTrack;
  34421. private _connectedAnalyser;
  34422. private _options;
  34423. private _isInitialized;
  34424. /**
  34425. * Creates a new sound track.
  34426. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34427. * @param scene Define the scene the sound track belongs to
  34428. * @param options
  34429. */
  34430. constructor(scene: Scene, options?: ISoundTrackOptions);
  34431. private _initializeSoundTrackAudioGraph;
  34432. /**
  34433. * Release the sound track and its associated resources
  34434. */
  34435. dispose(): void;
  34436. /**
  34437. * Adds a sound to this sound track
  34438. * @param sound define the cound to add
  34439. * @ignoreNaming
  34440. */
  34441. AddSound(sound: Sound): void;
  34442. /**
  34443. * Removes a sound to this sound track
  34444. * @param sound define the cound to remove
  34445. * @ignoreNaming
  34446. */
  34447. RemoveSound(sound: Sound): void;
  34448. /**
  34449. * Set a global volume for the full sound track.
  34450. * @param newVolume Define the new volume of the sound track
  34451. */
  34452. setVolume(newVolume: number): void;
  34453. /**
  34454. * Switch the panning model to HRTF:
  34455. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34456. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34457. */
  34458. switchPanningModelToHRTF(): void;
  34459. /**
  34460. * Switch the panning model to Equal Power:
  34461. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34463. */
  34464. switchPanningModelToEqualPower(): void;
  34465. /**
  34466. * Connect the sound track to an audio analyser allowing some amazing
  34467. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34468. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34469. * @param analyser The analyser to connect to the engine
  34470. */
  34471. connectToAnalyser(analyser: Analyser): void;
  34472. }
  34473. }
  34474. declare module BABYLON {
  34475. interface AbstractScene {
  34476. /**
  34477. * The list of sounds used in the scene.
  34478. */
  34479. sounds: Nullable<Array<Sound>>;
  34480. }
  34481. interface Scene {
  34482. /**
  34483. * @hidden
  34484. * Backing field
  34485. */ private _mainSoundTrack: SoundTrack;
  34486. /**
  34487. * The main sound track played by the scene.
  34488. * It cotains your primary collection of sounds.
  34489. */
  34490. mainSoundTrack: SoundTrack;
  34491. /**
  34492. * The list of sound tracks added to the scene
  34493. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34494. */
  34495. soundTracks: Nullable<Array<SoundTrack>>;
  34496. /**
  34497. * Gets a sound using a given name
  34498. * @param name defines the name to search for
  34499. * @return the found sound or null if not found at all.
  34500. */
  34501. getSoundByName(name: string): Nullable<Sound>;
  34502. /**
  34503. * Gets or sets if audio support is enabled
  34504. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34505. */
  34506. audioEnabled: boolean;
  34507. /**
  34508. * Gets or sets if audio will be output to headphones
  34509. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34510. */
  34511. headphone: boolean;
  34512. /**
  34513. * Gets or sets custom audio listener position provider
  34514. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34515. */
  34516. audioListenerPositionProvider: Nullable<() => Vector3>;
  34517. }
  34518. /**
  34519. * Defines the sound scene component responsible to manage any sounds
  34520. * in a given scene.
  34521. */
  34522. export class AudioSceneComponent implements ISceneSerializableComponent {
  34523. /**
  34524. * The component name helpfull to identify the component in the list of scene components.
  34525. */
  34526. readonly name: string;
  34527. /**
  34528. * The scene the component belongs to.
  34529. */
  34530. scene: Scene;
  34531. private _audioEnabled;
  34532. /**
  34533. * Gets whether audio is enabled or not.
  34534. * Please use related enable/disable method to switch state.
  34535. */
  34536. readonly audioEnabled: boolean;
  34537. private _headphone;
  34538. /**
  34539. * Gets whether audio is outputing to headphone or not.
  34540. * Please use the according Switch methods to change output.
  34541. */
  34542. readonly headphone: boolean;
  34543. private _audioListenerPositionProvider;
  34544. /**
  34545. * Gets the current audio listener position provider
  34546. */
  34547. /**
  34548. * Sets a custom listener position for all sounds in the scene
  34549. * By default, this is the position of the first active camera
  34550. */
  34551. audioListenerPositionProvider: Nullable<() => Vector3>;
  34552. /**
  34553. * Creates a new instance of the component for the given scene
  34554. * @param scene Defines the scene to register the component in
  34555. */
  34556. constructor(scene: Scene);
  34557. /**
  34558. * Registers the component in a given scene
  34559. */
  34560. register(): void;
  34561. /**
  34562. * Rebuilds the elements related to this component in case of
  34563. * context lost for instance.
  34564. */
  34565. rebuild(): void;
  34566. /**
  34567. * Serializes the component data to the specified json object
  34568. * @param serializationObject The object to serialize to
  34569. */
  34570. serialize(serializationObject: any): void;
  34571. /**
  34572. * Adds all the elements from the container to the scene
  34573. * @param container the container holding the elements
  34574. */
  34575. addFromContainer(container: AbstractScene): void;
  34576. /**
  34577. * Removes all the elements in the container from the scene
  34578. * @param container contains the elements to remove
  34579. * @param dispose if the removed element should be disposed (default: false)
  34580. */
  34581. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34582. /**
  34583. * Disposes the component and the associated ressources.
  34584. */
  34585. dispose(): void;
  34586. /**
  34587. * Disables audio in the associated scene.
  34588. */
  34589. disableAudio(): void;
  34590. /**
  34591. * Enables audio in the associated scene.
  34592. */
  34593. enableAudio(): void;
  34594. /**
  34595. * Switch audio to headphone output.
  34596. */
  34597. switchAudioModeForHeadphones(): void;
  34598. /**
  34599. * Switch audio to normal speakers.
  34600. */
  34601. switchAudioModeForNormalSpeakers(): void;
  34602. private _afterRender;
  34603. }
  34604. }
  34605. declare module BABYLON {
  34606. /**
  34607. * Wraps one or more Sound objects and selects one with random weight for playback.
  34608. */
  34609. export class WeightedSound {
  34610. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34611. loop: boolean;
  34612. private _coneInnerAngle;
  34613. private _coneOuterAngle;
  34614. private _volume;
  34615. /** A Sound is currently playing. */
  34616. isPlaying: boolean;
  34617. /** A Sound is currently paused. */
  34618. isPaused: boolean;
  34619. private _sounds;
  34620. private _weights;
  34621. private _currentIndex?;
  34622. /**
  34623. * Creates a new WeightedSound from the list of sounds given.
  34624. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34625. * @param sounds Array of Sounds that will be selected from.
  34626. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34627. */
  34628. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34629. /**
  34630. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34631. */
  34632. /**
  34633. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34634. */
  34635. directionalConeInnerAngle: number;
  34636. /**
  34637. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34638. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34639. */
  34640. /**
  34641. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34642. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34643. */
  34644. directionalConeOuterAngle: number;
  34645. /**
  34646. * Playback volume.
  34647. */
  34648. /**
  34649. * Playback volume.
  34650. */
  34651. volume: number;
  34652. private _onended;
  34653. /**
  34654. * Suspend playback
  34655. */
  34656. pause(): void;
  34657. /**
  34658. * Stop playback
  34659. */
  34660. stop(): void;
  34661. /**
  34662. * Start playback.
  34663. * @param startOffset Position the clip head at a specific time in seconds.
  34664. */
  34665. play(startOffset?: number): void;
  34666. }
  34667. }
  34668. declare module BABYLON {
  34669. /**
  34670. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34671. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34672. */
  34673. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34674. /**
  34675. * Gets the name of the behavior.
  34676. */
  34677. readonly name: string;
  34678. /**
  34679. * The easing function used by animations
  34680. */
  34681. static EasingFunction: BackEase;
  34682. /**
  34683. * The easing mode used by animations
  34684. */
  34685. static EasingMode: number;
  34686. /**
  34687. * The duration of the animation, in milliseconds
  34688. */
  34689. transitionDuration: number;
  34690. /**
  34691. * Length of the distance animated by the transition when lower radius is reached
  34692. */
  34693. lowerRadiusTransitionRange: number;
  34694. /**
  34695. * Length of the distance animated by the transition when upper radius is reached
  34696. */
  34697. upperRadiusTransitionRange: number;
  34698. private _autoTransitionRange;
  34699. /**
  34700. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34701. */
  34702. /**
  34703. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34704. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34705. */
  34706. autoTransitionRange: boolean;
  34707. private _attachedCamera;
  34708. private _onAfterCheckInputsObserver;
  34709. private _onMeshTargetChangedObserver;
  34710. /**
  34711. * Initializes the behavior.
  34712. */
  34713. init(): void;
  34714. /**
  34715. * Attaches the behavior to its arc rotate camera.
  34716. * @param camera Defines the camera to attach the behavior to
  34717. */
  34718. attach(camera: ArcRotateCamera): void;
  34719. /**
  34720. * Detaches the behavior from its current arc rotate camera.
  34721. */
  34722. detach(): void;
  34723. private _radiusIsAnimating;
  34724. private _radiusBounceTransition;
  34725. private _animatables;
  34726. private _cachedWheelPrecision;
  34727. /**
  34728. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34729. * @param radiusLimit The limit to check against.
  34730. * @return Bool to indicate if at limit.
  34731. */
  34732. private _isRadiusAtLimit;
  34733. /**
  34734. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34735. * @param radiusDelta The delta by which to animate to. Can be negative.
  34736. */
  34737. private _applyBoundRadiusAnimation;
  34738. /**
  34739. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34740. */
  34741. protected _clearAnimationLocks(): void;
  34742. /**
  34743. * Stops and removes all animations that have been applied to the camera
  34744. */
  34745. stopAllAnimations(): void;
  34746. }
  34747. }
  34748. declare module BABYLON {
  34749. /**
  34750. * 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.
  34751. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34752. */
  34753. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34754. /**
  34755. * Gets the name of the behavior.
  34756. */
  34757. readonly name: string;
  34758. private _mode;
  34759. private _radiusScale;
  34760. private _positionScale;
  34761. private _defaultElevation;
  34762. private _elevationReturnTime;
  34763. private _elevationReturnWaitTime;
  34764. private _zoomStopsAnimation;
  34765. private _framingTime;
  34766. /**
  34767. * The easing function used by animations
  34768. */
  34769. static EasingFunction: ExponentialEase;
  34770. /**
  34771. * The easing mode used by animations
  34772. */
  34773. static EasingMode: number;
  34774. /**
  34775. * Sets the current mode used by the behavior
  34776. */
  34777. /**
  34778. * Gets current mode used by the behavior.
  34779. */
  34780. mode: number;
  34781. /**
  34782. * Sets the scale applied to the radius (1 by default)
  34783. */
  34784. /**
  34785. * Gets the scale applied to the radius
  34786. */
  34787. radiusScale: number;
  34788. /**
  34789. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34790. */
  34791. /**
  34792. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34793. */
  34794. positionScale: number;
  34795. /**
  34796. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34797. * behaviour is triggered, in radians.
  34798. */
  34799. /**
  34800. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34801. * behaviour is triggered, in radians.
  34802. */
  34803. defaultElevation: number;
  34804. /**
  34805. * Sets the time (in milliseconds) taken to return to the default beta position.
  34806. * Negative value indicates camera should not return to default.
  34807. */
  34808. /**
  34809. * Gets the time (in milliseconds) taken to return to the default beta position.
  34810. * Negative value indicates camera should not return to default.
  34811. */
  34812. elevationReturnTime: number;
  34813. /**
  34814. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34815. */
  34816. /**
  34817. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34818. */
  34819. elevationReturnWaitTime: number;
  34820. /**
  34821. * Sets the flag that indicates if user zooming should stop animation.
  34822. */
  34823. /**
  34824. * Gets the flag that indicates if user zooming should stop animation.
  34825. */
  34826. zoomStopsAnimation: boolean;
  34827. /**
  34828. * Sets the transition time when framing the mesh, in milliseconds
  34829. */
  34830. /**
  34831. * Gets the transition time when framing the mesh, in milliseconds
  34832. */
  34833. framingTime: number;
  34834. /**
  34835. * Define if the behavior should automatically change the configured
  34836. * camera limits and sensibilities.
  34837. */
  34838. autoCorrectCameraLimitsAndSensibility: boolean;
  34839. private _onPrePointerObservableObserver;
  34840. private _onAfterCheckInputsObserver;
  34841. private _onMeshTargetChangedObserver;
  34842. private _attachedCamera;
  34843. private _isPointerDown;
  34844. private _lastInteractionTime;
  34845. /**
  34846. * Initializes the behavior.
  34847. */
  34848. init(): void;
  34849. /**
  34850. * Attaches the behavior to its arc rotate camera.
  34851. * @param camera Defines the camera to attach the behavior to
  34852. */
  34853. attach(camera: ArcRotateCamera): void;
  34854. /**
  34855. * Detaches the behavior from its current arc rotate camera.
  34856. */
  34857. detach(): void;
  34858. private _animatables;
  34859. private _betaIsAnimating;
  34860. private _betaTransition;
  34861. private _radiusTransition;
  34862. private _vectorTransition;
  34863. /**
  34864. * Targets the given mesh and updates zoom level accordingly.
  34865. * @param mesh The mesh to target.
  34866. * @param radius Optional. If a cached radius position already exists, overrides default.
  34867. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34868. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34869. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34870. */
  34871. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34872. /**
  34873. * Targets the given mesh with its children and updates zoom level accordingly.
  34874. * @param mesh The mesh to target.
  34875. * @param radius Optional. If a cached radius position already exists, overrides default.
  34876. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34877. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34878. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34879. */
  34880. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34881. /**
  34882. * Targets the given meshes with their children and updates zoom level accordingly.
  34883. * @param meshes The mesh to target.
  34884. * @param radius Optional. If a cached radius position already exists, overrides default.
  34885. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34886. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34887. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34888. */
  34889. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34890. /**
  34891. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34892. * @param minimumWorld Determines the smaller position of the bounding box extend
  34893. * @param maximumWorld Determines the bigger position of the bounding box extend
  34894. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34895. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34896. */
  34897. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34898. /**
  34899. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34900. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34901. * frustum width.
  34902. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34903. * to fully enclose the mesh in the viewing frustum.
  34904. */
  34905. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34906. /**
  34907. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34908. * is automatically returned to its default position (expected to be above ground plane).
  34909. */
  34910. private _maintainCameraAboveGround;
  34911. /**
  34912. * Returns the frustum slope based on the canvas ratio and camera FOV
  34913. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34914. */
  34915. private _getFrustumSlope;
  34916. /**
  34917. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34918. */
  34919. private _clearAnimationLocks;
  34920. /**
  34921. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34922. */
  34923. private _applyUserInteraction;
  34924. /**
  34925. * Stops and removes all animations that have been applied to the camera
  34926. */
  34927. stopAllAnimations(): void;
  34928. /**
  34929. * Gets a value indicating if the user is moving the camera
  34930. */
  34931. readonly isUserIsMoving: boolean;
  34932. /**
  34933. * The camera can move all the way towards the mesh.
  34934. */
  34935. static IgnoreBoundsSizeMode: number;
  34936. /**
  34937. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34938. */
  34939. static FitFrustumSidesMode: number;
  34940. }
  34941. }
  34942. declare module BABYLON {
  34943. /**
  34944. * Base class for Camera Pointer Inputs.
  34945. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34946. * for example usage.
  34947. */
  34948. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34949. /**
  34950. * Defines the camera the input is attached to.
  34951. */
  34952. abstract camera: Camera;
  34953. /**
  34954. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34955. */
  34956. protected _altKey: boolean;
  34957. protected _ctrlKey: boolean;
  34958. protected _metaKey: boolean;
  34959. protected _shiftKey: boolean;
  34960. /**
  34961. * Which mouse buttons were pressed at time of last mouse event.
  34962. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34963. */
  34964. protected _buttonsPressed: number;
  34965. /**
  34966. * Defines the buttons associated with the input to handle camera move.
  34967. */
  34968. buttons: number[];
  34969. /**
  34970. * Attach the input controls to a specific dom element to get the input from.
  34971. * @param element Defines the element the controls should be listened from
  34972. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34973. */
  34974. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34975. /**
  34976. * Detach the current controls from the specified dom element.
  34977. * @param element Defines the element to stop listening the inputs from
  34978. */
  34979. detachControl(element: Nullable<HTMLElement>): void;
  34980. /**
  34981. * Gets the class name of the current input.
  34982. * @returns the class name
  34983. */
  34984. getClassName(): string;
  34985. /**
  34986. * Get the friendly name associated with the input class.
  34987. * @returns the input friendly name
  34988. */
  34989. getSimpleName(): string;
  34990. /**
  34991. * Called on pointer POINTERDOUBLETAP event.
  34992. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34993. */
  34994. protected onDoubleTap(type: string): void;
  34995. /**
  34996. * Called on pointer POINTERMOVE event if only a single touch is active.
  34997. * Override this method to provide functionality.
  34998. */
  34999. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35000. /**
  35001. * Called on pointer POINTERMOVE event if multiple touches are active.
  35002. * Override this method to provide functionality.
  35003. */
  35004. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35005. /**
  35006. * Called on JS contextmenu event.
  35007. * Override this method to provide functionality.
  35008. */
  35009. protected onContextMenu(evt: PointerEvent): void;
  35010. /**
  35011. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35012. * press.
  35013. * Override this method to provide functionality.
  35014. */
  35015. protected onButtonDown(evt: PointerEvent): void;
  35016. /**
  35017. * Called each time a new POINTERUP event occurs. Ie, for each button
  35018. * release.
  35019. * Override this method to provide functionality.
  35020. */
  35021. protected onButtonUp(evt: PointerEvent): void;
  35022. /**
  35023. * Called when window becomes inactive.
  35024. * Override this method to provide functionality.
  35025. */
  35026. protected onLostFocus(): void;
  35027. private _pointerInput;
  35028. private _observer;
  35029. private _onLostFocus;
  35030. private pointA;
  35031. private pointB;
  35032. }
  35033. }
  35034. declare module BABYLON {
  35035. /**
  35036. * Manage the pointers inputs to control an arc rotate camera.
  35037. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35038. */
  35039. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35040. /**
  35041. * Defines the camera the input is attached to.
  35042. */
  35043. camera: ArcRotateCamera;
  35044. /**
  35045. * Gets the class name of the current input.
  35046. * @returns the class name
  35047. */
  35048. getClassName(): string;
  35049. /**
  35050. * Defines the buttons associated with the input to handle camera move.
  35051. */
  35052. buttons: number[];
  35053. /**
  35054. * Defines the pointer angular sensibility along the X axis or how fast is
  35055. * the camera rotating.
  35056. */
  35057. angularSensibilityX: number;
  35058. /**
  35059. * Defines the pointer angular sensibility along the Y axis or how fast is
  35060. * the camera rotating.
  35061. */
  35062. angularSensibilityY: number;
  35063. /**
  35064. * Defines the pointer pinch precision or how fast is the camera zooming.
  35065. */
  35066. pinchPrecision: number;
  35067. /**
  35068. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35069. * from 0.
  35070. * It defines the percentage of current camera.radius to use as delta when
  35071. * pinch zoom is used.
  35072. */
  35073. pinchDeltaPercentage: number;
  35074. /**
  35075. * Defines the pointer panning sensibility or how fast is the camera moving.
  35076. */
  35077. panningSensibility: number;
  35078. /**
  35079. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35080. */
  35081. multiTouchPanning: boolean;
  35082. /**
  35083. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35084. * zoom (pinch) through multitouch.
  35085. */
  35086. multiTouchPanAndZoom: boolean;
  35087. /**
  35088. * Revers pinch action direction.
  35089. */
  35090. pinchInwards: boolean;
  35091. private _isPanClick;
  35092. private _twoFingerActivityCount;
  35093. private _isPinching;
  35094. /**
  35095. * Called on pointer POINTERMOVE event if only a single touch is active.
  35096. */
  35097. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35098. /**
  35099. * Called on pointer POINTERDOUBLETAP event.
  35100. */
  35101. protected onDoubleTap(type: string): void;
  35102. /**
  35103. * Called on pointer POINTERMOVE event if multiple touches are active.
  35104. */
  35105. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35106. /**
  35107. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35108. * press.
  35109. */
  35110. protected onButtonDown(evt: PointerEvent): void;
  35111. /**
  35112. * Called each time a new POINTERUP event occurs. Ie, for each button
  35113. * release.
  35114. */
  35115. protected onButtonUp(evt: PointerEvent): void;
  35116. /**
  35117. * Called when window becomes inactive.
  35118. */
  35119. protected onLostFocus(): void;
  35120. }
  35121. }
  35122. declare module BABYLON {
  35123. /**
  35124. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35125. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35126. */
  35127. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35128. /**
  35129. * Defines the camera the input is attached to.
  35130. */
  35131. camera: ArcRotateCamera;
  35132. /**
  35133. * Defines the list of key codes associated with the up action (increase alpha)
  35134. */
  35135. keysUp: number[];
  35136. /**
  35137. * Defines the list of key codes associated with the down action (decrease alpha)
  35138. */
  35139. keysDown: number[];
  35140. /**
  35141. * Defines the list of key codes associated with the left action (increase beta)
  35142. */
  35143. keysLeft: number[];
  35144. /**
  35145. * Defines the list of key codes associated with the right action (decrease beta)
  35146. */
  35147. keysRight: number[];
  35148. /**
  35149. * Defines the list of key codes associated with the reset action.
  35150. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35151. */
  35152. keysReset: number[];
  35153. /**
  35154. * Defines the panning sensibility of the inputs.
  35155. * (How fast is the camera paning)
  35156. */
  35157. panningSensibility: number;
  35158. /**
  35159. * Defines the zooming sensibility of the inputs.
  35160. * (How fast is the camera zooming)
  35161. */
  35162. zoomingSensibility: number;
  35163. /**
  35164. * Defines wether maintaining the alt key down switch the movement mode from
  35165. * orientation to zoom.
  35166. */
  35167. useAltToZoom: boolean;
  35168. /**
  35169. * Rotation speed of the camera
  35170. */
  35171. angularSpeed: number;
  35172. private _keys;
  35173. private _ctrlPressed;
  35174. private _altPressed;
  35175. private _onCanvasBlurObserver;
  35176. private _onKeyboardObserver;
  35177. private _engine;
  35178. private _scene;
  35179. /**
  35180. * Attach the input controls to a specific dom element to get the input from.
  35181. * @param element Defines the element the controls should be listened from
  35182. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35183. */
  35184. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35185. /**
  35186. * Detach the current controls from the specified dom element.
  35187. * @param element Defines the element to stop listening the inputs from
  35188. */
  35189. detachControl(element: Nullable<HTMLElement>): void;
  35190. /**
  35191. * Update the current camera state depending on the inputs that have been used this frame.
  35192. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35193. */
  35194. checkInputs(): void;
  35195. /**
  35196. * Gets the class name of the current intput.
  35197. * @returns the class name
  35198. */
  35199. getClassName(): string;
  35200. /**
  35201. * Get the friendly name associated with the input class.
  35202. * @returns the input friendly name
  35203. */
  35204. getSimpleName(): string;
  35205. }
  35206. }
  35207. declare module BABYLON {
  35208. /**
  35209. * Manage the mouse wheel inputs to control an arc rotate camera.
  35210. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35211. */
  35212. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35213. /**
  35214. * Defines the camera the input is attached to.
  35215. */
  35216. camera: ArcRotateCamera;
  35217. /**
  35218. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35219. */
  35220. wheelPrecision: number;
  35221. /**
  35222. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35223. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35224. */
  35225. wheelDeltaPercentage: number;
  35226. private _wheel;
  35227. private _observer;
  35228. private computeDeltaFromMouseWheelLegacyEvent;
  35229. /**
  35230. * Attach the input controls to a specific dom element to get the input from.
  35231. * @param element Defines the element the controls should be listened from
  35232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35233. */
  35234. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35235. /**
  35236. * Detach the current controls from the specified dom element.
  35237. * @param element Defines the element to stop listening the inputs from
  35238. */
  35239. detachControl(element: Nullable<HTMLElement>): void;
  35240. /**
  35241. * Gets the class name of the current intput.
  35242. * @returns the class name
  35243. */
  35244. getClassName(): string;
  35245. /**
  35246. * Get the friendly name associated with the input class.
  35247. * @returns the input friendly name
  35248. */
  35249. getSimpleName(): string;
  35250. }
  35251. }
  35252. declare module BABYLON {
  35253. /**
  35254. * Default Inputs manager for the ArcRotateCamera.
  35255. * It groups all the default supported inputs for ease of use.
  35256. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35257. */
  35258. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35259. /**
  35260. * Instantiates a new ArcRotateCameraInputsManager.
  35261. * @param camera Defines the camera the inputs belong to
  35262. */
  35263. constructor(camera: ArcRotateCamera);
  35264. /**
  35265. * Add mouse wheel input support to the input manager.
  35266. * @returns the current input manager
  35267. */
  35268. addMouseWheel(): ArcRotateCameraInputsManager;
  35269. /**
  35270. * Add pointers input support to the input manager.
  35271. * @returns the current input manager
  35272. */
  35273. addPointers(): ArcRotateCameraInputsManager;
  35274. /**
  35275. * Add keyboard input support to the input manager.
  35276. * @returns the current input manager
  35277. */
  35278. addKeyboard(): ArcRotateCameraInputsManager;
  35279. }
  35280. }
  35281. declare module BABYLON {
  35282. /**
  35283. * This represents an orbital type of camera.
  35284. *
  35285. * 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.
  35286. * 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.
  35287. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35288. */
  35289. export class ArcRotateCamera extends TargetCamera {
  35290. /**
  35291. * Defines the rotation angle of the camera along the longitudinal axis.
  35292. */
  35293. alpha: number;
  35294. /**
  35295. * Defines the rotation angle of the camera along the latitudinal axis.
  35296. */
  35297. beta: number;
  35298. /**
  35299. * Defines the radius of the camera from it s target point.
  35300. */
  35301. radius: number;
  35302. protected _target: Vector3;
  35303. protected _targetHost: Nullable<AbstractMesh>;
  35304. /**
  35305. * Defines the target point of the camera.
  35306. * The camera looks towards it form the radius distance.
  35307. */
  35308. target: Vector3;
  35309. /**
  35310. * Define the current local position of the camera in the scene
  35311. */
  35312. position: Vector3;
  35313. protected _upVector: Vector3;
  35314. protected _upToYMatrix: Matrix;
  35315. protected _YToUpMatrix: Matrix;
  35316. /**
  35317. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35318. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35319. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35320. */
  35321. upVector: Vector3;
  35322. /**
  35323. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35324. */
  35325. setMatUp(): void;
  35326. /**
  35327. * Current inertia value on the longitudinal axis.
  35328. * The bigger this number the longer it will take for the camera to stop.
  35329. */
  35330. inertialAlphaOffset: number;
  35331. /**
  35332. * Current inertia value on the latitudinal axis.
  35333. * The bigger this number the longer it will take for the camera to stop.
  35334. */
  35335. inertialBetaOffset: number;
  35336. /**
  35337. * Current inertia value on the radius axis.
  35338. * The bigger this number the longer it will take for the camera to stop.
  35339. */
  35340. inertialRadiusOffset: number;
  35341. /**
  35342. * Minimum allowed angle on the longitudinal axis.
  35343. * This can help limiting how the Camera is able to move in the scene.
  35344. */
  35345. lowerAlphaLimit: Nullable<number>;
  35346. /**
  35347. * Maximum allowed angle on the longitudinal axis.
  35348. * This can help limiting how the Camera is able to move in the scene.
  35349. */
  35350. upperAlphaLimit: Nullable<number>;
  35351. /**
  35352. * Minimum allowed angle on the latitudinal axis.
  35353. * This can help limiting how the Camera is able to move in the scene.
  35354. */
  35355. lowerBetaLimit: number;
  35356. /**
  35357. * Maximum allowed angle on the latitudinal axis.
  35358. * This can help limiting how the Camera is able to move in the scene.
  35359. */
  35360. upperBetaLimit: number;
  35361. /**
  35362. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35363. * This can help limiting how the Camera is able to move in the scene.
  35364. */
  35365. lowerRadiusLimit: Nullable<number>;
  35366. /**
  35367. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35368. * This can help limiting how the Camera is able to move in the scene.
  35369. */
  35370. upperRadiusLimit: Nullable<number>;
  35371. /**
  35372. * Defines the current inertia value used during panning of the camera along the X axis.
  35373. */
  35374. inertialPanningX: number;
  35375. /**
  35376. * Defines the current inertia value used during panning of the camera along the Y axis.
  35377. */
  35378. inertialPanningY: number;
  35379. /**
  35380. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35381. * Basically if your fingers moves away from more than this distance you will be considered
  35382. * in pinch mode.
  35383. */
  35384. pinchToPanMaxDistance: number;
  35385. /**
  35386. * Defines the maximum distance the camera can pan.
  35387. * This could help keeping the cammera always in your scene.
  35388. */
  35389. panningDistanceLimit: Nullable<number>;
  35390. /**
  35391. * Defines the target of the camera before paning.
  35392. */
  35393. panningOriginTarget: Vector3;
  35394. /**
  35395. * Defines the value of the inertia used during panning.
  35396. * 0 would mean stop inertia and one would mean no decelleration at all.
  35397. */
  35398. panningInertia: number;
  35399. /**
  35400. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35401. */
  35402. angularSensibilityX: number;
  35403. /**
  35404. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35405. */
  35406. angularSensibilityY: number;
  35407. /**
  35408. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35409. */
  35410. pinchPrecision: number;
  35411. /**
  35412. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35413. * It will be used instead of pinchDeltaPrecision if different from 0.
  35414. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35415. */
  35416. pinchDeltaPercentage: number;
  35417. /**
  35418. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35419. */
  35420. panningSensibility: number;
  35421. /**
  35422. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35423. */
  35424. keysUp: number[];
  35425. /**
  35426. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35427. */
  35428. keysDown: number[];
  35429. /**
  35430. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35431. */
  35432. keysLeft: number[];
  35433. /**
  35434. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35435. */
  35436. keysRight: number[];
  35437. /**
  35438. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35439. */
  35440. wheelPrecision: number;
  35441. /**
  35442. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35443. * It will be used instead of pinchDeltaPrecision if different from 0.
  35444. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35445. */
  35446. wheelDeltaPercentage: number;
  35447. /**
  35448. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35449. */
  35450. zoomOnFactor: number;
  35451. /**
  35452. * Defines a screen offset for the camera position.
  35453. */
  35454. targetScreenOffset: Vector2;
  35455. /**
  35456. * Allows the camera to be completely reversed.
  35457. * If false the camera can not arrive upside down.
  35458. */
  35459. allowUpsideDown: boolean;
  35460. /**
  35461. * Define if double tap/click is used to restore the previously saved state of the camera.
  35462. */
  35463. useInputToRestoreState: boolean;
  35464. /** @hidden */ private _viewMatrix: Matrix;
  35465. /** @hidden */ private _useCtrlForPanning: boolean;
  35466. /** @hidden */ private _panningMouseButton: number;
  35467. /**
  35468. * Defines the input associated to the camera.
  35469. */
  35470. inputs: ArcRotateCameraInputsManager;
  35471. /** @hidden */ private _reset: () => void;
  35472. /**
  35473. * Defines the allowed panning axis.
  35474. */
  35475. panningAxis: Vector3;
  35476. protected _localDirection: Vector3;
  35477. protected _transformedDirection: Vector3;
  35478. private _bouncingBehavior;
  35479. /**
  35480. * Gets the bouncing behavior of the camera if it has been enabled.
  35481. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35482. */
  35483. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35484. /**
  35485. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35486. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35487. */
  35488. useBouncingBehavior: boolean;
  35489. private _framingBehavior;
  35490. /**
  35491. * Gets the framing behavior of the camera if it has been enabled.
  35492. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35493. */
  35494. readonly framingBehavior: Nullable<FramingBehavior>;
  35495. /**
  35496. * Defines if the framing behavior of the camera is enabled on the camera.
  35497. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35498. */
  35499. useFramingBehavior: boolean;
  35500. private _autoRotationBehavior;
  35501. /**
  35502. * Gets the auto rotation behavior of the camera if it has been enabled.
  35503. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35504. */
  35505. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35506. /**
  35507. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35508. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35509. */
  35510. useAutoRotationBehavior: boolean;
  35511. /**
  35512. * Observable triggered when the mesh target has been changed on the camera.
  35513. */
  35514. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35515. /**
  35516. * Event raised when the camera is colliding with a mesh.
  35517. */
  35518. onCollide: (collidedMesh: AbstractMesh) => void;
  35519. /**
  35520. * Defines whether the camera should check collision with the objects oh the scene.
  35521. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35522. */
  35523. checkCollisions: boolean;
  35524. /**
  35525. * Defines the collision radius of the camera.
  35526. * This simulates a sphere around the camera.
  35527. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35528. */
  35529. collisionRadius: Vector3;
  35530. protected _collider: Collider;
  35531. protected _previousPosition: Vector3;
  35532. protected _collisionVelocity: Vector3;
  35533. protected _newPosition: Vector3;
  35534. protected _previousAlpha: number;
  35535. protected _previousBeta: number;
  35536. protected _previousRadius: number;
  35537. protected _collisionTriggered: boolean;
  35538. protected _targetBoundingCenter: Nullable<Vector3>;
  35539. private _computationVector;
  35540. /**
  35541. * Instantiates a new ArcRotateCamera in a given scene
  35542. * @param name Defines the name of the camera
  35543. * @param alpha Defines the camera rotation along the logitudinal axis
  35544. * @param beta Defines the camera rotation along the latitudinal axis
  35545. * @param radius Defines the camera distance from its target
  35546. * @param target Defines the camera target
  35547. * @param scene Defines the scene the camera belongs to
  35548. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35549. */
  35550. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35551. /** @hidden */ private _initCache(): void;
  35552. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  35553. protected _getTargetPosition(): Vector3;
  35554. private _storedAlpha;
  35555. private _storedBeta;
  35556. private _storedRadius;
  35557. private _storedTarget;
  35558. private _storedTargetScreenOffset;
  35559. /**
  35560. * Stores the current state of the camera (alpha, beta, radius and target)
  35561. * @returns the camera itself
  35562. */
  35563. storeState(): Camera;
  35564. /**
  35565. * @hidden
  35566. * Restored camera state. You must call storeState() first
  35567. */ private _restoreStateValues(): boolean;
  35568. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  35569. /**
  35570. * Attached controls to the current camera.
  35571. * @param element Defines the element the controls should be listened from
  35572. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35573. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35574. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35575. */
  35576. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35577. /**
  35578. * Detach the current controls from the camera.
  35579. * The camera will stop reacting to inputs.
  35580. * @param element Defines the element to stop listening the inputs from
  35581. */
  35582. detachControl(element: HTMLElement): void;
  35583. /** @hidden */ private _checkInputs(): void;
  35584. protected _checkLimits(): void;
  35585. /**
  35586. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35587. */
  35588. rebuildAnglesAndRadius(): void;
  35589. /**
  35590. * Use a position to define the current camera related information like aplha, beta and radius
  35591. * @param position Defines the position to set the camera at
  35592. */
  35593. setPosition(position: Vector3): void;
  35594. /**
  35595. * Defines the target the camera should look at.
  35596. * This will automatically adapt alpha beta and radius to fit within the new target.
  35597. * @param target Defines the new target as a Vector or a mesh
  35598. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35599. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35600. */
  35601. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35602. /** @hidden */ private _getViewMatrix(): Matrix;
  35603. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35604. /**
  35605. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35606. * @param meshes Defines the mesh to zoom on
  35607. * @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)
  35608. */
  35609. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35610. /**
  35611. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35612. * The target will be changed but the radius
  35613. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35614. * @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)
  35615. */
  35616. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35617. min: Vector3;
  35618. max: Vector3;
  35619. distance: number;
  35620. }, doNotUpdateMaxZ?: boolean): void;
  35621. /**
  35622. * @override
  35623. * Override Camera.createRigCamera
  35624. */
  35625. createRigCamera(name: string, cameraIndex: number): Camera;
  35626. /**
  35627. * @hidden
  35628. * @override
  35629. * Override Camera._updateRigCameras
  35630. */ private _updateRigCameras(): void;
  35631. /**
  35632. * Destroy the camera and release the current resources hold by it.
  35633. */
  35634. dispose(): void;
  35635. /**
  35636. * Gets the current object class name.
  35637. * @return the class name
  35638. */
  35639. getClassName(): string;
  35640. }
  35641. }
  35642. declare module BABYLON {
  35643. /**
  35644. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35645. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35646. */
  35647. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35648. /**
  35649. * Gets the name of the behavior.
  35650. */
  35651. readonly name: string;
  35652. private _zoomStopsAnimation;
  35653. private _idleRotationSpeed;
  35654. private _idleRotationWaitTime;
  35655. private _idleRotationSpinupTime;
  35656. /**
  35657. * Sets the flag that indicates if user zooming should stop animation.
  35658. */
  35659. /**
  35660. * Gets the flag that indicates if user zooming should stop animation.
  35661. */
  35662. zoomStopsAnimation: boolean;
  35663. /**
  35664. * Sets the default speed at which the camera rotates around the model.
  35665. */
  35666. /**
  35667. * Gets the default speed at which the camera rotates around the model.
  35668. */
  35669. idleRotationSpeed: number;
  35670. /**
  35671. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35672. */
  35673. /**
  35674. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35675. */
  35676. idleRotationWaitTime: number;
  35677. /**
  35678. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35679. */
  35680. /**
  35681. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35682. */
  35683. idleRotationSpinupTime: number;
  35684. /**
  35685. * Gets a value indicating if the camera is currently rotating because of this behavior
  35686. */
  35687. readonly rotationInProgress: boolean;
  35688. private _onPrePointerObservableObserver;
  35689. private _onAfterCheckInputsObserver;
  35690. private _attachedCamera;
  35691. private _isPointerDown;
  35692. private _lastFrameTime;
  35693. private _lastInteractionTime;
  35694. private _cameraRotationSpeed;
  35695. /**
  35696. * Initializes the behavior.
  35697. */
  35698. init(): void;
  35699. /**
  35700. * Attaches the behavior to its arc rotate camera.
  35701. * @param camera Defines the camera to attach the behavior to
  35702. */
  35703. attach(camera: ArcRotateCamera): void;
  35704. /**
  35705. * Detaches the behavior from its current arc rotate camera.
  35706. */
  35707. detach(): void;
  35708. /**
  35709. * Returns true if user is scrolling.
  35710. * @return true if user is scrolling.
  35711. */
  35712. private _userIsZooming;
  35713. private _lastFrameRadius;
  35714. private _shouldAnimationStopForInteraction;
  35715. /**
  35716. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35717. */
  35718. private _applyUserInteraction;
  35719. private _userIsMoving;
  35720. }
  35721. }
  35722. declare module BABYLON {
  35723. /**
  35724. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35725. */
  35726. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35727. private ui;
  35728. /**
  35729. * The name of the behavior
  35730. */
  35731. name: string;
  35732. /**
  35733. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35734. */
  35735. distanceAwayFromFace: number;
  35736. /**
  35737. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35738. */
  35739. distanceAwayFromBottomOfFace: number;
  35740. private _faceVectors;
  35741. private _target;
  35742. private _scene;
  35743. private _onRenderObserver;
  35744. private _tmpMatrix;
  35745. private _tmpVector;
  35746. /**
  35747. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35748. * @param ui The transform node that should be attched to the mesh
  35749. */
  35750. constructor(ui: TransformNode);
  35751. /**
  35752. * Initializes the behavior
  35753. */
  35754. init(): void;
  35755. private _closestFace;
  35756. private _zeroVector;
  35757. private _lookAtTmpMatrix;
  35758. private _lookAtToRef;
  35759. /**
  35760. * Attaches the AttachToBoxBehavior to the passed in mesh
  35761. * @param target The mesh that the specified node will be attached to
  35762. */
  35763. attach(target: Mesh): void;
  35764. /**
  35765. * Detaches the behavior from the mesh
  35766. */
  35767. detach(): void;
  35768. }
  35769. }
  35770. declare module BABYLON {
  35771. /**
  35772. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35773. */
  35774. export class FadeInOutBehavior implements Behavior<Mesh> {
  35775. /**
  35776. * Time in milliseconds to delay before fading in (Default: 0)
  35777. */
  35778. delay: number;
  35779. /**
  35780. * Time in milliseconds for the mesh to fade in (Default: 300)
  35781. */
  35782. fadeInTime: number;
  35783. private _millisecondsPerFrame;
  35784. private _hovered;
  35785. private _hoverValue;
  35786. private _ownerNode;
  35787. /**
  35788. * Instatiates the FadeInOutBehavior
  35789. */
  35790. constructor();
  35791. /**
  35792. * The name of the behavior
  35793. */
  35794. readonly name: string;
  35795. /**
  35796. * Initializes the behavior
  35797. */
  35798. init(): void;
  35799. /**
  35800. * Attaches the fade behavior on the passed in mesh
  35801. * @param ownerNode The mesh that will be faded in/out once attached
  35802. */
  35803. attach(ownerNode: Mesh): void;
  35804. /**
  35805. * Detaches the behavior from the mesh
  35806. */
  35807. detach(): void;
  35808. /**
  35809. * Triggers the mesh to begin fading in or out
  35810. * @param value if the object should fade in or out (true to fade in)
  35811. */
  35812. fadeIn(value: boolean): void;
  35813. private _update;
  35814. private _setAllVisibility;
  35815. }
  35816. }
  35817. declare module BABYLON {
  35818. /**
  35819. * Class containing a set of static utilities functions for managing Pivots
  35820. * @hidden
  35821. */
  35822. export class PivotTools {
  35823. private static _PivotCached;
  35824. private static _OldPivotPoint;
  35825. private static _PivotTranslation;
  35826. private static _PivotTmpVector;
  35827. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35828. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  35829. }
  35830. }
  35831. declare module BABYLON {
  35832. /**
  35833. * Class containing static functions to help procedurally build meshes
  35834. */
  35835. export class PlaneBuilder {
  35836. /**
  35837. * Creates a plane mesh
  35838. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35839. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35840. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35842. * * 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
  35843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35844. * @param name defines the name of the mesh
  35845. * @param options defines the options used to create the mesh
  35846. * @param scene defines the hosting scene
  35847. * @returns the plane mesh
  35848. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35849. */
  35850. static CreatePlane(name: string, options: {
  35851. size?: number;
  35852. width?: number;
  35853. height?: number;
  35854. sideOrientation?: number;
  35855. frontUVs?: Vector4;
  35856. backUVs?: Vector4;
  35857. updatable?: boolean;
  35858. sourcePlane?: Plane;
  35859. }, scene?: Nullable<Scene>): Mesh;
  35860. }
  35861. }
  35862. declare module BABYLON {
  35863. /**
  35864. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35865. */
  35866. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35867. private static _AnyMouseID;
  35868. /**
  35869. * Abstract mesh the behavior is set on
  35870. */
  35871. attachedNode: AbstractMesh;
  35872. private _dragPlane;
  35873. private _scene;
  35874. private _pointerObserver;
  35875. private _beforeRenderObserver;
  35876. private static _planeScene;
  35877. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35878. /**
  35879. * 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)
  35880. */
  35881. maxDragAngle: number;
  35882. /**
  35883. * @hidden
  35884. */ private _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35885. /**
  35886. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35887. */
  35888. currentDraggingPointerID: number;
  35889. /**
  35890. * The last position where the pointer hit the drag plane in world space
  35891. */
  35892. lastDragPosition: Vector3;
  35893. /**
  35894. * If the behavior is currently in a dragging state
  35895. */
  35896. dragging: boolean;
  35897. /**
  35898. * 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)
  35899. */
  35900. dragDeltaRatio: number;
  35901. /**
  35902. * If the drag plane orientation should be updated during the dragging (Default: true)
  35903. */
  35904. updateDragPlane: boolean;
  35905. private _debugMode;
  35906. private _moving;
  35907. /**
  35908. * Fires each time the attached mesh is dragged with the pointer
  35909. * * delta between last drag position and current drag position in world space
  35910. * * dragDistance along the drag axis
  35911. * * dragPlaneNormal normal of the current drag plane used during the drag
  35912. * * dragPlanePoint in world space where the drag intersects the drag plane
  35913. */
  35914. onDragObservable: Observable<{
  35915. delta: Vector3;
  35916. dragPlanePoint: Vector3;
  35917. dragPlaneNormal: Vector3;
  35918. dragDistance: number;
  35919. pointerId: number;
  35920. }>;
  35921. /**
  35922. * Fires each time a drag begins (eg. mouse down on mesh)
  35923. */
  35924. onDragStartObservable: Observable<{
  35925. dragPlanePoint: Vector3;
  35926. pointerId: number;
  35927. }>;
  35928. /**
  35929. * Fires each time a drag ends (eg. mouse release after drag)
  35930. */
  35931. onDragEndObservable: Observable<{
  35932. dragPlanePoint: Vector3;
  35933. pointerId: number;
  35934. }>;
  35935. /**
  35936. * If the attached mesh should be moved when dragged
  35937. */
  35938. moveAttached: boolean;
  35939. /**
  35940. * If the drag behavior will react to drag events (Default: true)
  35941. */
  35942. enabled: boolean;
  35943. /**
  35944. * If pointer events should start and release the drag (Default: true)
  35945. */
  35946. startAndReleaseDragOnPointerEvents: boolean;
  35947. /**
  35948. * If camera controls should be detached during the drag
  35949. */
  35950. detachCameraControls: boolean;
  35951. /**
  35952. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35953. */
  35954. useObjectOrienationForDragging: boolean;
  35955. private _options;
  35956. /**
  35957. * Creates a pointer drag behavior that can be attached to a mesh
  35958. * @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)
  35959. */
  35960. constructor(options?: {
  35961. dragAxis?: Vector3;
  35962. dragPlaneNormal?: Vector3;
  35963. });
  35964. /**
  35965. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35966. */
  35967. validateDrag: (targetPosition: Vector3) => boolean;
  35968. /**
  35969. * The name of the behavior
  35970. */
  35971. readonly name: string;
  35972. /**
  35973. * Initializes the behavior
  35974. */
  35975. init(): void;
  35976. private _tmpVector;
  35977. private _alternatePickedPoint;
  35978. private _worldDragAxis;
  35979. private _targetPosition;
  35980. private _attachedElement;
  35981. /**
  35982. * Attaches the drag behavior the passed in mesh
  35983. * @param ownerNode The mesh that will be dragged around once attached
  35984. * @param predicate Predicate to use for pick filtering
  35985. */
  35986. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  35987. /**
  35988. * Force relase the drag action by code.
  35989. */
  35990. releaseDrag(): void;
  35991. private _startDragRay;
  35992. private _lastPointerRay;
  35993. /**
  35994. * Simulates the start of a pointer drag event on the behavior
  35995. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35996. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35997. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35998. */
  35999. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36000. private _startDrag;
  36001. private _dragDelta;
  36002. private _moveDrag;
  36003. private _pickWithRayOnDragPlane;
  36004. private _pointA;
  36005. private _pointB;
  36006. private _pointC;
  36007. private _lineA;
  36008. private _lineB;
  36009. private _localAxis;
  36010. private _lookAt;
  36011. private _updateDragPlanePosition;
  36012. /**
  36013. * Detaches the behavior from the mesh
  36014. */
  36015. detach(): void;
  36016. }
  36017. }
  36018. declare module BABYLON {
  36019. /**
  36020. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36021. */
  36022. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36023. private _dragBehaviorA;
  36024. private _dragBehaviorB;
  36025. private _startDistance;
  36026. private _initialScale;
  36027. private _targetScale;
  36028. private _ownerNode;
  36029. private _sceneRenderObserver;
  36030. /**
  36031. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36032. */
  36033. constructor();
  36034. /**
  36035. * The name of the behavior
  36036. */
  36037. readonly name: string;
  36038. /**
  36039. * Initializes the behavior
  36040. */
  36041. init(): void;
  36042. private _getCurrentDistance;
  36043. /**
  36044. * Attaches the scale behavior the passed in mesh
  36045. * @param ownerNode The mesh that will be scaled around once attached
  36046. */
  36047. attach(ownerNode: Mesh): void;
  36048. /**
  36049. * Detaches the behavior from the mesh
  36050. */
  36051. detach(): void;
  36052. }
  36053. }
  36054. declare module BABYLON {
  36055. /**
  36056. * 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
  36057. */
  36058. export class SixDofDragBehavior implements Behavior<Mesh> {
  36059. private static _virtualScene;
  36060. private _ownerNode;
  36061. private _sceneRenderObserver;
  36062. private _scene;
  36063. private _targetPosition;
  36064. private _virtualOriginMesh;
  36065. private _virtualDragMesh;
  36066. private _pointerObserver;
  36067. private _moving;
  36068. private _startingOrientation;
  36069. /**
  36070. * 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)
  36071. */
  36072. private zDragFactor;
  36073. /**
  36074. * If the object should rotate to face the drag origin
  36075. */
  36076. rotateDraggedObject: boolean;
  36077. /**
  36078. * If the behavior is currently in a dragging state
  36079. */
  36080. dragging: boolean;
  36081. /**
  36082. * 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)
  36083. */
  36084. dragDeltaRatio: number;
  36085. /**
  36086. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36087. */
  36088. currentDraggingPointerID: number;
  36089. /**
  36090. * If camera controls should be detached during the drag
  36091. */
  36092. detachCameraControls: boolean;
  36093. /**
  36094. * Fires each time a drag starts
  36095. */
  36096. onDragStartObservable: Observable<{}>;
  36097. /**
  36098. * Fires each time a drag ends (eg. mouse release after drag)
  36099. */
  36100. onDragEndObservable: Observable<{}>;
  36101. /**
  36102. * 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
  36103. */
  36104. constructor();
  36105. /**
  36106. * The name of the behavior
  36107. */
  36108. readonly name: string;
  36109. /**
  36110. * Initializes the behavior
  36111. */
  36112. init(): void;
  36113. /**
  36114. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36115. */
  36116. private readonly _pointerCamera;
  36117. /**
  36118. * Attaches the scale behavior the passed in mesh
  36119. * @param ownerNode The mesh that will be scaled around once attached
  36120. */
  36121. attach(ownerNode: Mesh): void;
  36122. /**
  36123. * Detaches the behavior from the mesh
  36124. */
  36125. detach(): void;
  36126. }
  36127. }
  36128. declare module BABYLON {
  36129. /**
  36130. * Class used to apply inverse kinematics to bones
  36131. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36132. */
  36133. export class BoneIKController {
  36134. private static _tmpVecs;
  36135. private static _tmpQuat;
  36136. private static _tmpMats;
  36137. /**
  36138. * Gets or sets the target mesh
  36139. */
  36140. targetMesh: AbstractMesh;
  36141. /** Gets or sets the mesh used as pole */
  36142. poleTargetMesh: AbstractMesh;
  36143. /**
  36144. * Gets or sets the bone used as pole
  36145. */
  36146. poleTargetBone: Nullable<Bone>;
  36147. /**
  36148. * Gets or sets the target position
  36149. */
  36150. targetPosition: Vector3;
  36151. /**
  36152. * Gets or sets the pole target position
  36153. */
  36154. poleTargetPosition: Vector3;
  36155. /**
  36156. * Gets or sets the pole target local offset
  36157. */
  36158. poleTargetLocalOffset: Vector3;
  36159. /**
  36160. * Gets or sets the pole angle
  36161. */
  36162. poleAngle: number;
  36163. /**
  36164. * Gets or sets the mesh associated with the controller
  36165. */
  36166. mesh: AbstractMesh;
  36167. /**
  36168. * 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)
  36169. */
  36170. slerpAmount: number;
  36171. private _bone1Quat;
  36172. private _bone1Mat;
  36173. private _bone2Ang;
  36174. private _bone1;
  36175. private _bone2;
  36176. private _bone1Length;
  36177. private _bone2Length;
  36178. private _maxAngle;
  36179. private _maxReach;
  36180. private _rightHandedSystem;
  36181. private _bendAxis;
  36182. private _slerping;
  36183. private _adjustRoll;
  36184. /**
  36185. * Gets or sets maximum allowed angle
  36186. */
  36187. maxAngle: number;
  36188. /**
  36189. * Creates a new BoneIKController
  36190. * @param mesh defines the mesh to control
  36191. * @param bone defines the bone to control
  36192. * @param options defines options to set up the controller
  36193. */
  36194. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36195. targetMesh?: AbstractMesh;
  36196. poleTargetMesh?: AbstractMesh;
  36197. poleTargetBone?: Bone;
  36198. poleTargetLocalOffset?: Vector3;
  36199. poleAngle?: number;
  36200. bendAxis?: Vector3;
  36201. maxAngle?: number;
  36202. slerpAmount?: number;
  36203. });
  36204. private _setMaxAngle;
  36205. /**
  36206. * Force the controller to update the bones
  36207. */
  36208. update(): void;
  36209. }
  36210. }
  36211. declare module BABYLON {
  36212. /**
  36213. * Class used to make a bone look toward a point in space
  36214. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36215. */
  36216. export class BoneLookController {
  36217. private static _tmpVecs;
  36218. private static _tmpQuat;
  36219. private static _tmpMats;
  36220. /**
  36221. * The target Vector3 that the bone will look at
  36222. */
  36223. target: Vector3;
  36224. /**
  36225. * The mesh that the bone is attached to
  36226. */
  36227. mesh: AbstractMesh;
  36228. /**
  36229. * The bone that will be looking to the target
  36230. */
  36231. bone: Bone;
  36232. /**
  36233. * The up axis of the coordinate system that is used when the bone is rotated
  36234. */
  36235. upAxis: Vector3;
  36236. /**
  36237. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36238. */
  36239. upAxisSpace: Space;
  36240. /**
  36241. * Used to make an adjustment to the yaw of the bone
  36242. */
  36243. adjustYaw: number;
  36244. /**
  36245. * Used to make an adjustment to the pitch of the bone
  36246. */
  36247. adjustPitch: number;
  36248. /**
  36249. * Used to make an adjustment to the roll of the bone
  36250. */
  36251. adjustRoll: number;
  36252. /**
  36253. * 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)
  36254. */
  36255. slerpAmount: number;
  36256. private _minYaw;
  36257. private _maxYaw;
  36258. private _minPitch;
  36259. private _maxPitch;
  36260. private _minYawSin;
  36261. private _minYawCos;
  36262. private _maxYawSin;
  36263. private _maxYawCos;
  36264. private _midYawConstraint;
  36265. private _minPitchTan;
  36266. private _maxPitchTan;
  36267. private _boneQuat;
  36268. private _slerping;
  36269. private _transformYawPitch;
  36270. private _transformYawPitchInv;
  36271. private _firstFrameSkipped;
  36272. private _yawRange;
  36273. private _fowardAxis;
  36274. /**
  36275. * Gets or sets the minimum yaw angle that the bone can look to
  36276. */
  36277. minYaw: number;
  36278. /**
  36279. * Gets or sets the maximum yaw angle that the bone can look to
  36280. */
  36281. maxYaw: number;
  36282. /**
  36283. * Gets or sets the minimum pitch angle that the bone can look to
  36284. */
  36285. minPitch: number;
  36286. /**
  36287. * Gets or sets the maximum pitch angle that the bone can look to
  36288. */
  36289. maxPitch: number;
  36290. /**
  36291. * Create a BoneLookController
  36292. * @param mesh the mesh that the bone belongs to
  36293. * @param bone the bone that will be looking to the target
  36294. * @param target the target Vector3 to look at
  36295. * @param options optional settings:
  36296. * * maxYaw: the maximum angle the bone will yaw to
  36297. * * minYaw: the minimum angle the bone will yaw to
  36298. * * maxPitch: the maximum angle the bone will pitch to
  36299. * * minPitch: the minimum angle the bone will yaw to
  36300. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36301. * * upAxis: the up axis of the coordinate system
  36302. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36303. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36304. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36305. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36306. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36307. * * adjustRoll: used to make an adjustment to the roll of the bone
  36308. **/
  36309. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36310. maxYaw?: number;
  36311. minYaw?: number;
  36312. maxPitch?: number;
  36313. minPitch?: number;
  36314. slerpAmount?: number;
  36315. upAxis?: Vector3;
  36316. upAxisSpace?: Space;
  36317. yawAxis?: Vector3;
  36318. pitchAxis?: Vector3;
  36319. adjustYaw?: number;
  36320. adjustPitch?: number;
  36321. adjustRoll?: number;
  36322. });
  36323. /**
  36324. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36325. */
  36326. update(): void;
  36327. private _getAngleDiff;
  36328. private _getAngleBetween;
  36329. private _isAngleBetween;
  36330. }
  36331. }
  36332. declare module BABYLON {
  36333. /**
  36334. * Manage the gamepad inputs to control an arc rotate camera.
  36335. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36336. */
  36337. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36338. /**
  36339. * Defines the camera the input is attached to.
  36340. */
  36341. camera: ArcRotateCamera;
  36342. /**
  36343. * Defines the gamepad the input is gathering event from.
  36344. */
  36345. gamepad: Nullable<Gamepad>;
  36346. /**
  36347. * Defines the gamepad rotation sensiblity.
  36348. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36349. */
  36350. gamepadRotationSensibility: number;
  36351. /**
  36352. * Defines the gamepad move sensiblity.
  36353. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36354. */
  36355. gamepadMoveSensibility: number;
  36356. private _onGamepadConnectedObserver;
  36357. private _onGamepadDisconnectedObserver;
  36358. /**
  36359. * Attach the input controls to a specific dom element to get the input from.
  36360. * @param element Defines the element the controls should be listened from
  36361. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36362. */
  36363. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36364. /**
  36365. * Detach the current controls from the specified dom element.
  36366. * @param element Defines the element to stop listening the inputs from
  36367. */
  36368. detachControl(element: Nullable<HTMLElement>): void;
  36369. /**
  36370. * Update the current camera state depending on the inputs that have been used this frame.
  36371. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36372. */
  36373. checkInputs(): void;
  36374. /**
  36375. * Gets the class name of the current intput.
  36376. * @returns the class name
  36377. */
  36378. getClassName(): string;
  36379. /**
  36380. * Get the friendly name associated with the input class.
  36381. * @returns the input friendly name
  36382. */
  36383. getSimpleName(): string;
  36384. }
  36385. }
  36386. declare module BABYLON {
  36387. interface ArcRotateCameraInputsManager {
  36388. /**
  36389. * Add orientation input support to the input manager.
  36390. * @returns the current input manager
  36391. */
  36392. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36393. }
  36394. /**
  36395. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36396. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36397. */
  36398. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36399. /**
  36400. * Defines the camera the input is attached to.
  36401. */
  36402. camera: ArcRotateCamera;
  36403. /**
  36404. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36405. */
  36406. alphaCorrection: number;
  36407. /**
  36408. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36409. */
  36410. gammaCorrection: number;
  36411. private _alpha;
  36412. private _gamma;
  36413. private _dirty;
  36414. private _deviceOrientationHandler;
  36415. /**
  36416. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36417. */
  36418. constructor();
  36419. /**
  36420. * Attach the input controls to a specific dom element to get the input from.
  36421. * @param element Defines the element the controls should be listened from
  36422. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36423. */
  36424. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36425. /** @hidden */ private _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36426. /**
  36427. * Update the current camera state depending on the inputs that have been used this frame.
  36428. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36429. */
  36430. checkInputs(): void;
  36431. /**
  36432. * Detach the current controls from the specified dom element.
  36433. * @param element Defines the element to stop listening the inputs from
  36434. */
  36435. detachControl(element: Nullable<HTMLElement>): void;
  36436. /**
  36437. * Gets the class name of the current intput.
  36438. * @returns the class name
  36439. */
  36440. getClassName(): string;
  36441. /**
  36442. * Get the friendly name associated with the input class.
  36443. * @returns the input friendly name
  36444. */
  36445. getSimpleName(): string;
  36446. }
  36447. }
  36448. declare module BABYLON {
  36449. /**
  36450. * Listen to mouse events to control the camera.
  36451. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36452. */
  36453. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36454. /**
  36455. * Defines the camera the input is attached to.
  36456. */
  36457. camera: FlyCamera;
  36458. /**
  36459. * Defines if touch is enabled. (Default is true.)
  36460. */
  36461. touchEnabled: boolean;
  36462. /**
  36463. * Defines the buttons associated with the input to handle camera rotation.
  36464. */
  36465. buttons: number[];
  36466. /**
  36467. * Assign buttons for Yaw control.
  36468. */
  36469. buttonsYaw: number[];
  36470. /**
  36471. * Assign buttons for Pitch control.
  36472. */
  36473. buttonsPitch: number[];
  36474. /**
  36475. * Assign buttons for Roll control.
  36476. */
  36477. buttonsRoll: number[];
  36478. /**
  36479. * Detect if any button is being pressed while mouse is moved.
  36480. * -1 = Mouse locked.
  36481. * 0 = Left button.
  36482. * 1 = Middle Button.
  36483. * 2 = Right Button.
  36484. */
  36485. activeButton: number;
  36486. /**
  36487. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36488. * Higher values reduce its sensitivity.
  36489. */
  36490. angularSensibility: number;
  36491. private _mousemoveCallback;
  36492. private _observer;
  36493. private _rollObserver;
  36494. private previousPosition;
  36495. private noPreventDefault;
  36496. private element;
  36497. /**
  36498. * Listen to mouse events to control the camera.
  36499. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36500. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36501. */
  36502. constructor(touchEnabled?: boolean);
  36503. /**
  36504. * Attach the mouse control to the HTML DOM element.
  36505. * @param element Defines the element that listens to the input events.
  36506. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36507. */
  36508. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36509. /**
  36510. * Detach the current controls from the specified dom element.
  36511. * @param element Defines the element to stop listening the inputs from
  36512. */
  36513. detachControl(element: Nullable<HTMLElement>): void;
  36514. /**
  36515. * Gets the class name of the current input.
  36516. * @returns the class name.
  36517. */
  36518. getClassName(): string;
  36519. /**
  36520. * Get the friendly name associated with the input class.
  36521. * @returns the input's friendly name.
  36522. */
  36523. getSimpleName(): string;
  36524. private _pointerInput;
  36525. private _onMouseMove;
  36526. /**
  36527. * Rotate camera by mouse offset.
  36528. */
  36529. private rotateCamera;
  36530. }
  36531. }
  36532. declare module BABYLON {
  36533. /**
  36534. * Default Inputs manager for the FlyCamera.
  36535. * It groups all the default supported inputs for ease of use.
  36536. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36537. */
  36538. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36539. /**
  36540. * Instantiates a new FlyCameraInputsManager.
  36541. * @param camera Defines the camera the inputs belong to.
  36542. */
  36543. constructor(camera: FlyCamera);
  36544. /**
  36545. * Add keyboard input support to the input manager.
  36546. * @returns the new FlyCameraKeyboardMoveInput().
  36547. */
  36548. addKeyboard(): FlyCameraInputsManager;
  36549. /**
  36550. * Add mouse input support to the input manager.
  36551. * @param touchEnabled Enable touch screen support.
  36552. * @returns the new FlyCameraMouseInput().
  36553. */
  36554. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36555. }
  36556. }
  36557. declare module BABYLON {
  36558. /**
  36559. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36560. * such as in a 3D Space Shooter or a Flight Simulator.
  36561. */
  36562. export class FlyCamera extends TargetCamera {
  36563. /**
  36564. * Define the collision ellipsoid of the camera.
  36565. * This is helpful for simulating a camera body, like a player's body.
  36566. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36567. */
  36568. ellipsoid: Vector3;
  36569. /**
  36570. * Define an offset for the position of the ellipsoid around the camera.
  36571. * This can be helpful if the camera is attached away from the player's body center,
  36572. * such as at its head.
  36573. */
  36574. ellipsoidOffset: Vector3;
  36575. /**
  36576. * Enable or disable collisions of the camera with the rest of the scene objects.
  36577. */
  36578. checkCollisions: boolean;
  36579. /**
  36580. * Enable or disable gravity on the camera.
  36581. */
  36582. applyGravity: boolean;
  36583. /**
  36584. * Define the current direction the camera is moving to.
  36585. */
  36586. cameraDirection: Vector3;
  36587. /**
  36588. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36589. * This overrides and empties cameraRotation.
  36590. */
  36591. rotationQuaternion: Quaternion;
  36592. /**
  36593. * Track Roll to maintain the wanted Rolling when looking around.
  36594. */ private _trackRoll: number;
  36595. /**
  36596. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36597. */
  36598. rollCorrect: number;
  36599. /**
  36600. * Mimic a banked turn, Rolling the camera when Yawing.
  36601. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36602. */
  36603. bankedTurn: boolean;
  36604. /**
  36605. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36606. */
  36607. bankedTurnLimit: number;
  36608. /**
  36609. * Value of 0 disables the banked Roll.
  36610. * Value of 1 is equal to the Yaw angle in radians.
  36611. */
  36612. bankedTurnMultiplier: number;
  36613. /**
  36614. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36615. */
  36616. inputs: FlyCameraInputsManager;
  36617. /**
  36618. * Gets the input sensibility for mouse input.
  36619. * Higher values reduce sensitivity.
  36620. */
  36621. /**
  36622. * Sets the input sensibility for a mouse input.
  36623. * Higher values reduce sensitivity.
  36624. */
  36625. angularSensibility: number;
  36626. /**
  36627. * Get the keys for camera movement forward.
  36628. */
  36629. /**
  36630. * Set the keys for camera movement forward.
  36631. */
  36632. keysForward: number[];
  36633. /**
  36634. * Get the keys for camera movement backward.
  36635. */
  36636. keysBackward: number[];
  36637. /**
  36638. * Get the keys for camera movement up.
  36639. */
  36640. /**
  36641. * Set the keys for camera movement up.
  36642. */
  36643. keysUp: number[];
  36644. /**
  36645. * Get the keys for camera movement down.
  36646. */
  36647. /**
  36648. * Set the keys for camera movement down.
  36649. */
  36650. keysDown: number[];
  36651. /**
  36652. * Get the keys for camera movement left.
  36653. */
  36654. /**
  36655. * Set the keys for camera movement left.
  36656. */
  36657. keysLeft: number[];
  36658. /**
  36659. * Set the keys for camera movement right.
  36660. */
  36661. /**
  36662. * Set the keys for camera movement right.
  36663. */
  36664. keysRight: number[];
  36665. /**
  36666. * Event raised when the camera collides with a mesh in the scene.
  36667. */
  36668. onCollide: (collidedMesh: AbstractMesh) => void;
  36669. private _collider;
  36670. private _needMoveForGravity;
  36671. private _oldPosition;
  36672. private _diffPosition;
  36673. private _newPosition;
  36674. /** @hidden */ private _localDirection: Vector3;
  36675. /** @hidden */ private _transformedDirection: Vector3;
  36676. /**
  36677. * Instantiates a FlyCamera.
  36678. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36679. * such as in a 3D Space Shooter or a Flight Simulator.
  36680. * @param name Define the name of the camera in the scene.
  36681. * @param position Define the starting position of the camera in the scene.
  36682. * @param scene Define the scene the camera belongs to.
  36683. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36684. */
  36685. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36686. /**
  36687. * Attach a control to the HTML DOM element.
  36688. * @param element Defines the element that listens to the input events.
  36689. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36690. */
  36691. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36692. /**
  36693. * Detach a control from the HTML DOM element.
  36694. * The camera will stop reacting to that input.
  36695. * @param element Defines the element that listens to the input events.
  36696. */
  36697. detachControl(element: HTMLElement): void;
  36698. private _collisionMask;
  36699. /**
  36700. * Get the mask that the camera ignores in collision events.
  36701. */
  36702. /**
  36703. * Set the mask that the camera ignores in collision events.
  36704. */
  36705. collisionMask: number;
  36706. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  36707. /** @hidden */
  36708. private _onCollisionPositionChange;
  36709. /** @hidden */ private _checkInputs(): void;
  36710. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  36711. /** @hidden */ private _updatePosition(): void;
  36712. /**
  36713. * Restore the Roll to its target value at the rate specified.
  36714. * @param rate - Higher means slower restoring.
  36715. * @hidden
  36716. */
  36717. restoreRoll(rate: number): void;
  36718. /**
  36719. * Destroy the camera and release the current resources held by it.
  36720. */
  36721. dispose(): void;
  36722. /**
  36723. * Get the current object class name.
  36724. * @returns the class name.
  36725. */
  36726. getClassName(): string;
  36727. }
  36728. }
  36729. declare module BABYLON {
  36730. /**
  36731. * Listen to keyboard events to control the camera.
  36732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36733. */
  36734. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36735. /**
  36736. * Defines the camera the input is attached to.
  36737. */
  36738. camera: FlyCamera;
  36739. /**
  36740. * The list of keyboard keys used to control the forward move of the camera.
  36741. */
  36742. keysForward: number[];
  36743. /**
  36744. * The list of keyboard keys used to control the backward move of the camera.
  36745. */
  36746. keysBackward: number[];
  36747. /**
  36748. * The list of keyboard keys used to control the forward move of the camera.
  36749. */
  36750. keysUp: number[];
  36751. /**
  36752. * The list of keyboard keys used to control the backward move of the camera.
  36753. */
  36754. keysDown: number[];
  36755. /**
  36756. * The list of keyboard keys used to control the right strafe move of the camera.
  36757. */
  36758. keysRight: number[];
  36759. /**
  36760. * The list of keyboard keys used to control the left strafe move of the camera.
  36761. */
  36762. keysLeft: number[];
  36763. private _keys;
  36764. private _onCanvasBlurObserver;
  36765. private _onKeyboardObserver;
  36766. private _engine;
  36767. private _scene;
  36768. /**
  36769. * Attach the input controls to a specific dom element to get the input from.
  36770. * @param element Defines the element the controls should be listened from
  36771. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36772. */
  36773. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36774. /**
  36775. * Detach the current controls from the specified dom element.
  36776. * @param element Defines the element to stop listening the inputs from
  36777. */
  36778. detachControl(element: Nullable<HTMLElement>): void;
  36779. /**
  36780. * Gets the class name of the current intput.
  36781. * @returns the class name
  36782. */
  36783. getClassName(): string;
  36784. /** @hidden */ private _onLostFocus(e: FocusEvent): void;
  36785. /**
  36786. * Get the friendly name associated with the input class.
  36787. * @returns the input friendly name
  36788. */
  36789. getSimpleName(): string;
  36790. /**
  36791. * Update the current camera state depending on the inputs that have been used this frame.
  36792. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36793. */
  36794. checkInputs(): void;
  36795. }
  36796. }
  36797. declare module BABYLON {
  36798. /**
  36799. * Manage the mouse wheel inputs to control a follow camera.
  36800. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36801. */
  36802. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36803. /**
  36804. * Defines the camera the input is attached to.
  36805. */
  36806. camera: FollowCamera;
  36807. /**
  36808. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36809. */
  36810. axisControlRadius: boolean;
  36811. /**
  36812. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36813. */
  36814. axisControlHeight: boolean;
  36815. /**
  36816. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36817. */
  36818. axisControlRotation: boolean;
  36819. /**
  36820. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36821. * relation to mouseWheel events.
  36822. */
  36823. wheelPrecision: number;
  36824. /**
  36825. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36826. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36827. */
  36828. wheelDeltaPercentage: number;
  36829. private _wheel;
  36830. private _observer;
  36831. /**
  36832. * Attach the input controls to a specific dom element to get the input from.
  36833. * @param element Defines the element the controls should be listened from
  36834. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36835. */
  36836. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36837. /**
  36838. * Detach the current controls from the specified dom element.
  36839. * @param element Defines the element to stop listening the inputs from
  36840. */
  36841. detachControl(element: Nullable<HTMLElement>): void;
  36842. /**
  36843. * Gets the class name of the current intput.
  36844. * @returns the class name
  36845. */
  36846. getClassName(): string;
  36847. /**
  36848. * Get the friendly name associated with the input class.
  36849. * @returns the input friendly name
  36850. */
  36851. getSimpleName(): string;
  36852. }
  36853. }
  36854. declare module BABYLON {
  36855. /**
  36856. * Manage the pointers inputs to control an follow camera.
  36857. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36858. */
  36859. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36860. /**
  36861. * Defines the camera the input is attached to.
  36862. */
  36863. camera: FollowCamera;
  36864. /**
  36865. * Gets the class name of the current input.
  36866. * @returns the class name
  36867. */
  36868. getClassName(): string;
  36869. /**
  36870. * Defines the pointer angular sensibility along the X axis or how fast is
  36871. * the camera rotating.
  36872. * A negative number will reverse the axis direction.
  36873. */
  36874. angularSensibilityX: number;
  36875. /**
  36876. * Defines the pointer angular sensibility along the Y axis or how fast is
  36877. * the camera rotating.
  36878. * A negative number will reverse the axis direction.
  36879. */
  36880. angularSensibilityY: number;
  36881. /**
  36882. * Defines the pointer pinch precision or how fast is the camera zooming.
  36883. * A negative number will reverse the axis direction.
  36884. */
  36885. pinchPrecision: number;
  36886. /**
  36887. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36888. * from 0.
  36889. * It defines the percentage of current camera.radius to use as delta when
  36890. * pinch zoom is used.
  36891. */
  36892. pinchDeltaPercentage: number;
  36893. /**
  36894. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36895. */
  36896. axisXControlRadius: boolean;
  36897. /**
  36898. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36899. */
  36900. axisXControlHeight: boolean;
  36901. /**
  36902. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36903. */
  36904. axisXControlRotation: boolean;
  36905. /**
  36906. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36907. */
  36908. axisYControlRadius: boolean;
  36909. /**
  36910. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36911. */
  36912. axisYControlHeight: boolean;
  36913. /**
  36914. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36915. */
  36916. axisYControlRotation: boolean;
  36917. /**
  36918. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36919. */
  36920. axisPinchControlRadius: boolean;
  36921. /**
  36922. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36923. */
  36924. axisPinchControlHeight: boolean;
  36925. /**
  36926. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36927. */
  36928. axisPinchControlRotation: boolean;
  36929. /**
  36930. * Log error messages if basic misconfiguration has occurred.
  36931. */
  36932. warningEnable: boolean;
  36933. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36934. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36935. private _warningCounter;
  36936. private _warning;
  36937. }
  36938. }
  36939. declare module BABYLON {
  36940. /**
  36941. * Default Inputs manager for the FollowCamera.
  36942. * It groups all the default supported inputs for ease of use.
  36943. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36944. */
  36945. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36946. /**
  36947. * Instantiates a new FollowCameraInputsManager.
  36948. * @param camera Defines the camera the inputs belong to
  36949. */
  36950. constructor(camera: FollowCamera);
  36951. /**
  36952. * Add keyboard input support to the input manager.
  36953. * @returns the current input manager
  36954. */
  36955. addKeyboard(): FollowCameraInputsManager;
  36956. /**
  36957. * Add mouse wheel input support to the input manager.
  36958. * @returns the current input manager
  36959. */
  36960. addMouseWheel(): FollowCameraInputsManager;
  36961. /**
  36962. * Add pointers input support to the input manager.
  36963. * @returns the current input manager
  36964. */
  36965. addPointers(): FollowCameraInputsManager;
  36966. /**
  36967. * Add orientation input support to the input manager.
  36968. * @returns the current input manager
  36969. */
  36970. addVRDeviceOrientation(): FollowCameraInputsManager;
  36971. }
  36972. }
  36973. declare module BABYLON {
  36974. /**
  36975. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36976. * an arc rotate version arcFollowCamera are available.
  36977. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36978. */
  36979. export class FollowCamera extends TargetCamera {
  36980. /**
  36981. * Distance the follow camera should follow an object at
  36982. */
  36983. radius: number;
  36984. /**
  36985. * Minimum allowed distance of the camera to the axis of rotation
  36986. * (The camera can not get closer).
  36987. * This can help limiting how the Camera is able to move in the scene.
  36988. */
  36989. lowerRadiusLimit: Nullable<number>;
  36990. /**
  36991. * Maximum allowed distance of the camera to the axis of rotation
  36992. * (The camera can not get further).
  36993. * This can help limiting how the Camera is able to move in the scene.
  36994. */
  36995. upperRadiusLimit: Nullable<number>;
  36996. /**
  36997. * Define a rotation offset between the camera and the object it follows
  36998. */
  36999. rotationOffset: number;
  37000. /**
  37001. * Minimum allowed angle to camera position relative to target object.
  37002. * This can help limiting how the Camera is able to move in the scene.
  37003. */
  37004. lowerRotationOffsetLimit: Nullable<number>;
  37005. /**
  37006. * Maximum allowed angle to camera position relative to target object.
  37007. * This can help limiting how the Camera is able to move in the scene.
  37008. */
  37009. upperRotationOffsetLimit: Nullable<number>;
  37010. /**
  37011. * Define a height offset between the camera and the object it follows.
  37012. * It can help following an object from the top (like a car chaing a plane)
  37013. */
  37014. heightOffset: number;
  37015. /**
  37016. * Minimum allowed height of camera position relative to target object.
  37017. * This can help limiting how the Camera is able to move in the scene.
  37018. */
  37019. lowerHeightOffsetLimit: Nullable<number>;
  37020. /**
  37021. * Maximum allowed height of camera position relative to target object.
  37022. * This can help limiting how the Camera is able to move in the scene.
  37023. */
  37024. upperHeightOffsetLimit: Nullable<number>;
  37025. /**
  37026. * Define how fast the camera can accelerate to follow it s target.
  37027. */
  37028. cameraAcceleration: number;
  37029. /**
  37030. * Define the speed limit of the camera following an object.
  37031. */
  37032. maxCameraSpeed: number;
  37033. /**
  37034. * Define the target of the camera.
  37035. */
  37036. lockedTarget: Nullable<AbstractMesh>;
  37037. /**
  37038. * Defines the input associated with the camera.
  37039. */
  37040. inputs: FollowCameraInputsManager;
  37041. /**
  37042. * Instantiates the follow camera.
  37043. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37044. * @param name Define the name of the camera in the scene
  37045. * @param position Define the position of the camera
  37046. * @param scene Define the scene the camera belong to
  37047. * @param lockedTarget Define the target of the camera
  37048. */
  37049. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37050. private _follow;
  37051. /**
  37052. * Attached controls to the current camera.
  37053. * @param element Defines the element the controls should be listened from
  37054. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37055. */
  37056. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37057. /**
  37058. * Detach the current controls from the camera.
  37059. * The camera will stop reacting to inputs.
  37060. * @param element Defines the element to stop listening the inputs from
  37061. */
  37062. detachControl(element: HTMLElement): void;
  37063. /** @hidden */ private _checkInputs(): void;
  37064. private _checkLimits;
  37065. /**
  37066. * Gets the camera class name.
  37067. * @returns the class name
  37068. */
  37069. getClassName(): string;
  37070. }
  37071. /**
  37072. * Arc Rotate version of the follow camera.
  37073. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37074. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37075. */
  37076. export class ArcFollowCamera extends TargetCamera {
  37077. /** The longitudinal angle of the camera */
  37078. alpha: number;
  37079. /** The latitudinal angle of the camera */
  37080. beta: number;
  37081. /** The radius of the camera from its target */
  37082. radius: number;
  37083. /** Define the camera target (the messh it should follow) */
  37084. target: Nullable<AbstractMesh>;
  37085. private _cartesianCoordinates;
  37086. /**
  37087. * Instantiates a new ArcFollowCamera
  37088. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37089. * @param name Define the name of the camera
  37090. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37091. * @param beta Define the rotation angle of the camera around the elevation axis
  37092. * @param radius Define the radius of the camera from its target point
  37093. * @param target Define the target of the camera
  37094. * @param scene Define the scene the camera belongs to
  37095. */
  37096. constructor(name: string,
  37097. /** The longitudinal angle of the camera */
  37098. alpha: number,
  37099. /** The latitudinal angle of the camera */
  37100. beta: number,
  37101. /** The radius of the camera from its target */
  37102. radius: number,
  37103. /** Define the camera target (the messh it should follow) */
  37104. target: Nullable<AbstractMesh>, scene: Scene);
  37105. private _follow;
  37106. /** @hidden */ private _checkInputs(): void;
  37107. /**
  37108. * Returns the class name of the object.
  37109. * It is mostly used internally for serialization purposes.
  37110. */
  37111. getClassName(): string;
  37112. }
  37113. }
  37114. declare module BABYLON {
  37115. /**
  37116. * Manage the keyboard inputs to control the movement of a follow camera.
  37117. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37118. */
  37119. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37120. /**
  37121. * Defines the camera the input is attached to.
  37122. */
  37123. camera: FollowCamera;
  37124. /**
  37125. * Defines the list of key codes associated with the up action (increase heightOffset)
  37126. */
  37127. keysHeightOffsetIncr: number[];
  37128. /**
  37129. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37130. */
  37131. keysHeightOffsetDecr: number[];
  37132. /**
  37133. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37134. */
  37135. keysHeightOffsetModifierAlt: boolean;
  37136. /**
  37137. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37138. */
  37139. keysHeightOffsetModifierCtrl: boolean;
  37140. /**
  37141. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37142. */
  37143. keysHeightOffsetModifierShift: boolean;
  37144. /**
  37145. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37146. */
  37147. keysRotationOffsetIncr: number[];
  37148. /**
  37149. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37150. */
  37151. keysRotationOffsetDecr: number[];
  37152. /**
  37153. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37154. */
  37155. keysRotationOffsetModifierAlt: boolean;
  37156. /**
  37157. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37158. */
  37159. keysRotationOffsetModifierCtrl: boolean;
  37160. /**
  37161. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37162. */
  37163. keysRotationOffsetModifierShift: boolean;
  37164. /**
  37165. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37166. */
  37167. keysRadiusIncr: number[];
  37168. /**
  37169. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37170. */
  37171. keysRadiusDecr: number[];
  37172. /**
  37173. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37174. */
  37175. keysRadiusModifierAlt: boolean;
  37176. /**
  37177. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37178. */
  37179. keysRadiusModifierCtrl: boolean;
  37180. /**
  37181. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37182. */
  37183. keysRadiusModifierShift: boolean;
  37184. /**
  37185. * Defines the rate of change of heightOffset.
  37186. */
  37187. heightSensibility: number;
  37188. /**
  37189. * Defines the rate of change of rotationOffset.
  37190. */
  37191. rotationSensibility: number;
  37192. /**
  37193. * Defines the rate of change of radius.
  37194. */
  37195. radiusSensibility: number;
  37196. private _keys;
  37197. private _ctrlPressed;
  37198. private _altPressed;
  37199. private _shiftPressed;
  37200. private _onCanvasBlurObserver;
  37201. private _onKeyboardObserver;
  37202. private _engine;
  37203. private _scene;
  37204. /**
  37205. * Attach the input controls to a specific dom element to get the input from.
  37206. * @param element Defines the element the controls should be listened from
  37207. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37208. */
  37209. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37210. /**
  37211. * Detach the current controls from the specified dom element.
  37212. * @param element Defines the element to stop listening the inputs from
  37213. */
  37214. detachControl(element: Nullable<HTMLElement>): void;
  37215. /**
  37216. * Update the current camera state depending on the inputs that have been used this frame.
  37217. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37218. */
  37219. checkInputs(): void;
  37220. /**
  37221. * Gets the class name of the current input.
  37222. * @returns the class name
  37223. */
  37224. getClassName(): string;
  37225. /**
  37226. * Get the friendly name associated with the input class.
  37227. * @returns the input friendly name
  37228. */
  37229. getSimpleName(): string;
  37230. /**
  37231. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37232. * allow modification of the heightOffset value.
  37233. */
  37234. private _modifierHeightOffset;
  37235. /**
  37236. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37237. * allow modification of the rotationOffset value.
  37238. */
  37239. private _modifierRotationOffset;
  37240. /**
  37241. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37242. * allow modification of the radius value.
  37243. */
  37244. private _modifierRadius;
  37245. }
  37246. }
  37247. declare module BABYLON {
  37248. interface FreeCameraInputsManager {
  37249. /**
  37250. * @hidden
  37251. */ private _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37252. /**
  37253. * Add orientation input support to the input manager.
  37254. * @returns the current input manager
  37255. */
  37256. addDeviceOrientation(): FreeCameraInputsManager;
  37257. }
  37258. /**
  37259. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37260. * Screen rotation is taken into account.
  37261. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37262. */
  37263. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37264. private _camera;
  37265. private _screenOrientationAngle;
  37266. private _constantTranform;
  37267. private _screenQuaternion;
  37268. private _alpha;
  37269. private _beta;
  37270. private _gamma;
  37271. /**
  37272. * Can be used to detect if a device orientation sensor is availible on a device
  37273. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37274. * @returns a promise that will resolve on orientation change
  37275. */
  37276. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37277. /**
  37278. * @hidden
  37279. */ private _onDeviceOrientationChangedObservable: Observable<void>;
  37280. /**
  37281. * Instantiates a new input
  37282. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37283. */
  37284. constructor();
  37285. /**
  37286. * Define the camera controlled by the input.
  37287. */
  37288. camera: FreeCamera;
  37289. /**
  37290. * Attach the input controls to a specific dom element to get the input from.
  37291. * @param element Defines the element the controls should be listened from
  37292. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37293. */
  37294. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37295. private _orientationChanged;
  37296. private _deviceOrientation;
  37297. /**
  37298. * Detach the current controls from the specified dom element.
  37299. * @param element Defines the element to stop listening the inputs from
  37300. */
  37301. detachControl(element: Nullable<HTMLElement>): void;
  37302. /**
  37303. * Update the current camera state depending on the inputs that have been used this frame.
  37304. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37305. */
  37306. checkInputs(): void;
  37307. /**
  37308. * Gets the class name of the current intput.
  37309. * @returns the class name
  37310. */
  37311. getClassName(): string;
  37312. /**
  37313. * Get the friendly name associated with the input class.
  37314. * @returns the input friendly name
  37315. */
  37316. getSimpleName(): string;
  37317. }
  37318. }
  37319. declare module BABYLON {
  37320. /**
  37321. * Manage the gamepad inputs to control a free camera.
  37322. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37323. */
  37324. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37325. /**
  37326. * Define the camera the input is attached to.
  37327. */
  37328. camera: FreeCamera;
  37329. /**
  37330. * Define the Gamepad controlling the input
  37331. */
  37332. gamepad: Nullable<Gamepad>;
  37333. /**
  37334. * Defines the gamepad rotation sensiblity.
  37335. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37336. */
  37337. gamepadAngularSensibility: number;
  37338. /**
  37339. * Defines the gamepad move sensiblity.
  37340. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37341. */
  37342. gamepadMoveSensibility: number;
  37343. private _onGamepadConnectedObserver;
  37344. private _onGamepadDisconnectedObserver;
  37345. private _cameraTransform;
  37346. private _deltaTransform;
  37347. private _vector3;
  37348. private _vector2;
  37349. /**
  37350. * Attach the input controls to a specific dom element to get the input from.
  37351. * @param element Defines the element the controls should be listened from
  37352. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37353. */
  37354. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37355. /**
  37356. * Detach the current controls from the specified dom element.
  37357. * @param element Defines the element to stop listening the inputs from
  37358. */
  37359. detachControl(element: Nullable<HTMLElement>): void;
  37360. /**
  37361. * Update the current camera state depending on the inputs that have been used this frame.
  37362. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37363. */
  37364. checkInputs(): void;
  37365. /**
  37366. * Gets the class name of the current intput.
  37367. * @returns the class name
  37368. */
  37369. getClassName(): string;
  37370. /**
  37371. * Get the friendly name associated with the input class.
  37372. * @returns the input friendly name
  37373. */
  37374. getSimpleName(): string;
  37375. }
  37376. }
  37377. declare module BABYLON {
  37378. /**
  37379. * Defines the potential axis of a Joystick
  37380. */
  37381. export enum JoystickAxis {
  37382. /** X axis */
  37383. X = 0,
  37384. /** Y axis */
  37385. Y = 1,
  37386. /** Z axis */
  37387. Z = 2
  37388. }
  37389. /**
  37390. * Class used to define virtual joystick (used in touch mode)
  37391. */
  37392. export class VirtualJoystick {
  37393. /**
  37394. * Gets or sets a boolean indicating that left and right values must be inverted
  37395. */
  37396. reverseLeftRight: boolean;
  37397. /**
  37398. * Gets or sets a boolean indicating that up and down values must be inverted
  37399. */
  37400. reverseUpDown: boolean;
  37401. /**
  37402. * Gets the offset value for the position (ie. the change of the position value)
  37403. */
  37404. deltaPosition: Vector3;
  37405. /**
  37406. * Gets a boolean indicating if the virtual joystick was pressed
  37407. */
  37408. pressed: boolean;
  37409. /**
  37410. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37411. */
  37412. static Canvas: Nullable<HTMLCanvasElement>;
  37413. private static _globalJoystickIndex;
  37414. private static vjCanvasContext;
  37415. private static vjCanvasWidth;
  37416. private static vjCanvasHeight;
  37417. private static halfWidth;
  37418. private _action;
  37419. private _axisTargetedByLeftAndRight;
  37420. private _axisTargetedByUpAndDown;
  37421. private _joystickSensibility;
  37422. private _inversedSensibility;
  37423. private _joystickPointerID;
  37424. private _joystickColor;
  37425. private _joystickPointerPos;
  37426. private _joystickPreviousPointerPos;
  37427. private _joystickPointerStartPos;
  37428. private _deltaJoystickVector;
  37429. private _leftJoystick;
  37430. private _touches;
  37431. private _onPointerDownHandlerRef;
  37432. private _onPointerMoveHandlerRef;
  37433. private _onPointerUpHandlerRef;
  37434. private _onResize;
  37435. /**
  37436. * Creates a new virtual joystick
  37437. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37438. */
  37439. constructor(leftJoystick?: boolean);
  37440. /**
  37441. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37442. * @param newJoystickSensibility defines the new sensibility
  37443. */
  37444. setJoystickSensibility(newJoystickSensibility: number): void;
  37445. private _onPointerDown;
  37446. private _onPointerMove;
  37447. private _onPointerUp;
  37448. /**
  37449. * Change the color of the virtual joystick
  37450. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37451. */
  37452. setJoystickColor(newColor: string): void;
  37453. /**
  37454. * Defines a callback to call when the joystick is touched
  37455. * @param action defines the callback
  37456. */
  37457. setActionOnTouch(action: () => any): void;
  37458. /**
  37459. * Defines which axis you'd like to control for left & right
  37460. * @param axis defines the axis to use
  37461. */
  37462. setAxisForLeftRight(axis: JoystickAxis): void;
  37463. /**
  37464. * Defines which axis you'd like to control for up & down
  37465. * @param axis defines the axis to use
  37466. */
  37467. setAxisForUpDown(axis: JoystickAxis): void;
  37468. private _drawVirtualJoystick;
  37469. /**
  37470. * Release internal HTML canvas
  37471. */
  37472. releaseCanvas(): void;
  37473. }
  37474. }
  37475. declare module BABYLON {
  37476. interface FreeCameraInputsManager {
  37477. /**
  37478. * Add virtual joystick input support to the input manager.
  37479. * @returns the current input manager
  37480. */
  37481. addVirtualJoystick(): FreeCameraInputsManager;
  37482. }
  37483. /**
  37484. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37485. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37486. */
  37487. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37488. /**
  37489. * Defines the camera the input is attached to.
  37490. */
  37491. camera: FreeCamera;
  37492. private _leftjoystick;
  37493. private _rightjoystick;
  37494. /**
  37495. * Gets the left stick of the virtual joystick.
  37496. * @returns The virtual Joystick
  37497. */
  37498. getLeftJoystick(): VirtualJoystick;
  37499. /**
  37500. * Gets the right stick of the virtual joystick.
  37501. * @returns The virtual Joystick
  37502. */
  37503. getRightJoystick(): VirtualJoystick;
  37504. /**
  37505. * Update the current camera state depending on the inputs that have been used this frame.
  37506. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37507. */
  37508. checkInputs(): void;
  37509. /**
  37510. * Attach the input controls to a specific dom element to get the input from.
  37511. * @param element Defines the element the controls should be listened from
  37512. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37513. */
  37514. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37515. /**
  37516. * Detach the current controls from the specified dom element.
  37517. * @param element Defines the element to stop listening the inputs from
  37518. */
  37519. detachControl(element: Nullable<HTMLElement>): void;
  37520. /**
  37521. * Gets the class name of the current intput.
  37522. * @returns the class name
  37523. */
  37524. getClassName(): string;
  37525. /**
  37526. * Get the friendly name associated with the input class.
  37527. * @returns the input friendly name
  37528. */
  37529. getSimpleName(): string;
  37530. }
  37531. }
  37532. declare module BABYLON {
  37533. /**
  37534. * This represents a FPS type of camera controlled by touch.
  37535. * This is like a universal camera minus the Gamepad controls.
  37536. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37537. */
  37538. export class TouchCamera extends FreeCamera {
  37539. /**
  37540. * Defines the touch sensibility for rotation.
  37541. * The higher the faster.
  37542. */
  37543. touchAngularSensibility: number;
  37544. /**
  37545. * Defines the touch sensibility for move.
  37546. * The higher the faster.
  37547. */
  37548. touchMoveSensibility: number;
  37549. /**
  37550. * Instantiates a new touch camera.
  37551. * This represents a FPS type of camera controlled by touch.
  37552. * This is like a universal camera minus the Gamepad controls.
  37553. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37554. * @param name Define the name of the camera in the scene
  37555. * @param position Define the start position of the camera in the scene
  37556. * @param scene Define the scene the camera belongs to
  37557. */
  37558. constructor(name: string, position: Vector3, scene: Scene);
  37559. /**
  37560. * Gets the current object class name.
  37561. * @return the class name
  37562. */
  37563. getClassName(): string;
  37564. /** @hidden */ private _setupInputs(): void;
  37565. }
  37566. }
  37567. declare module BABYLON {
  37568. /**
  37569. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37570. * being tilted forward or back and left or right.
  37571. */
  37572. export class DeviceOrientationCamera extends FreeCamera {
  37573. private _initialQuaternion;
  37574. private _quaternionCache;
  37575. private _tmpDragQuaternion;
  37576. private _disablePointerInputWhenUsingDeviceOrientation;
  37577. /**
  37578. * Creates a new device orientation camera
  37579. * @param name The name of the camera
  37580. * @param position The start position camera
  37581. * @param scene The scene the camera belongs to
  37582. */
  37583. constructor(name: string, position: Vector3, scene: Scene);
  37584. /**
  37585. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  37586. */
  37587. disablePointerInputWhenUsingDeviceOrientation: boolean;
  37588. private _dragFactor;
  37589. /**
  37590. * Enabled turning on the y axis when the orientation sensor is active
  37591. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37592. */
  37593. enableHorizontalDragging(dragFactor?: number): void;
  37594. /**
  37595. * Gets the current instance class name ("DeviceOrientationCamera").
  37596. * This helps avoiding instanceof at run time.
  37597. * @returns the class name
  37598. */
  37599. getClassName(): string;
  37600. /**
  37601. * @hidden
  37602. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37603. */ private _checkInputs(): void;
  37604. /**
  37605. * Reset the camera to its default orientation on the specified axis only.
  37606. * @param axis The axis to reset
  37607. */
  37608. resetToCurrentRotation(axis?: Axis): void;
  37609. }
  37610. }
  37611. declare module BABYLON {
  37612. /**
  37613. * Defines supported buttons for XBox360 compatible gamepads
  37614. */
  37615. export enum Xbox360Button {
  37616. /** A */
  37617. A = 0,
  37618. /** B */
  37619. B = 1,
  37620. /** X */
  37621. X = 2,
  37622. /** Y */
  37623. Y = 3,
  37624. /** Start */
  37625. Start = 4,
  37626. /** Back */
  37627. Back = 5,
  37628. /** Left button */
  37629. LB = 6,
  37630. /** Right button */
  37631. RB = 7,
  37632. /** Left stick */
  37633. LeftStick = 8,
  37634. /** Right stick */
  37635. RightStick = 9
  37636. }
  37637. /** Defines values for XBox360 DPad */
  37638. export enum Xbox360Dpad {
  37639. /** Up */
  37640. Up = 0,
  37641. /** Down */
  37642. Down = 1,
  37643. /** Left */
  37644. Left = 2,
  37645. /** Right */
  37646. Right = 3
  37647. }
  37648. /**
  37649. * Defines a XBox360 gamepad
  37650. */
  37651. export class Xbox360Pad extends Gamepad {
  37652. private _leftTrigger;
  37653. private _rightTrigger;
  37654. private _onlefttriggerchanged;
  37655. private _onrighttriggerchanged;
  37656. private _onbuttondown;
  37657. private _onbuttonup;
  37658. private _ondpaddown;
  37659. private _ondpadup;
  37660. /** Observable raised when a button is pressed */
  37661. onButtonDownObservable: Observable<Xbox360Button>;
  37662. /** Observable raised when a button is released */
  37663. onButtonUpObservable: Observable<Xbox360Button>;
  37664. /** Observable raised when a pad is pressed */
  37665. onPadDownObservable: Observable<Xbox360Dpad>;
  37666. /** Observable raised when a pad is released */
  37667. onPadUpObservable: Observable<Xbox360Dpad>;
  37668. private _buttonA;
  37669. private _buttonB;
  37670. private _buttonX;
  37671. private _buttonY;
  37672. private _buttonBack;
  37673. private _buttonStart;
  37674. private _buttonLB;
  37675. private _buttonRB;
  37676. private _buttonLeftStick;
  37677. private _buttonRightStick;
  37678. private _dPadUp;
  37679. private _dPadDown;
  37680. private _dPadLeft;
  37681. private _dPadRight;
  37682. private _isXboxOnePad;
  37683. /**
  37684. * Creates a new XBox360 gamepad object
  37685. * @param id defines the id of this gamepad
  37686. * @param index defines its index
  37687. * @param gamepad defines the internal HTML gamepad object
  37688. * @param xboxOne defines if it is a XBox One gamepad
  37689. */
  37690. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37691. /**
  37692. * Defines the callback to call when left trigger is pressed
  37693. * @param callback defines the callback to use
  37694. */
  37695. onlefttriggerchanged(callback: (value: number) => void): void;
  37696. /**
  37697. * Defines the callback to call when right trigger is pressed
  37698. * @param callback defines the callback to use
  37699. */
  37700. onrighttriggerchanged(callback: (value: number) => void): void;
  37701. /**
  37702. * Gets the left trigger value
  37703. */
  37704. /**
  37705. * Sets the left trigger value
  37706. */
  37707. leftTrigger: number;
  37708. /**
  37709. * Gets the right trigger value
  37710. */
  37711. /**
  37712. * Sets the right trigger value
  37713. */
  37714. rightTrigger: number;
  37715. /**
  37716. * Defines the callback to call when a button is pressed
  37717. * @param callback defines the callback to use
  37718. */
  37719. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37720. /**
  37721. * Defines the callback to call when a button is released
  37722. * @param callback defines the callback to use
  37723. */
  37724. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37725. /**
  37726. * Defines the callback to call when a pad is pressed
  37727. * @param callback defines the callback to use
  37728. */
  37729. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37730. /**
  37731. * Defines the callback to call when a pad is released
  37732. * @param callback defines the callback to use
  37733. */
  37734. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37735. private _setButtonValue;
  37736. private _setDPadValue;
  37737. /**
  37738. * Gets the value of the `A` button
  37739. */
  37740. /**
  37741. * Sets the value of the `A` button
  37742. */
  37743. buttonA: number;
  37744. /**
  37745. * Gets the value of the `B` button
  37746. */
  37747. /**
  37748. * Sets the value of the `B` button
  37749. */
  37750. buttonB: number;
  37751. /**
  37752. * Gets the value of the `X` button
  37753. */
  37754. /**
  37755. * Sets the value of the `X` button
  37756. */
  37757. buttonX: number;
  37758. /**
  37759. * Gets the value of the `Y` button
  37760. */
  37761. /**
  37762. * Sets the value of the `Y` button
  37763. */
  37764. buttonY: number;
  37765. /**
  37766. * Gets the value of the `Start` button
  37767. */
  37768. /**
  37769. * Sets the value of the `Start` button
  37770. */
  37771. buttonStart: number;
  37772. /**
  37773. * Gets the value of the `Back` button
  37774. */
  37775. /**
  37776. * Sets the value of the `Back` button
  37777. */
  37778. buttonBack: number;
  37779. /**
  37780. * Gets the value of the `Left` button
  37781. */
  37782. /**
  37783. * Sets the value of the `Left` button
  37784. */
  37785. buttonLB: number;
  37786. /**
  37787. * Gets the value of the `Right` button
  37788. */
  37789. /**
  37790. * Sets the value of the `Right` button
  37791. */
  37792. buttonRB: number;
  37793. /**
  37794. * Gets the value of the Left joystick
  37795. */
  37796. /**
  37797. * Sets the value of the Left joystick
  37798. */
  37799. buttonLeftStick: number;
  37800. /**
  37801. * Gets the value of the Right joystick
  37802. */
  37803. /**
  37804. * Sets the value of the Right joystick
  37805. */
  37806. buttonRightStick: number;
  37807. /**
  37808. * Gets the value of D-pad up
  37809. */
  37810. /**
  37811. * Sets the value of D-pad up
  37812. */
  37813. dPadUp: number;
  37814. /**
  37815. * Gets the value of D-pad down
  37816. */
  37817. /**
  37818. * Sets the value of D-pad down
  37819. */
  37820. dPadDown: number;
  37821. /**
  37822. * Gets the value of D-pad left
  37823. */
  37824. /**
  37825. * Sets the value of D-pad left
  37826. */
  37827. dPadLeft: number;
  37828. /**
  37829. * Gets the value of D-pad right
  37830. */
  37831. /**
  37832. * Sets the value of D-pad right
  37833. */
  37834. dPadRight: number;
  37835. /**
  37836. * Force the gamepad to synchronize with device values
  37837. */
  37838. update(): void;
  37839. /**
  37840. * Disposes the gamepad
  37841. */
  37842. dispose(): void;
  37843. }
  37844. }
  37845. declare module BABYLON {
  37846. /**
  37847. * Defines supported buttons for DualShock compatible gamepads
  37848. */
  37849. export enum DualShockButton {
  37850. /** Cross */
  37851. Cross = 0,
  37852. /** Circle */
  37853. Circle = 1,
  37854. /** Square */
  37855. Square = 2,
  37856. /** Triangle */
  37857. Triangle = 3,
  37858. /** Options */
  37859. Options = 4,
  37860. /** Share */
  37861. Share = 5,
  37862. /** L1 */
  37863. L1 = 6,
  37864. /** R1 */
  37865. R1 = 7,
  37866. /** Left stick */
  37867. LeftStick = 8,
  37868. /** Right stick */
  37869. RightStick = 9
  37870. }
  37871. /** Defines values for DualShock DPad */
  37872. export enum DualShockDpad {
  37873. /** Up */
  37874. Up = 0,
  37875. /** Down */
  37876. Down = 1,
  37877. /** Left */
  37878. Left = 2,
  37879. /** Right */
  37880. Right = 3
  37881. }
  37882. /**
  37883. * Defines a DualShock gamepad
  37884. */
  37885. export class DualShockPad extends Gamepad {
  37886. private _leftTrigger;
  37887. private _rightTrigger;
  37888. private _onlefttriggerchanged;
  37889. private _onrighttriggerchanged;
  37890. private _onbuttondown;
  37891. private _onbuttonup;
  37892. private _ondpaddown;
  37893. private _ondpadup;
  37894. /** Observable raised when a button is pressed */
  37895. onButtonDownObservable: Observable<DualShockButton>;
  37896. /** Observable raised when a button is released */
  37897. onButtonUpObservable: Observable<DualShockButton>;
  37898. /** Observable raised when a pad is pressed */
  37899. onPadDownObservable: Observable<DualShockDpad>;
  37900. /** Observable raised when a pad is released */
  37901. onPadUpObservable: Observable<DualShockDpad>;
  37902. private _buttonCross;
  37903. private _buttonCircle;
  37904. private _buttonSquare;
  37905. private _buttonTriangle;
  37906. private _buttonShare;
  37907. private _buttonOptions;
  37908. private _buttonL1;
  37909. private _buttonR1;
  37910. private _buttonLeftStick;
  37911. private _buttonRightStick;
  37912. private _dPadUp;
  37913. private _dPadDown;
  37914. private _dPadLeft;
  37915. private _dPadRight;
  37916. /**
  37917. * Creates a new DualShock gamepad object
  37918. * @param id defines the id of this gamepad
  37919. * @param index defines its index
  37920. * @param gamepad defines the internal HTML gamepad object
  37921. */
  37922. constructor(id: string, index: number, gamepad: any);
  37923. /**
  37924. * Defines the callback to call when left trigger is pressed
  37925. * @param callback defines the callback to use
  37926. */
  37927. onlefttriggerchanged(callback: (value: number) => void): void;
  37928. /**
  37929. * Defines the callback to call when right trigger is pressed
  37930. * @param callback defines the callback to use
  37931. */
  37932. onrighttriggerchanged(callback: (value: number) => void): void;
  37933. /**
  37934. * Gets the left trigger value
  37935. */
  37936. /**
  37937. * Sets the left trigger value
  37938. */
  37939. leftTrigger: number;
  37940. /**
  37941. * Gets the right trigger value
  37942. */
  37943. /**
  37944. * Sets the right trigger value
  37945. */
  37946. rightTrigger: number;
  37947. /**
  37948. * Defines the callback to call when a button is pressed
  37949. * @param callback defines the callback to use
  37950. */
  37951. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  37952. /**
  37953. * Defines the callback to call when a button is released
  37954. * @param callback defines the callback to use
  37955. */
  37956. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  37957. /**
  37958. * Defines the callback to call when a pad is pressed
  37959. * @param callback defines the callback to use
  37960. */
  37961. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  37962. /**
  37963. * Defines the callback to call when a pad is released
  37964. * @param callback defines the callback to use
  37965. */
  37966. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  37967. private _setButtonValue;
  37968. private _setDPadValue;
  37969. /**
  37970. * Gets the value of the `Cross` button
  37971. */
  37972. /**
  37973. * Sets the value of the `Cross` button
  37974. */
  37975. buttonCross: number;
  37976. /**
  37977. * Gets the value of the `Circle` button
  37978. */
  37979. /**
  37980. * Sets the value of the `Circle` button
  37981. */
  37982. buttonCircle: number;
  37983. /**
  37984. * Gets the value of the `Square` button
  37985. */
  37986. /**
  37987. * Sets the value of the `Square` button
  37988. */
  37989. buttonSquare: number;
  37990. /**
  37991. * Gets the value of the `Triangle` button
  37992. */
  37993. /**
  37994. * Sets the value of the `Triangle` button
  37995. */
  37996. buttonTriangle: number;
  37997. /**
  37998. * Gets the value of the `Options` button
  37999. */
  38000. /**
  38001. * Sets the value of the `Options` button
  38002. */
  38003. buttonOptions: number;
  38004. /**
  38005. * Gets the value of the `Share` button
  38006. */
  38007. /**
  38008. * Sets the value of the `Share` button
  38009. */
  38010. buttonShare: number;
  38011. /**
  38012. * Gets the value of the `L1` button
  38013. */
  38014. /**
  38015. * Sets the value of the `L1` button
  38016. */
  38017. buttonL1: number;
  38018. /**
  38019. * Gets the value of the `R1` button
  38020. */
  38021. /**
  38022. * Sets the value of the `R1` button
  38023. */
  38024. buttonR1: number;
  38025. /**
  38026. * Gets the value of the Left joystick
  38027. */
  38028. /**
  38029. * Sets the value of the Left joystick
  38030. */
  38031. buttonLeftStick: number;
  38032. /**
  38033. * Gets the value of the Right joystick
  38034. */
  38035. /**
  38036. * Sets the value of the Right joystick
  38037. */
  38038. buttonRightStick: number;
  38039. /**
  38040. * Gets the value of D-pad up
  38041. */
  38042. /**
  38043. * Sets the value of D-pad up
  38044. */
  38045. dPadUp: number;
  38046. /**
  38047. * Gets the value of D-pad down
  38048. */
  38049. /**
  38050. * Sets the value of D-pad down
  38051. */
  38052. dPadDown: number;
  38053. /**
  38054. * Gets the value of D-pad left
  38055. */
  38056. /**
  38057. * Sets the value of D-pad left
  38058. */
  38059. dPadLeft: number;
  38060. /**
  38061. * Gets the value of D-pad right
  38062. */
  38063. /**
  38064. * Sets the value of D-pad right
  38065. */
  38066. dPadRight: number;
  38067. /**
  38068. * Force the gamepad to synchronize with device values
  38069. */
  38070. update(): void;
  38071. /**
  38072. * Disposes the gamepad
  38073. */
  38074. dispose(): void;
  38075. }
  38076. }
  38077. declare module BABYLON {
  38078. /**
  38079. * Manager for handling gamepads
  38080. */
  38081. export class GamepadManager {
  38082. private _scene?;
  38083. private _babylonGamepads;
  38084. private _oneGamepadConnected;
  38085. /** @hidden */ private _isMonitoring: boolean;
  38086. private _gamepadEventSupported;
  38087. private _gamepadSupport;
  38088. /**
  38089. * observable to be triggered when the gamepad controller has been connected
  38090. */
  38091. onGamepadConnectedObservable: Observable<Gamepad>;
  38092. /**
  38093. * observable to be triggered when the gamepad controller has been disconnected
  38094. */
  38095. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38096. private _onGamepadConnectedEvent;
  38097. private _onGamepadDisconnectedEvent;
  38098. /**
  38099. * Initializes the gamepad manager
  38100. * @param _scene BabylonJS scene
  38101. */
  38102. constructor(_scene?: Scene | undefined);
  38103. /**
  38104. * The gamepads in the game pad manager
  38105. */
  38106. readonly gamepads: Gamepad[];
  38107. /**
  38108. * Get the gamepad controllers based on type
  38109. * @param type The type of gamepad controller
  38110. * @returns Nullable gamepad
  38111. */
  38112. getGamepadByType(type?: number): Nullable<Gamepad>;
  38113. /**
  38114. * Disposes the gamepad manager
  38115. */
  38116. dispose(): void;
  38117. private _addNewGamepad;
  38118. private _startMonitoringGamepads;
  38119. private _stopMonitoringGamepads;
  38120. /** @hidden */ private _checkGamepadsStatus(): void;
  38121. private _updateGamepadObjects;
  38122. }
  38123. }
  38124. declare module BABYLON {
  38125. interface Scene {
  38126. /** @hidden */ private _gamepadManager: Nullable<GamepadManager>;
  38127. /**
  38128. * Gets the gamepad manager associated with the scene
  38129. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38130. */
  38131. gamepadManager: GamepadManager;
  38132. }
  38133. /**
  38134. * Interface representing a free camera inputs manager
  38135. */
  38136. interface FreeCameraInputsManager {
  38137. /**
  38138. * Adds gamepad input support to the FreeCameraInputsManager.
  38139. * @returns the FreeCameraInputsManager
  38140. */
  38141. addGamepad(): FreeCameraInputsManager;
  38142. }
  38143. /**
  38144. * Interface representing an arc rotate camera inputs manager
  38145. */
  38146. interface ArcRotateCameraInputsManager {
  38147. /**
  38148. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38149. * @returns the camera inputs manager
  38150. */
  38151. addGamepad(): ArcRotateCameraInputsManager;
  38152. }
  38153. /**
  38154. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38155. */
  38156. export class GamepadSystemSceneComponent implements ISceneComponent {
  38157. /**
  38158. * The component name helpfull to identify the component in the list of scene components.
  38159. */
  38160. readonly name: string;
  38161. /**
  38162. * The scene the component belongs to.
  38163. */
  38164. scene: Scene;
  38165. /**
  38166. * Creates a new instance of the component for the given scene
  38167. * @param scene Defines the scene to register the component in
  38168. */
  38169. constructor(scene: Scene);
  38170. /**
  38171. * Registers the component in a given scene
  38172. */
  38173. register(): void;
  38174. /**
  38175. * Rebuilds the elements related to this component in case of
  38176. * context lost for instance.
  38177. */
  38178. rebuild(): void;
  38179. /**
  38180. * Disposes the component and the associated ressources
  38181. */
  38182. dispose(): void;
  38183. private _beforeCameraUpdate;
  38184. }
  38185. }
  38186. declare module BABYLON {
  38187. /**
  38188. * 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,
  38189. * which still works and will still be found in many Playgrounds.
  38190. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38191. */
  38192. export class UniversalCamera extends TouchCamera {
  38193. /**
  38194. * Defines the gamepad rotation sensiblity.
  38195. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38196. */
  38197. gamepadAngularSensibility: number;
  38198. /**
  38199. * Defines the gamepad move sensiblity.
  38200. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38201. */
  38202. gamepadMoveSensibility: number;
  38203. /**
  38204. * 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,
  38205. * which still works and will still be found in many Playgrounds.
  38206. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38207. * @param name Define the name of the camera in the scene
  38208. * @param position Define the start position of the camera in the scene
  38209. * @param scene Define the scene the camera belongs to
  38210. */
  38211. constructor(name: string, position: Vector3, scene: Scene);
  38212. /**
  38213. * Gets the current object class name.
  38214. * @return the class name
  38215. */
  38216. getClassName(): string;
  38217. }
  38218. }
  38219. declare module BABYLON {
  38220. /**
  38221. * This represents a FPS type of camera. This is only here for back compat purpose.
  38222. * Please use the UniversalCamera instead as both are identical.
  38223. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38224. */
  38225. export class GamepadCamera extends UniversalCamera {
  38226. /**
  38227. * Instantiates a new Gamepad Camera
  38228. * This represents a FPS type of camera. This is only here for back compat purpose.
  38229. * Please use the UniversalCamera instead as both are identical.
  38230. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38231. * @param name Define the name of the camera in the scene
  38232. * @param position Define the start position of the camera in the scene
  38233. * @param scene Define the scene the camera belongs to
  38234. */
  38235. constructor(name: string, position: Vector3, scene: Scene);
  38236. /**
  38237. * Gets the current object class name.
  38238. * @return the class name
  38239. */
  38240. getClassName(): string;
  38241. }
  38242. }
  38243. declare module BABYLON {
  38244. /** @hidden */
  38245. export var passPixelShader: {
  38246. name: string;
  38247. shader: string;
  38248. };
  38249. }
  38250. declare module BABYLON {
  38251. /** @hidden */
  38252. export var passCubePixelShader: {
  38253. name: string;
  38254. shader: string;
  38255. };
  38256. }
  38257. declare module BABYLON {
  38258. /**
  38259. * PassPostProcess which produces an output the same as it's input
  38260. */
  38261. export class PassPostProcess extends PostProcess {
  38262. /**
  38263. * Creates the PassPostProcess
  38264. * @param name The name of the effect.
  38265. * @param options The required width/height ratio to downsize to before computing the render pass.
  38266. * @param camera The camera to apply the render pass to.
  38267. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38268. * @param engine The engine which the post process will be applied. (default: current engine)
  38269. * @param reusable If the post process can be reused on the same frame. (default: false)
  38270. * @param textureType The type of texture to be used when performing the post processing.
  38271. * @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)
  38272. */
  38273. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38274. }
  38275. /**
  38276. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38277. */
  38278. export class PassCubePostProcess extends PostProcess {
  38279. private _face;
  38280. /**
  38281. * Gets or sets the cube face to display.
  38282. * * 0 is +X
  38283. * * 1 is -X
  38284. * * 2 is +Y
  38285. * * 3 is -Y
  38286. * * 4 is +Z
  38287. * * 5 is -Z
  38288. */
  38289. face: number;
  38290. /**
  38291. * Creates the PassCubePostProcess
  38292. * @param name The name of the effect.
  38293. * @param options The required width/height ratio to downsize to before computing the render pass.
  38294. * @param camera The camera to apply the render pass to.
  38295. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38296. * @param engine The engine which the post process will be applied. (default: current engine)
  38297. * @param reusable If the post process can be reused on the same frame. (default: false)
  38298. * @param textureType The type of texture to be used when performing the post processing.
  38299. * @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)
  38300. */
  38301. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38302. }
  38303. }
  38304. declare module BABYLON {
  38305. /** @hidden */
  38306. export var anaglyphPixelShader: {
  38307. name: string;
  38308. shader: string;
  38309. };
  38310. }
  38311. declare module BABYLON {
  38312. /**
  38313. * Postprocess used to generate anaglyphic rendering
  38314. */
  38315. export class AnaglyphPostProcess extends PostProcess {
  38316. private _passedProcess;
  38317. /**
  38318. * Creates a new AnaglyphPostProcess
  38319. * @param name defines postprocess name
  38320. * @param options defines creation options or target ratio scale
  38321. * @param rigCameras defines cameras using this postprocess
  38322. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38323. * @param engine defines hosting engine
  38324. * @param reusable defines if the postprocess will be reused multiple times per frame
  38325. */
  38326. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38327. }
  38328. }
  38329. declare module BABYLON {
  38330. /**
  38331. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38332. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38333. */
  38334. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38335. /**
  38336. * Creates a new AnaglyphArcRotateCamera
  38337. * @param name defines camera name
  38338. * @param alpha defines alpha angle (in radians)
  38339. * @param beta defines beta angle (in radians)
  38340. * @param radius defines radius
  38341. * @param target defines camera target
  38342. * @param interaxialDistance defines distance between each color axis
  38343. * @param scene defines the hosting scene
  38344. */
  38345. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38346. /**
  38347. * Gets camera class name
  38348. * @returns AnaglyphArcRotateCamera
  38349. */
  38350. getClassName(): string;
  38351. }
  38352. }
  38353. declare module BABYLON {
  38354. /**
  38355. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38356. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38357. */
  38358. export class AnaglyphFreeCamera extends FreeCamera {
  38359. /**
  38360. * Creates a new AnaglyphFreeCamera
  38361. * @param name defines camera name
  38362. * @param position defines initial position
  38363. * @param interaxialDistance defines distance between each color axis
  38364. * @param scene defines the hosting scene
  38365. */
  38366. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38367. /**
  38368. * Gets camera class name
  38369. * @returns AnaglyphFreeCamera
  38370. */
  38371. getClassName(): string;
  38372. }
  38373. }
  38374. declare module BABYLON {
  38375. /**
  38376. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38377. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38378. */
  38379. export class AnaglyphGamepadCamera extends GamepadCamera {
  38380. /**
  38381. * Creates a new AnaglyphGamepadCamera
  38382. * @param name defines camera name
  38383. * @param position defines initial position
  38384. * @param interaxialDistance defines distance between each color axis
  38385. * @param scene defines the hosting scene
  38386. */
  38387. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38388. /**
  38389. * Gets camera class name
  38390. * @returns AnaglyphGamepadCamera
  38391. */
  38392. getClassName(): string;
  38393. }
  38394. }
  38395. declare module BABYLON {
  38396. /**
  38397. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38398. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38399. */
  38400. export class AnaglyphUniversalCamera extends UniversalCamera {
  38401. /**
  38402. * Creates a new AnaglyphUniversalCamera
  38403. * @param name defines camera name
  38404. * @param position defines initial position
  38405. * @param interaxialDistance defines distance between each color axis
  38406. * @param scene defines the hosting scene
  38407. */
  38408. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38409. /**
  38410. * Gets camera class name
  38411. * @returns AnaglyphUniversalCamera
  38412. */
  38413. getClassName(): string;
  38414. }
  38415. }
  38416. declare module BABYLON {
  38417. /** @hidden */
  38418. export var stereoscopicInterlacePixelShader: {
  38419. name: string;
  38420. shader: string;
  38421. };
  38422. }
  38423. declare module BABYLON {
  38424. /**
  38425. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38426. */
  38427. export class StereoscopicInterlacePostProcess extends PostProcess {
  38428. private _stepSize;
  38429. private _passedProcess;
  38430. /**
  38431. * Initializes a StereoscopicInterlacePostProcess
  38432. * @param name The name of the effect.
  38433. * @param rigCameras The rig cameras to be appled to the post process
  38434. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38435. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38436. * @param engine The engine which the post process will be applied. (default: current engine)
  38437. * @param reusable If the post process can be reused on the same frame. (default: false)
  38438. */
  38439. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38440. }
  38441. }
  38442. declare module BABYLON {
  38443. /**
  38444. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38445. * @see http://doc.babylonjs.com/features/cameras
  38446. */
  38447. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38448. /**
  38449. * Creates a new StereoscopicArcRotateCamera
  38450. * @param name defines camera name
  38451. * @param alpha defines alpha angle (in radians)
  38452. * @param beta defines beta angle (in radians)
  38453. * @param radius defines radius
  38454. * @param target defines camera target
  38455. * @param interaxialDistance defines distance between each color axis
  38456. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38457. * @param scene defines the hosting scene
  38458. */
  38459. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38460. /**
  38461. * Gets camera class name
  38462. * @returns StereoscopicArcRotateCamera
  38463. */
  38464. getClassName(): string;
  38465. }
  38466. }
  38467. declare module BABYLON {
  38468. /**
  38469. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38470. * @see http://doc.babylonjs.com/features/cameras
  38471. */
  38472. export class StereoscopicFreeCamera extends FreeCamera {
  38473. /**
  38474. * Creates a new StereoscopicFreeCamera
  38475. * @param name defines camera name
  38476. * @param position defines initial position
  38477. * @param interaxialDistance defines distance between each color axis
  38478. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38479. * @param scene defines the hosting scene
  38480. */
  38481. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38482. /**
  38483. * Gets camera class name
  38484. * @returns StereoscopicFreeCamera
  38485. */
  38486. getClassName(): string;
  38487. }
  38488. }
  38489. declare module BABYLON {
  38490. /**
  38491. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38492. * @see http://doc.babylonjs.com/features/cameras
  38493. */
  38494. export class StereoscopicGamepadCamera extends GamepadCamera {
  38495. /**
  38496. * Creates a new StereoscopicGamepadCamera
  38497. * @param name defines camera name
  38498. * @param position defines initial position
  38499. * @param interaxialDistance defines distance between each color axis
  38500. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38501. * @param scene defines the hosting scene
  38502. */
  38503. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38504. /**
  38505. * Gets camera class name
  38506. * @returns StereoscopicGamepadCamera
  38507. */
  38508. getClassName(): string;
  38509. }
  38510. }
  38511. declare module BABYLON {
  38512. /**
  38513. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38514. * @see http://doc.babylonjs.com/features/cameras
  38515. */
  38516. export class StereoscopicUniversalCamera extends UniversalCamera {
  38517. /**
  38518. * Creates a new StereoscopicUniversalCamera
  38519. * @param name defines camera name
  38520. * @param position defines initial position
  38521. * @param interaxialDistance defines distance between each color axis
  38522. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38523. * @param scene defines the hosting scene
  38524. */
  38525. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38526. /**
  38527. * Gets camera class name
  38528. * @returns StereoscopicUniversalCamera
  38529. */
  38530. getClassName(): string;
  38531. }
  38532. }
  38533. declare module BABYLON {
  38534. /**
  38535. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38536. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38537. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38538. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38539. */
  38540. export class VirtualJoysticksCamera extends FreeCamera {
  38541. /**
  38542. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38543. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38544. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38545. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38546. * @param name Define the name of the camera in the scene
  38547. * @param position Define the start position of the camera in the scene
  38548. * @param scene Define the scene the camera belongs to
  38549. */
  38550. constructor(name: string, position: Vector3, scene: Scene);
  38551. /**
  38552. * Gets the current object class name.
  38553. * @return the class name
  38554. */
  38555. getClassName(): string;
  38556. }
  38557. }
  38558. declare module BABYLON {
  38559. /**
  38560. * This represents all the required metrics to create a VR camera.
  38561. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38562. */
  38563. export class VRCameraMetrics {
  38564. /**
  38565. * Define the horizontal resolution off the screen.
  38566. */
  38567. hResolution: number;
  38568. /**
  38569. * Define the vertical resolution off the screen.
  38570. */
  38571. vResolution: number;
  38572. /**
  38573. * Define the horizontal screen size.
  38574. */
  38575. hScreenSize: number;
  38576. /**
  38577. * Define the vertical screen size.
  38578. */
  38579. vScreenSize: number;
  38580. /**
  38581. * Define the vertical screen center position.
  38582. */
  38583. vScreenCenter: number;
  38584. /**
  38585. * Define the distance of the eyes to the screen.
  38586. */
  38587. eyeToScreenDistance: number;
  38588. /**
  38589. * Define the distance between both lenses
  38590. */
  38591. lensSeparationDistance: number;
  38592. /**
  38593. * Define the distance between both viewer's eyes.
  38594. */
  38595. interpupillaryDistance: number;
  38596. /**
  38597. * Define the distortion factor of the VR postprocess.
  38598. * Please, touch with care.
  38599. */
  38600. distortionK: number[];
  38601. /**
  38602. * Define the chromatic aberration correction factors for the VR post process.
  38603. */
  38604. chromaAbCorrection: number[];
  38605. /**
  38606. * Define the scale factor of the post process.
  38607. * The smaller the better but the slower.
  38608. */
  38609. postProcessScaleFactor: number;
  38610. /**
  38611. * Define an offset for the lens center.
  38612. */
  38613. lensCenterOffset: number;
  38614. /**
  38615. * Define if the current vr camera should compensate the distortion of the lense or not.
  38616. */
  38617. compensateDistortion: boolean;
  38618. /**
  38619. * Defines if multiview should be enabled when rendering (Default: false)
  38620. */
  38621. multiviewEnabled: boolean;
  38622. /**
  38623. * Gets the rendering aspect ratio based on the provided resolutions.
  38624. */
  38625. readonly aspectRatio: number;
  38626. /**
  38627. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38628. */
  38629. readonly aspectRatioFov: number;
  38630. /**
  38631. * @hidden
  38632. */
  38633. readonly leftHMatrix: Matrix;
  38634. /**
  38635. * @hidden
  38636. */
  38637. readonly rightHMatrix: Matrix;
  38638. /**
  38639. * @hidden
  38640. */
  38641. readonly leftPreViewMatrix: Matrix;
  38642. /**
  38643. * @hidden
  38644. */
  38645. readonly rightPreViewMatrix: Matrix;
  38646. /**
  38647. * Get the default VRMetrics based on the most generic setup.
  38648. * @returns the default vr metrics
  38649. */
  38650. static GetDefault(): VRCameraMetrics;
  38651. }
  38652. }
  38653. declare module BABYLON {
  38654. /** @hidden */
  38655. export var vrDistortionCorrectionPixelShader: {
  38656. name: string;
  38657. shader: string;
  38658. };
  38659. }
  38660. declare module BABYLON {
  38661. /**
  38662. * VRDistortionCorrectionPostProcess used for mobile VR
  38663. */
  38664. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38665. private _isRightEye;
  38666. private _distortionFactors;
  38667. private _postProcessScaleFactor;
  38668. private _lensCenterOffset;
  38669. private _scaleIn;
  38670. private _scaleFactor;
  38671. private _lensCenter;
  38672. /**
  38673. * Initializes the VRDistortionCorrectionPostProcess
  38674. * @param name The name of the effect.
  38675. * @param camera The camera to apply the render pass to.
  38676. * @param isRightEye If this is for the right eye distortion
  38677. * @param vrMetrics All the required metrics for the VR camera
  38678. */
  38679. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38680. }
  38681. }
  38682. declare module BABYLON {
  38683. /**
  38684. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38685. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38686. */
  38687. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38688. /**
  38689. * Creates a new VRDeviceOrientationArcRotateCamera
  38690. * @param name defines camera name
  38691. * @param alpha defines the camera rotation along the logitudinal axis
  38692. * @param beta defines the camera rotation along the latitudinal axis
  38693. * @param radius defines the camera distance from its target
  38694. * @param target defines the camera target
  38695. * @param scene defines the scene the camera belongs to
  38696. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38697. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38698. */
  38699. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38700. /**
  38701. * Gets camera class name
  38702. * @returns VRDeviceOrientationArcRotateCamera
  38703. */
  38704. getClassName(): string;
  38705. }
  38706. }
  38707. declare module BABYLON {
  38708. /**
  38709. * Camera used to simulate VR rendering (based on FreeCamera)
  38710. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38711. */
  38712. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38713. /**
  38714. * Creates a new VRDeviceOrientationFreeCamera
  38715. * @param name defines camera name
  38716. * @param position defines the start position of the camera
  38717. * @param scene defines the scene the camera belongs to
  38718. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38719. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38720. */
  38721. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38722. /**
  38723. * Gets camera class name
  38724. * @returns VRDeviceOrientationFreeCamera
  38725. */
  38726. getClassName(): string;
  38727. }
  38728. }
  38729. declare module BABYLON {
  38730. /**
  38731. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38732. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38733. */
  38734. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38735. /**
  38736. * Creates a new VRDeviceOrientationGamepadCamera
  38737. * @param name defines camera name
  38738. * @param position defines the start position of the camera
  38739. * @param scene defines the scene the camera belongs to
  38740. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38741. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38742. */
  38743. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38744. /**
  38745. * Gets camera class name
  38746. * @returns VRDeviceOrientationGamepadCamera
  38747. */
  38748. getClassName(): string;
  38749. }
  38750. }
  38751. declare module BABYLON {
  38752. /**
  38753. * Base class of materials working in push mode in babylon JS
  38754. * @hidden
  38755. */
  38756. export class PushMaterial extends Material {
  38757. protected _activeEffect: Effect;
  38758. protected _normalMatrix: Matrix;
  38759. /**
  38760. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38761. * This means that the material can keep using a previous shader while a new one is being compiled.
  38762. * This is mostly used when shader parallel compilation is supported (true by default)
  38763. */
  38764. allowShaderHotSwapping: boolean;
  38765. constructor(name: string, scene: Scene);
  38766. getEffect(): Effect;
  38767. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38768. /**
  38769. * Binds the given world matrix to the active effect
  38770. *
  38771. * @param world the matrix to bind
  38772. */
  38773. bindOnlyWorldMatrix(world: Matrix): void;
  38774. /**
  38775. * Binds the given normal matrix to the active effect
  38776. *
  38777. * @param normalMatrix the matrix to bind
  38778. */
  38779. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38780. bind(world: Matrix, mesh?: Mesh): void;
  38781. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38782. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38783. }
  38784. }
  38785. declare module BABYLON {
  38786. /**
  38787. * This groups all the flags used to control the materials channel.
  38788. */
  38789. export class MaterialFlags {
  38790. private static _DiffuseTextureEnabled;
  38791. /**
  38792. * Are diffuse textures enabled in the application.
  38793. */
  38794. static DiffuseTextureEnabled: boolean;
  38795. private static _AmbientTextureEnabled;
  38796. /**
  38797. * Are ambient textures enabled in the application.
  38798. */
  38799. static AmbientTextureEnabled: boolean;
  38800. private static _OpacityTextureEnabled;
  38801. /**
  38802. * Are opacity textures enabled in the application.
  38803. */
  38804. static OpacityTextureEnabled: boolean;
  38805. private static _ReflectionTextureEnabled;
  38806. /**
  38807. * Are reflection textures enabled in the application.
  38808. */
  38809. static ReflectionTextureEnabled: boolean;
  38810. private static _EmissiveTextureEnabled;
  38811. /**
  38812. * Are emissive textures enabled in the application.
  38813. */
  38814. static EmissiveTextureEnabled: boolean;
  38815. private static _SpecularTextureEnabled;
  38816. /**
  38817. * Are specular textures enabled in the application.
  38818. */
  38819. static SpecularTextureEnabled: boolean;
  38820. private static _BumpTextureEnabled;
  38821. /**
  38822. * Are bump textures enabled in the application.
  38823. */
  38824. static BumpTextureEnabled: boolean;
  38825. private static _LightmapTextureEnabled;
  38826. /**
  38827. * Are lightmap textures enabled in the application.
  38828. */
  38829. static LightmapTextureEnabled: boolean;
  38830. private static _RefractionTextureEnabled;
  38831. /**
  38832. * Are refraction textures enabled in the application.
  38833. */
  38834. static RefractionTextureEnabled: boolean;
  38835. private static _ColorGradingTextureEnabled;
  38836. /**
  38837. * Are color grading textures enabled in the application.
  38838. */
  38839. static ColorGradingTextureEnabled: boolean;
  38840. private static _FresnelEnabled;
  38841. /**
  38842. * Are fresnels enabled in the application.
  38843. */
  38844. static FresnelEnabled: boolean;
  38845. private static _ClearCoatTextureEnabled;
  38846. /**
  38847. * Are clear coat textures enabled in the application.
  38848. */
  38849. static ClearCoatTextureEnabled: boolean;
  38850. private static _ClearCoatBumpTextureEnabled;
  38851. /**
  38852. * Are clear coat bump textures enabled in the application.
  38853. */
  38854. static ClearCoatBumpTextureEnabled: boolean;
  38855. private static _ClearCoatTintTextureEnabled;
  38856. /**
  38857. * Are clear coat tint textures enabled in the application.
  38858. */
  38859. static ClearCoatTintTextureEnabled: boolean;
  38860. private static _SheenTextureEnabled;
  38861. /**
  38862. * Are sheen textures enabled in the application.
  38863. */
  38864. static SheenTextureEnabled: boolean;
  38865. private static _AnisotropicTextureEnabled;
  38866. /**
  38867. * Are anisotropic textures enabled in the application.
  38868. */
  38869. static AnisotropicTextureEnabled: boolean;
  38870. private static _ThicknessTextureEnabled;
  38871. /**
  38872. * Are thickness textures enabled in the application.
  38873. */
  38874. static ThicknessTextureEnabled: boolean;
  38875. }
  38876. }
  38877. declare module BABYLON {
  38878. /** @hidden */
  38879. export var defaultFragmentDeclaration: {
  38880. name: string;
  38881. shader: string;
  38882. };
  38883. }
  38884. declare module BABYLON {
  38885. /** @hidden */
  38886. export var defaultUboDeclaration: {
  38887. name: string;
  38888. shader: string;
  38889. };
  38890. }
  38891. declare module BABYLON {
  38892. /** @hidden */
  38893. export var lightFragmentDeclaration: {
  38894. name: string;
  38895. shader: string;
  38896. };
  38897. }
  38898. declare module BABYLON {
  38899. /** @hidden */
  38900. export var lightUboDeclaration: {
  38901. name: string;
  38902. shader: string;
  38903. };
  38904. }
  38905. declare module BABYLON {
  38906. /** @hidden */
  38907. export var lightsFragmentFunctions: {
  38908. name: string;
  38909. shader: string;
  38910. };
  38911. }
  38912. declare module BABYLON {
  38913. /** @hidden */
  38914. export var shadowsFragmentFunctions: {
  38915. name: string;
  38916. shader: string;
  38917. };
  38918. }
  38919. declare module BABYLON {
  38920. /** @hidden */
  38921. export var fresnelFunction: {
  38922. name: string;
  38923. shader: string;
  38924. };
  38925. }
  38926. declare module BABYLON {
  38927. /** @hidden */
  38928. export var reflectionFunction: {
  38929. name: string;
  38930. shader: string;
  38931. };
  38932. }
  38933. declare module BABYLON {
  38934. /** @hidden */
  38935. export var bumpFragmentFunctions: {
  38936. name: string;
  38937. shader: string;
  38938. };
  38939. }
  38940. declare module BABYLON {
  38941. /** @hidden */
  38942. export var logDepthDeclaration: {
  38943. name: string;
  38944. shader: string;
  38945. };
  38946. }
  38947. declare module BABYLON {
  38948. /** @hidden */
  38949. export var bumpFragment: {
  38950. name: string;
  38951. shader: string;
  38952. };
  38953. }
  38954. declare module BABYLON {
  38955. /** @hidden */
  38956. export var depthPrePass: {
  38957. name: string;
  38958. shader: string;
  38959. };
  38960. }
  38961. declare module BABYLON {
  38962. /** @hidden */
  38963. export var lightFragment: {
  38964. name: string;
  38965. shader: string;
  38966. };
  38967. }
  38968. declare module BABYLON {
  38969. /** @hidden */
  38970. export var logDepthFragment: {
  38971. name: string;
  38972. shader: string;
  38973. };
  38974. }
  38975. declare module BABYLON {
  38976. /** @hidden */
  38977. export var defaultPixelShader: {
  38978. name: string;
  38979. shader: string;
  38980. };
  38981. }
  38982. declare module BABYLON {
  38983. /** @hidden */
  38984. export var defaultVertexDeclaration: {
  38985. name: string;
  38986. shader: string;
  38987. };
  38988. }
  38989. declare module BABYLON {
  38990. /** @hidden */
  38991. export var bumpVertexDeclaration: {
  38992. name: string;
  38993. shader: string;
  38994. };
  38995. }
  38996. declare module BABYLON {
  38997. /** @hidden */
  38998. export var bumpVertex: {
  38999. name: string;
  39000. shader: string;
  39001. };
  39002. }
  39003. declare module BABYLON {
  39004. /** @hidden */
  39005. export var fogVertex: {
  39006. name: string;
  39007. shader: string;
  39008. };
  39009. }
  39010. declare module BABYLON {
  39011. /** @hidden */
  39012. export var shadowsVertex: {
  39013. name: string;
  39014. shader: string;
  39015. };
  39016. }
  39017. declare module BABYLON {
  39018. /** @hidden */
  39019. export var pointCloudVertex: {
  39020. name: string;
  39021. shader: string;
  39022. };
  39023. }
  39024. declare module BABYLON {
  39025. /** @hidden */
  39026. export var logDepthVertex: {
  39027. name: string;
  39028. shader: string;
  39029. };
  39030. }
  39031. declare module BABYLON {
  39032. /** @hidden */
  39033. export var defaultVertexShader: {
  39034. name: string;
  39035. shader: string;
  39036. };
  39037. }
  39038. declare module BABYLON {
  39039. /** @hidden */
  39040. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39041. MAINUV1: boolean;
  39042. MAINUV2: boolean;
  39043. DIFFUSE: boolean;
  39044. DIFFUSEDIRECTUV: number;
  39045. AMBIENT: boolean;
  39046. AMBIENTDIRECTUV: number;
  39047. OPACITY: boolean;
  39048. OPACITYDIRECTUV: number;
  39049. OPACITYRGB: boolean;
  39050. REFLECTION: boolean;
  39051. EMISSIVE: boolean;
  39052. EMISSIVEDIRECTUV: number;
  39053. SPECULAR: boolean;
  39054. SPECULARDIRECTUV: number;
  39055. BUMP: boolean;
  39056. BUMPDIRECTUV: number;
  39057. PARALLAX: boolean;
  39058. PARALLAXOCCLUSION: boolean;
  39059. SPECULAROVERALPHA: boolean;
  39060. CLIPPLANE: boolean;
  39061. CLIPPLANE2: boolean;
  39062. CLIPPLANE3: boolean;
  39063. CLIPPLANE4: boolean;
  39064. ALPHATEST: boolean;
  39065. DEPTHPREPASS: boolean;
  39066. ALPHAFROMDIFFUSE: boolean;
  39067. POINTSIZE: boolean;
  39068. FOG: boolean;
  39069. SPECULARTERM: boolean;
  39070. DIFFUSEFRESNEL: boolean;
  39071. OPACITYFRESNEL: boolean;
  39072. REFLECTIONFRESNEL: boolean;
  39073. REFRACTIONFRESNEL: boolean;
  39074. EMISSIVEFRESNEL: boolean;
  39075. FRESNEL: boolean;
  39076. NORMAL: boolean;
  39077. UV1: boolean;
  39078. UV2: boolean;
  39079. VERTEXCOLOR: boolean;
  39080. VERTEXALPHA: boolean;
  39081. NUM_BONE_INFLUENCERS: number;
  39082. BonesPerMesh: number;
  39083. BONETEXTURE: boolean;
  39084. INSTANCES: boolean;
  39085. GLOSSINESS: boolean;
  39086. ROUGHNESS: boolean;
  39087. EMISSIVEASILLUMINATION: boolean;
  39088. LINKEMISSIVEWITHDIFFUSE: boolean;
  39089. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39090. LIGHTMAP: boolean;
  39091. LIGHTMAPDIRECTUV: number;
  39092. OBJECTSPACE_NORMALMAP: boolean;
  39093. USELIGHTMAPASSHADOWMAP: boolean;
  39094. REFLECTIONMAP_3D: boolean;
  39095. REFLECTIONMAP_SPHERICAL: boolean;
  39096. REFLECTIONMAP_PLANAR: boolean;
  39097. REFLECTIONMAP_CUBIC: boolean;
  39098. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39099. REFLECTIONMAP_PROJECTION: boolean;
  39100. REFLECTIONMAP_SKYBOX: boolean;
  39101. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39102. REFLECTIONMAP_EXPLICIT: boolean;
  39103. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39104. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39105. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39106. INVERTCUBICMAP: boolean;
  39107. LOGARITHMICDEPTH: boolean;
  39108. REFRACTION: boolean;
  39109. REFRACTIONMAP_3D: boolean;
  39110. REFLECTIONOVERALPHA: boolean;
  39111. TWOSIDEDLIGHTING: boolean;
  39112. SHADOWFLOAT: boolean;
  39113. MORPHTARGETS: boolean;
  39114. MORPHTARGETS_NORMAL: boolean;
  39115. MORPHTARGETS_TANGENT: boolean;
  39116. MORPHTARGETS_UV: boolean;
  39117. NUM_MORPH_INFLUENCERS: number;
  39118. NONUNIFORMSCALING: boolean;
  39119. PREMULTIPLYALPHA: boolean;
  39120. IMAGEPROCESSING: boolean;
  39121. VIGNETTE: boolean;
  39122. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39123. VIGNETTEBLENDMODEOPAQUE: boolean;
  39124. TONEMAPPING: boolean;
  39125. TONEMAPPING_ACES: boolean;
  39126. CONTRAST: boolean;
  39127. COLORCURVES: boolean;
  39128. COLORGRADING: boolean;
  39129. COLORGRADING3D: boolean;
  39130. SAMPLER3DGREENDEPTH: boolean;
  39131. SAMPLER3DBGRMAP: boolean;
  39132. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39133. MULTIVIEW: boolean;
  39134. /**
  39135. * If the reflection texture on this material is in linear color space
  39136. * @hidden
  39137. */
  39138. IS_REFLECTION_LINEAR: boolean;
  39139. /**
  39140. * If the refraction texture on this material is in linear color space
  39141. * @hidden
  39142. */
  39143. IS_REFRACTION_LINEAR: boolean;
  39144. EXPOSURE: boolean;
  39145. constructor();
  39146. setReflectionMode(modeToEnable: string): void;
  39147. }
  39148. /**
  39149. * This is the default material used in Babylon. It is the best trade off between quality
  39150. * and performances.
  39151. * @see http://doc.babylonjs.com/babylon101/materials
  39152. */
  39153. export class StandardMaterial extends PushMaterial {
  39154. private _diffuseTexture;
  39155. /**
  39156. * The basic texture of the material as viewed under a light.
  39157. */
  39158. diffuseTexture: Nullable<BaseTexture>;
  39159. private _ambientTexture;
  39160. /**
  39161. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39162. */
  39163. ambientTexture: Nullable<BaseTexture>;
  39164. private _opacityTexture;
  39165. /**
  39166. * Define the transparency of the material from a texture.
  39167. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39168. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39169. */
  39170. opacityTexture: Nullable<BaseTexture>;
  39171. private _reflectionTexture;
  39172. /**
  39173. * Define the texture used to display the reflection.
  39174. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39175. */
  39176. reflectionTexture: Nullable<BaseTexture>;
  39177. private _emissiveTexture;
  39178. /**
  39179. * Define texture of the material as if self lit.
  39180. * This will be mixed in the final result even in the absence of light.
  39181. */
  39182. emissiveTexture: Nullable<BaseTexture>;
  39183. private _specularTexture;
  39184. /**
  39185. * Define how the color and intensity of the highlight given by the light in the material.
  39186. */
  39187. specularTexture: Nullable<BaseTexture>;
  39188. private _bumpTexture;
  39189. /**
  39190. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39191. * 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.
  39192. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39193. */
  39194. bumpTexture: Nullable<BaseTexture>;
  39195. private _lightmapTexture;
  39196. /**
  39197. * Complex lighting can be computationally expensive to compute at runtime.
  39198. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39199. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39200. */
  39201. lightmapTexture: Nullable<BaseTexture>;
  39202. private _refractionTexture;
  39203. /**
  39204. * Define the texture used to display the refraction.
  39205. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39206. */
  39207. refractionTexture: Nullable<BaseTexture>;
  39208. /**
  39209. * The color of the material lit by the environmental background lighting.
  39210. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39211. */
  39212. ambientColor: Color3;
  39213. /**
  39214. * The basic color of the material as viewed under a light.
  39215. */
  39216. diffuseColor: Color3;
  39217. /**
  39218. * Define how the color and intensity of the highlight given by the light in the material.
  39219. */
  39220. specularColor: Color3;
  39221. /**
  39222. * Define the color of the material as if self lit.
  39223. * This will be mixed in the final result even in the absence of light.
  39224. */
  39225. emissiveColor: Color3;
  39226. /**
  39227. * Defines how sharp are the highlights in the material.
  39228. * The bigger the value the sharper giving a more glossy feeling to the result.
  39229. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39230. */
  39231. specularPower: number;
  39232. private _useAlphaFromDiffuseTexture;
  39233. /**
  39234. * Does the transparency come from the diffuse texture alpha channel.
  39235. */
  39236. useAlphaFromDiffuseTexture: boolean;
  39237. private _useEmissiveAsIllumination;
  39238. /**
  39239. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39240. */
  39241. useEmissiveAsIllumination: boolean;
  39242. private _linkEmissiveWithDiffuse;
  39243. /**
  39244. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39245. * the emissive level when the final color is close to one.
  39246. */
  39247. linkEmissiveWithDiffuse: boolean;
  39248. private _useSpecularOverAlpha;
  39249. /**
  39250. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39251. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39252. */
  39253. useSpecularOverAlpha: boolean;
  39254. private _useReflectionOverAlpha;
  39255. /**
  39256. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39257. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39258. */
  39259. useReflectionOverAlpha: boolean;
  39260. private _disableLighting;
  39261. /**
  39262. * Does lights from the scene impacts this material.
  39263. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39264. */
  39265. disableLighting: boolean;
  39266. private _useObjectSpaceNormalMap;
  39267. /**
  39268. * Allows using an object space normal map (instead of tangent space).
  39269. */
  39270. useObjectSpaceNormalMap: boolean;
  39271. private _useParallax;
  39272. /**
  39273. * Is parallax enabled or not.
  39274. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39275. */
  39276. useParallax: boolean;
  39277. private _useParallaxOcclusion;
  39278. /**
  39279. * Is parallax occlusion enabled or not.
  39280. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39281. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39282. */
  39283. useParallaxOcclusion: boolean;
  39284. /**
  39285. * 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.
  39286. */
  39287. parallaxScaleBias: number;
  39288. private _roughness;
  39289. /**
  39290. * Helps to define how blurry the reflections should appears in the material.
  39291. */
  39292. roughness: number;
  39293. /**
  39294. * In case of refraction, define the value of the index of refraction.
  39295. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39296. */
  39297. indexOfRefraction: number;
  39298. /**
  39299. * Invert the refraction texture alongside the y axis.
  39300. * It can be useful with procedural textures or probe for instance.
  39301. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39302. */
  39303. invertRefractionY: boolean;
  39304. /**
  39305. * Defines the alpha limits in alpha test mode.
  39306. */
  39307. alphaCutOff: number;
  39308. private _useLightmapAsShadowmap;
  39309. /**
  39310. * In case of light mapping, define whether the map contains light or shadow informations.
  39311. */
  39312. useLightmapAsShadowmap: boolean;
  39313. private _diffuseFresnelParameters;
  39314. /**
  39315. * Define the diffuse fresnel parameters of the material.
  39316. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39317. */
  39318. diffuseFresnelParameters: FresnelParameters;
  39319. private _opacityFresnelParameters;
  39320. /**
  39321. * Define the opacity fresnel parameters of the material.
  39322. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39323. */
  39324. opacityFresnelParameters: FresnelParameters;
  39325. private _reflectionFresnelParameters;
  39326. /**
  39327. * Define the reflection fresnel parameters of the material.
  39328. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39329. */
  39330. reflectionFresnelParameters: FresnelParameters;
  39331. private _refractionFresnelParameters;
  39332. /**
  39333. * Define the refraction fresnel parameters of the material.
  39334. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39335. */
  39336. refractionFresnelParameters: FresnelParameters;
  39337. private _emissiveFresnelParameters;
  39338. /**
  39339. * Define the emissive fresnel parameters of the material.
  39340. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39341. */
  39342. emissiveFresnelParameters: FresnelParameters;
  39343. private _useReflectionFresnelFromSpecular;
  39344. /**
  39345. * If true automatically deducts the fresnels values from the material specularity.
  39346. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39347. */
  39348. useReflectionFresnelFromSpecular: boolean;
  39349. private _useGlossinessFromSpecularMapAlpha;
  39350. /**
  39351. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39352. */
  39353. useGlossinessFromSpecularMapAlpha: boolean;
  39354. private _maxSimultaneousLights;
  39355. /**
  39356. * Defines the maximum number of lights that can be used in the material
  39357. */
  39358. maxSimultaneousLights: number;
  39359. private _invertNormalMapX;
  39360. /**
  39361. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39362. */
  39363. invertNormalMapX: boolean;
  39364. private _invertNormalMapY;
  39365. /**
  39366. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39367. */
  39368. invertNormalMapY: boolean;
  39369. private _twoSidedLighting;
  39370. /**
  39371. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39372. */
  39373. twoSidedLighting: boolean;
  39374. /**
  39375. * Default configuration related to image processing available in the standard Material.
  39376. */
  39377. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39378. /**
  39379. * Gets the image processing configuration used either in this material.
  39380. */
  39381. /**
  39382. * Sets the Default image processing configuration used either in the this material.
  39383. *
  39384. * If sets to null, the scene one is in use.
  39385. */
  39386. imageProcessingConfiguration: ImageProcessingConfiguration;
  39387. /**
  39388. * Keep track of the image processing observer to allow dispose and replace.
  39389. */
  39390. private _imageProcessingObserver;
  39391. /**
  39392. * Attaches a new image processing configuration to the Standard Material.
  39393. * @param configuration
  39394. */
  39395. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39396. /**
  39397. * Gets wether the color curves effect is enabled.
  39398. */
  39399. /**
  39400. * Sets wether the color curves effect is enabled.
  39401. */
  39402. cameraColorCurvesEnabled: boolean;
  39403. /**
  39404. * Gets wether the color grading effect is enabled.
  39405. */
  39406. /**
  39407. * Gets wether the color grading effect is enabled.
  39408. */
  39409. cameraColorGradingEnabled: boolean;
  39410. /**
  39411. * Gets wether tonemapping is enabled or not.
  39412. */
  39413. /**
  39414. * Sets wether tonemapping is enabled or not
  39415. */
  39416. cameraToneMappingEnabled: boolean;
  39417. /**
  39418. * The camera exposure used on this material.
  39419. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39420. * This corresponds to a photographic exposure.
  39421. */
  39422. /**
  39423. * The camera exposure used on this material.
  39424. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39425. * This corresponds to a photographic exposure.
  39426. */
  39427. cameraExposure: number;
  39428. /**
  39429. * Gets The camera contrast used on this material.
  39430. */
  39431. /**
  39432. * Sets The camera contrast used on this material.
  39433. */
  39434. cameraContrast: number;
  39435. /**
  39436. * Gets the Color Grading 2D Lookup Texture.
  39437. */
  39438. /**
  39439. * Sets the Color Grading 2D Lookup Texture.
  39440. */
  39441. cameraColorGradingTexture: Nullable<BaseTexture>;
  39442. /**
  39443. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39444. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39445. * 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;
  39446. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39447. */
  39448. /**
  39449. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39450. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39451. * 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;
  39452. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39453. */
  39454. cameraColorCurves: Nullable<ColorCurves>;
  39455. /**
  39456. * Custom callback helping to override the default shader used in the material.
  39457. */
  39458. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39459. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39460. protected _worldViewProjectionMatrix: Matrix;
  39461. protected _globalAmbientColor: Color3;
  39462. protected _useLogarithmicDepth: boolean;
  39463. protected _rebuildInParallel: boolean;
  39464. /**
  39465. * Instantiates a new standard material.
  39466. * This is the default material used in Babylon. It is the best trade off between quality
  39467. * and performances.
  39468. * @see http://doc.babylonjs.com/babylon101/materials
  39469. * @param name Define the name of the material in the scene
  39470. * @param scene Define the scene the material belong to
  39471. */
  39472. constructor(name: string, scene: Scene);
  39473. /**
  39474. * Gets a boolean indicating that current material needs to register RTT
  39475. */
  39476. readonly hasRenderTargetTextures: boolean;
  39477. /**
  39478. * Gets the current class name of the material e.g. "StandardMaterial"
  39479. * Mainly use in serialization.
  39480. * @returns the class name
  39481. */
  39482. getClassName(): string;
  39483. /**
  39484. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39485. * You can try switching to logarithmic depth.
  39486. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39487. */
  39488. useLogarithmicDepth: boolean;
  39489. /**
  39490. * Specifies if the material will require alpha blending
  39491. * @returns a boolean specifying if alpha blending is needed
  39492. */
  39493. needAlphaBlending(): boolean;
  39494. /**
  39495. * Specifies if this material should be rendered in alpha test mode
  39496. * @returns a boolean specifying if an alpha test is needed.
  39497. */
  39498. needAlphaTesting(): boolean;
  39499. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39500. /**
  39501. * Get the texture used for alpha test purpose.
  39502. * @returns the diffuse texture in case of the standard material.
  39503. */
  39504. getAlphaTestTexture(): Nullable<BaseTexture>;
  39505. /**
  39506. * Get if the submesh is ready to be used and all its information available.
  39507. * Child classes can use it to update shaders
  39508. * @param mesh defines the mesh to check
  39509. * @param subMesh defines which submesh to check
  39510. * @param useInstances specifies that instances should be used
  39511. * @returns a boolean indicating that the submesh is ready or not
  39512. */
  39513. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39514. /**
  39515. * Builds the material UBO layouts.
  39516. * Used internally during the effect preparation.
  39517. */
  39518. buildUniformLayout(): void;
  39519. /**
  39520. * Unbinds the material from the mesh
  39521. */
  39522. unbind(): void;
  39523. /**
  39524. * Binds the submesh to this material by preparing the effect and shader to draw
  39525. * @param world defines the world transformation matrix
  39526. * @param mesh defines the mesh containing the submesh
  39527. * @param subMesh defines the submesh to bind the material to
  39528. */
  39529. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39530. /**
  39531. * Get the list of animatables in the material.
  39532. * @returns the list of animatables object used in the material
  39533. */
  39534. getAnimatables(): IAnimatable[];
  39535. /**
  39536. * Gets the active textures from the material
  39537. * @returns an array of textures
  39538. */
  39539. getActiveTextures(): BaseTexture[];
  39540. /**
  39541. * Specifies if the material uses a texture
  39542. * @param texture defines the texture to check against the material
  39543. * @returns a boolean specifying if the material uses the texture
  39544. */
  39545. hasTexture(texture: BaseTexture): boolean;
  39546. /**
  39547. * Disposes the material
  39548. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39549. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39550. */
  39551. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39552. /**
  39553. * Makes a duplicate of the material, and gives it a new name
  39554. * @param name defines the new name for the duplicated material
  39555. * @returns the cloned material
  39556. */
  39557. clone(name: string): StandardMaterial;
  39558. /**
  39559. * Serializes this material in a JSON representation
  39560. * @returns the serialized material object
  39561. */
  39562. serialize(): any;
  39563. /**
  39564. * Creates a standard material from parsed material data
  39565. * @param source defines the JSON representation of the material
  39566. * @param scene defines the hosting scene
  39567. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39568. * @returns a new standard material
  39569. */
  39570. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39571. /**
  39572. * Are diffuse textures enabled in the application.
  39573. */
  39574. static DiffuseTextureEnabled: boolean;
  39575. /**
  39576. * Are ambient textures enabled in the application.
  39577. */
  39578. static AmbientTextureEnabled: boolean;
  39579. /**
  39580. * Are opacity textures enabled in the application.
  39581. */
  39582. static OpacityTextureEnabled: boolean;
  39583. /**
  39584. * Are reflection textures enabled in the application.
  39585. */
  39586. static ReflectionTextureEnabled: boolean;
  39587. /**
  39588. * Are emissive textures enabled in the application.
  39589. */
  39590. static EmissiveTextureEnabled: boolean;
  39591. /**
  39592. * Are specular textures enabled in the application.
  39593. */
  39594. static SpecularTextureEnabled: boolean;
  39595. /**
  39596. * Are bump textures enabled in the application.
  39597. */
  39598. static BumpTextureEnabled: boolean;
  39599. /**
  39600. * Are lightmap textures enabled in the application.
  39601. */
  39602. static LightmapTextureEnabled: boolean;
  39603. /**
  39604. * Are refraction textures enabled in the application.
  39605. */
  39606. static RefractionTextureEnabled: boolean;
  39607. /**
  39608. * Are color grading textures enabled in the application.
  39609. */
  39610. static ColorGradingTextureEnabled: boolean;
  39611. /**
  39612. * Are fresnels enabled in the application.
  39613. */
  39614. static FresnelEnabled: boolean;
  39615. }
  39616. }
  39617. declare module BABYLON {
  39618. /** @hidden */
  39619. export var imageProcessingPixelShader: {
  39620. name: string;
  39621. shader: string;
  39622. };
  39623. }
  39624. declare module BABYLON {
  39625. /**
  39626. * ImageProcessingPostProcess
  39627. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39628. */
  39629. export class ImageProcessingPostProcess extends PostProcess {
  39630. /**
  39631. * Default configuration related to image processing available in the PBR Material.
  39632. */
  39633. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39634. /**
  39635. * Gets the image processing configuration used either in this material.
  39636. */
  39637. /**
  39638. * Sets the Default image processing configuration used either in the this material.
  39639. *
  39640. * If sets to null, the scene one is in use.
  39641. */
  39642. imageProcessingConfiguration: ImageProcessingConfiguration;
  39643. /**
  39644. * Keep track of the image processing observer to allow dispose and replace.
  39645. */
  39646. private _imageProcessingObserver;
  39647. /**
  39648. * Attaches a new image processing configuration to the PBR Material.
  39649. * @param configuration
  39650. */
  39651. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39652. /**
  39653. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39654. */
  39655. /**
  39656. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39657. */
  39658. colorCurves: Nullable<ColorCurves>;
  39659. /**
  39660. * Gets wether the color curves effect is enabled.
  39661. */
  39662. /**
  39663. * Sets wether the color curves effect is enabled.
  39664. */
  39665. colorCurvesEnabled: boolean;
  39666. /**
  39667. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39668. */
  39669. /**
  39670. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39671. */
  39672. colorGradingTexture: Nullable<BaseTexture>;
  39673. /**
  39674. * Gets wether the color grading effect is enabled.
  39675. */
  39676. /**
  39677. * Gets wether the color grading effect is enabled.
  39678. */
  39679. colorGradingEnabled: boolean;
  39680. /**
  39681. * Gets exposure used in the effect.
  39682. */
  39683. /**
  39684. * Sets exposure used in the effect.
  39685. */
  39686. exposure: number;
  39687. /**
  39688. * Gets wether tonemapping is enabled or not.
  39689. */
  39690. /**
  39691. * Sets wether tonemapping is enabled or not
  39692. */
  39693. toneMappingEnabled: boolean;
  39694. /**
  39695. * Gets the type of tone mapping effect.
  39696. */
  39697. /**
  39698. * Sets the type of tone mapping effect.
  39699. */
  39700. toneMappingType: number;
  39701. /**
  39702. * Gets contrast used in the effect.
  39703. */
  39704. /**
  39705. * Sets contrast used in the effect.
  39706. */
  39707. contrast: number;
  39708. /**
  39709. * Gets Vignette stretch size.
  39710. */
  39711. /**
  39712. * Sets Vignette stretch size.
  39713. */
  39714. vignetteStretch: number;
  39715. /**
  39716. * Gets Vignette centre X Offset.
  39717. */
  39718. /**
  39719. * Sets Vignette centre X Offset.
  39720. */
  39721. vignetteCentreX: number;
  39722. /**
  39723. * Gets Vignette centre Y Offset.
  39724. */
  39725. /**
  39726. * Sets Vignette centre Y Offset.
  39727. */
  39728. vignetteCentreY: number;
  39729. /**
  39730. * Gets Vignette weight or intensity of the vignette effect.
  39731. */
  39732. /**
  39733. * Sets Vignette weight or intensity of the vignette effect.
  39734. */
  39735. vignetteWeight: number;
  39736. /**
  39737. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39738. * if vignetteEnabled is set to true.
  39739. */
  39740. /**
  39741. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39742. * if vignetteEnabled is set to true.
  39743. */
  39744. vignetteColor: Color4;
  39745. /**
  39746. * Gets Camera field of view used by the Vignette effect.
  39747. */
  39748. /**
  39749. * Sets Camera field of view used by the Vignette effect.
  39750. */
  39751. vignetteCameraFov: number;
  39752. /**
  39753. * Gets the vignette blend mode allowing different kind of effect.
  39754. */
  39755. /**
  39756. * Sets the vignette blend mode allowing different kind of effect.
  39757. */
  39758. vignetteBlendMode: number;
  39759. /**
  39760. * Gets wether the vignette effect is enabled.
  39761. */
  39762. /**
  39763. * Sets wether the vignette effect is enabled.
  39764. */
  39765. vignetteEnabled: boolean;
  39766. private _fromLinearSpace;
  39767. /**
  39768. * Gets wether the input of the processing is in Gamma or Linear Space.
  39769. */
  39770. /**
  39771. * Sets wether the input of the processing is in Gamma or Linear Space.
  39772. */
  39773. fromLinearSpace: boolean;
  39774. /**
  39775. * Defines cache preventing GC.
  39776. */
  39777. private _defines;
  39778. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39779. /**
  39780. * "ImageProcessingPostProcess"
  39781. * @returns "ImageProcessingPostProcess"
  39782. */
  39783. getClassName(): string;
  39784. protected _updateParameters(): void;
  39785. dispose(camera?: Camera): void;
  39786. }
  39787. }
  39788. declare module BABYLON {
  39789. /**
  39790. * Class containing static functions to help procedurally build meshes
  39791. */
  39792. export class GroundBuilder {
  39793. /**
  39794. * Creates a ground mesh
  39795. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39796. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39798. * @param name defines the name of the mesh
  39799. * @param options defines the options used to create the mesh
  39800. * @param scene defines the hosting scene
  39801. * @returns the ground mesh
  39802. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39803. */
  39804. static CreateGround(name: string, options: {
  39805. width?: number;
  39806. height?: number;
  39807. subdivisions?: number;
  39808. subdivisionsX?: number;
  39809. subdivisionsY?: number;
  39810. updatable?: boolean;
  39811. }, scene: any): Mesh;
  39812. /**
  39813. * Creates a tiled ground mesh
  39814. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39815. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39816. * * 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
  39817. * * 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
  39818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39819. * @param name defines the name of the mesh
  39820. * @param options defines the options used to create the mesh
  39821. * @param scene defines the hosting scene
  39822. * @returns the tiled ground mesh
  39823. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39824. */
  39825. static CreateTiledGround(name: string, options: {
  39826. xmin: number;
  39827. zmin: number;
  39828. xmax: number;
  39829. zmax: number;
  39830. subdivisions?: {
  39831. w: number;
  39832. h: number;
  39833. };
  39834. precision?: {
  39835. w: number;
  39836. h: number;
  39837. };
  39838. updatable?: boolean;
  39839. }, scene?: Nullable<Scene>): Mesh;
  39840. /**
  39841. * Creates a ground mesh from a height map
  39842. * * The parameter `url` sets the URL of the height map image resource.
  39843. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39844. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39845. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39846. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39847. * * 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.
  39848. * * 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).
  39849. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39851. * @param name defines the name of the mesh
  39852. * @param url defines the url to the height map
  39853. * @param options defines the options used to create the mesh
  39854. * @param scene defines the hosting scene
  39855. * @returns the ground mesh
  39856. * @see https://doc.babylonjs.com/babylon101/height_map
  39857. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39858. */
  39859. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39860. width?: number;
  39861. height?: number;
  39862. subdivisions?: number;
  39863. minHeight?: number;
  39864. maxHeight?: number;
  39865. colorFilter?: Color3;
  39866. alphaFilter?: number;
  39867. updatable?: boolean;
  39868. onReady?: (mesh: GroundMesh) => void;
  39869. }, scene?: Nullable<Scene>): GroundMesh;
  39870. }
  39871. }
  39872. declare module BABYLON {
  39873. /**
  39874. * Class containing static functions to help procedurally build meshes
  39875. */
  39876. export class TorusBuilder {
  39877. /**
  39878. * Creates a torus mesh
  39879. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39880. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39881. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39882. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39883. * * 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
  39884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39885. * @param name defines the name of the mesh
  39886. * @param options defines the options used to create the mesh
  39887. * @param scene defines the hosting scene
  39888. * @returns the torus mesh
  39889. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39890. */
  39891. static CreateTorus(name: string, options: {
  39892. diameter?: number;
  39893. thickness?: number;
  39894. tessellation?: number;
  39895. updatable?: boolean;
  39896. sideOrientation?: number;
  39897. frontUVs?: Vector4;
  39898. backUVs?: Vector4;
  39899. }, scene: any): Mesh;
  39900. }
  39901. }
  39902. declare module BABYLON {
  39903. /**
  39904. * Class containing static functions to help procedurally build meshes
  39905. */
  39906. export class CylinderBuilder {
  39907. /**
  39908. * Creates a cylinder or a cone mesh
  39909. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39910. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39911. * * 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.
  39912. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39913. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39914. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39915. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39916. * * 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).
  39917. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39918. * * 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).
  39919. * * 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
  39920. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39921. * * 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
  39922. * * 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.
  39923. * * If `enclose` is false, a ring surface is one element.
  39924. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39925. * * 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
  39926. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39927. * * 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
  39928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39929. * @param name defines the name of the mesh
  39930. * @param options defines the options used to create the mesh
  39931. * @param scene defines the hosting scene
  39932. * @returns the cylinder mesh
  39933. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39934. */
  39935. static CreateCylinder(name: string, options: {
  39936. height?: number;
  39937. diameterTop?: number;
  39938. diameterBottom?: number;
  39939. diameter?: number;
  39940. tessellation?: number;
  39941. subdivisions?: number;
  39942. arc?: number;
  39943. faceColors?: Color4[];
  39944. faceUV?: Vector4[];
  39945. updatable?: boolean;
  39946. hasRings?: boolean;
  39947. enclose?: boolean;
  39948. cap?: number;
  39949. sideOrientation?: number;
  39950. frontUVs?: Vector4;
  39951. backUVs?: Vector4;
  39952. }, scene: any): Mesh;
  39953. }
  39954. }
  39955. declare module BABYLON {
  39956. /**
  39957. * Options to modify the vr teleportation behavior.
  39958. */
  39959. export interface VRTeleportationOptions {
  39960. /**
  39961. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39962. */
  39963. floorMeshName?: string;
  39964. /**
  39965. * A list of meshes to be used as the teleportation floor. (default: empty)
  39966. */
  39967. floorMeshes?: Mesh[];
  39968. }
  39969. /**
  39970. * Options to modify the vr experience helper's behavior.
  39971. */
  39972. export interface VRExperienceHelperOptions extends WebVROptions {
  39973. /**
  39974. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39975. */
  39976. createDeviceOrientationCamera?: boolean;
  39977. /**
  39978. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39979. */
  39980. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39981. /**
  39982. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39983. */
  39984. laserToggle?: boolean;
  39985. /**
  39986. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39987. */
  39988. floorMeshes?: Mesh[];
  39989. /**
  39990. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39991. */
  39992. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39993. }
  39994. /**
  39995. * Event containing information after VR has been entered
  39996. */
  39997. export class OnAfterEnteringVRObservableEvent {
  39998. /**
  39999. * If entering vr was successful
  40000. */
  40001. success: boolean;
  40002. }
  40003. /**
  40004. * Helps to quickly add VR support to an existing scene.
  40005. * See http://doc.babylonjs.com/how_to/webvr_helper
  40006. */
  40007. export class VRExperienceHelper {
  40008. /** Options to modify the vr experience helper's behavior. */
  40009. webVROptions: VRExperienceHelperOptions;
  40010. private _scene;
  40011. private _position;
  40012. private _btnVR;
  40013. private _btnVRDisplayed;
  40014. private _webVRsupported;
  40015. private _webVRready;
  40016. private _webVRrequesting;
  40017. private _webVRpresenting;
  40018. private _hasEnteredVR;
  40019. private _fullscreenVRpresenting;
  40020. private _canvas;
  40021. private _webVRCamera;
  40022. private _vrDeviceOrientationCamera;
  40023. private _deviceOrientationCamera;
  40024. private _existingCamera;
  40025. private _onKeyDown;
  40026. private _onVrDisplayPresentChange;
  40027. private _onVRDisplayChanged;
  40028. private _onVRRequestPresentStart;
  40029. private _onVRRequestPresentComplete;
  40030. /**
  40031. * 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)
  40032. */
  40033. enableGazeEvenWhenNoPointerLock: boolean;
  40034. /**
  40035. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40036. */
  40037. exitVROnDoubleTap: boolean;
  40038. /**
  40039. * Observable raised right before entering VR.
  40040. */
  40041. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40042. /**
  40043. * Observable raised when entering VR has completed.
  40044. */
  40045. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40046. /**
  40047. * Observable raised when exiting VR.
  40048. */
  40049. onExitingVRObservable: Observable<VRExperienceHelper>;
  40050. /**
  40051. * Observable raised when controller mesh is loaded.
  40052. */
  40053. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40054. /** Return this.onEnteringVRObservable
  40055. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40056. */
  40057. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40058. /** Return this.onExitingVRObservable
  40059. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40060. */
  40061. readonly onExitingVR: Observable<VRExperienceHelper>;
  40062. /** Return this.onControllerMeshLoadedObservable
  40063. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40064. */
  40065. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40066. private _rayLength;
  40067. private _useCustomVRButton;
  40068. private _teleportationRequested;
  40069. private _teleportActive;
  40070. private _floorMeshName;
  40071. private _floorMeshesCollection;
  40072. private _rotationAllowed;
  40073. private _teleportBackwardsVector;
  40074. private _teleportationTarget;
  40075. private _isDefaultTeleportationTarget;
  40076. private _postProcessMove;
  40077. private _teleportationFillColor;
  40078. private _teleportationBorderColor;
  40079. private _rotationAngle;
  40080. private _haloCenter;
  40081. private _cameraGazer;
  40082. private _padSensibilityUp;
  40083. private _padSensibilityDown;
  40084. private _leftController;
  40085. private _rightController;
  40086. /**
  40087. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40088. */
  40089. onNewMeshSelected: Observable<AbstractMesh>;
  40090. /**
  40091. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  40092. * This observable will provide the mesh and the controller used to select the mesh
  40093. */
  40094. onMeshSelectedWithController: Observable<{
  40095. mesh: AbstractMesh;
  40096. controller: WebVRController;
  40097. }>;
  40098. /**
  40099. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40100. */
  40101. onNewMeshPicked: Observable<PickingInfo>;
  40102. private _circleEase;
  40103. /**
  40104. * Observable raised before camera teleportation
  40105. */
  40106. onBeforeCameraTeleport: Observable<Vector3>;
  40107. /**
  40108. * Observable raised after camera teleportation
  40109. */
  40110. onAfterCameraTeleport: Observable<Vector3>;
  40111. /**
  40112. * Observable raised when current selected mesh gets unselected
  40113. */
  40114. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40115. private _raySelectionPredicate;
  40116. /**
  40117. * To be optionaly changed by user to define custom ray selection
  40118. */
  40119. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40120. /**
  40121. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40122. */
  40123. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40124. /**
  40125. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40126. */
  40127. teleportationEnabled: boolean;
  40128. private _defaultHeight;
  40129. private _teleportationInitialized;
  40130. private _interactionsEnabled;
  40131. private _interactionsRequested;
  40132. private _displayGaze;
  40133. private _displayLaserPointer;
  40134. /**
  40135. * The mesh used to display where the user is going to teleport.
  40136. */
  40137. /**
  40138. * Sets the mesh to be used to display where the user is going to teleport.
  40139. */
  40140. teleportationTarget: Mesh;
  40141. /**
  40142. * 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
  40143. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40144. * See http://doc.babylonjs.com/resources/baking_transformations
  40145. */
  40146. gazeTrackerMesh: Mesh;
  40147. /**
  40148. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40149. */
  40150. updateGazeTrackerScale: boolean;
  40151. /**
  40152. * If the gaze trackers color should be updated when selecting meshes
  40153. */
  40154. updateGazeTrackerColor: boolean;
  40155. /**
  40156. * If the controller laser color should be updated when selecting meshes
  40157. */
  40158. updateControllerLaserColor: boolean;
  40159. /**
  40160. * The gaze tracking mesh corresponding to the left controller
  40161. */
  40162. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40163. /**
  40164. * The gaze tracking mesh corresponding to the right controller
  40165. */
  40166. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40167. /**
  40168. * If the ray of the gaze should be displayed.
  40169. */
  40170. /**
  40171. * Sets if the ray of the gaze should be displayed.
  40172. */
  40173. displayGaze: boolean;
  40174. /**
  40175. * If the ray of the LaserPointer should be displayed.
  40176. */
  40177. /**
  40178. * Sets if the ray of the LaserPointer should be displayed.
  40179. */
  40180. displayLaserPointer: boolean;
  40181. /**
  40182. * The deviceOrientationCamera used as the camera when not in VR.
  40183. */
  40184. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40185. /**
  40186. * Based on the current WebVR support, returns the current VR camera used.
  40187. */
  40188. readonly currentVRCamera: Nullable<Camera>;
  40189. /**
  40190. * The webVRCamera which is used when in VR.
  40191. */
  40192. readonly webVRCamera: WebVRFreeCamera;
  40193. /**
  40194. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40195. */
  40196. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40197. /**
  40198. * The html button that is used to trigger entering into VR.
  40199. */
  40200. readonly vrButton: Nullable<HTMLButtonElement>;
  40201. private readonly _teleportationRequestInitiated;
  40202. /**
  40203. * Defines wether or not Pointer lock should be requested when switching to
  40204. * full screen.
  40205. */
  40206. requestPointerLockOnFullScreen: boolean;
  40207. /**
  40208. * Instantiates a VRExperienceHelper.
  40209. * Helps to quickly add VR support to an existing scene.
  40210. * @param scene The scene the VRExperienceHelper belongs to.
  40211. * @param webVROptions Options to modify the vr experience helper's behavior.
  40212. */
  40213. constructor(scene: Scene,
  40214. /** Options to modify the vr experience helper's behavior. */
  40215. webVROptions?: VRExperienceHelperOptions);
  40216. private _onDefaultMeshLoaded;
  40217. private _onResize;
  40218. private _onFullscreenChange;
  40219. /**
  40220. * Gets a value indicating if we are currently in VR mode.
  40221. */
  40222. readonly isInVRMode: boolean;
  40223. private onVrDisplayPresentChange;
  40224. private onVRDisplayChanged;
  40225. private moveButtonToBottomRight;
  40226. private displayVRButton;
  40227. private updateButtonVisibility;
  40228. private _cachedAngularSensibility;
  40229. /**
  40230. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40231. * Otherwise, will use the fullscreen API.
  40232. */
  40233. enterVR(): void;
  40234. /**
  40235. * Attempt to exit VR, or fullscreen.
  40236. */
  40237. exitVR(): void;
  40238. /**
  40239. * The position of the vr experience helper.
  40240. */
  40241. /**
  40242. * Sets the position of the vr experience helper.
  40243. */
  40244. position: Vector3;
  40245. /**
  40246. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40247. */
  40248. enableInteractions(): void;
  40249. private readonly _noControllerIsActive;
  40250. private beforeRender;
  40251. private _isTeleportationFloor;
  40252. /**
  40253. * Adds a floor mesh to be used for teleportation.
  40254. * @param floorMesh the mesh to be used for teleportation.
  40255. */
  40256. addFloorMesh(floorMesh: Mesh): void;
  40257. /**
  40258. * Removes a floor mesh from being used for teleportation.
  40259. * @param floorMesh the mesh to be removed.
  40260. */
  40261. removeFloorMesh(floorMesh: Mesh): void;
  40262. /**
  40263. * Enables interactions and teleportation using the VR controllers and gaze.
  40264. * @param vrTeleportationOptions options to modify teleportation behavior.
  40265. */
  40266. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40267. private _onNewGamepadConnected;
  40268. private _tryEnableInteractionOnController;
  40269. private _onNewGamepadDisconnected;
  40270. private _enableInteractionOnController;
  40271. private _checkTeleportWithRay;
  40272. private _checkRotate;
  40273. private _checkTeleportBackwards;
  40274. private _enableTeleportationOnController;
  40275. private _createTeleportationCircles;
  40276. private _displayTeleportationTarget;
  40277. private _hideTeleportationTarget;
  40278. private _rotateCamera;
  40279. private _moveTeleportationSelectorTo;
  40280. private _workingVector;
  40281. private _workingQuaternion;
  40282. private _workingMatrix;
  40283. /**
  40284. * Teleports the users feet to the desired location
  40285. * @param location The location where the user's feet should be placed
  40286. */
  40287. teleportCamera(location: Vector3): void;
  40288. private _convertNormalToDirectionOfRay;
  40289. private _castRayAndSelectObject;
  40290. private _notifySelectedMeshUnselected;
  40291. /**
  40292. * Sets the color of the laser ray from the vr controllers.
  40293. * @param color new color for the ray.
  40294. */
  40295. changeLaserColor(color: Color3): void;
  40296. /**
  40297. * Sets the color of the ray from the vr headsets gaze.
  40298. * @param color new color for the ray.
  40299. */
  40300. changeGazeColor(color: Color3): void;
  40301. /**
  40302. * Exits VR and disposes of the vr experience helper
  40303. */
  40304. dispose(): void;
  40305. /**
  40306. * Gets the name of the VRExperienceHelper class
  40307. * @returns "VRExperienceHelper"
  40308. */
  40309. getClassName(): string;
  40310. }
  40311. }
  40312. declare module BABYLON {
  40313. /**
  40314. * Manages an XRSession to work with Babylon's engine
  40315. * @see https://doc.babylonjs.com/how_to/webxr
  40316. */
  40317. export class WebXRSessionManager implements IDisposable {
  40318. private scene;
  40319. /**
  40320. * Fires every time a new xrFrame arrives which can be used to update the camera
  40321. */
  40322. onXRFrameObservable: Observable<any>;
  40323. /**
  40324. * Fires when the xr session is ended either by the device or manually done
  40325. */
  40326. onXRSessionEnded: Observable<any>;
  40327. /**
  40328. * Underlying xr session
  40329. */
  40330. session: XRSession;
  40331. /**
  40332. * Type of reference space used when creating the session
  40333. */
  40334. referenceSpace: XRReferenceSpace;
  40335. /** @hidden */ private _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40336. /**
  40337. * Current XR frame
  40338. */
  40339. currentFrame: Nullable<XRFrame>;
  40340. private _xrNavigator;
  40341. private baseLayer;
  40342. /**
  40343. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40344. * @param scene The scene which the session should be created for
  40345. */
  40346. constructor(scene: Scene);
  40347. /**
  40348. * Initializes the manager
  40349. * After initialization enterXR can be called to start an XR session
  40350. * @returns Promise which resolves after it is initialized
  40351. */
  40352. initializeAsync(): Promise<void>;
  40353. /**
  40354. * Initializes an xr session
  40355. * @param xrSessionMode mode to initialize
  40356. * @returns a promise which will resolve once the session has been initialized
  40357. */
  40358. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  40359. /**
  40360. * Sets the reference space on the xr session
  40361. * @param referenceSpace space to set
  40362. * @returns a promise that will resolve once the reference space has been set
  40363. */
  40364. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  40365. /**
  40366. * Updates the render state of the session
  40367. * @param state state to set
  40368. * @returns a promise that resolves once the render state has been updated
  40369. */
  40370. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  40371. /**
  40372. * Starts rendering to the xr layer
  40373. * @returns a promise that will resolve once rendering has started
  40374. */
  40375. startRenderingToXRAsync(): Promise<void>;
  40376. /**
  40377. * Stops the xrSession and restores the renderloop
  40378. * @returns Promise which resolves after it exits XR
  40379. */
  40380. exitXRAsync(): Promise<unknown>;
  40381. /**
  40382. * Checks if a session would be supported for the creation options specified
  40383. * @param sessionMode session mode to check if supported eg. immersive-vr
  40384. * @returns true if supported
  40385. */
  40386. supportsSessionAsync(sessionMode: XRSessionMode): any;
  40387. /**
  40388. * @hidden
  40389. * Converts the render layer of xrSession to a render target
  40390. * @param session session to create render target for
  40391. * @param scene scene the new render target should be created for
  40392. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  40393. /**
  40394. * Disposes of the session manager
  40395. */
  40396. dispose(): void;
  40397. }
  40398. }
  40399. declare module BABYLON {
  40400. /**
  40401. * WebXR Camera which holds the views for the xrSession
  40402. * @see https://doc.babylonjs.com/how_to/webxr
  40403. */
  40404. export class WebXRCamera extends FreeCamera {
  40405. private static _TmpMatrix;
  40406. /**
  40407. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40408. * @param name the name of the camera
  40409. * @param scene the scene to add the camera to
  40410. */
  40411. constructor(name: string, scene: Scene);
  40412. private _updateNumberOfRigCameras;
  40413. /** @hidden */ private _updateForDualEyeDebugging(pupilDistance?: number): void;
  40414. /**
  40415. * Updates the cameras position from the current pose information of the XR session
  40416. * @param xrSessionManager the session containing pose information
  40417. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40418. */
  40419. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40420. }
  40421. }
  40422. declare module BABYLON {
  40423. /**
  40424. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40425. */
  40426. export class WebXRManagedOutputCanvas implements IDisposable {
  40427. private helper;
  40428. private _canvas;
  40429. /**
  40430. * xrpresent context of the canvas which can be used to display/mirror xr content
  40431. */
  40432. canvasContext: WebGLRenderingContext;
  40433. /**
  40434. * xr layer for the canvas
  40435. */
  40436. xrLayer: Nullable<XRWebGLLayer>;
  40437. /**
  40438. * Initializes the xr layer for the session
  40439. * @param xrSession xr session
  40440. * @returns a promise that will resolve once the XR Layer has been created
  40441. */
  40442. initializeXRLayerAsync(xrSession: any): any;
  40443. /**
  40444. * Initializes the canvas to be added/removed upon entering/exiting xr
  40445. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40446. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40447. */
  40448. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40449. /**
  40450. * Disposes of the object
  40451. */
  40452. dispose(): void;
  40453. private _setManagedOutputCanvas;
  40454. private _addCanvas;
  40455. private _removeCanvas;
  40456. }
  40457. }
  40458. declare module BABYLON {
  40459. /**
  40460. * States of the webXR experience
  40461. */
  40462. export enum WebXRState {
  40463. /**
  40464. * Transitioning to being in XR mode
  40465. */
  40466. ENTERING_XR = 0,
  40467. /**
  40468. * Transitioning to non XR mode
  40469. */
  40470. EXITING_XR = 1,
  40471. /**
  40472. * In XR mode and presenting
  40473. */
  40474. IN_XR = 2,
  40475. /**
  40476. * Not entered XR mode
  40477. */
  40478. NOT_IN_XR = 3
  40479. }
  40480. /**
  40481. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  40482. * @see https://doc.babylonjs.com/how_to/webxr
  40483. */
  40484. export class WebXRExperienceHelper implements IDisposable {
  40485. private scene;
  40486. /**
  40487. * 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
  40488. */
  40489. container: AbstractMesh;
  40490. /**
  40491. * Camera used to render xr content
  40492. */
  40493. camera: WebXRCamera;
  40494. /**
  40495. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40496. */
  40497. state: WebXRState;
  40498. private _setState;
  40499. private static _TmpVector;
  40500. /**
  40501. * Fires when the state of the experience helper has changed
  40502. */
  40503. onStateChangedObservable: Observable<WebXRState>;
  40504. /** Session manager used to keep track of xr session */
  40505. sessionManager: WebXRSessionManager;
  40506. private _nonVRCamera;
  40507. private _originalSceneAutoClear;
  40508. private _supported;
  40509. /**
  40510. * Creates the experience helper
  40511. * @param scene the scene to attach the experience helper to
  40512. * @returns a promise for the experience helper
  40513. */
  40514. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40515. /**
  40516. * Creates a WebXRExperienceHelper
  40517. * @param scene The scene the helper should be created in
  40518. */
  40519. private constructor();
  40520. /**
  40521. * Exits XR mode and returns the scene to its original state
  40522. * @returns promise that resolves after xr mode has exited
  40523. */
  40524. exitXRAsync(): Promise<unknown>;
  40525. /**
  40526. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40527. * @param sessionCreationOptions options for the XR session
  40528. * @param referenceSpaceType frame of reference of the XR session
  40529. * @param outputCanvas the output canvas that will be used to enter XR mode
  40530. * @returns promise that resolves after xr mode has entered
  40531. */
  40532. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  40533. /**
  40534. * Updates the global position of the camera by moving the camera's container
  40535. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40536. * @param position The desired global position of the camera
  40537. */
  40538. setPositionOfCameraUsingContainer(position: Vector3): void;
  40539. /**
  40540. * Rotates the xr camera by rotating the camera's container around the camera's position
  40541. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40542. * @param rotation the desired quaternion rotation to apply to the camera
  40543. */
  40544. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40545. /**
  40546. * Disposes of the experience helper
  40547. */
  40548. dispose(): void;
  40549. }
  40550. }
  40551. declare module BABYLON {
  40552. /**
  40553. * Button which can be used to enter a different mode of XR
  40554. */
  40555. export class WebXREnterExitUIButton {
  40556. /** button element */
  40557. element: HTMLElement;
  40558. /** XR initialization options for the button */
  40559. sessionMode: XRSessionMode;
  40560. /** Reference space type */
  40561. referenceSpaceType: XRReferenceSpaceType;
  40562. /**
  40563. * Creates a WebXREnterExitUIButton
  40564. * @param element button element
  40565. * @param sessionMode XR initialization session mode
  40566. * @param referenceSpaceType the type of reference space to be used
  40567. */
  40568. constructor(
  40569. /** button element */
  40570. element: HTMLElement,
  40571. /** XR initialization options for the button */
  40572. sessionMode: XRSessionMode,
  40573. /** Reference space type */
  40574. referenceSpaceType: XRReferenceSpaceType);
  40575. /**
  40576. * Overwritable function which can be used to update the button's visuals when the state changes
  40577. * @param activeButton the current active button in the UI
  40578. */
  40579. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40580. }
  40581. /**
  40582. * Options to create the webXR UI
  40583. */
  40584. export class WebXREnterExitUIOptions {
  40585. /**
  40586. * Context to enter xr with
  40587. */
  40588. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  40589. /**
  40590. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40591. */
  40592. customButtons?: Array<WebXREnterExitUIButton>;
  40593. }
  40594. /**
  40595. * UI to allow the user to enter/exit XR mode
  40596. */
  40597. export class WebXREnterExitUI implements IDisposable {
  40598. private scene;
  40599. private _overlay;
  40600. private _buttons;
  40601. private _activeButton;
  40602. /**
  40603. * Fired every time the active button is changed.
  40604. *
  40605. * When xr is entered via a button that launches xr that button will be the callback parameter
  40606. *
  40607. * When exiting xr the callback parameter will be null)
  40608. */
  40609. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40610. /**
  40611. * Creates UI to allow the user to enter/exit XR mode
  40612. * @param scene the scene to add the ui to
  40613. * @param helper the xr experience helper to enter/exit xr with
  40614. * @param options options to configure the UI
  40615. * @returns the created ui
  40616. */
  40617. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40618. private constructor();
  40619. private _updateButtons;
  40620. /**
  40621. * Disposes of the object
  40622. */
  40623. dispose(): void;
  40624. }
  40625. }
  40626. declare module BABYLON {
  40627. /**
  40628. * Represents an XR input
  40629. */
  40630. export class WebXRController {
  40631. private scene;
  40632. /** The underlying input source for the controller */
  40633. inputSource: XRInputSource;
  40634. private parentContainer;
  40635. /**
  40636. * 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
  40637. */
  40638. grip?: AbstractMesh;
  40639. /**
  40640. * Pointer which can be used to select objects or attach a visible laser to
  40641. */
  40642. pointer: AbstractMesh;
  40643. /**
  40644. * Event that fires when the controller is removed/disposed
  40645. */
  40646. onDisposeObservable: Observable<{}>;
  40647. private _tmpMatrix;
  40648. private _tmpQuaternion;
  40649. private _tmpVector;
  40650. /**
  40651. * Creates the controller
  40652. * @see https://doc.babylonjs.com/how_to/webxr
  40653. * @param scene the scene which the controller should be associated to
  40654. * @param inputSource the underlying input source for the controller
  40655. * @param parentContainer parent that the controller meshes should be children of
  40656. */
  40657. constructor(scene: Scene,
  40658. /** The underlying input source for the controller */
  40659. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  40660. /**
  40661. * Updates the controller pose based on the given XRFrame
  40662. * @param xrFrame xr frame to update the pose with
  40663. * @param referenceSpace reference space to use
  40664. */
  40665. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  40666. /**
  40667. * Gets a world space ray coming from the controller
  40668. * @param result the resulting ray
  40669. */
  40670. getWorldPointerRayToRef(result: Ray): void;
  40671. /**
  40672. * Disposes of the object
  40673. */
  40674. dispose(): void;
  40675. }
  40676. }
  40677. declare module BABYLON {
  40678. /**
  40679. * XR input used to track XR inputs such as controllers/rays
  40680. */
  40681. export class WebXRInput implements IDisposable {
  40682. /**
  40683. * Base experience the input listens to
  40684. */
  40685. baseExperience: WebXRExperienceHelper;
  40686. /**
  40687. * XR controllers being tracked
  40688. */
  40689. controllers: Array<WebXRController>;
  40690. private _frameObserver;
  40691. private _stateObserver;
  40692. /**
  40693. * Event when a controller has been connected/added
  40694. */
  40695. onControllerAddedObservable: Observable<WebXRController>;
  40696. /**
  40697. * Event when a controller has been removed/disconnected
  40698. */
  40699. onControllerRemovedObservable: Observable<WebXRController>;
  40700. /**
  40701. * Initializes the WebXRInput
  40702. * @param baseExperience experience helper which the input should be created for
  40703. */
  40704. constructor(
  40705. /**
  40706. * Base experience the input listens to
  40707. */
  40708. baseExperience: WebXRExperienceHelper);
  40709. private _onInputSourcesChange;
  40710. private _addAndRemoveControllers;
  40711. /**
  40712. * Disposes of the object
  40713. */
  40714. dispose(): void;
  40715. }
  40716. }
  40717. declare module BABYLON {
  40718. /**
  40719. * Enables teleportation
  40720. */
  40721. export class WebXRControllerTeleportation {
  40722. private _teleportationFillColor;
  40723. private _teleportationBorderColor;
  40724. private _tmpRay;
  40725. private _tmpVector;
  40726. /**
  40727. * Creates a WebXRControllerTeleportation
  40728. * @param input input manager to add teleportation to
  40729. * @param floorMeshes floormeshes which can be teleported to
  40730. */
  40731. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  40732. }
  40733. }
  40734. declare module BABYLON {
  40735. /**
  40736. * Handles pointer input automatically for the pointer of XR controllers
  40737. */
  40738. export class WebXRControllerPointerSelection {
  40739. private static _idCounter;
  40740. private _tmpRay;
  40741. /**
  40742. * Creates a WebXRControllerPointerSelection
  40743. * @param input input manager to setup pointer selection
  40744. */
  40745. constructor(input: WebXRInput);
  40746. private _convertNormalToDirectionOfRay;
  40747. private _updatePointerDistance;
  40748. }
  40749. }
  40750. declare module BABYLON {
  40751. /**
  40752. * Class used to represent data loading progression
  40753. */
  40754. export class SceneLoaderProgressEvent {
  40755. /** defines if data length to load can be evaluated */
  40756. readonly lengthComputable: boolean;
  40757. /** defines the loaded data length */
  40758. readonly loaded: number;
  40759. /** defines the data length to load */
  40760. readonly total: number;
  40761. /**
  40762. * Create a new progress event
  40763. * @param lengthComputable defines if data length to load can be evaluated
  40764. * @param loaded defines the loaded data length
  40765. * @param total defines the data length to load
  40766. */
  40767. constructor(
  40768. /** defines if data length to load can be evaluated */
  40769. lengthComputable: boolean,
  40770. /** defines the loaded data length */
  40771. loaded: number,
  40772. /** defines the data length to load */
  40773. total: number);
  40774. /**
  40775. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  40776. * @param event defines the source event
  40777. * @returns a new SceneLoaderProgressEvent
  40778. */
  40779. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  40780. }
  40781. /**
  40782. * Interface used by SceneLoader plugins to define supported file extensions
  40783. */
  40784. export interface ISceneLoaderPluginExtensions {
  40785. /**
  40786. * Defines the list of supported extensions
  40787. */
  40788. [extension: string]: {
  40789. isBinary: boolean;
  40790. };
  40791. }
  40792. /**
  40793. * Interface used by SceneLoader plugin factory
  40794. */
  40795. export interface ISceneLoaderPluginFactory {
  40796. /**
  40797. * Defines the name of the factory
  40798. */
  40799. name: string;
  40800. /**
  40801. * Function called to create a new plugin
  40802. * @return the new plugin
  40803. */
  40804. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  40805. /**
  40806. * Boolean indicating if the plugin can direct load specific data
  40807. */
  40808. canDirectLoad?: (data: string) => boolean;
  40809. }
  40810. /**
  40811. * Interface used to define a SceneLoader plugin
  40812. */
  40813. export interface ISceneLoaderPlugin {
  40814. /**
  40815. * The friendly name of this plugin.
  40816. */
  40817. name: string;
  40818. /**
  40819. * The file extensions supported by this plugin.
  40820. */
  40821. extensions: string | ISceneLoaderPluginExtensions;
  40822. /**
  40823. * Import meshes into a scene.
  40824. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40825. * @param scene The scene to import into
  40826. * @param data The data to import
  40827. * @param rootUrl The root url for scene and resources
  40828. * @param meshes The meshes array to import into
  40829. * @param particleSystems The particle systems array to import into
  40830. * @param skeletons The skeletons array to import into
  40831. * @param onError The callback when import fails
  40832. * @returns True if successful or false otherwise
  40833. */
  40834. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  40835. /**
  40836. * Load into a scene.
  40837. * @param scene The scene to load into
  40838. * @param data The data to import
  40839. * @param rootUrl The root url for scene and resources
  40840. * @param onError The callback when import fails
  40841. * @returns true if successful or false otherwise
  40842. */
  40843. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  40844. /**
  40845. * The callback that returns true if the data can be directly loaded.
  40846. */
  40847. canDirectLoad?: (data: string) => boolean;
  40848. /**
  40849. * The callback that allows custom handling of the root url based on the response url.
  40850. */
  40851. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40852. /**
  40853. * Load into an asset container.
  40854. * @param scene The scene to load into
  40855. * @param data The data to import
  40856. * @param rootUrl The root url for scene and resources
  40857. * @param onError The callback when import fails
  40858. * @returns The loaded asset container
  40859. */
  40860. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  40861. }
  40862. /**
  40863. * Interface used to define an async SceneLoader plugin
  40864. */
  40865. export interface ISceneLoaderPluginAsync {
  40866. /**
  40867. * The friendly name of this plugin.
  40868. */
  40869. name: string;
  40870. /**
  40871. * The file extensions supported by this plugin.
  40872. */
  40873. extensions: string | ISceneLoaderPluginExtensions;
  40874. /**
  40875. * Import meshes into a scene.
  40876. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40877. * @param scene The scene to import into
  40878. * @param data The data to import
  40879. * @param rootUrl The root url for scene and resources
  40880. * @param onProgress The callback when the load progresses
  40881. * @param fileName Defines the name of the file to load
  40882. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  40883. */
  40884. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  40885. meshes: AbstractMesh[];
  40886. particleSystems: IParticleSystem[];
  40887. skeletons: Skeleton[];
  40888. animationGroups: AnimationGroup[];
  40889. }>;
  40890. /**
  40891. * Load into a scene.
  40892. * @param scene The scene to load into
  40893. * @param data The data to import
  40894. * @param rootUrl The root url for scene and resources
  40895. * @param onProgress The callback when the load progresses
  40896. * @param fileName Defines the name of the file to load
  40897. * @returns Nothing
  40898. */
  40899. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  40900. /**
  40901. * The callback that returns true if the data can be directly loaded.
  40902. */
  40903. canDirectLoad?: (data: string) => boolean;
  40904. /**
  40905. * The callback that allows custom handling of the root url based on the response url.
  40906. */
  40907. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40908. /**
  40909. * Load into an asset container.
  40910. * @param scene The scene to load into
  40911. * @param data The data to import
  40912. * @param rootUrl The root url for scene and resources
  40913. * @param onProgress The callback when the load progresses
  40914. * @param fileName Defines the name of the file to load
  40915. * @returns The loaded asset container
  40916. */
  40917. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  40918. }
  40919. /**
  40920. * Class used to load scene from various file formats using registered plugins
  40921. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  40922. */
  40923. export class SceneLoader {
  40924. /**
  40925. * No logging while loading
  40926. */
  40927. static readonly NO_LOGGING: number;
  40928. /**
  40929. * Minimal logging while loading
  40930. */
  40931. static readonly MINIMAL_LOGGING: number;
  40932. /**
  40933. * Summary logging while loading
  40934. */
  40935. static readonly SUMMARY_LOGGING: number;
  40936. /**
  40937. * Detailled logging while loading
  40938. */
  40939. static readonly DETAILED_LOGGING: number;
  40940. /**
  40941. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  40942. */
  40943. static ForceFullSceneLoadingForIncremental: boolean;
  40944. /**
  40945. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  40946. */
  40947. static ShowLoadingScreen: boolean;
  40948. /**
  40949. * Defines the current logging level (while loading the scene)
  40950. * @ignorenaming
  40951. */
  40952. static loggingLevel: number;
  40953. /**
  40954. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  40955. */
  40956. static CleanBoneMatrixWeights: boolean;
  40957. /**
  40958. * Event raised when a plugin is used to load a scene
  40959. */
  40960. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  40961. private static _registeredPlugins;
  40962. private static _getDefaultPlugin;
  40963. private static _getPluginForExtension;
  40964. private static _getPluginForDirectLoad;
  40965. private static _getPluginForFilename;
  40966. private static _getDirectLoad;
  40967. private static _loadData;
  40968. private static _getFileInfo;
  40969. /**
  40970. * Gets a plugin that can load the given extension
  40971. * @param extension defines the extension to load
  40972. * @returns a plugin or null if none works
  40973. */
  40974. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  40975. /**
  40976. * Gets a boolean indicating that the given extension can be loaded
  40977. * @param extension defines the extension to load
  40978. * @returns true if the extension is supported
  40979. */
  40980. static IsPluginForExtensionAvailable(extension: string): boolean;
  40981. /**
  40982. * Adds a new plugin to the list of registered plugins
  40983. * @param plugin defines the plugin to add
  40984. */
  40985. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  40986. /**
  40987. * Import meshes into a scene
  40988. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40989. * @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)
  40990. * @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)
  40991. * @param scene the instance of BABYLON.Scene to append to
  40992. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  40993. * @param onProgress a callback with a progress event for each file being loaded
  40994. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40995. * @param pluginExtension the extension used to determine the plugin
  40996. * @returns The loaded plugin
  40997. */
  40998. 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>;
  40999. /**
  41000. * Import meshes into a scene
  41001. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41002. * @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)
  41003. * @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)
  41004. * @param scene the instance of BABYLON.Scene to append to
  41005. * @param onProgress a callback with a progress event for each file being loaded
  41006. * @param pluginExtension the extension used to determine the plugin
  41007. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41008. */
  41009. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41010. meshes: AbstractMesh[];
  41011. particleSystems: IParticleSystem[];
  41012. skeletons: Skeleton[];
  41013. animationGroups: AnimationGroup[];
  41014. }>;
  41015. /**
  41016. * Load a scene
  41017. * @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)
  41018. * @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)
  41019. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41020. * @param onSuccess a callback with the scene when import succeeds
  41021. * @param onProgress a callback with a progress event for each file being loaded
  41022. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41023. * @param pluginExtension the extension used to determine the plugin
  41024. * @returns The loaded plugin
  41025. */
  41026. 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>;
  41027. /**
  41028. * Load a scene
  41029. * @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)
  41030. * @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)
  41031. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41032. * @param onProgress a callback with a progress event for each file being loaded
  41033. * @param pluginExtension the extension used to determine the plugin
  41034. * @returns The loaded scene
  41035. */
  41036. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41037. /**
  41038. * Append a scene
  41039. * @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)
  41040. * @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)
  41041. * @param scene is the instance of BABYLON.Scene to append to
  41042. * @param onSuccess a callback with the scene when import succeeds
  41043. * @param onProgress a callback with a progress event for each file being loaded
  41044. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41045. * @param pluginExtension the extension used to determine the plugin
  41046. * @returns The loaded plugin
  41047. */
  41048. 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>;
  41049. /**
  41050. * Append a scene
  41051. * @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)
  41052. * @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)
  41053. * @param scene is the instance of BABYLON.Scene to append to
  41054. * @param onProgress a callback with a progress event for each file being loaded
  41055. * @param pluginExtension the extension used to determine the plugin
  41056. * @returns The given scene
  41057. */
  41058. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41059. /**
  41060. * Load a scene into an asset container
  41061. * @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)
  41062. * @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)
  41063. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41064. * @param onSuccess a callback with the scene when import succeeds
  41065. * @param onProgress a callback with a progress event for each file being loaded
  41066. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41067. * @param pluginExtension the extension used to determine the plugin
  41068. * @returns The loaded plugin
  41069. */
  41070. 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>;
  41071. /**
  41072. * Load a scene into an asset container
  41073. * @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)
  41074. * @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)
  41075. * @param scene is the instance of Scene to append to
  41076. * @param onProgress a callback with a progress event for each file being loaded
  41077. * @param pluginExtension the extension used to determine the plugin
  41078. * @returns The loaded asset container
  41079. */
  41080. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41081. }
  41082. }
  41083. declare module BABYLON {
  41084. /**
  41085. * Generic Controller
  41086. */
  41087. export class GenericController extends WebVRController {
  41088. /**
  41089. * Base Url for the controller model.
  41090. */
  41091. static readonly MODEL_BASE_URL: string;
  41092. /**
  41093. * File name for the controller model.
  41094. */
  41095. static readonly MODEL_FILENAME: string;
  41096. /**
  41097. * Creates a new GenericController from a gamepad
  41098. * @param vrGamepad the gamepad that the controller should be created from
  41099. */
  41100. constructor(vrGamepad: any);
  41101. /**
  41102. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41103. * @param scene scene in which to add meshes
  41104. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41105. */
  41106. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41107. /**
  41108. * Called once for each button that changed state since the last frame
  41109. * @param buttonIdx Which button index changed
  41110. * @param state New state of the button
  41111. * @param changes Which properties on the state changed since last frame
  41112. */
  41113. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41114. }
  41115. }
  41116. declare module BABYLON {
  41117. /**
  41118. * Defines the WindowsMotionController object that the state of the windows motion controller
  41119. */
  41120. export class WindowsMotionController extends WebVRController {
  41121. /**
  41122. * The base url used to load the left and right controller models
  41123. */
  41124. static MODEL_BASE_URL: string;
  41125. /**
  41126. * The name of the left controller model file
  41127. */
  41128. static MODEL_LEFT_FILENAME: string;
  41129. /**
  41130. * The name of the right controller model file
  41131. */
  41132. static MODEL_RIGHT_FILENAME: string;
  41133. /**
  41134. * The controller name prefix for this controller type
  41135. */
  41136. static readonly GAMEPAD_ID_PREFIX: string;
  41137. /**
  41138. * The controller id pattern for this controller type
  41139. */
  41140. private static readonly GAMEPAD_ID_PATTERN;
  41141. private _loadedMeshInfo;
  41142. private readonly _mapping;
  41143. /**
  41144. * Fired when the trackpad on this controller is clicked
  41145. */
  41146. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41147. /**
  41148. * Fired when the trackpad on this controller is modified
  41149. */
  41150. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41151. /**
  41152. * The current x and y values of this controller's trackpad
  41153. */
  41154. trackpad: StickValues;
  41155. /**
  41156. * Creates a new WindowsMotionController from a gamepad
  41157. * @param vrGamepad the gamepad that the controller should be created from
  41158. */
  41159. constructor(vrGamepad: any);
  41160. /**
  41161. * Fired when the trigger on this controller is modified
  41162. */
  41163. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41164. /**
  41165. * Fired when the menu button on this controller is modified
  41166. */
  41167. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41168. /**
  41169. * Fired when the grip button on this controller is modified
  41170. */
  41171. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41172. /**
  41173. * Fired when the thumbstick button on this controller is modified
  41174. */
  41175. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41176. /**
  41177. * Fired when the touchpad button on this controller is modified
  41178. */
  41179. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41180. /**
  41181. * Fired when the touchpad values on this controller are modified
  41182. */
  41183. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41184. private _updateTrackpad;
  41185. /**
  41186. * Called once per frame by the engine.
  41187. */
  41188. update(): void;
  41189. /**
  41190. * Called once for each button that changed state since the last frame
  41191. * @param buttonIdx Which button index changed
  41192. * @param state New state of the button
  41193. * @param changes Which properties on the state changed since last frame
  41194. */
  41195. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41196. /**
  41197. * Moves the buttons on the controller mesh based on their current state
  41198. * @param buttonName the name of the button to move
  41199. * @param buttonValue the value of the button which determines the buttons new position
  41200. */
  41201. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41202. /**
  41203. * Moves the axis on the controller mesh based on its current state
  41204. * @param axis the index of the axis
  41205. * @param axisValue the value of the axis which determines the meshes new position
  41206. * @hidden
  41207. */
  41208. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41209. /**
  41210. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41211. * @param scene scene in which to add meshes
  41212. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41213. */
  41214. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41215. /**
  41216. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41217. * can be transformed by button presses and axes values, based on this._mapping.
  41218. *
  41219. * @param scene scene in which the meshes exist
  41220. * @param meshes list of meshes that make up the controller model to process
  41221. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41222. */
  41223. private processModel;
  41224. private createMeshInfo;
  41225. /**
  41226. * Gets the ray of the controller in the direction the controller is pointing
  41227. * @param length the length the resulting ray should be
  41228. * @returns a ray in the direction the controller is pointing
  41229. */
  41230. getForwardRay(length?: number): Ray;
  41231. /**
  41232. * Disposes of the controller
  41233. */
  41234. dispose(): void;
  41235. }
  41236. }
  41237. declare module BABYLON {
  41238. /**
  41239. * Oculus Touch Controller
  41240. */
  41241. export class OculusTouchController extends WebVRController {
  41242. /**
  41243. * Base Url for the controller model.
  41244. */
  41245. static MODEL_BASE_URL: string;
  41246. /**
  41247. * File name for the left controller model.
  41248. */
  41249. static MODEL_LEFT_FILENAME: string;
  41250. /**
  41251. * File name for the right controller model.
  41252. */
  41253. static MODEL_RIGHT_FILENAME: string;
  41254. /**
  41255. * Base Url for the Quest controller model.
  41256. */
  41257. static QUEST_MODEL_BASE_URL: string;
  41258. /**
  41259. * @hidden
  41260. * If the controllers are running on a device that needs the updated Quest controller models
  41261. */ private static _IsQuest: boolean;
  41262. /**
  41263. * Fired when the secondary trigger on this controller is modified
  41264. */
  41265. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41266. /**
  41267. * Fired when the thumb rest on this controller is modified
  41268. */
  41269. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41270. /**
  41271. * Creates a new OculusTouchController from a gamepad
  41272. * @param vrGamepad the gamepad that the controller should be created from
  41273. */
  41274. constructor(vrGamepad: any);
  41275. /**
  41276. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41277. * @param scene scene in which to add meshes
  41278. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41279. */
  41280. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41281. /**
  41282. * Fired when the A button on this controller is modified
  41283. */
  41284. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41285. /**
  41286. * Fired when the B button on this controller is modified
  41287. */
  41288. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41289. /**
  41290. * Fired when the X button on this controller is modified
  41291. */
  41292. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41293. /**
  41294. * Fired when the Y button on this controller is modified
  41295. */
  41296. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41297. /**
  41298. * Called once for each button that changed state since the last frame
  41299. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41300. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41301. * 2) secondary trigger (same)
  41302. * 3) A (right) X (left), touch, pressed = value
  41303. * 4) B / Y
  41304. * 5) thumb rest
  41305. * @param buttonIdx Which button index changed
  41306. * @param state New state of the button
  41307. * @param changes Which properties on the state changed since last frame
  41308. */
  41309. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41310. }
  41311. }
  41312. declare module BABYLON {
  41313. /**
  41314. * Vive Controller
  41315. */
  41316. export class ViveController extends WebVRController {
  41317. /**
  41318. * Base Url for the controller model.
  41319. */
  41320. static MODEL_BASE_URL: string;
  41321. /**
  41322. * File name for the controller model.
  41323. */
  41324. static MODEL_FILENAME: string;
  41325. /**
  41326. * Creates a new ViveController from a gamepad
  41327. * @param vrGamepad the gamepad that the controller should be created from
  41328. */
  41329. constructor(vrGamepad: any);
  41330. /**
  41331. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41332. * @param scene scene in which to add meshes
  41333. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41334. */
  41335. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41336. /**
  41337. * Fired when the left button on this controller is modified
  41338. */
  41339. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41340. /**
  41341. * Fired when the right button on this controller is modified
  41342. */
  41343. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41344. /**
  41345. * Fired when the menu button on this controller is modified
  41346. */
  41347. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41348. /**
  41349. * Called once for each button that changed state since the last frame
  41350. * Vive mapping:
  41351. * 0: touchpad
  41352. * 1: trigger
  41353. * 2: left AND right buttons
  41354. * 3: menu button
  41355. * @param buttonIdx Which button index changed
  41356. * @param state New state of the button
  41357. * @param changes Which properties on the state changed since last frame
  41358. */
  41359. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41360. }
  41361. }
  41362. declare module BABYLON {
  41363. /**
  41364. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  41365. */
  41366. export class WebXRControllerModelLoader {
  41367. /**
  41368. * Creates the WebXRControllerModelLoader
  41369. * @param input xr input that creates the controllers
  41370. */
  41371. constructor(input: WebXRInput);
  41372. }
  41373. }
  41374. declare module BABYLON {
  41375. /**
  41376. * Contains an array of blocks representing the octree
  41377. */
  41378. export interface IOctreeContainer<T> {
  41379. /**
  41380. * Blocks within the octree
  41381. */
  41382. blocks: Array<OctreeBlock<T>>;
  41383. }
  41384. /**
  41385. * Class used to store a cell in an octree
  41386. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41387. */
  41388. export class OctreeBlock<T> {
  41389. /**
  41390. * Gets the content of the current block
  41391. */
  41392. entries: T[];
  41393. /**
  41394. * Gets the list of block children
  41395. */
  41396. blocks: Array<OctreeBlock<T>>;
  41397. private _depth;
  41398. private _maxDepth;
  41399. private _capacity;
  41400. private _minPoint;
  41401. private _maxPoint;
  41402. private _boundingVectors;
  41403. private _creationFunc;
  41404. /**
  41405. * Creates a new block
  41406. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41407. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41408. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41409. * @param depth defines the current depth of this block in the octree
  41410. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41411. * @param creationFunc defines a callback to call when an element is added to the block
  41412. */
  41413. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41414. /**
  41415. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41416. */
  41417. readonly capacity: number;
  41418. /**
  41419. * Gets the minimum vector (in world space) of the block's bounding box
  41420. */
  41421. readonly minPoint: Vector3;
  41422. /**
  41423. * Gets the maximum vector (in world space) of the block's bounding box
  41424. */
  41425. readonly maxPoint: Vector3;
  41426. /**
  41427. * Add a new element to this block
  41428. * @param entry defines the element to add
  41429. */
  41430. addEntry(entry: T): void;
  41431. /**
  41432. * Remove an element from this block
  41433. * @param entry defines the element to remove
  41434. */
  41435. removeEntry(entry: T): void;
  41436. /**
  41437. * Add an array of elements to this block
  41438. * @param entries defines the array of elements to add
  41439. */
  41440. addEntries(entries: T[]): void;
  41441. /**
  41442. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41443. * @param frustumPlanes defines the frustum planes to test
  41444. * @param selection defines the array to store current content if selection is positive
  41445. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41446. */
  41447. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41448. /**
  41449. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41450. * @param sphereCenter defines the bounding sphere center
  41451. * @param sphereRadius defines the bounding sphere radius
  41452. * @param selection defines the array to store current content if selection is positive
  41453. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41454. */
  41455. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41456. /**
  41457. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41458. * @param ray defines the ray to test with
  41459. * @param selection defines the array to store current content if selection is positive
  41460. */
  41461. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41462. /**
  41463. * Subdivide the content into child blocks (this block will then be empty)
  41464. */
  41465. createInnerBlocks(): void;
  41466. /**
  41467. * @hidden
  41468. */ 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;
  41469. }
  41470. }
  41471. declare module BABYLON {
  41472. /**
  41473. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41474. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41475. */
  41476. export class Octree<T> {
  41477. /** 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.) */
  41478. maxDepth: number;
  41479. /**
  41480. * Blocks within the octree containing objects
  41481. */
  41482. blocks: Array<OctreeBlock<T>>;
  41483. /**
  41484. * Content stored in the octree
  41485. */
  41486. dynamicContent: T[];
  41487. private _maxBlockCapacity;
  41488. private _selectionContent;
  41489. private _creationFunc;
  41490. /**
  41491. * Creates a octree
  41492. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41493. * @param creationFunc function to be used to instatiate the octree
  41494. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41495. * @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.)
  41496. */
  41497. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41498. /** 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.) */
  41499. maxDepth?: number);
  41500. /**
  41501. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41502. * @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);
  41503. * @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);
  41504. * @param entries meshes to be added to the octree blocks
  41505. */
  41506. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41507. /**
  41508. * Adds a mesh to the octree
  41509. * @param entry Mesh to add to the octree
  41510. */
  41511. addMesh(entry: T): void;
  41512. /**
  41513. * Remove an element from the octree
  41514. * @param entry defines the element to remove
  41515. */
  41516. removeMesh(entry: T): void;
  41517. /**
  41518. * Selects an array of meshes within the frustum
  41519. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41520. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41521. * @returns array of meshes within the frustum
  41522. */
  41523. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41524. /**
  41525. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41526. * @param sphereCenter defines the bounding sphere center
  41527. * @param sphereRadius defines the bounding sphere radius
  41528. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41529. * @returns an array of objects that intersect the sphere
  41530. */
  41531. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41532. /**
  41533. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41534. * @param ray defines the ray to test with
  41535. * @returns array of intersected objects
  41536. */
  41537. intersectsRay(ray: Ray): SmartArray<T>;
  41538. /**
  41539. * Adds a mesh into the octree block if it intersects the block
  41540. */
  41541. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41542. /**
  41543. * Adds a submesh into the octree block if it intersects the block
  41544. */
  41545. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41546. }
  41547. }
  41548. declare module BABYLON {
  41549. interface Scene {
  41550. /**
  41551. * @hidden
  41552. * Backing Filed
  41553. */ private _selectionOctree: Octree<AbstractMesh>;
  41554. /**
  41555. * Gets the octree used to boost mesh selection (picking)
  41556. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41557. */
  41558. selectionOctree: Octree<AbstractMesh>;
  41559. /**
  41560. * Creates or updates the octree used to boost selection (picking)
  41561. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41562. * @param maxCapacity defines the maximum capacity per leaf
  41563. * @param maxDepth defines the maximum depth of the octree
  41564. * @returns an octree of AbstractMesh
  41565. */
  41566. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41567. }
  41568. interface AbstractMesh {
  41569. /**
  41570. * @hidden
  41571. * Backing Field
  41572. */ private _submeshesOctree: Octree<SubMesh>;
  41573. /**
  41574. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41575. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41576. * @param maxCapacity defines the maximum size of each block (64 by default)
  41577. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41578. * @returns the new octree
  41579. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41580. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41581. */
  41582. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41583. }
  41584. /**
  41585. * Defines the octree scene component responsible to manage any octrees
  41586. * in a given scene.
  41587. */
  41588. export class OctreeSceneComponent {
  41589. /**
  41590. * The component name help to identify the component in the list of scene components.
  41591. */
  41592. readonly name: string;
  41593. /**
  41594. * The scene the component belongs to.
  41595. */
  41596. scene: Scene;
  41597. /**
  41598. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41599. */
  41600. readonly checksIsEnabled: boolean;
  41601. /**
  41602. * Creates a new instance of the component for the given scene
  41603. * @param scene Defines the scene to register the component in
  41604. */
  41605. constructor(scene: Scene);
  41606. /**
  41607. * Registers the component in a given scene
  41608. */
  41609. register(): void;
  41610. /**
  41611. * Return the list of active meshes
  41612. * @returns the list of active meshes
  41613. */
  41614. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41615. /**
  41616. * Return the list of active sub meshes
  41617. * @param mesh The mesh to get the candidates sub meshes from
  41618. * @returns the list of active sub meshes
  41619. */
  41620. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41621. private _tempRay;
  41622. /**
  41623. * Return the list of sub meshes intersecting with a given local ray
  41624. * @param mesh defines the mesh to find the submesh for
  41625. * @param localRay defines the ray in local space
  41626. * @returns the list of intersecting sub meshes
  41627. */
  41628. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41629. /**
  41630. * Return the list of sub meshes colliding with a collider
  41631. * @param mesh defines the mesh to find the submesh for
  41632. * @param collider defines the collider to evaluate the collision against
  41633. * @returns the list of colliding sub meshes
  41634. */
  41635. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41636. /**
  41637. * Rebuilds the elements related to this component in case of
  41638. * context lost for instance.
  41639. */
  41640. rebuild(): void;
  41641. /**
  41642. * Disposes the component and the associated ressources.
  41643. */
  41644. dispose(): void;
  41645. }
  41646. }
  41647. declare module BABYLON {
  41648. /**
  41649. * Renders a layer on top of an existing scene
  41650. */
  41651. export class UtilityLayerRenderer implements IDisposable {
  41652. /** the original scene that will be rendered on top of */
  41653. originalScene: Scene;
  41654. private _pointerCaptures;
  41655. private _lastPointerEvents;
  41656. private static _DefaultUtilityLayer;
  41657. private static _DefaultKeepDepthUtilityLayer;
  41658. private _sharedGizmoLight;
  41659. private _renderCamera;
  41660. /**
  41661. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  41662. * @returns the camera that is used when rendering the utility layer
  41663. */
  41664. getRenderCamera(): Nullable<Camera>;
  41665. /**
  41666. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  41667. * @param cam the camera that should be used when rendering the utility layer
  41668. */
  41669. setRenderCamera(cam: Nullable<Camera>): void;
  41670. /**
  41671. * @hidden
  41672. * Light which used by gizmos to get light shading
  41673. */ private _getSharedGizmoLight(): HemisphericLight;
  41674. /**
  41675. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41676. */
  41677. pickUtilitySceneFirst: boolean;
  41678. /**
  41679. * 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)
  41680. */
  41681. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41682. /**
  41683. * 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)
  41684. */
  41685. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41686. /**
  41687. * The scene that is rendered on top of the original scene
  41688. */
  41689. utilityLayerScene: Scene;
  41690. /**
  41691. * If the utility layer should automatically be rendered on top of existing scene
  41692. */
  41693. shouldRender: boolean;
  41694. /**
  41695. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41696. */
  41697. onlyCheckPointerDownEvents: boolean;
  41698. /**
  41699. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41700. */
  41701. processAllEvents: boolean;
  41702. /**
  41703. * Observable raised when the pointer move from the utility layer scene to the main scene
  41704. */
  41705. onPointerOutObservable: Observable<number>;
  41706. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41707. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41708. private _afterRenderObserver;
  41709. private _sceneDisposeObserver;
  41710. private _originalPointerObserver;
  41711. /**
  41712. * Instantiates a UtilityLayerRenderer
  41713. * @param originalScene the original scene that will be rendered on top of
  41714. * @param handleEvents boolean indicating if the utility layer should handle events
  41715. */
  41716. constructor(
  41717. /** the original scene that will be rendered on top of */
  41718. originalScene: Scene, handleEvents?: boolean);
  41719. private _notifyObservers;
  41720. /**
  41721. * Renders the utility layers scene on top of the original scene
  41722. */
  41723. render(): void;
  41724. /**
  41725. * Disposes of the renderer
  41726. */
  41727. dispose(): void;
  41728. private _updateCamera;
  41729. }
  41730. }
  41731. declare module BABYLON {
  41732. /**
  41733. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41734. */
  41735. export class Gizmo implements IDisposable {
  41736. /** The utility layer the gizmo will be added to */
  41737. gizmoLayer: UtilityLayerRenderer;
  41738. /**
  41739. * The root mesh of the gizmo
  41740. */ private _rootMesh: Mesh;
  41741. private _attachedMesh;
  41742. /**
  41743. * Ratio for the scale of the gizmo (Default: 1)
  41744. */
  41745. scaleRatio: number;
  41746. /**
  41747. * If a custom mesh has been set (Default: false)
  41748. */
  41749. protected _customMeshSet: boolean;
  41750. /**
  41751. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41752. * * When set, interactions will be enabled
  41753. */
  41754. attachedMesh: Nullable<AbstractMesh>;
  41755. /**
  41756. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41757. * @param mesh The mesh to replace the default mesh of the gizmo
  41758. */
  41759. setCustomMesh(mesh: Mesh): void;
  41760. /**
  41761. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41762. */
  41763. updateGizmoRotationToMatchAttachedMesh: boolean;
  41764. /**
  41765. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41766. */
  41767. updateGizmoPositionToMatchAttachedMesh: boolean;
  41768. /**
  41769. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  41770. */
  41771. updateScale: boolean;
  41772. protected _interactionsEnabled: boolean;
  41773. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41774. private _beforeRenderObserver;
  41775. private _tempVector;
  41776. /**
  41777. * Creates a gizmo
  41778. * @param gizmoLayer The utility layer the gizmo will be added to
  41779. */
  41780. constructor(
  41781. /** The utility layer the gizmo will be added to */
  41782. gizmoLayer?: UtilityLayerRenderer);
  41783. /**
  41784. * Updates the gizmo to match the attached mesh's position/rotation
  41785. */
  41786. protected _update(): void;
  41787. /**
  41788. * Disposes of the gizmo
  41789. */
  41790. dispose(): void;
  41791. }
  41792. }
  41793. declare module BABYLON {
  41794. /**
  41795. * Single plane drag gizmo
  41796. */
  41797. export class PlaneDragGizmo extends Gizmo {
  41798. /**
  41799. * Drag behavior responsible for the gizmos dragging interactions
  41800. */
  41801. dragBehavior: PointerDragBehavior;
  41802. private _pointerObserver;
  41803. /**
  41804. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41805. */
  41806. snapDistance: number;
  41807. /**
  41808. * Event that fires each time the gizmo snaps to a new location.
  41809. * * snapDistance is the the change in distance
  41810. */
  41811. onSnapObservable: Observable<{
  41812. snapDistance: number;
  41813. }>;
  41814. private _plane;
  41815. private _coloredMaterial;
  41816. private _hoverMaterial;
  41817. private _isEnabled;
  41818. private _parent;
  41819. /** @hidden */ private static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  41820. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41821. /**
  41822. * Creates a PlaneDragGizmo
  41823. * @param gizmoLayer The utility layer the gizmo will be added to
  41824. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  41825. * @param color The color of the gizmo
  41826. */
  41827. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41828. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41829. /**
  41830. * If the gizmo is enabled
  41831. */
  41832. isEnabled: boolean;
  41833. /**
  41834. * Disposes of the gizmo
  41835. */
  41836. dispose(): void;
  41837. }
  41838. }
  41839. declare module BABYLON {
  41840. /**
  41841. * Gizmo that enables dragging a mesh along 3 axis
  41842. */
  41843. export class PositionGizmo extends Gizmo {
  41844. /**
  41845. * Internal gizmo used for interactions on the x axis
  41846. */
  41847. xGizmo: AxisDragGizmo;
  41848. /**
  41849. * Internal gizmo used for interactions on the y axis
  41850. */
  41851. yGizmo: AxisDragGizmo;
  41852. /**
  41853. * Internal gizmo used for interactions on the z axis
  41854. */
  41855. zGizmo: AxisDragGizmo;
  41856. /**
  41857. * Internal gizmo used for interactions on the yz plane
  41858. */
  41859. xPlaneGizmo: PlaneDragGizmo;
  41860. /**
  41861. * Internal gizmo used for interactions on the xz plane
  41862. */
  41863. yPlaneGizmo: PlaneDragGizmo;
  41864. /**
  41865. * Internal gizmo used for interactions on the xy plane
  41866. */
  41867. zPlaneGizmo: PlaneDragGizmo;
  41868. /**
  41869. * private variables
  41870. */
  41871. private _meshAttached;
  41872. private _updateGizmoRotationToMatchAttachedMesh;
  41873. private _snapDistance;
  41874. private _scaleRatio;
  41875. /** Fires an event when any of it's sub gizmos are dragged */
  41876. onDragStartObservable: Observable<unknown>;
  41877. /** Fires an event when any of it's sub gizmos are released from dragging */
  41878. onDragEndObservable: Observable<unknown>;
  41879. /**
  41880. * If set to true, planar drag is enabled
  41881. */
  41882. private _planarGizmoEnabled;
  41883. attachedMesh: Nullable<AbstractMesh>;
  41884. /**
  41885. * Creates a PositionGizmo
  41886. * @param gizmoLayer The utility layer the gizmo will be added to
  41887. */
  41888. constructor(gizmoLayer?: UtilityLayerRenderer);
  41889. /**
  41890. * If the planar drag gizmo is enabled
  41891. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  41892. */
  41893. planarGizmoEnabled: boolean;
  41894. updateGizmoRotationToMatchAttachedMesh: boolean;
  41895. /**
  41896. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41897. */
  41898. snapDistance: number;
  41899. /**
  41900. * Ratio for the scale of the gizmo (Default: 1)
  41901. */
  41902. scaleRatio: number;
  41903. /**
  41904. * Disposes of the gizmo
  41905. */
  41906. dispose(): void;
  41907. /**
  41908. * CustomMeshes are not supported by this gizmo
  41909. * @param mesh The mesh to replace the default mesh of the gizmo
  41910. */
  41911. setCustomMesh(mesh: Mesh): void;
  41912. }
  41913. }
  41914. declare module BABYLON {
  41915. /**
  41916. * Single axis drag gizmo
  41917. */
  41918. export class AxisDragGizmo extends Gizmo {
  41919. /**
  41920. * Drag behavior responsible for the gizmos dragging interactions
  41921. */
  41922. dragBehavior: PointerDragBehavior;
  41923. private _pointerObserver;
  41924. /**
  41925. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41926. */
  41927. snapDistance: number;
  41928. /**
  41929. * Event that fires each time the gizmo snaps to a new location.
  41930. * * snapDistance is the the change in distance
  41931. */
  41932. onSnapObservable: Observable<{
  41933. snapDistance: number;
  41934. }>;
  41935. private _isEnabled;
  41936. private _parent;
  41937. private _arrow;
  41938. private _coloredMaterial;
  41939. private _hoverMaterial;
  41940. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41941. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41942. /**
  41943. * Creates an AxisDragGizmo
  41944. * @param gizmoLayer The utility layer the gizmo will be added to
  41945. * @param dragAxis The axis which the gizmo will be able to drag on
  41946. * @param color The color of the gizmo
  41947. */
  41948. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41949. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41950. /**
  41951. * If the gizmo is enabled
  41952. */
  41953. isEnabled: boolean;
  41954. /**
  41955. * Disposes of the gizmo
  41956. */
  41957. dispose(): void;
  41958. }
  41959. }
  41960. declare module BABYLON.Debug {
  41961. /**
  41962. * The Axes viewer will show 3 axes in a specific point in space
  41963. */
  41964. export class AxesViewer {
  41965. private _xAxis;
  41966. private _yAxis;
  41967. private _zAxis;
  41968. private _scaleLinesFactor;
  41969. private _instanced;
  41970. /**
  41971. * Gets the hosting scene
  41972. */
  41973. scene: Scene;
  41974. /**
  41975. * Gets or sets a number used to scale line length
  41976. */
  41977. scaleLines: number;
  41978. /** Gets the node hierarchy used to render x-axis */
  41979. readonly xAxis: TransformNode;
  41980. /** Gets the node hierarchy used to render y-axis */
  41981. readonly yAxis: TransformNode;
  41982. /** Gets the node hierarchy used to render z-axis */
  41983. readonly zAxis: TransformNode;
  41984. /**
  41985. * Creates a new AxesViewer
  41986. * @param scene defines the hosting scene
  41987. * @param scaleLines defines a number used to scale line length (1 by default)
  41988. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41989. * @param xAxis defines the node hierarchy used to render the x-axis
  41990. * @param yAxis defines the node hierarchy used to render the y-axis
  41991. * @param zAxis defines the node hierarchy used to render the z-axis
  41992. */
  41993. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41994. /**
  41995. * Force the viewer to update
  41996. * @param position defines the position of the viewer
  41997. * @param xaxis defines the x axis of the viewer
  41998. * @param yaxis defines the y axis of the viewer
  41999. * @param zaxis defines the z axis of the viewer
  42000. */
  42001. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42002. /**
  42003. * Creates an instance of this axes viewer.
  42004. * @returns a new axes viewer with instanced meshes
  42005. */
  42006. createInstance(): AxesViewer;
  42007. /** Releases resources */
  42008. dispose(): void;
  42009. private static _SetRenderingGroupId;
  42010. }
  42011. }
  42012. declare module BABYLON.Debug {
  42013. /**
  42014. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42015. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42016. */
  42017. export class BoneAxesViewer extends AxesViewer {
  42018. /**
  42019. * Gets or sets the target mesh where to display the axes viewer
  42020. */
  42021. mesh: Nullable<Mesh>;
  42022. /**
  42023. * Gets or sets the target bone where to display the axes viewer
  42024. */
  42025. bone: Nullable<Bone>;
  42026. /** Gets current position */
  42027. pos: Vector3;
  42028. /** Gets direction of X axis */
  42029. xaxis: Vector3;
  42030. /** Gets direction of Y axis */
  42031. yaxis: Vector3;
  42032. /** Gets direction of Z axis */
  42033. zaxis: Vector3;
  42034. /**
  42035. * Creates a new BoneAxesViewer
  42036. * @param scene defines the hosting scene
  42037. * @param bone defines the target bone
  42038. * @param mesh defines the target mesh
  42039. * @param scaleLines defines a scaling factor for line length (1 by default)
  42040. */
  42041. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42042. /**
  42043. * Force the viewer to update
  42044. */
  42045. update(): void;
  42046. /** Releases resources */
  42047. dispose(): void;
  42048. }
  42049. }
  42050. declare module BABYLON {
  42051. /**
  42052. * Interface used to define scene explorer extensibility option
  42053. */
  42054. export interface IExplorerExtensibilityOption {
  42055. /**
  42056. * Define the option label
  42057. */
  42058. label: string;
  42059. /**
  42060. * Defines the action to execute on click
  42061. */
  42062. action: (entity: any) => void;
  42063. }
  42064. /**
  42065. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42066. */
  42067. export interface IExplorerExtensibilityGroup {
  42068. /**
  42069. * Defines a predicate to test if a given type mut be extended
  42070. */
  42071. predicate: (entity: any) => boolean;
  42072. /**
  42073. * Gets the list of options added to a type
  42074. */
  42075. entries: IExplorerExtensibilityOption[];
  42076. }
  42077. /**
  42078. * Interface used to define the options to use to create the Inspector
  42079. */
  42080. export interface IInspectorOptions {
  42081. /**
  42082. * Display in overlay mode (default: false)
  42083. */
  42084. overlay?: boolean;
  42085. /**
  42086. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42087. */
  42088. globalRoot?: HTMLElement;
  42089. /**
  42090. * Display the Scene explorer
  42091. */
  42092. showExplorer?: boolean;
  42093. /**
  42094. * Display the property inspector
  42095. */
  42096. showInspector?: boolean;
  42097. /**
  42098. * Display in embed mode (both panes on the right)
  42099. */
  42100. embedMode?: boolean;
  42101. /**
  42102. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42103. */
  42104. handleResize?: boolean;
  42105. /**
  42106. * Allow the panes to popup (default: true)
  42107. */
  42108. enablePopup?: boolean;
  42109. /**
  42110. * Allow the panes to be closed by users (default: true)
  42111. */
  42112. enableClose?: boolean;
  42113. /**
  42114. * Optional list of extensibility entries
  42115. */
  42116. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42117. /**
  42118. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42119. */
  42120. inspectorURL?: string;
  42121. }
  42122. interface Scene {
  42123. /**
  42124. * @hidden
  42125. * Backing field
  42126. */ private _debugLayer: DebugLayer;
  42127. /**
  42128. * Gets the debug layer (aka Inspector) associated with the scene
  42129. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42130. */
  42131. debugLayer: DebugLayer;
  42132. }
  42133. /**
  42134. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42135. * what is happening in your scene
  42136. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42137. */
  42138. export class DebugLayer {
  42139. /**
  42140. * Define the url to get the inspector script from.
  42141. * By default it uses the babylonjs CDN.
  42142. * @ignoreNaming
  42143. */
  42144. static InspectorURL: string;
  42145. private _scene;
  42146. private BJSINSPECTOR;
  42147. private _onPropertyChangedObservable?;
  42148. /**
  42149. * Observable triggered when a property is changed through the inspector.
  42150. */
  42151. readonly onPropertyChangedObservable: any;
  42152. /**
  42153. * Instantiates a new debug layer.
  42154. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42155. * what is happening in your scene
  42156. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42157. * @param scene Defines the scene to inspect
  42158. */
  42159. constructor(scene: Scene);
  42160. /** Creates the inspector window. */
  42161. private _createInspector;
  42162. /**
  42163. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42164. * @param entity defines the entity to select
  42165. * @param lineContainerTitle defines the specific block to highlight
  42166. */
  42167. select(entity: any, lineContainerTitle?: string): void;
  42168. /** Get the inspector from bundle or global */
  42169. private _getGlobalInspector;
  42170. /**
  42171. * Get if the inspector is visible or not.
  42172. * @returns true if visible otherwise, false
  42173. */
  42174. isVisible(): boolean;
  42175. /**
  42176. * Hide the inspector and close its window.
  42177. */
  42178. hide(): void;
  42179. /**
  42180. * Launch the debugLayer.
  42181. * @param config Define the configuration of the inspector
  42182. * @return a promise fulfilled when the debug layer is visible
  42183. */
  42184. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42185. }
  42186. }
  42187. declare module BABYLON {
  42188. /**
  42189. * Class containing static functions to help procedurally build meshes
  42190. */
  42191. export class BoxBuilder {
  42192. /**
  42193. * Creates a box mesh
  42194. * * The parameter `size` sets the size (float) of each box side (default 1)
  42195. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42196. * * 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)
  42197. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42198. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42199. * * 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
  42200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42201. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42202. * @param name defines the name of the mesh
  42203. * @param options defines the options used to create the mesh
  42204. * @param scene defines the hosting scene
  42205. * @returns the box mesh
  42206. */
  42207. static CreateBox(name: string, options: {
  42208. size?: number;
  42209. width?: number;
  42210. height?: number;
  42211. depth?: number;
  42212. faceUV?: Vector4[];
  42213. faceColors?: Color4[];
  42214. sideOrientation?: number;
  42215. frontUVs?: Vector4;
  42216. backUVs?: Vector4;
  42217. wrap?: boolean;
  42218. topBaseAt?: number;
  42219. bottomBaseAt?: number;
  42220. updatable?: boolean;
  42221. }, scene?: Nullable<Scene>): Mesh;
  42222. }
  42223. }
  42224. declare module BABYLON {
  42225. /**
  42226. * Class containing static functions to help procedurally build meshes
  42227. */
  42228. export class SphereBuilder {
  42229. /**
  42230. * Creates a sphere mesh
  42231. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42232. * * 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`)
  42233. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42234. * * 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
  42235. * * 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)
  42236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42237. * * 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
  42238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42239. * @param name defines the name of the mesh
  42240. * @param options defines the options used to create the mesh
  42241. * @param scene defines the hosting scene
  42242. * @returns the sphere mesh
  42243. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42244. */
  42245. static CreateSphere(name: string, options: {
  42246. segments?: number;
  42247. diameter?: number;
  42248. diameterX?: number;
  42249. diameterY?: number;
  42250. diameterZ?: number;
  42251. arc?: number;
  42252. slice?: number;
  42253. sideOrientation?: number;
  42254. frontUVs?: Vector4;
  42255. backUVs?: Vector4;
  42256. updatable?: boolean;
  42257. }, scene?: Nullable<Scene>): Mesh;
  42258. }
  42259. }
  42260. declare module BABYLON.Debug {
  42261. /**
  42262. * Used to show the physics impostor around the specific mesh
  42263. */
  42264. export class PhysicsViewer {
  42265. /** @hidden */
  42266. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42267. /** @hidden */
  42268. protected _meshes: Array<Nullable<AbstractMesh>>;
  42269. /** @hidden */
  42270. protected _scene: Nullable<Scene>;
  42271. /** @hidden */
  42272. protected _numMeshes: number;
  42273. /** @hidden */
  42274. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42275. private _renderFunction;
  42276. private _utilityLayer;
  42277. private _debugBoxMesh;
  42278. private _debugSphereMesh;
  42279. private _debugCylinderMesh;
  42280. private _debugMaterial;
  42281. private _debugMeshMeshes;
  42282. /**
  42283. * Creates a new PhysicsViewer
  42284. * @param scene defines the hosting scene
  42285. */
  42286. constructor(scene: Scene);
  42287. /** @hidden */
  42288. protected _updateDebugMeshes(): void;
  42289. /**
  42290. * Renders a specified physic impostor
  42291. * @param impostor defines the impostor to render
  42292. * @param targetMesh defines the mesh represented by the impostor
  42293. * @returns the new debug mesh used to render the impostor
  42294. */
  42295. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42296. /**
  42297. * Hides a specified physic impostor
  42298. * @param impostor defines the impostor to hide
  42299. */
  42300. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42301. private _getDebugMaterial;
  42302. private _getDebugBoxMesh;
  42303. private _getDebugSphereMesh;
  42304. private _getDebugCylinderMesh;
  42305. private _getDebugMeshMesh;
  42306. private _getDebugMesh;
  42307. /** Releases all resources */
  42308. dispose(): void;
  42309. }
  42310. }
  42311. declare module BABYLON {
  42312. /**
  42313. * Class containing static functions to help procedurally build meshes
  42314. */
  42315. export class LinesBuilder {
  42316. /**
  42317. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42318. * * 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
  42319. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42320. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42321. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42322. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42323. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42324. * * 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
  42325. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42327. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42328. * @param name defines the name of the new line system
  42329. * @param options defines the options used to create the line system
  42330. * @param scene defines the hosting scene
  42331. * @returns a new line system mesh
  42332. */
  42333. static CreateLineSystem(name: string, options: {
  42334. lines: Vector3[][];
  42335. updatable?: boolean;
  42336. instance?: Nullable<LinesMesh>;
  42337. colors?: Nullable<Color4[][]>;
  42338. useVertexAlpha?: boolean;
  42339. }, scene: Nullable<Scene>): LinesMesh;
  42340. /**
  42341. * Creates a line mesh
  42342. * 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
  42343. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42344. * * The parameter `points` is an array successive Vector3
  42345. * * 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
  42346. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42347. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42348. * * When updating an instance, remember that only point positions can change, not the number of points
  42349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42350. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42351. * @param name defines the name of the new line system
  42352. * @param options defines the options used to create the line system
  42353. * @param scene defines the hosting scene
  42354. * @returns a new line mesh
  42355. */
  42356. static CreateLines(name: string, options: {
  42357. points: Vector3[];
  42358. updatable?: boolean;
  42359. instance?: Nullable<LinesMesh>;
  42360. colors?: Color4[];
  42361. useVertexAlpha?: boolean;
  42362. }, scene?: Nullable<Scene>): LinesMesh;
  42363. /**
  42364. * Creates a dashed line mesh
  42365. * * 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
  42366. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42367. * * The parameter `points` is an array successive Vector3
  42368. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42369. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42370. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42371. * * 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
  42372. * * When updating an instance, remember that only point positions can change, not the number of points
  42373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42374. * @param name defines the name of the mesh
  42375. * @param options defines the options used to create the mesh
  42376. * @param scene defines the hosting scene
  42377. * @returns the dashed line mesh
  42378. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42379. */
  42380. static CreateDashedLines(name: string, options: {
  42381. points: Vector3[];
  42382. dashSize?: number;
  42383. gapSize?: number;
  42384. dashNb?: number;
  42385. updatable?: boolean;
  42386. instance?: LinesMesh;
  42387. }, scene?: Nullable<Scene>): LinesMesh;
  42388. }
  42389. }
  42390. declare module BABYLON {
  42391. /**
  42392. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42393. * in order to better appreciate the issue one might have.
  42394. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42395. */
  42396. export class RayHelper {
  42397. /**
  42398. * Defines the ray we are currently tryin to visualize.
  42399. */
  42400. ray: Nullable<Ray>;
  42401. private _renderPoints;
  42402. private _renderLine;
  42403. private _renderFunction;
  42404. private _scene;
  42405. private _updateToMeshFunction;
  42406. private _attachedToMesh;
  42407. private _meshSpaceDirection;
  42408. private _meshSpaceOrigin;
  42409. /**
  42410. * Helper function to create a colored helper in a scene in one line.
  42411. * @param ray Defines the ray we are currently tryin to visualize
  42412. * @param scene Defines the scene the ray is used in
  42413. * @param color Defines the color we want to see the ray in
  42414. * @returns The newly created ray helper.
  42415. */
  42416. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42417. /**
  42418. * Instantiate a new ray helper.
  42419. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42420. * in order to better appreciate the issue one might have.
  42421. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42422. * @param ray Defines the ray we are currently tryin to visualize
  42423. */
  42424. constructor(ray: Ray);
  42425. /**
  42426. * Shows the ray we are willing to debug.
  42427. * @param scene Defines the scene the ray needs to be rendered in
  42428. * @param color Defines the color the ray needs to be rendered in
  42429. */
  42430. show(scene: Scene, color?: Color3): void;
  42431. /**
  42432. * Hides the ray we are debugging.
  42433. */
  42434. hide(): void;
  42435. private _render;
  42436. /**
  42437. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42438. * @param mesh Defines the mesh we want the helper attached to
  42439. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42440. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42441. * @param length Defines the length of the ray
  42442. */
  42443. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42444. /**
  42445. * Detach the ray helper from the mesh it has previously been attached to.
  42446. */
  42447. detachFromMesh(): void;
  42448. private _updateToMesh;
  42449. /**
  42450. * Dispose the helper and release its associated resources.
  42451. */
  42452. dispose(): void;
  42453. }
  42454. }
  42455. declare module BABYLON.Debug {
  42456. /**
  42457. * Class used to render a debug view of a given skeleton
  42458. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42459. */
  42460. export class SkeletonViewer {
  42461. /** defines the skeleton to render */
  42462. skeleton: Skeleton;
  42463. /** defines the mesh attached to the skeleton */
  42464. mesh: AbstractMesh;
  42465. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42466. autoUpdateBonesMatrices: boolean;
  42467. /** defines the rendering group id to use with the viewer */
  42468. renderingGroupId: number;
  42469. /** Gets or sets the color used to render the skeleton */
  42470. color: Color3;
  42471. private _scene;
  42472. private _debugLines;
  42473. private _debugMesh;
  42474. private _isEnabled;
  42475. private _renderFunction;
  42476. private _utilityLayer;
  42477. /**
  42478. * Returns the mesh used to render the bones
  42479. */
  42480. readonly debugMesh: Nullable<LinesMesh>;
  42481. /**
  42482. * Creates a new SkeletonViewer
  42483. * @param skeleton defines the skeleton to render
  42484. * @param mesh defines the mesh attached to the skeleton
  42485. * @param scene defines the hosting scene
  42486. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42487. * @param renderingGroupId defines the rendering group id to use with the viewer
  42488. */
  42489. constructor(
  42490. /** defines the skeleton to render */
  42491. skeleton: Skeleton,
  42492. /** defines the mesh attached to the skeleton */
  42493. mesh: AbstractMesh, scene: Scene,
  42494. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42495. autoUpdateBonesMatrices?: boolean,
  42496. /** defines the rendering group id to use with the viewer */
  42497. renderingGroupId?: number);
  42498. /** Gets or sets a boolean indicating if the viewer is enabled */
  42499. isEnabled: boolean;
  42500. private _getBonePosition;
  42501. private _getLinesForBonesWithLength;
  42502. private _getLinesForBonesNoLength;
  42503. /** Update the viewer to sync with current skeleton state */
  42504. update(): void;
  42505. /** Release associated resources */
  42506. dispose(): void;
  42507. }
  42508. }
  42509. declare module BABYLON {
  42510. /**
  42511. * Options to create the null engine
  42512. */
  42513. export class NullEngineOptions {
  42514. /**
  42515. * Render width (Default: 512)
  42516. */
  42517. renderWidth: number;
  42518. /**
  42519. * Render height (Default: 256)
  42520. */
  42521. renderHeight: number;
  42522. /**
  42523. * Texture size (Default: 512)
  42524. */
  42525. textureSize: number;
  42526. /**
  42527. * If delta time between frames should be constant
  42528. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42529. */
  42530. deterministicLockstep: boolean;
  42531. /**
  42532. * Maximum about of steps between frames (Default: 4)
  42533. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42534. */
  42535. lockstepMaxSteps: number;
  42536. }
  42537. /**
  42538. * The null engine class provides support for headless version of babylon.js.
  42539. * This can be used in server side scenario or for testing purposes
  42540. */
  42541. export class NullEngine extends Engine {
  42542. private _options;
  42543. /**
  42544. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42545. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42546. * @returns true if engine is in deterministic lock step mode
  42547. */
  42548. isDeterministicLockStep(): boolean;
  42549. /**
  42550. * Gets the max steps when engine is running in deterministic lock step
  42551. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42552. * @returns the max steps
  42553. */
  42554. getLockstepMaxSteps(): number;
  42555. /**
  42556. * Gets the current hardware scaling level.
  42557. * By default the hardware scaling level is computed from the window device ratio.
  42558. * 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.
  42559. * @returns a number indicating the current hardware scaling level
  42560. */
  42561. getHardwareScalingLevel(): number;
  42562. constructor(options?: NullEngineOptions);
  42563. /**
  42564. * Creates a vertex buffer
  42565. * @param vertices the data for the vertex buffer
  42566. * @returns the new WebGL static buffer
  42567. */
  42568. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42569. /**
  42570. * Creates a new index buffer
  42571. * @param indices defines the content of the index buffer
  42572. * @param updatable defines if the index buffer must be updatable
  42573. * @returns a new webGL buffer
  42574. */
  42575. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42576. /**
  42577. * Clear the current render buffer or the current render target (if any is set up)
  42578. * @param color defines the color to use
  42579. * @param backBuffer defines if the back buffer must be cleared
  42580. * @param depth defines if the depth buffer must be cleared
  42581. * @param stencil defines if the stencil buffer must be cleared
  42582. */
  42583. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42584. /**
  42585. * Gets the current render width
  42586. * @param useScreen defines if screen size must be used (or the current render target if any)
  42587. * @returns a number defining the current render width
  42588. */
  42589. getRenderWidth(useScreen?: boolean): number;
  42590. /**
  42591. * Gets the current render height
  42592. * @param useScreen defines if screen size must be used (or the current render target if any)
  42593. * @returns a number defining the current render height
  42594. */
  42595. getRenderHeight(useScreen?: boolean): number;
  42596. /**
  42597. * Set the WebGL's viewport
  42598. * @param viewport defines the viewport element to be used
  42599. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  42600. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  42601. */
  42602. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  42603. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42604. /**
  42605. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  42606. * @param pipelineContext defines the pipeline context to use
  42607. * @param uniformsNames defines the list of uniform names
  42608. * @returns an array of webGL uniform locations
  42609. */
  42610. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42611. /**
  42612. * Gets the lsit of active attributes for a given webGL program
  42613. * @param pipelineContext defines the pipeline context to use
  42614. * @param attributesNames defines the list of attribute names to get
  42615. * @returns an array of indices indicating the offset of each attribute
  42616. */
  42617. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42618. /**
  42619. * Binds an effect to the webGL context
  42620. * @param effect defines the effect to bind
  42621. */
  42622. bindSamplers(effect: Effect): void;
  42623. /**
  42624. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  42625. * @param effect defines the effect to activate
  42626. */
  42627. enableEffect(effect: Effect): void;
  42628. /**
  42629. * Set various states to the webGL context
  42630. * @param culling defines backface culling state
  42631. * @param zOffset defines the value to apply to zOffset (0 by default)
  42632. * @param force defines if states must be applied even if cache is up to date
  42633. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42634. */
  42635. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42636. /**
  42637. * Set the value of an uniform to an array of int32
  42638. * @param uniform defines the webGL uniform location where to store the value
  42639. * @param array defines the array of int32 to store
  42640. */
  42641. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42642. /**
  42643. * Set the value of an uniform to an array of int32 (stored as vec2)
  42644. * @param uniform defines the webGL uniform location where to store the value
  42645. * @param array defines the array of int32 to store
  42646. */
  42647. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42648. /**
  42649. * Set the value of an uniform to an array of int32 (stored as vec3)
  42650. * @param uniform defines the webGL uniform location where to store the value
  42651. * @param array defines the array of int32 to store
  42652. */
  42653. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42654. /**
  42655. * Set the value of an uniform to an array of int32 (stored as vec4)
  42656. * @param uniform defines the webGL uniform location where to store the value
  42657. * @param array defines the array of int32 to store
  42658. */
  42659. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42660. /**
  42661. * Set the value of an uniform to an array of float32
  42662. * @param uniform defines the webGL uniform location where to store the value
  42663. * @param array defines the array of float32 to store
  42664. */
  42665. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42666. /**
  42667. * Set the value of an uniform to an array of float32 (stored as vec2)
  42668. * @param uniform defines the webGL uniform location where to store the value
  42669. * @param array defines the array of float32 to store
  42670. */
  42671. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42672. /**
  42673. * Set the value of an uniform to an array of float32 (stored as vec3)
  42674. * @param uniform defines the webGL uniform location where to store the value
  42675. * @param array defines the array of float32 to store
  42676. */
  42677. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42678. /**
  42679. * Set the value of an uniform to an array of float32 (stored as vec4)
  42680. * @param uniform defines the webGL uniform location where to store the value
  42681. * @param array defines the array of float32 to store
  42682. */
  42683. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42684. /**
  42685. * Set the value of an uniform to an array of number
  42686. * @param uniform defines the webGL uniform location where to store the value
  42687. * @param array defines the array of number to store
  42688. */
  42689. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42690. /**
  42691. * Set the value of an uniform to an array of number (stored as vec2)
  42692. * @param uniform defines the webGL uniform location where to store the value
  42693. * @param array defines the array of number to store
  42694. */
  42695. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42696. /**
  42697. * Set the value of an uniform to an array of number (stored as vec3)
  42698. * @param uniform defines the webGL uniform location where to store the value
  42699. * @param array defines the array of number to store
  42700. */
  42701. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42702. /**
  42703. * Set the value of an uniform to an array of number (stored as vec4)
  42704. * @param uniform defines the webGL uniform location where to store the value
  42705. * @param array defines the array of number to store
  42706. */
  42707. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42708. /**
  42709. * Set the value of an uniform to an array of float32 (stored as matrices)
  42710. * @param uniform defines the webGL uniform location where to store the value
  42711. * @param matrices defines the array of float32 to store
  42712. */
  42713. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42714. /**
  42715. * Set the value of an uniform to a matrix (3x3)
  42716. * @param uniform defines the webGL uniform location where to store the value
  42717. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  42718. */
  42719. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42720. /**
  42721. * Set the value of an uniform to a matrix (2x2)
  42722. * @param uniform defines the webGL uniform location where to store the value
  42723. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  42724. */
  42725. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42726. /**
  42727. * Set the value of an uniform to a number (float)
  42728. * @param uniform defines the webGL uniform location where to store the value
  42729. * @param value defines the float number to store
  42730. */
  42731. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42732. /**
  42733. * Set the value of an uniform to a vec2
  42734. * @param uniform defines the webGL uniform location where to store the value
  42735. * @param x defines the 1st component of the value
  42736. * @param y defines the 2nd component of the value
  42737. */
  42738. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42739. /**
  42740. * Set the value of an uniform to a vec3
  42741. * @param uniform defines the webGL uniform location where to store the value
  42742. * @param x defines the 1st component of the value
  42743. * @param y defines the 2nd component of the value
  42744. * @param z defines the 3rd component of the value
  42745. */
  42746. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42747. /**
  42748. * Set the value of an uniform to a boolean
  42749. * @param uniform defines the webGL uniform location where to store the value
  42750. * @param bool defines the boolean to store
  42751. */
  42752. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42753. /**
  42754. * Set the value of an uniform to a vec4
  42755. * @param uniform defines the webGL uniform location where to store the value
  42756. * @param x defines the 1st component of the value
  42757. * @param y defines the 2nd component of the value
  42758. * @param z defines the 3rd component of the value
  42759. * @param w defines the 4th component of the value
  42760. */
  42761. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42762. /**
  42763. * Sets the current alpha mode
  42764. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  42765. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  42766. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  42767. */
  42768. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42769. /**
  42770. * Bind webGl buffers directly to the webGL context
  42771. * @param vertexBuffers defines the vertex buffer to bind
  42772. * @param indexBuffer defines the index buffer to bind
  42773. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  42774. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  42775. * @param effect defines the effect associated with the vertex buffer
  42776. */
  42777. bindBuffers(vertexBuffers: {
  42778. [key: string]: VertexBuffer;
  42779. }, indexBuffer: DataBuffer, effect: Effect): void;
  42780. /**
  42781. * Force the entire cache to be cleared
  42782. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  42783. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  42784. */
  42785. wipeCaches(bruteForce?: boolean): void;
  42786. /**
  42787. * Send a draw order
  42788. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  42789. * @param indexStart defines the starting index
  42790. * @param indexCount defines the number of index to draw
  42791. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  42792. */
  42793. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42794. /**
  42795. * Draw a list of indexed primitives
  42796. * @param fillMode defines the primitive to use
  42797. * @param indexStart defines the starting index
  42798. * @param indexCount defines the number of index to draw
  42799. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  42800. */
  42801. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42802. /**
  42803. * Draw a list of unindexed primitives
  42804. * @param fillMode defines the primitive to use
  42805. * @param verticesStart defines the index of first vertex to draw
  42806. * @param verticesCount defines the count of vertices to draw
  42807. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  42808. */
  42809. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42810. /** @hidden */ private _createTexture(): WebGLTexture;
  42811. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  42812. /**
  42813. * Usually called from Texture.ts.
  42814. * Passed information to create a WebGLTexture
  42815. * @param urlArg defines a value which contains one of the following:
  42816. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  42817. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  42818. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  42819. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  42820. * @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)
  42821. * @param scene needed for loading to the correct scene
  42822. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  42823. * @param onLoad optional callback to be called upon successful completion
  42824. * @param onError optional callback to be called upon failure
  42825. * @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
  42826. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  42827. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  42828. * @param forcedExtension defines the extension to use to pick the right loader
  42829. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  42830. * @returns a InternalTexture for assignment back into BABYLON.Texture
  42831. */
  42832. 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;
  42833. /**
  42834. * Creates a new render target texture
  42835. * @param size defines the size of the texture
  42836. * @param options defines the options used to create the texture
  42837. * @returns a new render target texture stored in an InternalTexture
  42838. */
  42839. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42840. /**
  42841. * Update the sampling mode of a given texture
  42842. * @param samplingMode defines the required sampling mode
  42843. * @param texture defines the texture to update
  42844. */
  42845. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42846. /**
  42847. * Binds the frame buffer to the specified texture.
  42848. * @param texture The texture to render to or null for the default canvas
  42849. * @param faceIndex The face of the texture to render to in case of cube texture
  42850. * @param requiredWidth The width of the target to render to
  42851. * @param requiredHeight The height of the target to render to
  42852. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  42853. * @param depthStencilTexture The depth stencil texture to use to render
  42854. * @param lodLevel defines le lod level to bind to the frame buffer
  42855. */
  42856. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42857. /**
  42858. * Unbind the current render target texture from the webGL context
  42859. * @param texture defines the render target texture to unbind
  42860. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  42861. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  42862. */
  42863. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42864. /**
  42865. * Creates a dynamic vertex buffer
  42866. * @param vertices the data for the dynamic vertex buffer
  42867. * @returns the new WebGL dynamic buffer
  42868. */
  42869. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42870. /**
  42871. * Update the content of a dynamic texture
  42872. * @param texture defines the texture to update
  42873. * @param canvas defines the canvas containing the source
  42874. * @param invertY defines if data must be stored with Y axis inverted
  42875. * @param premulAlpha defines if alpha is stored as premultiplied
  42876. * @param format defines the format of the data
  42877. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  42878. */
  42879. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42880. /**
  42881. * Gets a boolean indicating if all created effects are ready
  42882. * @returns true if all effects are ready
  42883. */
  42884. areAllEffectsReady(): boolean;
  42885. /**
  42886. * @hidden
  42887. * Get the current error code of the webGL context
  42888. * @returns the error code
  42889. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42890. */
  42891. getError(): number;
  42892. /** @hidden */ private _getUnpackAlignement(): number;
  42893. /** @hidden */ private _unpackFlipY(value: boolean): void;
  42894. /**
  42895. * Update a dynamic index buffer
  42896. * @param indexBuffer defines the target index buffer
  42897. * @param indices defines the data to update
  42898. * @param offset defines the offset in the target index buffer where update should start
  42899. */
  42900. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42901. /**
  42902. * Updates a dynamic vertex buffer.
  42903. * @param vertexBuffer the vertex buffer to update
  42904. * @param vertices the data used to update the vertex buffer
  42905. * @param byteOffset the byte offset of the data (optional)
  42906. * @param byteLength the byte length of the data (optional)
  42907. */
  42908. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42909. /** @hidden */ private _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42910. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  42911. protected _deleteBuffer(buffer: WebGLBuffer): void;
  42912. /**
  42913. * 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
  42914. */
  42915. releaseEffects(): void;
  42916. displayLoadingUI(): void;
  42917. hideLoadingUI(): void;
  42918. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42919. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42920. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42921. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42922. }
  42923. }
  42924. declare module BABYLON {
  42925. /** @hidden */
  42926. export class _OcclusionDataStorage {
  42927. /** @hidden */
  42928. occlusionInternalRetryCounter: number;
  42929. /** @hidden */
  42930. isOcclusionQueryInProgress: boolean;
  42931. /** @hidden */
  42932. isOccluded: boolean;
  42933. /** @hidden */
  42934. occlusionRetryCount: number;
  42935. /** @hidden */
  42936. occlusionType: number;
  42937. /** @hidden */
  42938. occlusionQueryAlgorithmType: number;
  42939. }
  42940. interface Engine {
  42941. /**
  42942. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42943. * @return the new query
  42944. */
  42945. createQuery(): WebGLQuery;
  42946. /**
  42947. * Delete and release a webGL query
  42948. * @param query defines the query to delete
  42949. * @return the current engine
  42950. */
  42951. deleteQuery(query: WebGLQuery): Engine;
  42952. /**
  42953. * Check if a given query has resolved and got its value
  42954. * @param query defines the query to check
  42955. * @returns true if the query got its value
  42956. */
  42957. isQueryResultAvailable(query: WebGLQuery): boolean;
  42958. /**
  42959. * Gets the value of a given query
  42960. * @param query defines the query to check
  42961. * @returns the value of the query
  42962. */
  42963. getQueryResult(query: WebGLQuery): number;
  42964. /**
  42965. * Initiates an occlusion query
  42966. * @param algorithmType defines the algorithm to use
  42967. * @param query defines the query to use
  42968. * @returns the current engine
  42969. * @see http://doc.babylonjs.com/features/occlusionquery
  42970. */
  42971. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42972. /**
  42973. * Ends an occlusion query
  42974. * @see http://doc.babylonjs.com/features/occlusionquery
  42975. * @param algorithmType defines the algorithm to use
  42976. * @returns the current engine
  42977. */
  42978. endOcclusionQuery(algorithmType: number): Engine;
  42979. /**
  42980. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42981. * Please note that only one query can be issued at a time
  42982. * @returns a time token used to track the time span
  42983. */
  42984. startTimeQuery(): Nullable<_TimeToken>;
  42985. /**
  42986. * Ends a time query
  42987. * @param token defines the token used to measure the time span
  42988. * @returns the time spent (in ns)
  42989. */
  42990. endTimeQuery(token: _TimeToken): int;
  42991. /** @hidden */ private _currentNonTimestampToken: Nullable<_TimeToken>;
  42992. /** @hidden */ private _createTimeQuery(): WebGLQuery;
  42993. /** @hidden */ private _deleteTimeQuery(query: WebGLQuery): void;
  42994. /** @hidden */ private _getGlAlgorithmType(algorithmType: number): number;
  42995. /** @hidden */ private _getTimeQueryResult(query: WebGLQuery): any;
  42996. /** @hidden */ private _getTimeQueryAvailability(query: WebGLQuery): any;
  42997. }
  42998. interface AbstractMesh {
  42999. /**
  43000. * Backing filed
  43001. * @hidden
  43002. */ private __occlusionDataStorage: _OcclusionDataStorage;
  43003. /**
  43004. * Access property
  43005. * @hidden
  43006. */ private _occlusionDataStorage: _OcclusionDataStorage;
  43007. /**
  43008. * 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.
  43009. * The default value is -1 which means don't break the query and wait till the result
  43010. * @see http://doc.babylonjs.com/features/occlusionquery
  43011. */
  43012. occlusionRetryCount: number;
  43013. /**
  43014. * 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:
  43015. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43016. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43017. * * 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.
  43018. * @see http://doc.babylonjs.com/features/occlusionquery
  43019. */
  43020. occlusionType: number;
  43021. /**
  43022. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43023. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43024. * * 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.
  43025. * @see http://doc.babylonjs.com/features/occlusionquery
  43026. */
  43027. occlusionQueryAlgorithmType: number;
  43028. /**
  43029. * 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
  43030. * @see http://doc.babylonjs.com/features/occlusionquery
  43031. */
  43032. isOccluded: boolean;
  43033. /**
  43034. * Flag to check the progress status of the query
  43035. * @see http://doc.babylonjs.com/features/occlusionquery
  43036. */
  43037. isOcclusionQueryInProgress: boolean;
  43038. }
  43039. }
  43040. declare module BABYLON {
  43041. /** @hidden */
  43042. export var _forceTransformFeedbackToBundle: boolean;
  43043. interface Engine {
  43044. /**
  43045. * Creates a webGL transform feedback object
  43046. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43047. * @returns the webGL transform feedback object
  43048. */
  43049. createTransformFeedback(): WebGLTransformFeedback;
  43050. /**
  43051. * Delete a webGL transform feedback object
  43052. * @param value defines the webGL transform feedback object to delete
  43053. */
  43054. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43055. /**
  43056. * Bind a webGL transform feedback object to the webgl context
  43057. * @param value defines the webGL transform feedback object to bind
  43058. */
  43059. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43060. /**
  43061. * Begins a transform feedback operation
  43062. * @param usePoints defines if points or triangles must be used
  43063. */
  43064. beginTransformFeedback(usePoints: boolean): void;
  43065. /**
  43066. * Ends a transform feedback operation
  43067. */
  43068. endTransformFeedback(): void;
  43069. /**
  43070. * Specify the varyings to use with transform feedback
  43071. * @param program defines the associated webGL program
  43072. * @param value defines the list of strings representing the varying names
  43073. */
  43074. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43075. /**
  43076. * Bind a webGL buffer for a transform feedback operation
  43077. * @param value defines the webGL buffer to bind
  43078. */
  43079. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43080. }
  43081. }
  43082. declare module BABYLON {
  43083. /**
  43084. * Creation options of the multi render target texture.
  43085. */
  43086. export interface IMultiRenderTargetOptions {
  43087. /**
  43088. * Define if the texture needs to create mip maps after render.
  43089. */
  43090. generateMipMaps?: boolean;
  43091. /**
  43092. * Define the types of all the draw buffers we want to create
  43093. */
  43094. types?: number[];
  43095. /**
  43096. * Define the sampling modes of all the draw buffers we want to create
  43097. */
  43098. samplingModes?: number[];
  43099. /**
  43100. * Define if a depth buffer is required
  43101. */
  43102. generateDepthBuffer?: boolean;
  43103. /**
  43104. * Define if a stencil buffer is required
  43105. */
  43106. generateStencilBuffer?: boolean;
  43107. /**
  43108. * Define if a depth texture is required instead of a depth buffer
  43109. */
  43110. generateDepthTexture?: boolean;
  43111. /**
  43112. * Define the number of desired draw buffers
  43113. */
  43114. textureCount?: number;
  43115. /**
  43116. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43117. */
  43118. doNotChangeAspectRatio?: boolean;
  43119. /**
  43120. * Define the default type of the buffers we are creating
  43121. */
  43122. defaultType?: number;
  43123. }
  43124. /**
  43125. * A multi render target, like a render target provides the ability to render to a texture.
  43126. * Unlike the render target, it can render to several draw buffers in one draw.
  43127. * This is specially interesting in deferred rendering or for any effects requiring more than
  43128. * just one color from a single pass.
  43129. */
  43130. export class MultiRenderTarget extends RenderTargetTexture {
  43131. private _internalTextures;
  43132. private _textures;
  43133. private _multiRenderTargetOptions;
  43134. /**
  43135. * Get if draw buffers are currently supported by the used hardware and browser.
  43136. */
  43137. readonly isSupported: boolean;
  43138. /**
  43139. * Get the list of textures generated by the multi render target.
  43140. */
  43141. readonly textures: Texture[];
  43142. /**
  43143. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43144. */
  43145. readonly depthTexture: Texture;
  43146. /**
  43147. * Set the wrapping mode on U of all the textures we are rendering to.
  43148. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43149. */
  43150. wrapU: number;
  43151. /**
  43152. * Set the wrapping mode on V of all the textures we are rendering to.
  43153. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43154. */
  43155. wrapV: number;
  43156. /**
  43157. * Instantiate a new multi render target texture.
  43158. * A multi render target, like a render target provides the ability to render to a texture.
  43159. * Unlike the render target, it can render to several draw buffers in one draw.
  43160. * This is specially interesting in deferred rendering or for any effects requiring more than
  43161. * just one color from a single pass.
  43162. * @param name Define the name of the texture
  43163. * @param size Define the size of the buffers to render to
  43164. * @param count Define the number of target we are rendering into
  43165. * @param scene Define the scene the texture belongs to
  43166. * @param options Define the options used to create the multi render target
  43167. */
  43168. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43169. /** @hidden */ private _rebuild(): void;
  43170. private _createInternalTextures;
  43171. private _createTextures;
  43172. /**
  43173. * Define the number of samples used if MSAA is enabled.
  43174. */
  43175. samples: number;
  43176. /**
  43177. * Resize all the textures in the multi render target.
  43178. * Be carrefull as it will recreate all the data in the new texture.
  43179. * @param size Define the new size
  43180. */
  43181. resize(size: any): void;
  43182. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43183. /**
  43184. * Dispose the render targets and their associated resources
  43185. */
  43186. dispose(): void;
  43187. /**
  43188. * Release all the underlying texture used as draw buffers.
  43189. */
  43190. releaseInternalTextures(): void;
  43191. }
  43192. }
  43193. declare module BABYLON {
  43194. interface BaseEngine {
  43195. /**
  43196. * Unbind a list of render target textures from the webGL context
  43197. * This is used only when drawBuffer extension or webGL2 are active
  43198. * @param textures defines the render target textures to unbind
  43199. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43200. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43201. */
  43202. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43203. /**
  43204. * Create a multi render target texture
  43205. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43206. * @param size defines the size of the texture
  43207. * @param options defines the creation options
  43208. * @returns the cube texture as an InternalTexture
  43209. */
  43210. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43211. /**
  43212. * Update the sample count for a given multiple render target texture
  43213. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43214. * @param textures defines the textures to update
  43215. * @param samples defines the sample count to set
  43216. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43217. */
  43218. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43219. }
  43220. }
  43221. declare module BABYLON {
  43222. /** @hidden */
  43223. export var rgbdEncodePixelShader: {
  43224. name: string;
  43225. shader: string;
  43226. };
  43227. }
  43228. declare module BABYLON {
  43229. /** @hidden */
  43230. export var rgbdDecodePixelShader: {
  43231. name: string;
  43232. shader: string;
  43233. };
  43234. }
  43235. declare module BABYLON {
  43236. /**
  43237. * Raw texture data and descriptor sufficient for WebGL texture upload
  43238. */
  43239. export interface EnvironmentTextureInfo {
  43240. /**
  43241. * Version of the environment map
  43242. */
  43243. version: number;
  43244. /**
  43245. * Width of image
  43246. */
  43247. width: number;
  43248. /**
  43249. * Irradiance information stored in the file.
  43250. */
  43251. irradiance: any;
  43252. /**
  43253. * Specular information stored in the file.
  43254. */
  43255. specular: any;
  43256. }
  43257. /**
  43258. * Defines One Image in the file. It requires only the position in the file
  43259. * as well as the length.
  43260. */
  43261. interface BufferImageData {
  43262. /**
  43263. * Length of the image data.
  43264. */
  43265. length: number;
  43266. /**
  43267. * Position of the data from the null terminator delimiting the end of the JSON.
  43268. */
  43269. position: number;
  43270. }
  43271. /**
  43272. * Defines the specular data enclosed in the file.
  43273. * This corresponds to the version 1 of the data.
  43274. */
  43275. export interface EnvironmentTextureSpecularInfoV1 {
  43276. /**
  43277. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  43278. */
  43279. specularDataPosition?: number;
  43280. /**
  43281. * This contains all the images data needed to reconstruct the cubemap.
  43282. */
  43283. mipmaps: Array<BufferImageData>;
  43284. /**
  43285. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  43286. */
  43287. lodGenerationScale: number;
  43288. }
  43289. /**
  43290. * Sets of helpers addressing the serialization and deserialization of environment texture
  43291. * stored in a BabylonJS env file.
  43292. * Those files are usually stored as .env files.
  43293. */
  43294. export class EnvironmentTextureTools {
  43295. /**
  43296. * Magic number identifying the env file.
  43297. */
  43298. private static _MagicBytes;
  43299. /**
  43300. * Gets the environment info from an env file.
  43301. * @param data The array buffer containing the .env bytes.
  43302. * @returns the environment file info (the json header) if successfully parsed.
  43303. */
  43304. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  43305. /**
  43306. * Creates an environment texture from a loaded cube texture.
  43307. * @param texture defines the cube texture to convert in env file
  43308. * @return a promise containing the environment data if succesfull.
  43309. */
  43310. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  43311. /**
  43312. * Creates a JSON representation of the spherical data.
  43313. * @param texture defines the texture containing the polynomials
  43314. * @return the JSON representation of the spherical info
  43315. */
  43316. private static _CreateEnvTextureIrradiance;
  43317. /**
  43318. * Creates the ArrayBufferViews used for initializing environment texture image data.
  43319. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  43320. * @param info parameters that determine what views will be created for accessing the underlying buffer
  43321. * @return the views described by info providing access to the underlying buffer
  43322. */
  43323. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  43324. /**
  43325. * Uploads the texture info contained in the env file to the GPU.
  43326. * @param texture defines the internal texture to upload to
  43327. * @param arrayBuffer defines the buffer cotaining the data to load
  43328. * @param info defines the texture info retrieved through the GetEnvInfo method
  43329. * @returns a promise
  43330. */
  43331. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  43332. /**
  43333. * Uploads the levels of image data to the GPU.
  43334. * @param texture defines the internal texture to upload to
  43335. * @param imageData defines the array buffer views of image data [mipmap][face]
  43336. * @returns a promise
  43337. */
  43338. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  43339. /**
  43340. * Uploads spherical polynomials information to the texture.
  43341. * @param texture defines the texture we are trying to upload the information to
  43342. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  43343. */
  43344. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  43345. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  43346. }
  43347. }
  43348. declare module BABYLON {
  43349. /**
  43350. * Contains position and normal vectors for a vertex
  43351. */
  43352. export class PositionNormalVertex {
  43353. /** the position of the vertex (defaut: 0,0,0) */
  43354. position: Vector3;
  43355. /** the normal of the vertex (defaut: 0,1,0) */
  43356. normal: Vector3;
  43357. /**
  43358. * Creates a PositionNormalVertex
  43359. * @param position the position of the vertex (defaut: 0,0,0)
  43360. * @param normal the normal of the vertex (defaut: 0,1,0)
  43361. */
  43362. constructor(
  43363. /** the position of the vertex (defaut: 0,0,0) */
  43364. position?: Vector3,
  43365. /** the normal of the vertex (defaut: 0,1,0) */
  43366. normal?: Vector3);
  43367. /**
  43368. * Clones the PositionNormalVertex
  43369. * @returns the cloned PositionNormalVertex
  43370. */
  43371. clone(): PositionNormalVertex;
  43372. }
  43373. /**
  43374. * Contains position, normal and uv vectors for a vertex
  43375. */
  43376. export class PositionNormalTextureVertex {
  43377. /** the position of the vertex (defaut: 0,0,0) */
  43378. position: Vector3;
  43379. /** the normal of the vertex (defaut: 0,1,0) */
  43380. normal: Vector3;
  43381. /** the uv of the vertex (default: 0,0) */
  43382. uv: Vector2;
  43383. /**
  43384. * Creates a PositionNormalTextureVertex
  43385. * @param position the position of the vertex (defaut: 0,0,0)
  43386. * @param normal the normal of the vertex (defaut: 0,1,0)
  43387. * @param uv the uv of the vertex (default: 0,0)
  43388. */
  43389. constructor(
  43390. /** the position of the vertex (defaut: 0,0,0) */
  43391. position?: Vector3,
  43392. /** the normal of the vertex (defaut: 0,1,0) */
  43393. normal?: Vector3,
  43394. /** the uv of the vertex (default: 0,0) */
  43395. uv?: Vector2);
  43396. /**
  43397. * Clones the PositionNormalTextureVertex
  43398. * @returns the cloned PositionNormalTextureVertex
  43399. */
  43400. clone(): PositionNormalTextureVertex;
  43401. }
  43402. }
  43403. declare module BABYLON {
  43404. /** @hidden */
  43405. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  43406. private _genericAttributeLocation;
  43407. private _varyingLocationCount;
  43408. private _varyingLocationMap;
  43409. private _replacements;
  43410. private _textureCount;
  43411. private _uniforms;
  43412. lineProcessor(line: string): string;
  43413. attributeProcessor(attribute: string): string;
  43414. varyingProcessor(varying: string, isFragment: boolean): string;
  43415. uniformProcessor(uniform: string): string;
  43416. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  43417. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  43418. }
  43419. }
  43420. declare module BABYLON {
  43421. /**
  43422. * Container for accessors for natively-stored mesh data buffers.
  43423. */
  43424. class NativeDataBuffer extends DataBuffer {
  43425. /**
  43426. * Accessor value used to identify/retrieve a natively-stored index buffer.
  43427. */
  43428. nativeIndexBuffer?: any;
  43429. /**
  43430. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  43431. */
  43432. nativeVertexBuffer?: any;
  43433. }
  43434. /** @hidden */
  43435. export class NativeEngine extends Engine {
  43436. private readonly _native;
  43437. getHardwareScalingLevel(): number;
  43438. constructor();
  43439. /**
  43440. * Can be used to override the current requestAnimationFrame requester.
  43441. * @hidden
  43442. */
  43443. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  43444. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43445. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  43446. createVertexBuffer(data: DataArray): NativeDataBuffer;
  43447. recordVertexArrayObject(vertexBuffers: {
  43448. [key: string]: VertexBuffer;
  43449. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  43450. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  43451. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  43452. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43453. /**
  43454. * Draw a list of indexed primitives
  43455. * @param fillMode defines the primitive to use
  43456. * @param indexStart defines the starting index
  43457. * @param indexCount defines the number of index to draw
  43458. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43459. */
  43460. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43461. /**
  43462. * Draw a list of unindexed primitives
  43463. * @param fillMode defines the primitive to use
  43464. * @param verticesStart defines the index of first vertex to draw
  43465. * @param verticesCount defines the count of vertices to draw
  43466. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43467. */
  43468. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43469. createPipelineContext(): IPipelineContext; private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  43470. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  43471. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  43472. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  43473. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  43474. protected _setProgram(program: WebGLProgram): void; private _releaseEffect(effect: Effect): void; private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  43475. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  43476. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  43477. bindSamplers(effect: Effect): void;
  43478. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  43479. getRenderWidth(useScreen?: boolean): number;
  43480. getRenderHeight(useScreen?: boolean): number;
  43481. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  43482. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43483. /**
  43484. * Set the z offset to apply to current rendering
  43485. * @param value defines the offset to apply
  43486. */
  43487. setZOffset(value: number): void;
  43488. /**
  43489. * Gets the current value of the zOffset
  43490. * @returns the current zOffset state
  43491. */
  43492. getZOffset(): number;
  43493. /**
  43494. * Enable or disable depth buffering
  43495. * @param enable defines the state to set
  43496. */
  43497. setDepthBuffer(enable: boolean): void;
  43498. /**
  43499. * Gets a boolean indicating if depth writing is enabled
  43500. * @returns the current depth writing state
  43501. */
  43502. getDepthWrite(): boolean;
  43503. /**
  43504. * Enable or disable depth writing
  43505. * @param enable defines the state to set
  43506. */
  43507. setDepthWrite(enable: boolean): void;
  43508. /**
  43509. * Enable or disable color writing
  43510. * @param enable defines the state to set
  43511. */
  43512. setColorWrite(enable: boolean): void;
  43513. /**
  43514. * Gets a boolean indicating if color writing is enabled
  43515. * @returns the current color writing state
  43516. */
  43517. getColorWrite(): boolean;
  43518. /**
  43519. * Sets alpha constants used by some alpha blending modes
  43520. * @param r defines the red component
  43521. * @param g defines the green component
  43522. * @param b defines the blue component
  43523. * @param a defines the alpha component
  43524. */
  43525. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  43526. /**
  43527. * Sets the current alpha mode
  43528. * @param mode defines the mode to use (one of the BABYLON.Constants.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. * Gets the current alpha mode
  43535. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43536. * @returns the current alpha mode
  43537. */
  43538. getAlphaMode(): number;
  43539. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43540. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43541. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43542. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43543. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43544. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43545. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43546. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43547. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43548. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43549. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43550. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43551. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43552. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43553. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43554. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43555. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43556. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43557. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43558. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43559. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  43560. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  43561. wipeCaches(bruteForce?: boolean): void; private _createTexture(): WebGLTexture;
  43562. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  43563. /**
  43564. * Usually called from BABYLON.Texture.ts.
  43565. * Passed information to create a WebGLTexture
  43566. * @param urlArg defines a value which contains one of the following:
  43567. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  43568. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  43569. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  43570. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  43571. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  43572. * @param scene needed for loading to the correct scene
  43573. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  43574. * @param onLoad optional callback to be called upon successful completion
  43575. * @param onError optional callback to be called upon failure
  43576. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  43577. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  43578. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  43579. * @param forcedExtension defines the extension to use to pick the right loader
  43580. * @returns a InternalTexture for assignment back into BABYLON.Texture
  43581. */
  43582. 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;
  43583. /**
  43584. * Creates a cube texture
  43585. * @param rootUrl defines the url where the files to load is located
  43586. * @param scene defines the current scene
  43587. * @param files defines the list of files to load (1 per face)
  43588. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  43589. * @param onLoad defines an optional callback raised when the texture is loaded
  43590. * @param onError defines an optional callback raised if there is an issue to load the texture
  43591. * @param format defines the format of the data
  43592. * @param forcedExtension defines the extension to use to pick the right loader
  43593. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  43594. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  43595. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  43596. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  43597. * @returns the cube texture as an InternalTexture
  43598. */
  43599. 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;
  43600. private _getSamplingFilter;
  43601. private static _GetNativeTextureFormat;
  43602. createRenderTargetTexture(size: number | {
  43603. width: number;
  43604. height: number;
  43605. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43606. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43607. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43608. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43609. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  43610. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  43611. /**
  43612. * Updates a dynamic vertex buffer.
  43613. * @param vertexBuffer the vertex buffer to update
  43614. * @param data the data used to update the vertex buffer
  43615. * @param byteOffset the byte offset of the data (optional)
  43616. * @param byteLength the byte length of the data (optional)
  43617. */
  43618. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  43619. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  43620. private _updateAnisotropicLevel;
  43621. private _getAddressMode;
  43622. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  43623. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  43624. releaseEffects(): void;
  43625. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43626. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43627. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43628. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43629. }
  43630. }
  43631. declare module BABYLON {
  43632. /**
  43633. * Gather the list of clipboard event types as constants.
  43634. */
  43635. export class ClipboardEventTypes {
  43636. /**
  43637. * The clipboard event is fired when a copy command is active (pressed).
  43638. */
  43639. static readonly COPY: number;
  43640. /**
  43641. * The clipboard event is fired when a cut command is active (pressed).
  43642. */
  43643. static readonly CUT: number;
  43644. /**
  43645. * The clipboard event is fired when a paste command is active (pressed).
  43646. */
  43647. static readonly PASTE: number;
  43648. }
  43649. /**
  43650. * This class is used to store clipboard related info for the onClipboardObservable event.
  43651. */
  43652. export class ClipboardInfo {
  43653. /**
  43654. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43655. */
  43656. type: number;
  43657. /**
  43658. * Defines the related dom event
  43659. */
  43660. event: ClipboardEvent;
  43661. /**
  43662. *Creates an instance of ClipboardInfo.
  43663. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43664. * @param event Defines the related dom event
  43665. */
  43666. constructor(
  43667. /**
  43668. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43669. */
  43670. type: number,
  43671. /**
  43672. * Defines the related dom event
  43673. */
  43674. event: ClipboardEvent);
  43675. /**
  43676. * Get the clipboard event's type from the keycode.
  43677. * @param keyCode Defines the keyCode for the current keyboard event.
  43678. * @return {number}
  43679. */
  43680. static GetTypeFromCharacter(keyCode: number): number;
  43681. }
  43682. }
  43683. declare module BABYLON {
  43684. /**
  43685. * Google Daydream controller
  43686. */
  43687. export class DaydreamController extends WebVRController {
  43688. /**
  43689. * Base Url for the controller model.
  43690. */
  43691. static MODEL_BASE_URL: string;
  43692. /**
  43693. * File name for the controller model.
  43694. */
  43695. static MODEL_FILENAME: string;
  43696. /**
  43697. * Gamepad Id prefix used to identify Daydream Controller.
  43698. */
  43699. static readonly GAMEPAD_ID_PREFIX: string;
  43700. /**
  43701. * Creates a new DaydreamController from a gamepad
  43702. * @param vrGamepad the gamepad that the controller should be created from
  43703. */
  43704. constructor(vrGamepad: any);
  43705. /**
  43706. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43707. * @param scene scene in which to add meshes
  43708. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43709. */
  43710. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43711. /**
  43712. * Called once for each button that changed state since the last frame
  43713. * @param buttonIdx Which button index changed
  43714. * @param state New state of the button
  43715. * @param changes Which properties on the state changed since last frame
  43716. */
  43717. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43718. }
  43719. }
  43720. declare module BABYLON {
  43721. /**
  43722. * Gear VR Controller
  43723. */
  43724. export class GearVRController extends WebVRController {
  43725. /**
  43726. * Base Url for the controller model.
  43727. */
  43728. static MODEL_BASE_URL: string;
  43729. /**
  43730. * File name for the controller model.
  43731. */
  43732. static MODEL_FILENAME: string;
  43733. /**
  43734. * Gamepad Id prefix used to identify this controller.
  43735. */
  43736. static readonly GAMEPAD_ID_PREFIX: string;
  43737. private readonly _buttonIndexToObservableNameMap;
  43738. /**
  43739. * Creates a new GearVRController from a gamepad
  43740. * @param vrGamepad the gamepad that the controller should be created from
  43741. */
  43742. constructor(vrGamepad: any);
  43743. /**
  43744. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43745. * @param scene scene in which to add meshes
  43746. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43747. */
  43748. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43749. /**
  43750. * Called once for each button that changed state since the last frame
  43751. * @param buttonIdx Which button index changed
  43752. * @param state New state of the button
  43753. * @param changes Which properties on the state changed since last frame
  43754. */
  43755. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43756. }
  43757. }
  43758. declare module BABYLON {
  43759. /**
  43760. * Class containing static functions to help procedurally build meshes
  43761. */
  43762. export class PolyhedronBuilder {
  43763. /**
  43764. * Creates a polyhedron mesh
  43765. * * 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
  43766. * * The parameter `size` (positive float, default 1) sets the polygon size
  43767. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43768. * * 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`
  43769. * * 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
  43770. * * 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)`)
  43771. * * 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
  43772. * * 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
  43773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43774. * * 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
  43775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43776. * @param name defines the name of the mesh
  43777. * @param options defines the options used to create the mesh
  43778. * @param scene defines the hosting scene
  43779. * @returns the polyhedron mesh
  43780. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43781. */
  43782. static CreatePolyhedron(name: string, options: {
  43783. type?: number;
  43784. size?: number;
  43785. sizeX?: number;
  43786. sizeY?: number;
  43787. sizeZ?: number;
  43788. custom?: any;
  43789. faceUV?: Vector4[];
  43790. faceColors?: Color4[];
  43791. flat?: boolean;
  43792. updatable?: boolean;
  43793. sideOrientation?: number;
  43794. frontUVs?: Vector4;
  43795. backUVs?: Vector4;
  43796. }, scene?: Nullable<Scene>): Mesh;
  43797. }
  43798. }
  43799. declare module BABYLON {
  43800. /**
  43801. * Gizmo that enables scaling a mesh along 3 axis
  43802. */
  43803. export class ScaleGizmo extends Gizmo {
  43804. /**
  43805. * Internal gizmo used for interactions on the x axis
  43806. */
  43807. xGizmo: AxisScaleGizmo;
  43808. /**
  43809. * Internal gizmo used for interactions on the y axis
  43810. */
  43811. yGizmo: AxisScaleGizmo;
  43812. /**
  43813. * Internal gizmo used for interactions on the z axis
  43814. */
  43815. zGizmo: AxisScaleGizmo;
  43816. /**
  43817. * Internal gizmo used to scale all axis equally
  43818. */
  43819. uniformScaleGizmo: AxisScaleGizmo;
  43820. private _meshAttached;
  43821. private _updateGizmoRotationToMatchAttachedMesh;
  43822. private _snapDistance;
  43823. private _scaleRatio;
  43824. private _uniformScalingMesh;
  43825. private _octahedron;
  43826. /** Fires an event when any of it's sub gizmos are dragged */
  43827. onDragStartObservable: Observable<unknown>;
  43828. /** Fires an event when any of it's sub gizmos are released from dragging */
  43829. onDragEndObservable: Observable<unknown>;
  43830. attachedMesh: Nullable<AbstractMesh>;
  43831. /**
  43832. * Creates a ScaleGizmo
  43833. * @param gizmoLayer The utility layer the gizmo will be added to
  43834. */
  43835. constructor(gizmoLayer?: UtilityLayerRenderer);
  43836. updateGizmoRotationToMatchAttachedMesh: boolean;
  43837. /**
  43838. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43839. */
  43840. snapDistance: number;
  43841. /**
  43842. * Ratio for the scale of the gizmo (Default: 1)
  43843. */
  43844. scaleRatio: number;
  43845. /**
  43846. * Disposes of the gizmo
  43847. */
  43848. dispose(): void;
  43849. }
  43850. }
  43851. declare module BABYLON {
  43852. /**
  43853. * Single axis scale gizmo
  43854. */
  43855. export class AxisScaleGizmo extends Gizmo {
  43856. /**
  43857. * Drag behavior responsible for the gizmos dragging interactions
  43858. */
  43859. dragBehavior: PointerDragBehavior;
  43860. private _pointerObserver;
  43861. /**
  43862. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43863. */
  43864. snapDistance: number;
  43865. /**
  43866. * Event that fires each time the gizmo snaps to a new location.
  43867. * * snapDistance is the the change in distance
  43868. */
  43869. onSnapObservable: Observable<{
  43870. snapDistance: number;
  43871. }>;
  43872. /**
  43873. * If the scaling operation should be done on all axis (default: false)
  43874. */
  43875. uniformScaling: boolean;
  43876. private _isEnabled;
  43877. private _parent;
  43878. private _arrow;
  43879. private _coloredMaterial;
  43880. private _hoverMaterial;
  43881. /**
  43882. * Creates an AxisScaleGizmo
  43883. * @param gizmoLayer The utility layer the gizmo will be added to
  43884. * @param dragAxis The axis which the gizmo will be able to scale on
  43885. * @param color The color of the gizmo
  43886. */
  43887. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  43888. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43889. /**
  43890. * If the gizmo is enabled
  43891. */
  43892. isEnabled: boolean;
  43893. /**
  43894. * Disposes of the gizmo
  43895. */
  43896. dispose(): void;
  43897. /**
  43898. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43899. * @param mesh The mesh to replace the default mesh of the gizmo
  43900. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43901. */
  43902. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43903. }
  43904. }
  43905. declare module BABYLON {
  43906. /**
  43907. * Bounding box gizmo
  43908. */
  43909. export class BoundingBoxGizmo extends Gizmo {
  43910. private _lineBoundingBox;
  43911. private _rotateSpheresParent;
  43912. private _scaleBoxesParent;
  43913. private _boundingDimensions;
  43914. private _renderObserver;
  43915. private _pointerObserver;
  43916. private _scaleDragSpeed;
  43917. private _tmpQuaternion;
  43918. private _tmpVector;
  43919. private _tmpRotationMatrix;
  43920. /**
  43921. * 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)
  43922. */
  43923. ignoreChildren: boolean;
  43924. /**
  43925. * 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)
  43926. */
  43927. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43928. /**
  43929. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43930. */
  43931. rotationSphereSize: number;
  43932. /**
  43933. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43934. */
  43935. scaleBoxSize: number;
  43936. /**
  43937. * 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)
  43938. */
  43939. fixedDragMeshScreenSize: boolean;
  43940. /**
  43941. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43942. */
  43943. fixedDragMeshScreenSizeDistanceFactor: number;
  43944. /**
  43945. * Fired when a rotation sphere or scale box is dragged
  43946. */
  43947. onDragStartObservable: Observable<{}>;
  43948. /**
  43949. * Fired when a scale box is dragged
  43950. */
  43951. onScaleBoxDragObservable: Observable<{}>;
  43952. /**
  43953. * Fired when a scale box drag is ended
  43954. */
  43955. onScaleBoxDragEndObservable: Observable<{}>;
  43956. /**
  43957. * Fired when a rotation sphere is dragged
  43958. */
  43959. onRotationSphereDragObservable: Observable<{}>;
  43960. /**
  43961. * Fired when a rotation sphere drag is ended
  43962. */
  43963. onRotationSphereDragEndObservable: Observable<{}>;
  43964. /**
  43965. * 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)
  43966. */
  43967. scalePivot: Nullable<Vector3>;
  43968. /**
  43969. * Mesh used as a pivot to rotate the attached mesh
  43970. */
  43971. private _anchorMesh;
  43972. private _existingMeshScale;
  43973. private _dragMesh;
  43974. private pointerDragBehavior;
  43975. private coloredMaterial;
  43976. private hoverColoredMaterial;
  43977. /**
  43978. * Sets the color of the bounding box gizmo
  43979. * @param color the color to set
  43980. */
  43981. setColor(color: Color3): void;
  43982. /**
  43983. * Creates an BoundingBoxGizmo
  43984. * @param gizmoLayer The utility layer the gizmo will be added to
  43985. * @param color The color of the gizmo
  43986. */
  43987. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43988. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43989. private _selectNode;
  43990. /**
  43991. * Updates the bounding box information for the Gizmo
  43992. */
  43993. updateBoundingBox(): void;
  43994. private _updateRotationSpheres;
  43995. private _updateScaleBoxes;
  43996. /**
  43997. * Enables rotation on the specified axis and disables rotation on the others
  43998. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43999. */
  44000. setEnabledRotationAxis(axis: string): void;
  44001. /**
  44002. * Enables/disables scaling
  44003. * @param enable if scaling should be enabled
  44004. */
  44005. setEnabledScaling(enable: boolean): void;
  44006. private _updateDummy;
  44007. /**
  44008. * Enables a pointer drag behavior on the bounding box of the gizmo
  44009. */
  44010. enableDragBehavior(): void;
  44011. /**
  44012. * Disposes of the gizmo
  44013. */
  44014. dispose(): void;
  44015. /**
  44016. * 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)
  44017. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44018. * @returns the bounding box mesh with the passed in mesh as a child
  44019. */
  44020. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44021. /**
  44022. * CustomMeshes are not supported by this gizmo
  44023. * @param mesh The mesh to replace the default mesh of the gizmo
  44024. */
  44025. setCustomMesh(mesh: Mesh): void;
  44026. }
  44027. }
  44028. declare module BABYLON {
  44029. /**
  44030. * Single plane rotation gizmo
  44031. */
  44032. export class PlaneRotationGizmo extends Gizmo {
  44033. /**
  44034. * Drag behavior responsible for the gizmos dragging interactions
  44035. */
  44036. dragBehavior: PointerDragBehavior;
  44037. private _pointerObserver;
  44038. /**
  44039. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44040. */
  44041. snapDistance: number;
  44042. /**
  44043. * Event that fires each time the gizmo snaps to a new location.
  44044. * * snapDistance is the the change in distance
  44045. */
  44046. onSnapObservable: Observable<{
  44047. snapDistance: number;
  44048. }>;
  44049. private _isEnabled;
  44050. private _parent;
  44051. /**
  44052. * Creates a PlaneRotationGizmo
  44053. * @param gizmoLayer The utility layer the gizmo will be added to
  44054. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44055. * @param color The color of the gizmo
  44056. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44057. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44058. */
  44059. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  44060. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44061. /**
  44062. * If the gizmo is enabled
  44063. */
  44064. isEnabled: boolean;
  44065. /**
  44066. * Disposes of the gizmo
  44067. */
  44068. dispose(): void;
  44069. }
  44070. }
  44071. declare module BABYLON {
  44072. /**
  44073. * Gizmo that enables rotating a mesh along 3 axis
  44074. */
  44075. export class RotationGizmo extends Gizmo {
  44076. /**
  44077. * Internal gizmo used for interactions on the x axis
  44078. */
  44079. xGizmo: PlaneRotationGizmo;
  44080. /**
  44081. * Internal gizmo used for interactions on the y axis
  44082. */
  44083. yGizmo: PlaneRotationGizmo;
  44084. /**
  44085. * Internal gizmo used for interactions on the z axis
  44086. */
  44087. zGizmo: PlaneRotationGizmo;
  44088. /** Fires an event when any of it's sub gizmos are dragged */
  44089. onDragStartObservable: Observable<unknown>;
  44090. /** Fires an event when any of it's sub gizmos are released from dragging */
  44091. onDragEndObservable: Observable<unknown>;
  44092. private _meshAttached;
  44093. attachedMesh: Nullable<AbstractMesh>;
  44094. /**
  44095. * Creates a RotationGizmo
  44096. * @param gizmoLayer The utility layer the gizmo will be added to
  44097. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44098. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44099. */
  44100. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  44101. updateGizmoRotationToMatchAttachedMesh: boolean;
  44102. /**
  44103. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44104. */
  44105. snapDistance: number;
  44106. /**
  44107. * Ratio for the scale of the gizmo (Default: 1)
  44108. */
  44109. scaleRatio: number;
  44110. /**
  44111. * Disposes of the gizmo
  44112. */
  44113. dispose(): void;
  44114. /**
  44115. * CustomMeshes are not supported by this gizmo
  44116. * @param mesh The mesh to replace the default mesh of the gizmo
  44117. */
  44118. setCustomMesh(mesh: Mesh): void;
  44119. }
  44120. }
  44121. declare module BABYLON {
  44122. /**
  44123. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44124. */
  44125. export class GizmoManager implements IDisposable {
  44126. private scene;
  44127. /**
  44128. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44129. */
  44130. gizmos: {
  44131. positionGizmo: Nullable<PositionGizmo>;
  44132. rotationGizmo: Nullable<RotationGizmo>;
  44133. scaleGizmo: Nullable<ScaleGizmo>;
  44134. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44135. };
  44136. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44137. clearGizmoOnEmptyPointerEvent: boolean;
  44138. /** Fires an event when the manager is attached to a mesh */
  44139. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44140. private _gizmosEnabled;
  44141. private _pointerObserver;
  44142. private _attachedMesh;
  44143. private _boundingBoxColor;
  44144. private _defaultUtilityLayer;
  44145. private _defaultKeepDepthUtilityLayer;
  44146. /**
  44147. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44148. */
  44149. boundingBoxDragBehavior: SixDofDragBehavior;
  44150. /**
  44151. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44152. */
  44153. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44154. /**
  44155. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44156. */
  44157. usePointerToAttachGizmos: boolean;
  44158. /**
  44159. * Utility layer that the bounding box gizmo belongs to
  44160. */
  44161. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  44162. /**
  44163. * Utility layer that all gizmos besides bounding box belong to
  44164. */
  44165. readonly utilityLayer: UtilityLayerRenderer;
  44166. /**
  44167. * Instatiates a gizmo manager
  44168. * @param scene the scene to overlay the gizmos on top of
  44169. */
  44170. constructor(scene: Scene);
  44171. /**
  44172. * Attaches a set of gizmos to the specified mesh
  44173. * @param mesh The mesh the gizmo's should be attached to
  44174. */
  44175. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44176. /**
  44177. * If the position gizmo is enabled
  44178. */
  44179. positionGizmoEnabled: boolean;
  44180. /**
  44181. * If the rotation gizmo is enabled
  44182. */
  44183. rotationGizmoEnabled: boolean;
  44184. /**
  44185. * If the scale gizmo is enabled
  44186. */
  44187. scaleGizmoEnabled: boolean;
  44188. /**
  44189. * If the boundingBox gizmo is enabled
  44190. */
  44191. boundingBoxGizmoEnabled: boolean;
  44192. /**
  44193. * Disposes of the gizmo manager
  44194. */
  44195. dispose(): void;
  44196. }
  44197. }
  44198. declare module BABYLON {
  44199. /**
  44200. * A directional light is defined by a direction (what a surprise!).
  44201. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44202. * 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.
  44203. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44204. */
  44205. export class DirectionalLight extends ShadowLight {
  44206. private _shadowFrustumSize;
  44207. /**
  44208. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44209. */
  44210. /**
  44211. * Specifies a fix frustum size for the shadow generation.
  44212. */
  44213. shadowFrustumSize: number;
  44214. private _shadowOrthoScale;
  44215. /**
  44216. * Gets the shadow projection scale against the optimal computed one.
  44217. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44218. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44219. */
  44220. /**
  44221. * Sets the shadow projection scale against the optimal computed one.
  44222. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44223. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44224. */
  44225. shadowOrthoScale: number;
  44226. /**
  44227. * Automatically compute the projection matrix to best fit (including all the casters)
  44228. * on each frame.
  44229. */
  44230. autoUpdateExtends: boolean;
  44231. private _orthoLeft;
  44232. private _orthoRight;
  44233. private _orthoTop;
  44234. private _orthoBottom;
  44235. /**
  44236. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44237. * The directional light is emitted from everywhere in the given direction.
  44238. * It can cast shadows.
  44239. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44240. * @param name The friendly name of the light
  44241. * @param direction The direction of the light
  44242. * @param scene The scene the light belongs to
  44243. */
  44244. constructor(name: string, direction: Vector3, scene: Scene);
  44245. /**
  44246. * Returns the string "DirectionalLight".
  44247. * @return The class name
  44248. */
  44249. getClassName(): string;
  44250. /**
  44251. * Returns the integer 1.
  44252. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44253. */
  44254. getTypeID(): number;
  44255. /**
  44256. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44257. * Returns the DirectionalLight Shadow projection matrix.
  44258. */
  44259. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44260. /**
  44261. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44262. * Returns the DirectionalLight Shadow projection matrix.
  44263. */
  44264. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44265. /**
  44266. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44267. * Returns the DirectionalLight Shadow projection matrix.
  44268. */
  44269. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44270. protected _buildUniformLayout(): void;
  44271. /**
  44272. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44273. * @param effect The effect to update
  44274. * @param lightIndex The index of the light in the effect to update
  44275. * @returns The directional light
  44276. */
  44277. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44278. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  44279. /**
  44280. * Gets the minZ used for shadow according to both the scene and the light.
  44281. *
  44282. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44283. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44284. * @param activeCamera The camera we are returning the min for
  44285. * @returns the depth min z
  44286. */
  44287. getDepthMinZ(activeCamera: Camera): number;
  44288. /**
  44289. * Gets the maxZ used for shadow according to both the scene and the light.
  44290. *
  44291. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44292. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44293. * @param activeCamera The camera we are returning the max for
  44294. * @returns the depth max z
  44295. */
  44296. getDepthMaxZ(activeCamera: Camera): number;
  44297. /**
  44298. * Prepares the list of defines specific to the light type.
  44299. * @param defines the list of defines
  44300. * @param lightIndex defines the index of the light for the effect
  44301. */
  44302. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44303. }
  44304. }
  44305. declare module BABYLON {
  44306. /**
  44307. * Class containing static functions to help procedurally build meshes
  44308. */
  44309. export class HemisphereBuilder {
  44310. /**
  44311. * Creates a hemisphere mesh
  44312. * @param name defines the name of the mesh
  44313. * @param options defines the options used to create the mesh
  44314. * @param scene defines the hosting scene
  44315. * @returns the hemisphere mesh
  44316. */
  44317. static CreateHemisphere(name: string, options: {
  44318. segments?: number;
  44319. diameter?: number;
  44320. sideOrientation?: number;
  44321. }, scene: any): Mesh;
  44322. }
  44323. }
  44324. declare module BABYLON {
  44325. /**
  44326. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44327. * These values define a cone of light starting from the position, emitting toward the direction.
  44328. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44329. * and the exponent defines the speed of the decay of the light with distance (reach).
  44330. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44331. */
  44332. export class SpotLight extends ShadowLight {
  44333. private _angle;
  44334. private _innerAngle;
  44335. private _cosHalfAngle;
  44336. private _lightAngleScale;
  44337. private _lightAngleOffset;
  44338. /**
  44339. * Gets the cone angle of the spot light in Radians.
  44340. */
  44341. /**
  44342. * Sets the cone angle of the spot light in Radians.
  44343. */
  44344. angle: number;
  44345. /**
  44346. * Only used in gltf falloff mode, this defines the angle where
  44347. * the directional falloff will start before cutting at angle which could be seen
  44348. * as outer angle.
  44349. */
  44350. /**
  44351. * Only used in gltf falloff mode, this defines the angle where
  44352. * the directional falloff will start before cutting at angle which could be seen
  44353. * as outer angle.
  44354. */
  44355. innerAngle: number;
  44356. private _shadowAngleScale;
  44357. /**
  44358. * Allows scaling the angle of the light for shadow generation only.
  44359. */
  44360. /**
  44361. * Allows scaling the angle of the light for shadow generation only.
  44362. */
  44363. shadowAngleScale: number;
  44364. /**
  44365. * The light decay speed with the distance from the emission spot.
  44366. */
  44367. exponent: number;
  44368. private _projectionTextureMatrix;
  44369. /**
  44370. * Allows reading the projecton texture
  44371. */
  44372. readonly projectionTextureMatrix: Matrix;
  44373. protected _projectionTextureLightNear: number;
  44374. /**
  44375. * Gets the near clip of the Spotlight for texture projection.
  44376. */
  44377. /**
  44378. * Sets the near clip of the Spotlight for texture projection.
  44379. */
  44380. projectionTextureLightNear: number;
  44381. protected _projectionTextureLightFar: number;
  44382. /**
  44383. * Gets the far clip of the Spotlight for texture projection.
  44384. */
  44385. /**
  44386. * Sets the far clip of the Spotlight for texture projection.
  44387. */
  44388. projectionTextureLightFar: number;
  44389. protected _projectionTextureUpDirection: Vector3;
  44390. /**
  44391. * Gets the Up vector of the Spotlight for texture projection.
  44392. */
  44393. /**
  44394. * Sets the Up vector of the Spotlight for texture projection.
  44395. */
  44396. projectionTextureUpDirection: Vector3;
  44397. private _projectionTexture;
  44398. /**
  44399. * Gets the projection texture of the light.
  44400. */
  44401. /**
  44402. * Sets the projection texture of the light.
  44403. */
  44404. projectionTexture: Nullable<BaseTexture>;
  44405. private _projectionTextureViewLightDirty;
  44406. private _projectionTextureProjectionLightDirty;
  44407. private _projectionTextureDirty;
  44408. private _projectionTextureViewTargetVector;
  44409. private _projectionTextureViewLightMatrix;
  44410. private _projectionTextureProjectionLightMatrix;
  44411. private _projectionTextureScalingMatrix;
  44412. /**
  44413. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44414. * It can cast shadows.
  44415. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44416. * @param name The light friendly name
  44417. * @param position The position of the spot light in the scene
  44418. * @param direction The direction of the light in the scene
  44419. * @param angle The cone angle of the light in Radians
  44420. * @param exponent The light decay speed with the distance from the emission spot
  44421. * @param scene The scene the lights belongs to
  44422. */
  44423. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44424. /**
  44425. * Returns the string "SpotLight".
  44426. * @returns the class name
  44427. */
  44428. getClassName(): string;
  44429. /**
  44430. * Returns the integer 2.
  44431. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44432. */
  44433. getTypeID(): number;
  44434. /**
  44435. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44436. */
  44437. protected _setDirection(value: Vector3): void;
  44438. /**
  44439. * Overrides the position setter to recompute the projection texture view light Matrix.
  44440. */
  44441. protected _setPosition(value: Vector3): void;
  44442. /**
  44443. * 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.
  44444. * Returns the SpotLight.
  44445. */
  44446. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44447. protected _computeProjectionTextureViewLightMatrix(): void;
  44448. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44449. /**
  44450. * Main function for light texture projection matrix computing.
  44451. */
  44452. protected _computeProjectionTextureMatrix(): void;
  44453. protected _buildUniformLayout(): void;
  44454. private _computeAngleValues;
  44455. /**
  44456. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44457. * @param effect The effect to update
  44458. * @param lightIndex The index of the light in the effect to update
  44459. * @returns The spot light
  44460. */
  44461. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44462. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  44463. /**
  44464. * Disposes the light and the associated resources.
  44465. */
  44466. dispose(): void;
  44467. /**
  44468. * Prepares the list of defines specific to the light type.
  44469. * @param defines the list of defines
  44470. * @param lightIndex defines the index of the light for the effect
  44471. */
  44472. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44473. }
  44474. }
  44475. declare module BABYLON {
  44476. /**
  44477. * Gizmo that enables viewing a light
  44478. */
  44479. export class LightGizmo extends Gizmo {
  44480. private _lightMesh;
  44481. private _material;
  44482. private cachedPosition;
  44483. private cachedForward;
  44484. /**
  44485. * Creates a LightGizmo
  44486. * @param gizmoLayer The utility layer the gizmo will be added to
  44487. */
  44488. constructor(gizmoLayer?: UtilityLayerRenderer);
  44489. private _light;
  44490. /**
  44491. * The light that the gizmo is attached to
  44492. */
  44493. light: Nullable<Light>;
  44494. /**
  44495. * Gets the material used to render the light gizmo
  44496. */
  44497. readonly material: StandardMaterial;
  44498. /**
  44499. * @hidden
  44500. * Updates the gizmo to match the attached mesh's position/rotation
  44501. */
  44502. protected _update(): void;
  44503. private static _Scale;
  44504. /**
  44505. * Creates the lines for a light mesh
  44506. */
  44507. private static _createLightLines;
  44508. /**
  44509. * Disposes of the light gizmo
  44510. */
  44511. dispose(): void;
  44512. private static _CreateHemisphericLightMesh;
  44513. private static _CreatePointLightMesh;
  44514. private static _CreateSpotLightMesh;
  44515. private static _CreateDirectionalLightMesh;
  44516. }
  44517. }
  44518. declare module BABYLON {
  44519. /** @hidden */
  44520. export var backgroundFragmentDeclaration: {
  44521. name: string;
  44522. shader: string;
  44523. };
  44524. }
  44525. declare module BABYLON {
  44526. /** @hidden */
  44527. export var backgroundUboDeclaration: {
  44528. name: string;
  44529. shader: string;
  44530. };
  44531. }
  44532. declare module BABYLON {
  44533. /** @hidden */
  44534. export var backgroundPixelShader: {
  44535. name: string;
  44536. shader: string;
  44537. };
  44538. }
  44539. declare module BABYLON {
  44540. /** @hidden */
  44541. export var backgroundVertexDeclaration: {
  44542. name: string;
  44543. shader: string;
  44544. };
  44545. }
  44546. declare module BABYLON {
  44547. /** @hidden */
  44548. export var backgroundVertexShader: {
  44549. name: string;
  44550. shader: string;
  44551. };
  44552. }
  44553. declare module BABYLON {
  44554. /**
  44555. * Background material used to create an efficient environement around your scene.
  44556. */
  44557. export class BackgroundMaterial extends PushMaterial {
  44558. /**
  44559. * Standard reflectance value at parallel view angle.
  44560. */
  44561. static StandardReflectance0: number;
  44562. /**
  44563. * Standard reflectance value at grazing angle.
  44564. */
  44565. static StandardReflectance90: number;
  44566. protected _primaryColor: Color3;
  44567. /**
  44568. * Key light Color (multiply against the environement texture)
  44569. */
  44570. primaryColor: Color3;
  44571. protected __perceptualColor: Nullable<Color3>;
  44572. /**
  44573. * Experimental Internal Use Only.
  44574. *
  44575. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44576. * This acts as a helper to set the primary color to a more "human friendly" value.
  44577. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44578. * output color as close as possible from the chosen value.
  44579. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44580. * part of lighting setup.)
  44581. */ private _perceptualColor: Nullable<Color3>;
  44582. protected _primaryColorShadowLevel: float;
  44583. /**
  44584. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44585. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44586. */
  44587. primaryColorShadowLevel: float;
  44588. protected _primaryColorHighlightLevel: float;
  44589. /**
  44590. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44591. * The primary color is used at the level chosen to define what the white area would look.
  44592. */
  44593. primaryColorHighlightLevel: float;
  44594. protected _reflectionTexture: Nullable<BaseTexture>;
  44595. /**
  44596. * Reflection Texture used in the material.
  44597. * Should be author in a specific way for the best result (refer to the documentation).
  44598. */
  44599. reflectionTexture: Nullable<BaseTexture>;
  44600. protected _reflectionBlur: float;
  44601. /**
  44602. * Reflection Texture level of blur.
  44603. *
  44604. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44605. * texture twice.
  44606. */
  44607. reflectionBlur: float;
  44608. protected _diffuseTexture: Nullable<BaseTexture>;
  44609. /**
  44610. * Diffuse Texture used in the material.
  44611. * Should be author in a specific way for the best result (refer to the documentation).
  44612. */
  44613. diffuseTexture: Nullable<BaseTexture>;
  44614. protected _shadowLights: Nullable<IShadowLight[]>;
  44615. /**
  44616. * Specify the list of lights casting shadow on the material.
  44617. * All scene shadow lights will be included if null.
  44618. */
  44619. shadowLights: Nullable<IShadowLight[]>;
  44620. protected _shadowLevel: float;
  44621. /**
  44622. * Helps adjusting the shadow to a softer level if required.
  44623. * 0 means black shadows and 1 means no shadows.
  44624. */
  44625. shadowLevel: float;
  44626. protected _sceneCenter: Vector3;
  44627. /**
  44628. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44629. * It is usually zero but might be interesting to modify according to your setup.
  44630. */
  44631. sceneCenter: Vector3;
  44632. protected _opacityFresnel: boolean;
  44633. /**
  44634. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44635. * This helps ensuring a nice transition when the camera goes under the ground.
  44636. */
  44637. opacityFresnel: boolean;
  44638. protected _reflectionFresnel: boolean;
  44639. /**
  44640. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44641. * This helps adding a mirror texture on the ground.
  44642. */
  44643. reflectionFresnel: boolean;
  44644. protected _reflectionFalloffDistance: number;
  44645. /**
  44646. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44647. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44648. */
  44649. reflectionFalloffDistance: number;
  44650. protected _reflectionAmount: number;
  44651. /**
  44652. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44653. */
  44654. reflectionAmount: number;
  44655. protected _reflectionReflectance0: number;
  44656. /**
  44657. * This specifies the weight of the reflection at grazing angle.
  44658. */
  44659. reflectionReflectance0: number;
  44660. protected _reflectionReflectance90: number;
  44661. /**
  44662. * This specifies the weight of the reflection at a perpendicular point of view.
  44663. */
  44664. reflectionReflectance90: number;
  44665. /**
  44666. * Sets the reflection reflectance fresnel values according to the default standard
  44667. * empirically know to work well :-)
  44668. */
  44669. reflectionStandardFresnelWeight: number;
  44670. protected _useRGBColor: boolean;
  44671. /**
  44672. * Helps to directly use the maps channels instead of their level.
  44673. */
  44674. useRGBColor: boolean;
  44675. protected _enableNoise: boolean;
  44676. /**
  44677. * This helps reducing the banding effect that could occur on the background.
  44678. */
  44679. enableNoise: boolean;
  44680. /**
  44681. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44682. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44683. * Recommended to be keep at 1.0 except for special cases.
  44684. */
  44685. fovMultiplier: number;
  44686. private _fovMultiplier;
  44687. /**
  44688. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44689. */
  44690. useEquirectangularFOV: boolean;
  44691. private _maxSimultaneousLights;
  44692. /**
  44693. * Number of Simultaneous lights allowed on the material.
  44694. */
  44695. maxSimultaneousLights: int;
  44696. /**
  44697. * Default configuration related to image processing available in the Background Material.
  44698. */
  44699. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44700. /**
  44701. * Keep track of the image processing observer to allow dispose and replace.
  44702. */
  44703. private _imageProcessingObserver;
  44704. /**
  44705. * Attaches a new image processing configuration to the PBR Material.
  44706. * @param configuration (if null the scene configuration will be use)
  44707. */
  44708. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44709. /**
  44710. * Gets the image processing configuration used either in this material.
  44711. */
  44712. /**
  44713. * Sets the Default image processing configuration used either in the this material.
  44714. *
  44715. * If sets to null, the scene one is in use.
  44716. */
  44717. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44718. /**
  44719. * Gets wether the color curves effect is enabled.
  44720. */
  44721. /**
  44722. * Sets wether the color curves effect is enabled.
  44723. */
  44724. cameraColorCurvesEnabled: boolean;
  44725. /**
  44726. * Gets wether the color grading effect is enabled.
  44727. */
  44728. /**
  44729. * Gets wether the color grading effect is enabled.
  44730. */
  44731. cameraColorGradingEnabled: boolean;
  44732. /**
  44733. * Gets wether tonemapping is enabled or not.
  44734. */
  44735. /**
  44736. * Sets wether tonemapping is enabled or not
  44737. */
  44738. cameraToneMappingEnabled: boolean;
  44739. /**
  44740. * The camera exposure used on this material.
  44741. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44742. * This corresponds to a photographic exposure.
  44743. */
  44744. /**
  44745. * The camera exposure used on this material.
  44746. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44747. * This corresponds to a photographic exposure.
  44748. */
  44749. cameraExposure: float;
  44750. /**
  44751. * Gets The camera contrast used on this material.
  44752. */
  44753. /**
  44754. * Sets The camera contrast used on this material.
  44755. */
  44756. cameraContrast: float;
  44757. /**
  44758. * Gets the Color Grading 2D Lookup Texture.
  44759. */
  44760. /**
  44761. * Sets the Color Grading 2D Lookup Texture.
  44762. */
  44763. cameraColorGradingTexture: Nullable<BaseTexture>;
  44764. /**
  44765. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44766. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44767. * 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;
  44768. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44769. */
  44770. /**
  44771. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44772. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44773. * 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;
  44774. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44775. */
  44776. cameraColorCurves: Nullable<ColorCurves>;
  44777. /**
  44778. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44779. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44780. */
  44781. switchToBGR: boolean;
  44782. private _renderTargets;
  44783. private _reflectionControls;
  44784. private _white;
  44785. private _primaryShadowColor;
  44786. private _primaryHighlightColor;
  44787. /**
  44788. * Instantiates a Background Material in the given scene
  44789. * @param name The friendly name of the material
  44790. * @param scene The scene to add the material to
  44791. */
  44792. constructor(name: string, scene: Scene);
  44793. /**
  44794. * Gets a boolean indicating that current material needs to register RTT
  44795. */
  44796. readonly hasRenderTargetTextures: boolean;
  44797. /**
  44798. * The entire material has been created in order to prevent overdraw.
  44799. * @returns false
  44800. */
  44801. needAlphaTesting(): boolean;
  44802. /**
  44803. * The entire material has been created in order to prevent overdraw.
  44804. * @returns true if blending is enable
  44805. */
  44806. needAlphaBlending(): boolean;
  44807. /**
  44808. * Checks wether the material is ready to be rendered for a given mesh.
  44809. * @param mesh The mesh to render
  44810. * @param subMesh The submesh to check against
  44811. * @param useInstances Specify wether or not the material is used with instances
  44812. * @returns true if all the dependencies are ready (Textures, Effects...)
  44813. */
  44814. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44815. /**
  44816. * Compute the primary color according to the chosen perceptual color.
  44817. */
  44818. private _computePrimaryColorFromPerceptualColor;
  44819. /**
  44820. * Compute the highlights and shadow colors according to their chosen levels.
  44821. */
  44822. private _computePrimaryColors;
  44823. /**
  44824. * Build the uniform buffer used in the material.
  44825. */
  44826. buildUniformLayout(): void;
  44827. /**
  44828. * Unbind the material.
  44829. */
  44830. unbind(): void;
  44831. /**
  44832. * Bind only the world matrix to the material.
  44833. * @param world The world matrix to bind.
  44834. */
  44835. bindOnlyWorldMatrix(world: Matrix): void;
  44836. /**
  44837. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44838. * @param world The world matrix to bind.
  44839. * @param subMesh The submesh to bind for.
  44840. */
  44841. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44842. /**
  44843. * Checks to see if a texture is used in the material.
  44844. * @param texture - Base texture to use.
  44845. * @returns - Boolean specifying if a texture is used in the material.
  44846. */
  44847. hasTexture(texture: BaseTexture): boolean;
  44848. /**
  44849. * Dispose the material.
  44850. * @param forceDisposeEffect Force disposal of the associated effect.
  44851. * @param forceDisposeTextures Force disposal of the associated textures.
  44852. */
  44853. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44854. /**
  44855. * Clones the material.
  44856. * @param name The cloned name.
  44857. * @returns The cloned material.
  44858. */
  44859. clone(name: string): BackgroundMaterial;
  44860. /**
  44861. * Serializes the current material to its JSON representation.
  44862. * @returns The JSON representation.
  44863. */
  44864. serialize(): any;
  44865. /**
  44866. * Gets the class name of the material
  44867. * @returns "BackgroundMaterial"
  44868. */
  44869. getClassName(): string;
  44870. /**
  44871. * Parse a JSON input to create back a background material.
  44872. * @param source The JSON data to parse
  44873. * @param scene The scene to create the parsed material in
  44874. * @param rootUrl The root url of the assets the material depends upon
  44875. * @returns the instantiated BackgroundMaterial.
  44876. */
  44877. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44878. }
  44879. }
  44880. declare module BABYLON {
  44881. /**
  44882. * Represents the different options available during the creation of
  44883. * a Environment helper.
  44884. *
  44885. * This can control the default ground, skybox and image processing setup of your scene.
  44886. */
  44887. export interface IEnvironmentHelperOptions {
  44888. /**
  44889. * Specifies wether or not to create a ground.
  44890. * True by default.
  44891. */
  44892. createGround: boolean;
  44893. /**
  44894. * Specifies the ground size.
  44895. * 15 by default.
  44896. */
  44897. groundSize: number;
  44898. /**
  44899. * The texture used on the ground for the main color.
  44900. * Comes from the BabylonJS CDN by default.
  44901. *
  44902. * Remarks: Can be either a texture or a url.
  44903. */
  44904. groundTexture: string | BaseTexture;
  44905. /**
  44906. * The color mixed in the ground texture by default.
  44907. * BabylonJS clearColor by default.
  44908. */
  44909. groundColor: Color3;
  44910. /**
  44911. * Specifies the ground opacity.
  44912. * 1 by default.
  44913. */
  44914. groundOpacity: number;
  44915. /**
  44916. * Enables the ground to receive shadows.
  44917. * True by default.
  44918. */
  44919. enableGroundShadow: boolean;
  44920. /**
  44921. * Helps preventing the shadow to be fully black on the ground.
  44922. * 0.5 by default.
  44923. */
  44924. groundShadowLevel: number;
  44925. /**
  44926. * Creates a mirror texture attach to the ground.
  44927. * false by default.
  44928. */
  44929. enableGroundMirror: boolean;
  44930. /**
  44931. * Specifies the ground mirror size ratio.
  44932. * 0.3 by default as the default kernel is 64.
  44933. */
  44934. groundMirrorSizeRatio: number;
  44935. /**
  44936. * Specifies the ground mirror blur kernel size.
  44937. * 64 by default.
  44938. */
  44939. groundMirrorBlurKernel: number;
  44940. /**
  44941. * Specifies the ground mirror visibility amount.
  44942. * 1 by default
  44943. */
  44944. groundMirrorAmount: number;
  44945. /**
  44946. * Specifies the ground mirror reflectance weight.
  44947. * This uses the standard weight of the background material to setup the fresnel effect
  44948. * of the mirror.
  44949. * 1 by default.
  44950. */
  44951. groundMirrorFresnelWeight: number;
  44952. /**
  44953. * Specifies the ground mirror Falloff distance.
  44954. * This can helps reducing the size of the reflection.
  44955. * 0 by Default.
  44956. */
  44957. groundMirrorFallOffDistance: number;
  44958. /**
  44959. * Specifies the ground mirror texture type.
  44960. * Unsigned Int by Default.
  44961. */
  44962. groundMirrorTextureType: number;
  44963. /**
  44964. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44965. * the shown objects.
  44966. */
  44967. groundYBias: number;
  44968. /**
  44969. * Specifies wether or not to create a skybox.
  44970. * True by default.
  44971. */
  44972. createSkybox: boolean;
  44973. /**
  44974. * Specifies the skybox size.
  44975. * 20 by default.
  44976. */
  44977. skyboxSize: number;
  44978. /**
  44979. * The texture used on the skybox for the main color.
  44980. * Comes from the BabylonJS CDN by default.
  44981. *
  44982. * Remarks: Can be either a texture or a url.
  44983. */
  44984. skyboxTexture: string | BaseTexture;
  44985. /**
  44986. * The color mixed in the skybox texture by default.
  44987. * BabylonJS clearColor by default.
  44988. */
  44989. skyboxColor: Color3;
  44990. /**
  44991. * The background rotation around the Y axis of the scene.
  44992. * This helps aligning the key lights of your scene with the background.
  44993. * 0 by default.
  44994. */
  44995. backgroundYRotation: number;
  44996. /**
  44997. * Compute automatically the size of the elements to best fit with the scene.
  44998. */
  44999. sizeAuto: boolean;
  45000. /**
  45001. * Default position of the rootMesh if autoSize is not true.
  45002. */
  45003. rootPosition: Vector3;
  45004. /**
  45005. * Sets up the image processing in the scene.
  45006. * true by default.
  45007. */
  45008. setupImageProcessing: boolean;
  45009. /**
  45010. * The texture used as your environment texture in the scene.
  45011. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45012. *
  45013. * Remarks: Can be either a texture or a url.
  45014. */
  45015. environmentTexture: string | BaseTexture;
  45016. /**
  45017. * The value of the exposure to apply to the scene.
  45018. * 0.6 by default if setupImageProcessing is true.
  45019. */
  45020. cameraExposure: number;
  45021. /**
  45022. * The value of the contrast to apply to the scene.
  45023. * 1.6 by default if setupImageProcessing is true.
  45024. */
  45025. cameraContrast: number;
  45026. /**
  45027. * Specifies wether or not tonemapping should be enabled in the scene.
  45028. * true by default if setupImageProcessing is true.
  45029. */
  45030. toneMappingEnabled: boolean;
  45031. }
  45032. /**
  45033. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45034. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45035. * It also helps with the default setup of your imageProcessing configuration.
  45036. */
  45037. export class EnvironmentHelper {
  45038. /**
  45039. * Default ground texture URL.
  45040. */
  45041. private static _groundTextureCDNUrl;
  45042. /**
  45043. * Default skybox texture URL.
  45044. */
  45045. private static _skyboxTextureCDNUrl;
  45046. /**
  45047. * Default environment texture URL.
  45048. */
  45049. private static _environmentTextureCDNUrl;
  45050. /**
  45051. * Creates the default options for the helper.
  45052. */
  45053. private static _getDefaultOptions;
  45054. private _rootMesh;
  45055. /**
  45056. * Gets the root mesh created by the helper.
  45057. */
  45058. readonly rootMesh: Mesh;
  45059. private _skybox;
  45060. /**
  45061. * Gets the skybox created by the helper.
  45062. */
  45063. readonly skybox: Nullable<Mesh>;
  45064. private _skyboxTexture;
  45065. /**
  45066. * Gets the skybox texture created by the helper.
  45067. */
  45068. readonly skyboxTexture: Nullable<BaseTexture>;
  45069. private _skyboxMaterial;
  45070. /**
  45071. * Gets the skybox material created by the helper.
  45072. */
  45073. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45074. private _ground;
  45075. /**
  45076. * Gets the ground mesh created by the helper.
  45077. */
  45078. readonly ground: Nullable<Mesh>;
  45079. private _groundTexture;
  45080. /**
  45081. * Gets the ground texture created by the helper.
  45082. */
  45083. readonly groundTexture: Nullable<BaseTexture>;
  45084. private _groundMirror;
  45085. /**
  45086. * Gets the ground mirror created by the helper.
  45087. */
  45088. readonly groundMirror: Nullable<MirrorTexture>;
  45089. /**
  45090. * Gets the ground mirror render list to helps pushing the meshes
  45091. * you wish in the ground reflection.
  45092. */
  45093. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45094. private _groundMaterial;
  45095. /**
  45096. * Gets the ground material created by the helper.
  45097. */
  45098. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45099. /**
  45100. * Stores the creation options.
  45101. */
  45102. private readonly _scene;
  45103. private _options;
  45104. /**
  45105. * This observable will be notified with any error during the creation of the environment,
  45106. * mainly texture creation errors.
  45107. */
  45108. onErrorObservable: Observable<{
  45109. message?: string;
  45110. exception?: any;
  45111. }>;
  45112. /**
  45113. * constructor
  45114. * @param options Defines the options we want to customize the helper
  45115. * @param scene The scene to add the material to
  45116. */
  45117. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45118. /**
  45119. * Updates the background according to the new options
  45120. * @param options
  45121. */
  45122. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45123. /**
  45124. * Sets the primary color of all the available elements.
  45125. * @param color the main color to affect to the ground and the background
  45126. */
  45127. setMainColor(color: Color3): void;
  45128. /**
  45129. * Setup the image processing according to the specified options.
  45130. */
  45131. private _setupImageProcessing;
  45132. /**
  45133. * Setup the environment texture according to the specified options.
  45134. */
  45135. private _setupEnvironmentTexture;
  45136. /**
  45137. * Setup the background according to the specified options.
  45138. */
  45139. private _setupBackground;
  45140. /**
  45141. * Get the scene sizes according to the setup.
  45142. */
  45143. private _getSceneSize;
  45144. /**
  45145. * Setup the ground according to the specified options.
  45146. */
  45147. private _setupGround;
  45148. /**
  45149. * Setup the ground material according to the specified options.
  45150. */
  45151. private _setupGroundMaterial;
  45152. /**
  45153. * Setup the ground diffuse texture according to the specified options.
  45154. */
  45155. private _setupGroundDiffuseTexture;
  45156. /**
  45157. * Setup the ground mirror texture according to the specified options.
  45158. */
  45159. private _setupGroundMirrorTexture;
  45160. /**
  45161. * Setup the ground to receive the mirror texture.
  45162. */
  45163. private _setupMirrorInGroundMaterial;
  45164. /**
  45165. * Setup the skybox according to the specified options.
  45166. */
  45167. private _setupSkybox;
  45168. /**
  45169. * Setup the skybox material according to the specified options.
  45170. */
  45171. private _setupSkyboxMaterial;
  45172. /**
  45173. * Setup the skybox reflection texture according to the specified options.
  45174. */
  45175. private _setupSkyboxReflectionTexture;
  45176. private _errorHandler;
  45177. /**
  45178. * Dispose all the elements created by the Helper.
  45179. */
  45180. dispose(): void;
  45181. }
  45182. }
  45183. declare module BABYLON {
  45184. /**
  45185. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45186. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45187. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45188. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45189. */
  45190. export class PhotoDome extends TransformNode {
  45191. /**
  45192. * Define the image as a Monoscopic panoramic 360 image.
  45193. */
  45194. static readonly MODE_MONOSCOPIC: number;
  45195. /**
  45196. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45197. */
  45198. static readonly MODE_TOPBOTTOM: number;
  45199. /**
  45200. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45201. */
  45202. static readonly MODE_SIDEBYSIDE: number;
  45203. private _useDirectMapping;
  45204. /**
  45205. * The texture being displayed on the sphere
  45206. */
  45207. protected _photoTexture: Texture;
  45208. /**
  45209. * Gets or sets the texture being displayed on the sphere
  45210. */
  45211. photoTexture: Texture;
  45212. /**
  45213. * Observable raised when an error occured while loading the 360 image
  45214. */
  45215. onLoadErrorObservable: Observable<string>;
  45216. /**
  45217. * The skybox material
  45218. */
  45219. protected _material: BackgroundMaterial;
  45220. /**
  45221. * The surface used for the skybox
  45222. */
  45223. protected _mesh: Mesh;
  45224. /**
  45225. * Gets the mesh used for the skybox.
  45226. */
  45227. readonly mesh: Mesh;
  45228. /**
  45229. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45230. * Also see the options.resolution property.
  45231. */
  45232. fovMultiplier: number;
  45233. private _imageMode;
  45234. /**
  45235. * Gets or set the current video mode for the video. It can be:
  45236. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  45237. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45238. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45239. */
  45240. imageMode: number;
  45241. /**
  45242. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45243. * @param name Element's name, child elements will append suffixes for their own names.
  45244. * @param urlsOfPhoto defines the url of the photo to display
  45245. * @param options defines an object containing optional or exposed sub element properties
  45246. * @param onError defines a callback called when an error occured while loading the texture
  45247. */
  45248. constructor(name: string, urlOfPhoto: string, options: {
  45249. resolution?: number;
  45250. size?: number;
  45251. useDirectMapping?: boolean;
  45252. faceForward?: boolean;
  45253. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45254. private _onBeforeCameraRenderObserver;
  45255. private _changeImageMode;
  45256. /**
  45257. * Releases resources associated with this node.
  45258. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45259. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45260. */
  45261. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45262. }
  45263. }
  45264. declare module BABYLON {
  45265. /**
  45266. * Class used to host RGBD texture specific utilities
  45267. */
  45268. export class RGBDTextureTools {
  45269. /**
  45270. * Expand the RGBD Texture from RGBD to Half Float if possible.
  45271. * @param texture the texture to expand.
  45272. */
  45273. static ExpandRGBDTexture(texture: Texture): void;
  45274. }
  45275. }
  45276. declare module BABYLON {
  45277. /**
  45278. * Class used to host texture specific utilities
  45279. */
  45280. export class BRDFTextureTools {
  45281. /**
  45282. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45283. * @param scene defines the hosting scene
  45284. * @returns the environment BRDF texture
  45285. */
  45286. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45287. private static _environmentBRDFBase64Texture;
  45288. }
  45289. }
  45290. declare module BABYLON {
  45291. /**
  45292. * @hidden
  45293. */
  45294. export interface IMaterialClearCoatDefines {
  45295. CLEARCOAT: boolean;
  45296. CLEARCOAT_DEFAULTIOR: boolean;
  45297. CLEARCOAT_TEXTURE: boolean;
  45298. CLEARCOAT_TEXTUREDIRECTUV: number;
  45299. CLEARCOAT_BUMP: boolean;
  45300. CLEARCOAT_BUMPDIRECTUV: number;
  45301. CLEARCOAT_TINT: boolean;
  45302. CLEARCOAT_TINT_TEXTURE: boolean;
  45303. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45304. /** @hidden */ private _areTexturesDirty: boolean;
  45305. }
  45306. /**
  45307. * Define the code related to the clear coat parameters of the pbr material.
  45308. */
  45309. export class PBRClearCoatConfiguration {
  45310. /**
  45311. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45312. * The default fits with a polyurethane material.
  45313. */
  45314. private static readonly _DefaultIndexOfRefraction;
  45315. private _isEnabled;
  45316. /**
  45317. * Defines if the clear coat is enabled in the material.
  45318. */
  45319. isEnabled: boolean;
  45320. /**
  45321. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45322. */
  45323. intensity: number;
  45324. /**
  45325. * Defines the clear coat layer roughness.
  45326. */
  45327. roughness: number;
  45328. private _indexOfRefraction;
  45329. /**
  45330. * Defines the index of refraction of the clear coat.
  45331. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45332. * The default fits with a polyurethane material.
  45333. * Changing the default value is more performance intensive.
  45334. */
  45335. indexOfRefraction: number;
  45336. private _texture;
  45337. /**
  45338. * Stores the clear coat values in a texture.
  45339. */
  45340. texture: Nullable<BaseTexture>;
  45341. private _bumpTexture;
  45342. /**
  45343. * Define the clear coat specific bump texture.
  45344. */
  45345. bumpTexture: Nullable<BaseTexture>;
  45346. private _isTintEnabled;
  45347. /**
  45348. * Defines if the clear coat tint is enabled in the material.
  45349. */
  45350. isTintEnabled: boolean;
  45351. /**
  45352. * Defines the clear coat tint of the material.
  45353. * This is only use if tint is enabled
  45354. */
  45355. tintColor: Color3;
  45356. /**
  45357. * Defines the distance at which the tint color should be found in the
  45358. * clear coat media.
  45359. * This is only use if tint is enabled
  45360. */
  45361. tintColorAtDistance: number;
  45362. /**
  45363. * Defines the clear coat layer thickness.
  45364. * This is only use if tint is enabled
  45365. */
  45366. tintThickness: number;
  45367. private _tintTexture;
  45368. /**
  45369. * Stores the clear tint values in a texture.
  45370. * rgb is tint
  45371. * a is a thickness factor
  45372. */
  45373. tintTexture: Nullable<BaseTexture>;
  45374. /** @hidden */
  45375. private _internalMarkAllSubMeshesAsTexturesDirty;
  45376. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45377. /**
  45378. * Instantiate a new istance of clear coat configuration.
  45379. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45380. */
  45381. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45382. /**
  45383. * Gets wehter the submesh is ready to be used or not.
  45384. * @param defines the list of "defines" to update.
  45385. * @param scene defines the scene the material belongs to.
  45386. * @param engine defines the engine the material belongs to.
  45387. * @param disableBumpMap defines wether the material disables bump or not.
  45388. * @returns - boolean indicating that the submesh is ready or not.
  45389. */
  45390. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45391. /**
  45392. * Checks to see if a texture is used in the material.
  45393. * @param defines the list of "defines" to update.
  45394. * @param scene defines the scene to the material belongs to.
  45395. */
  45396. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45397. /**
  45398. * Binds the material data.
  45399. * @param uniformBuffer defines the Uniform buffer to fill in.
  45400. * @param scene defines the scene the material belongs to.
  45401. * @param engine defines the engine the material belongs to.
  45402. * @param disableBumpMap defines wether the material disables bump or not.
  45403. * @param isFrozen defines wether the material is frozen or not.
  45404. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45405. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45406. */
  45407. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45408. /**
  45409. * Checks to see if a texture is used in the material.
  45410. * @param texture - Base texture to use.
  45411. * @returns - Boolean specifying if a texture is used in the material.
  45412. */
  45413. hasTexture(texture: BaseTexture): boolean;
  45414. /**
  45415. * Returns an array of the actively used textures.
  45416. * @param activeTextures Array of BaseTextures
  45417. */
  45418. getActiveTextures(activeTextures: BaseTexture[]): void;
  45419. /**
  45420. * Returns the animatable textures.
  45421. * @param animatables Array of animatable textures.
  45422. */
  45423. getAnimatables(animatables: IAnimatable[]): void;
  45424. /**
  45425. * Disposes the resources of the material.
  45426. * @param forceDisposeTextures - Forces the disposal of all textures.
  45427. */
  45428. dispose(forceDisposeTextures?: boolean): void;
  45429. /**
  45430. * Get the current class name of the texture useful for serialization or dynamic coding.
  45431. * @returns "PBRClearCoatConfiguration"
  45432. */
  45433. getClassName(): string;
  45434. /**
  45435. * Add fallbacks to the effect fallbacks list.
  45436. * @param defines defines the Base texture to use.
  45437. * @param fallbacks defines the current fallback list.
  45438. * @param currentRank defines the current fallback rank.
  45439. * @returns the new fallback rank.
  45440. */
  45441. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45442. /**
  45443. * Add the required uniforms to the current list.
  45444. * @param uniforms defines the current uniform list.
  45445. */
  45446. static AddUniforms(uniforms: string[]): void;
  45447. /**
  45448. * Add the required samplers to the current list.
  45449. * @param samplers defines the current sampler list.
  45450. */
  45451. static AddSamplers(samplers: string[]): void;
  45452. /**
  45453. * Add the required uniforms to the current buffer.
  45454. * @param uniformBuffer defines the current uniform buffer.
  45455. */
  45456. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45457. /**
  45458. * Makes a duplicate of the current configuration into another one.
  45459. * @param clearCoatConfiguration define the config where to copy the info
  45460. */
  45461. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45462. /**
  45463. * Serializes this clear coat configuration.
  45464. * @returns - An object with the serialized config.
  45465. */
  45466. serialize(): any;
  45467. /**
  45468. * Parses a anisotropy Configuration from a serialized object.
  45469. * @param source - Serialized object.
  45470. * @param scene Defines the scene we are parsing for
  45471. * @param rootUrl Defines the rootUrl to load from
  45472. */
  45473. parse(source: any, scene: Scene, rootUrl: string): void;
  45474. }
  45475. }
  45476. declare module BABYLON {
  45477. /**
  45478. * @hidden
  45479. */
  45480. export interface IMaterialAnisotropicDefines {
  45481. ANISOTROPIC: boolean;
  45482. ANISOTROPIC_TEXTURE: boolean;
  45483. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45484. MAINUV1: boolean; private _areTexturesDirty: boolean; private _needUVs: boolean;
  45485. }
  45486. /**
  45487. * Define the code related to the anisotropic parameters of the pbr material.
  45488. */
  45489. export class PBRAnisotropicConfiguration {
  45490. private _isEnabled;
  45491. /**
  45492. * Defines if the anisotropy is enabled in the material.
  45493. */
  45494. isEnabled: boolean;
  45495. /**
  45496. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45497. */
  45498. intensity: number;
  45499. /**
  45500. * Defines if the effect is along the tangents, bitangents or in between.
  45501. * By default, the effect is "strectching" the highlights along the tangents.
  45502. */
  45503. direction: Vector2;
  45504. private _texture;
  45505. /**
  45506. * Stores the anisotropy values in a texture.
  45507. * rg is direction (like normal from -1 to 1)
  45508. * b is a intensity
  45509. */
  45510. texture: Nullable<BaseTexture>;
  45511. /** @hidden */
  45512. private _internalMarkAllSubMeshesAsTexturesDirty;
  45513. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45514. /**
  45515. * Instantiate a new istance of anisotropy configuration.
  45516. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45517. */
  45518. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45519. /**
  45520. * Specifies that the submesh is ready to be used.
  45521. * @param defines the list of "defines" to update.
  45522. * @param scene defines the scene the material belongs to.
  45523. * @returns - boolean indicating that the submesh is ready or not.
  45524. */
  45525. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45526. /**
  45527. * Checks to see if a texture is used in the material.
  45528. * @param defines the list of "defines" to update.
  45529. * @param mesh the mesh we are preparing the defines for.
  45530. * @param scene defines the scene the material belongs to.
  45531. */
  45532. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45533. /**
  45534. * Binds the material data.
  45535. * @param uniformBuffer defines the Uniform buffer to fill in.
  45536. * @param scene defines the scene the material belongs to.
  45537. * @param isFrozen defines wether the material is frozen or not.
  45538. */
  45539. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45540. /**
  45541. * Checks to see if a texture is used in the material.
  45542. * @param texture - Base texture to use.
  45543. * @returns - Boolean specifying if a texture is used in the material.
  45544. */
  45545. hasTexture(texture: BaseTexture): boolean;
  45546. /**
  45547. * Returns an array of the actively used textures.
  45548. * @param activeTextures Array of BaseTextures
  45549. */
  45550. getActiveTextures(activeTextures: BaseTexture[]): void;
  45551. /**
  45552. * Returns the animatable textures.
  45553. * @param animatables Array of animatable textures.
  45554. */
  45555. getAnimatables(animatables: IAnimatable[]): void;
  45556. /**
  45557. * Disposes the resources of the material.
  45558. * @param forceDisposeTextures - Forces the disposal of all textures.
  45559. */
  45560. dispose(forceDisposeTextures?: boolean): void;
  45561. /**
  45562. * Get the current class name of the texture useful for serialization or dynamic coding.
  45563. * @returns "PBRAnisotropicConfiguration"
  45564. */
  45565. getClassName(): string;
  45566. /**
  45567. * Add fallbacks to the effect fallbacks list.
  45568. * @param defines defines the Base texture to use.
  45569. * @param fallbacks defines the current fallback list.
  45570. * @param currentRank defines the current fallback rank.
  45571. * @returns the new fallback rank.
  45572. */
  45573. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45574. /**
  45575. * Add the required uniforms to the current list.
  45576. * @param uniforms defines the current uniform list.
  45577. */
  45578. static AddUniforms(uniforms: string[]): void;
  45579. /**
  45580. * Add the required uniforms to the current buffer.
  45581. * @param uniformBuffer defines the current uniform buffer.
  45582. */
  45583. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45584. /**
  45585. * Add the required samplers to the current list.
  45586. * @param samplers defines the current sampler list.
  45587. */
  45588. static AddSamplers(samplers: string[]): void;
  45589. /**
  45590. * Makes a duplicate of the current configuration into another one.
  45591. * @param anisotropicConfiguration define the config where to copy the info
  45592. */
  45593. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45594. /**
  45595. * Serializes this anisotropy configuration.
  45596. * @returns - An object with the serialized config.
  45597. */
  45598. serialize(): any;
  45599. /**
  45600. * Parses a anisotropy Configuration from a serialized object.
  45601. * @param source - Serialized object.
  45602. * @param scene Defines the scene we are parsing for
  45603. * @param rootUrl Defines the rootUrl to load from
  45604. */
  45605. parse(source: any, scene: Scene, rootUrl: string): void;
  45606. }
  45607. }
  45608. declare module BABYLON {
  45609. /**
  45610. * @hidden
  45611. */
  45612. export interface IMaterialBRDFDefines {
  45613. BRDF_V_HEIGHT_CORRELATED: boolean;
  45614. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45615. SPHERICAL_HARMONICS: boolean;
  45616. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  45617. /** @hidden */ private _areMiscDirty: boolean;
  45618. }
  45619. /**
  45620. * Define the code related to the BRDF parameters of the pbr material.
  45621. */
  45622. export class PBRBRDFConfiguration {
  45623. /**
  45624. * Default value used for the energy conservation.
  45625. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45626. */
  45627. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45628. /**
  45629. * Default value used for the Smith Visibility Height Correlated mode.
  45630. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45631. */
  45632. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45633. /**
  45634. * Default value used for the IBL diffuse part.
  45635. * This can help switching back to the polynomials mode globally which is a tiny bit
  45636. * less GPU intensive at the drawback of a lower quality.
  45637. */
  45638. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  45639. /**
  45640. * Default value used for activating energy conservation for the specular workflow.
  45641. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  45642. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  45643. */
  45644. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  45645. private _useEnergyConservation;
  45646. /**
  45647. * Defines if the material uses energy conservation.
  45648. */
  45649. useEnergyConservation: boolean;
  45650. private _useSmithVisibilityHeightCorrelated;
  45651. /**
  45652. * LEGACY Mode set to false
  45653. * Defines if the material uses height smith correlated visibility term.
  45654. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45655. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45656. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45657. * Not relying on height correlated will also disable energy conservation.
  45658. */
  45659. useSmithVisibilityHeightCorrelated: boolean;
  45660. private _useSphericalHarmonics;
  45661. /**
  45662. * LEGACY Mode set to false
  45663. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  45664. * diffuse part of the IBL.
  45665. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  45666. * to the ground truth.
  45667. */
  45668. useSphericalHarmonics: boolean;
  45669. private _useSpecularGlossinessInputEnergyConservation;
  45670. /**
  45671. * Defines if the material uses energy conservation, when the specular workflow is active.
  45672. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  45673. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  45674. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  45675. */
  45676. useSpecularGlossinessInputEnergyConservation: boolean;
  45677. /** @hidden */
  45678. private _internalMarkAllSubMeshesAsMiscDirty;
  45679. /** @hidden */ private _markAllSubMeshesAsMiscDirty(): void;
  45680. /**
  45681. * Instantiate a new istance of clear coat configuration.
  45682. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45683. */
  45684. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45685. /**
  45686. * Checks to see if a texture is used in the material.
  45687. * @param defines the list of "defines" to update.
  45688. */
  45689. prepareDefines(defines: IMaterialBRDFDefines): void;
  45690. /**
  45691. * Get the current class name of the texture useful for serialization or dynamic coding.
  45692. * @returns "PBRClearCoatConfiguration"
  45693. */
  45694. getClassName(): string;
  45695. /**
  45696. * Makes a duplicate of the current configuration into another one.
  45697. * @param brdfConfiguration define the config where to copy the info
  45698. */
  45699. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45700. /**
  45701. * Serializes this BRDF configuration.
  45702. * @returns - An object with the serialized config.
  45703. */
  45704. serialize(): any;
  45705. /**
  45706. * Parses a anisotropy Configuration from a serialized object.
  45707. * @param source - Serialized object.
  45708. * @param scene Defines the scene we are parsing for
  45709. * @param rootUrl Defines the rootUrl to load from
  45710. */
  45711. parse(source: any, scene: Scene, rootUrl: string): void;
  45712. }
  45713. }
  45714. declare module BABYLON {
  45715. /**
  45716. * @hidden
  45717. */
  45718. export interface IMaterialSheenDefines {
  45719. SHEEN: boolean;
  45720. SHEEN_TEXTURE: boolean;
  45721. SHEEN_TEXTUREDIRECTUV: number;
  45722. SHEEN_LINKWITHALBEDO: boolean;
  45723. /** @hidden */ private _areTexturesDirty: boolean;
  45724. }
  45725. /**
  45726. * Define the code related to the Sheen parameters of the pbr material.
  45727. */
  45728. export class PBRSheenConfiguration {
  45729. private _isEnabled;
  45730. /**
  45731. * Defines if the material uses sheen.
  45732. */
  45733. isEnabled: boolean;
  45734. private _linkSheenWithAlbedo;
  45735. /**
  45736. * Defines if the sheen is linked to the sheen color.
  45737. */
  45738. linkSheenWithAlbedo: boolean;
  45739. /**
  45740. * Defines the sheen intensity.
  45741. */
  45742. intensity: number;
  45743. /**
  45744. * Defines the sheen color.
  45745. */
  45746. color: Color3;
  45747. private _texture;
  45748. /**
  45749. * Stores the sheen tint values in a texture.
  45750. * rgb is tint
  45751. * a is a intensity
  45752. */
  45753. texture: Nullable<BaseTexture>;
  45754. /** @hidden */
  45755. private _internalMarkAllSubMeshesAsTexturesDirty;
  45756. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45757. /**
  45758. * Instantiate a new istance of clear coat configuration.
  45759. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45760. */
  45761. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45762. /**
  45763. * Specifies that the submesh is ready to be used.
  45764. * @param defines the list of "defines" to update.
  45765. * @param scene defines the scene the material belongs to.
  45766. * @returns - boolean indicating that the submesh is ready or not.
  45767. */
  45768. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45769. /**
  45770. * Checks to see if a texture is used in the material.
  45771. * @param defines the list of "defines" to update.
  45772. * @param scene defines the scene the material belongs to.
  45773. */
  45774. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45775. /**
  45776. * Binds the material data.
  45777. * @param uniformBuffer defines the Uniform buffer to fill in.
  45778. * @param scene defines the scene the material belongs to.
  45779. * @param isFrozen defines wether the material is frozen or not.
  45780. */
  45781. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45782. /**
  45783. * Checks to see if a texture is used in the material.
  45784. * @param texture - Base texture to use.
  45785. * @returns - Boolean specifying if a texture is used in the material.
  45786. */
  45787. hasTexture(texture: BaseTexture): boolean;
  45788. /**
  45789. * Returns an array of the actively used textures.
  45790. * @param activeTextures Array of BaseTextures
  45791. */
  45792. getActiveTextures(activeTextures: BaseTexture[]): void;
  45793. /**
  45794. * Returns the animatable textures.
  45795. * @param animatables Array of animatable textures.
  45796. */
  45797. getAnimatables(animatables: IAnimatable[]): void;
  45798. /**
  45799. * Disposes the resources of the material.
  45800. * @param forceDisposeTextures - Forces the disposal of all textures.
  45801. */
  45802. dispose(forceDisposeTextures?: boolean): void;
  45803. /**
  45804. * Get the current class name of the texture useful for serialization or dynamic coding.
  45805. * @returns "PBRSheenConfiguration"
  45806. */
  45807. getClassName(): string;
  45808. /**
  45809. * Add fallbacks to the effect fallbacks list.
  45810. * @param defines defines the Base texture to use.
  45811. * @param fallbacks defines the current fallback list.
  45812. * @param currentRank defines the current fallback rank.
  45813. * @returns the new fallback rank.
  45814. */
  45815. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45816. /**
  45817. * Add the required uniforms to the current list.
  45818. * @param uniforms defines the current uniform list.
  45819. */
  45820. static AddUniforms(uniforms: string[]): void;
  45821. /**
  45822. * Add the required uniforms to the current buffer.
  45823. * @param uniformBuffer defines the current uniform buffer.
  45824. */
  45825. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45826. /**
  45827. * Add the required samplers to the current list.
  45828. * @param samplers defines the current sampler list.
  45829. */
  45830. static AddSamplers(samplers: string[]): void;
  45831. /**
  45832. * Makes a duplicate of the current configuration into another one.
  45833. * @param sheenConfiguration define the config where to copy the info
  45834. */
  45835. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45836. /**
  45837. * Serializes this BRDF configuration.
  45838. * @returns - An object with the serialized config.
  45839. */
  45840. serialize(): any;
  45841. /**
  45842. * Parses a anisotropy Configuration from a serialized object.
  45843. * @param source - Serialized object.
  45844. * @param scene Defines the scene we are parsing for
  45845. * @param rootUrl Defines the rootUrl to load from
  45846. */
  45847. parse(source: any, scene: Scene, rootUrl: string): void;
  45848. }
  45849. }
  45850. declare module BABYLON {
  45851. /**
  45852. * @hidden
  45853. */
  45854. export interface IMaterialSubSurfaceDefines {
  45855. SUBSURFACE: boolean;
  45856. SS_REFRACTION: boolean;
  45857. SS_TRANSLUCENCY: boolean;
  45858. SS_SCATERRING: boolean;
  45859. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45860. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45861. SS_REFRACTIONMAP_3D: boolean;
  45862. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45863. SS_LODINREFRACTIONALPHA: boolean;
  45864. SS_GAMMAREFRACTION: boolean;
  45865. SS_RGBDREFRACTION: boolean;
  45866. SS_LINEARSPECULARREFRACTION: boolean;
  45867. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45868. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45869. /** @hidden */ private _areTexturesDirty: boolean;
  45870. }
  45871. /**
  45872. * Define the code related to the sub surface parameters of the pbr material.
  45873. */
  45874. export class PBRSubSurfaceConfiguration {
  45875. private _isRefractionEnabled;
  45876. /**
  45877. * Defines if the refraction is enabled in the material.
  45878. */
  45879. isRefractionEnabled: boolean;
  45880. private _isTranslucencyEnabled;
  45881. /**
  45882. * Defines if the translucency is enabled in the material.
  45883. */
  45884. isTranslucencyEnabled: boolean;
  45885. private _isScatteringEnabled;
  45886. /**
  45887. * Defines the refraction intensity of the material.
  45888. * The refraction when enabled replaces the Diffuse part of the material.
  45889. * The intensity helps transitionning between diffuse and refraction.
  45890. */
  45891. refractionIntensity: number;
  45892. /**
  45893. * Defines the translucency intensity of the material.
  45894. * When translucency has been enabled, this defines how much of the "translucency"
  45895. * is addded to the diffuse part of the material.
  45896. */
  45897. translucencyIntensity: number;
  45898. /**
  45899. * Defines the scattering intensity of the material.
  45900. * When scattering has been enabled, this defines how much of the "scattered light"
  45901. * is addded to the diffuse part of the material.
  45902. */
  45903. scatteringIntensity: number;
  45904. private _thicknessTexture;
  45905. /**
  45906. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45907. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45908. * 0 would mean minimumThickness
  45909. * 1 would mean maximumThickness
  45910. * The other channels might be use as a mask to vary the different effects intensity.
  45911. */
  45912. thicknessTexture: Nullable<BaseTexture>;
  45913. private _refractionTexture;
  45914. /**
  45915. * Defines the texture to use for refraction.
  45916. */
  45917. refractionTexture: Nullable<BaseTexture>;
  45918. private _indexOfRefraction;
  45919. /**
  45920. * Defines the index of refraction used in the material.
  45921. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45922. */
  45923. indexOfRefraction: number;
  45924. private _invertRefractionY;
  45925. /**
  45926. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45927. */
  45928. invertRefractionY: boolean;
  45929. private _linkRefractionWithTransparency;
  45930. /**
  45931. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45932. * Materials half opaque for instance using refraction could benefit from this control.
  45933. */
  45934. linkRefractionWithTransparency: boolean;
  45935. /**
  45936. * Defines the minimum thickness stored in the thickness map.
  45937. * If no thickness map is defined, this value will be used to simulate thickness.
  45938. */
  45939. minimumThickness: number;
  45940. /**
  45941. * Defines the maximum thickness stored in the thickness map.
  45942. */
  45943. maximumThickness: number;
  45944. /**
  45945. * Defines the volume tint of the material.
  45946. * This is used for both translucency and scattering.
  45947. */
  45948. tintColor: Color3;
  45949. /**
  45950. * Defines the distance at which the tint color should be found in the media.
  45951. * This is used for refraction only.
  45952. */
  45953. tintColorAtDistance: number;
  45954. /**
  45955. * Defines how far each channel transmit through the media.
  45956. * It is defined as a color to simplify it selection.
  45957. */
  45958. diffusionDistance: Color3;
  45959. private _useMaskFromThicknessTexture;
  45960. /**
  45961. * Stores the intensity of the different subsurface effects in the thickness texture.
  45962. * * the green channel is the translucency intensity.
  45963. * * the blue channel is the scattering intensity.
  45964. * * the alpha channel is the refraction intensity.
  45965. */
  45966. useMaskFromThicknessTexture: boolean;
  45967. /** @hidden */
  45968. private _internalMarkAllSubMeshesAsTexturesDirty;
  45969. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45970. /**
  45971. * Instantiate a new istance of sub surface configuration.
  45972. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45973. */
  45974. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45975. /**
  45976. * Gets wehter the submesh is ready to be used or not.
  45977. * @param defines the list of "defines" to update.
  45978. * @param scene defines the scene the material belongs to.
  45979. * @returns - boolean indicating that the submesh is ready or not.
  45980. */
  45981. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  45982. /**
  45983. * Checks to see if a texture is used in the material.
  45984. * @param defines the list of "defines" to update.
  45985. * @param scene defines the scene to the material belongs to.
  45986. */
  45987. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  45988. /**
  45989. * Binds the material data.
  45990. * @param uniformBuffer defines the Uniform buffer to fill in.
  45991. * @param scene defines the scene the material belongs to.
  45992. * @param engine defines the engine the material belongs to.
  45993. * @param isFrozen defines wether the material is frozen or not.
  45994. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  45995. */
  45996. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  45997. /**
  45998. * Unbinds the material from the mesh.
  45999. * @param activeEffect defines the effect that should be unbound from.
  46000. * @returns true if unbound, otherwise false
  46001. */
  46002. unbind(activeEffect: Effect): boolean;
  46003. /**
  46004. * Returns the texture used for refraction or null if none is used.
  46005. * @param scene defines the scene the material belongs to.
  46006. * @returns - Refraction texture if present. If no refraction texture and refraction
  46007. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46008. */
  46009. private _getRefractionTexture;
  46010. /**
  46011. * Returns true if alpha blending should be disabled.
  46012. */
  46013. readonly disableAlphaBlending: boolean;
  46014. /**
  46015. * Fills the list of render target textures.
  46016. * @param renderTargets the list of render targets to update
  46017. */
  46018. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46019. /**
  46020. * Checks to see if a texture is used in the material.
  46021. * @param texture - Base texture to use.
  46022. * @returns - Boolean specifying if a texture is used in the material.
  46023. */
  46024. hasTexture(texture: BaseTexture): boolean;
  46025. /**
  46026. * Gets a boolean indicating that current material needs to register RTT
  46027. * @returns true if this uses a render target otherwise false.
  46028. */
  46029. hasRenderTargetTextures(): boolean;
  46030. /**
  46031. * Returns an array of the actively used textures.
  46032. * @param activeTextures Array of BaseTextures
  46033. */
  46034. getActiveTextures(activeTextures: BaseTexture[]): void;
  46035. /**
  46036. * Returns the animatable textures.
  46037. * @param animatables Array of animatable textures.
  46038. */
  46039. getAnimatables(animatables: IAnimatable[]): void;
  46040. /**
  46041. * Disposes the resources of the material.
  46042. * @param forceDisposeTextures - Forces the disposal of all textures.
  46043. */
  46044. dispose(forceDisposeTextures?: boolean): void;
  46045. /**
  46046. * Get the current class name of the texture useful for serialization or dynamic coding.
  46047. * @returns "PBRSubSurfaceConfiguration"
  46048. */
  46049. getClassName(): string;
  46050. /**
  46051. * Add fallbacks to the effect fallbacks list.
  46052. * @param defines defines the Base texture to use.
  46053. * @param fallbacks defines the current fallback list.
  46054. * @param currentRank defines the current fallback rank.
  46055. * @returns the new fallback rank.
  46056. */
  46057. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46058. /**
  46059. * Add the required uniforms to the current list.
  46060. * @param uniforms defines the current uniform list.
  46061. */
  46062. static AddUniforms(uniforms: string[]): void;
  46063. /**
  46064. * Add the required samplers to the current list.
  46065. * @param samplers defines the current sampler list.
  46066. */
  46067. static AddSamplers(samplers: string[]): void;
  46068. /**
  46069. * Add the required uniforms to the current buffer.
  46070. * @param uniformBuffer defines the current uniform buffer.
  46071. */
  46072. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46073. /**
  46074. * Makes a duplicate of the current configuration into another one.
  46075. * @param configuration define the config where to copy the info
  46076. */
  46077. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46078. /**
  46079. * Serializes this Sub Surface configuration.
  46080. * @returns - An object with the serialized config.
  46081. */
  46082. serialize(): any;
  46083. /**
  46084. * Parses a anisotropy Configuration from a serialized object.
  46085. * @param source - Serialized object.
  46086. * @param scene Defines the scene we are parsing for
  46087. * @param rootUrl Defines the rootUrl to load from
  46088. */
  46089. parse(source: any, scene: Scene, rootUrl: string): void;
  46090. }
  46091. }
  46092. declare module BABYLON {
  46093. /** @hidden */
  46094. export var pbrFragmentDeclaration: {
  46095. name: string;
  46096. shader: string;
  46097. };
  46098. }
  46099. declare module BABYLON {
  46100. /** @hidden */
  46101. export var pbrUboDeclaration: {
  46102. name: string;
  46103. shader: string;
  46104. };
  46105. }
  46106. declare module BABYLON {
  46107. /** @hidden */
  46108. export var pbrFragmentExtraDeclaration: {
  46109. name: string;
  46110. shader: string;
  46111. };
  46112. }
  46113. declare module BABYLON {
  46114. /** @hidden */
  46115. export var pbrFragmentSamplersDeclaration: {
  46116. name: string;
  46117. shader: string;
  46118. };
  46119. }
  46120. declare module BABYLON {
  46121. /** @hidden */
  46122. export var pbrHelperFunctions: {
  46123. name: string;
  46124. shader: string;
  46125. };
  46126. }
  46127. declare module BABYLON {
  46128. /** @hidden */
  46129. export var harmonicsFunctions: {
  46130. name: string;
  46131. shader: string;
  46132. };
  46133. }
  46134. declare module BABYLON {
  46135. /** @hidden */
  46136. export var pbrDirectLightingSetupFunctions: {
  46137. name: string;
  46138. shader: string;
  46139. };
  46140. }
  46141. declare module BABYLON {
  46142. /** @hidden */
  46143. export var pbrDirectLightingFalloffFunctions: {
  46144. name: string;
  46145. shader: string;
  46146. };
  46147. }
  46148. declare module BABYLON {
  46149. /** @hidden */
  46150. export var pbrBRDFFunctions: {
  46151. name: string;
  46152. shader: string;
  46153. };
  46154. }
  46155. declare module BABYLON {
  46156. /** @hidden */
  46157. export var pbrDirectLightingFunctions: {
  46158. name: string;
  46159. shader: string;
  46160. };
  46161. }
  46162. declare module BABYLON {
  46163. /** @hidden */
  46164. export var pbrIBLFunctions: {
  46165. name: string;
  46166. shader: string;
  46167. };
  46168. }
  46169. declare module BABYLON {
  46170. /** @hidden */
  46171. export var pbrDebug: {
  46172. name: string;
  46173. shader: string;
  46174. };
  46175. }
  46176. declare module BABYLON {
  46177. /** @hidden */
  46178. export var pbrPixelShader: {
  46179. name: string;
  46180. shader: string;
  46181. };
  46182. }
  46183. declare module BABYLON {
  46184. /** @hidden */
  46185. export var pbrVertexDeclaration: {
  46186. name: string;
  46187. shader: string;
  46188. };
  46189. }
  46190. declare module BABYLON {
  46191. /** @hidden */
  46192. export var pbrVertexShader: {
  46193. name: string;
  46194. shader: string;
  46195. };
  46196. }
  46197. declare module BABYLON {
  46198. /**
  46199. * Manages the defines for the PBR Material.
  46200. * @hidden
  46201. */
  46202. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46203. PBR: boolean;
  46204. MAINUV1: boolean;
  46205. MAINUV2: boolean;
  46206. UV1: boolean;
  46207. UV2: boolean;
  46208. ALBEDO: boolean;
  46209. ALBEDODIRECTUV: number;
  46210. VERTEXCOLOR: boolean;
  46211. AMBIENT: boolean;
  46212. AMBIENTDIRECTUV: number;
  46213. AMBIENTINGRAYSCALE: boolean;
  46214. OPACITY: boolean;
  46215. VERTEXALPHA: boolean;
  46216. OPACITYDIRECTUV: number;
  46217. OPACITYRGB: boolean;
  46218. ALPHATEST: boolean;
  46219. DEPTHPREPASS: boolean;
  46220. ALPHABLEND: boolean;
  46221. ALPHAFROMALBEDO: boolean;
  46222. ALPHATESTVALUE: string;
  46223. SPECULAROVERALPHA: boolean;
  46224. RADIANCEOVERALPHA: boolean;
  46225. ALPHAFRESNEL: boolean;
  46226. LINEARALPHAFRESNEL: boolean;
  46227. PREMULTIPLYALPHA: boolean;
  46228. EMISSIVE: boolean;
  46229. EMISSIVEDIRECTUV: number;
  46230. REFLECTIVITY: boolean;
  46231. REFLECTIVITYDIRECTUV: number;
  46232. SPECULARTERM: boolean;
  46233. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46234. MICROSURFACEAUTOMATIC: boolean;
  46235. LODBASEDMICROSFURACE: boolean;
  46236. MICROSURFACEMAP: boolean;
  46237. MICROSURFACEMAPDIRECTUV: number;
  46238. METALLICWORKFLOW: boolean;
  46239. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46240. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46241. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46242. AOSTOREINMETALMAPRED: boolean;
  46243. ENVIRONMENTBRDF: boolean;
  46244. ENVIRONMENTBRDF_RGBD: boolean;
  46245. NORMAL: boolean;
  46246. TANGENT: boolean;
  46247. BUMP: boolean;
  46248. BUMPDIRECTUV: number;
  46249. OBJECTSPACE_NORMALMAP: boolean;
  46250. PARALLAX: boolean;
  46251. PARALLAXOCCLUSION: boolean;
  46252. NORMALXYSCALE: boolean;
  46253. LIGHTMAP: boolean;
  46254. LIGHTMAPDIRECTUV: number;
  46255. USELIGHTMAPASSHADOWMAP: boolean;
  46256. GAMMALIGHTMAP: boolean;
  46257. RGBDLIGHTMAP: boolean;
  46258. REFLECTION: boolean;
  46259. REFLECTIONMAP_3D: boolean;
  46260. REFLECTIONMAP_SPHERICAL: boolean;
  46261. REFLECTIONMAP_PLANAR: boolean;
  46262. REFLECTIONMAP_CUBIC: boolean;
  46263. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46264. REFLECTIONMAP_PROJECTION: boolean;
  46265. REFLECTIONMAP_SKYBOX: boolean;
  46266. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46267. REFLECTIONMAP_EXPLICIT: boolean;
  46268. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46269. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46270. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46271. INVERTCUBICMAP: boolean;
  46272. USESPHERICALFROMREFLECTIONMAP: boolean;
  46273. USEIRRADIANCEMAP: boolean;
  46274. SPHERICAL_HARMONICS: boolean;
  46275. USESPHERICALINVERTEX: boolean;
  46276. REFLECTIONMAP_OPPOSITEZ: boolean;
  46277. LODINREFLECTIONALPHA: boolean;
  46278. GAMMAREFLECTION: boolean;
  46279. RGBDREFLECTION: boolean;
  46280. LINEARSPECULARREFLECTION: boolean;
  46281. RADIANCEOCCLUSION: boolean;
  46282. HORIZONOCCLUSION: boolean;
  46283. INSTANCES: boolean;
  46284. NUM_BONE_INFLUENCERS: number;
  46285. BonesPerMesh: number;
  46286. BONETEXTURE: boolean;
  46287. NONUNIFORMSCALING: boolean;
  46288. MORPHTARGETS: boolean;
  46289. MORPHTARGETS_NORMAL: boolean;
  46290. MORPHTARGETS_TANGENT: boolean;
  46291. MORPHTARGETS_UV: boolean;
  46292. NUM_MORPH_INFLUENCERS: number;
  46293. IMAGEPROCESSING: boolean;
  46294. VIGNETTE: boolean;
  46295. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46296. VIGNETTEBLENDMODEOPAQUE: boolean;
  46297. TONEMAPPING: boolean;
  46298. TONEMAPPING_ACES: boolean;
  46299. CONTRAST: boolean;
  46300. COLORCURVES: boolean;
  46301. COLORGRADING: boolean;
  46302. COLORGRADING3D: boolean;
  46303. SAMPLER3DGREENDEPTH: boolean;
  46304. SAMPLER3DBGRMAP: boolean;
  46305. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46306. EXPOSURE: boolean;
  46307. MULTIVIEW: boolean;
  46308. USEPHYSICALLIGHTFALLOFF: boolean;
  46309. USEGLTFLIGHTFALLOFF: boolean;
  46310. TWOSIDEDLIGHTING: boolean;
  46311. SHADOWFLOAT: boolean;
  46312. CLIPPLANE: boolean;
  46313. CLIPPLANE2: boolean;
  46314. CLIPPLANE3: boolean;
  46315. CLIPPLANE4: boolean;
  46316. POINTSIZE: boolean;
  46317. FOG: boolean;
  46318. LOGARITHMICDEPTH: boolean;
  46319. FORCENORMALFORWARD: boolean;
  46320. SPECULARAA: boolean;
  46321. CLEARCOAT: boolean;
  46322. CLEARCOAT_DEFAULTIOR: boolean;
  46323. CLEARCOAT_TEXTURE: boolean;
  46324. CLEARCOAT_TEXTUREDIRECTUV: number;
  46325. CLEARCOAT_BUMP: boolean;
  46326. CLEARCOAT_BUMPDIRECTUV: number;
  46327. CLEARCOAT_TINT: boolean;
  46328. CLEARCOAT_TINT_TEXTURE: boolean;
  46329. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46330. ANISOTROPIC: boolean;
  46331. ANISOTROPIC_TEXTURE: boolean;
  46332. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46333. BRDF_V_HEIGHT_CORRELATED: boolean;
  46334. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46335. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46336. SHEEN: boolean;
  46337. SHEEN_TEXTURE: boolean;
  46338. SHEEN_TEXTUREDIRECTUV: number;
  46339. SHEEN_LINKWITHALBEDO: boolean;
  46340. SUBSURFACE: boolean;
  46341. SS_REFRACTION: boolean;
  46342. SS_TRANSLUCENCY: boolean;
  46343. SS_SCATERRING: boolean;
  46344. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46345. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46346. SS_REFRACTIONMAP_3D: boolean;
  46347. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46348. SS_LODINREFRACTIONALPHA: boolean;
  46349. SS_GAMMAREFRACTION: boolean;
  46350. SS_RGBDREFRACTION: boolean;
  46351. SS_LINEARSPECULARREFRACTION: boolean;
  46352. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46353. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46354. UNLIT: boolean;
  46355. DEBUGMODE: number;
  46356. /**
  46357. * Initializes the PBR Material defines.
  46358. */
  46359. constructor();
  46360. /**
  46361. * Resets the PBR Material defines.
  46362. */
  46363. reset(): void;
  46364. }
  46365. /**
  46366. * The Physically based material base class of BJS.
  46367. *
  46368. * This offers the main features of a standard PBR material.
  46369. * For more information, please refer to the documentation :
  46370. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46371. */
  46372. export abstract class PBRBaseMaterial extends PushMaterial {
  46373. /**
  46374. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46375. */
  46376. static readonly PBRMATERIAL_OPAQUE: number;
  46377. /**
  46378. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46379. */
  46380. static readonly PBRMATERIAL_ALPHATEST: number;
  46381. /**
  46382. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46383. */
  46384. static readonly PBRMATERIAL_ALPHABLEND: number;
  46385. /**
  46386. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46387. * They are also discarded below the alpha cutoff threshold to improve performances.
  46388. */
  46389. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46390. /**
  46391. * Defines the default value of how much AO map is occluding the analytical lights
  46392. * (point spot...).
  46393. */
  46394. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46395. /**
  46396. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46397. */
  46398. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46399. /**
  46400. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46401. * to enhance interoperability with other engines.
  46402. */
  46403. static readonly LIGHTFALLOFF_GLTF: number;
  46404. /**
  46405. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46406. * to enhance interoperability with other materials.
  46407. */
  46408. static readonly LIGHTFALLOFF_STANDARD: number;
  46409. /**
  46410. * Intensity of the direct lights e.g. the four lights available in your scene.
  46411. * This impacts both the direct diffuse and specular highlights.
  46412. */
  46413. protected _directIntensity: number;
  46414. /**
  46415. * Intensity of the emissive part of the material.
  46416. * This helps controlling the emissive effect without modifying the emissive color.
  46417. */
  46418. protected _emissiveIntensity: number;
  46419. /**
  46420. * Intensity of the environment e.g. how much the environment will light the object
  46421. * either through harmonics for rough material or through the refelction for shiny ones.
  46422. */
  46423. protected _environmentIntensity: number;
  46424. /**
  46425. * This is a special control allowing the reduction of the specular highlights coming from the
  46426. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46427. */
  46428. protected _specularIntensity: number;
  46429. /**
  46430. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46431. */
  46432. private _lightingInfos;
  46433. /**
  46434. * Debug Control allowing disabling the bump map on this material.
  46435. */
  46436. protected _disableBumpMap: boolean;
  46437. /**
  46438. * AKA Diffuse Texture in standard nomenclature.
  46439. */
  46440. protected _albedoTexture: Nullable<BaseTexture>;
  46441. /**
  46442. * AKA Occlusion Texture in other nomenclature.
  46443. */
  46444. protected _ambientTexture: Nullable<BaseTexture>;
  46445. /**
  46446. * AKA Occlusion Texture Intensity in other nomenclature.
  46447. */
  46448. protected _ambientTextureStrength: number;
  46449. /**
  46450. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46451. * 1 means it completely occludes it
  46452. * 0 mean it has no impact
  46453. */
  46454. protected _ambientTextureImpactOnAnalyticalLights: number;
  46455. /**
  46456. * Stores the alpha values in a texture.
  46457. */
  46458. protected _opacityTexture: Nullable<BaseTexture>;
  46459. /**
  46460. * Stores the reflection values in a texture.
  46461. */
  46462. protected _reflectionTexture: Nullable<BaseTexture>;
  46463. /**
  46464. * Stores the emissive values in a texture.
  46465. */
  46466. protected _emissiveTexture: Nullable<BaseTexture>;
  46467. /**
  46468. * AKA Specular texture in other nomenclature.
  46469. */
  46470. protected _reflectivityTexture: Nullable<BaseTexture>;
  46471. /**
  46472. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46473. */
  46474. protected _metallicTexture: Nullable<BaseTexture>;
  46475. /**
  46476. * Specifies the metallic scalar of the metallic/roughness workflow.
  46477. * Can also be used to scale the metalness values of the metallic texture.
  46478. */
  46479. protected _metallic: Nullable<number>;
  46480. /**
  46481. * Specifies the roughness scalar of the metallic/roughness workflow.
  46482. * Can also be used to scale the roughness values of the metallic texture.
  46483. */
  46484. protected _roughness: Nullable<number>;
  46485. /**
  46486. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46487. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46488. */
  46489. protected _microSurfaceTexture: Nullable<BaseTexture>;
  46490. /**
  46491. * Stores surface normal data used to displace a mesh in a texture.
  46492. */
  46493. protected _bumpTexture: Nullable<BaseTexture>;
  46494. /**
  46495. * Stores the pre-calculated light information of a mesh in a texture.
  46496. */
  46497. protected _lightmapTexture: Nullable<BaseTexture>;
  46498. /**
  46499. * The color of a material in ambient lighting.
  46500. */
  46501. protected _ambientColor: Color3;
  46502. /**
  46503. * AKA Diffuse Color in other nomenclature.
  46504. */
  46505. protected _albedoColor: Color3;
  46506. /**
  46507. * AKA Specular Color in other nomenclature.
  46508. */
  46509. protected _reflectivityColor: Color3;
  46510. /**
  46511. * The color applied when light is reflected from a material.
  46512. */
  46513. protected _reflectionColor: Color3;
  46514. /**
  46515. * The color applied when light is emitted from a material.
  46516. */
  46517. protected _emissiveColor: Color3;
  46518. /**
  46519. * AKA Glossiness in other nomenclature.
  46520. */
  46521. protected _microSurface: number;
  46522. /**
  46523. * Specifies that the material will use the light map as a show map.
  46524. */
  46525. protected _useLightmapAsShadowmap: boolean;
  46526. /**
  46527. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46528. * makes the reflect vector face the model (under horizon).
  46529. */
  46530. protected _useHorizonOcclusion: boolean;
  46531. /**
  46532. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46533. * too much the area relying on ambient texture to define their ambient occlusion.
  46534. */
  46535. protected _useRadianceOcclusion: boolean;
  46536. /**
  46537. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46538. */
  46539. protected _useAlphaFromAlbedoTexture: boolean;
  46540. /**
  46541. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46542. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46543. */
  46544. protected _useSpecularOverAlpha: boolean;
  46545. /**
  46546. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46547. */
  46548. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46549. /**
  46550. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46551. */
  46552. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46553. /**
  46554. * Specifies if the metallic texture contains the roughness information in its green channel.
  46555. */
  46556. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46557. /**
  46558. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46559. */
  46560. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46561. /**
  46562. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46563. */
  46564. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46565. /**
  46566. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46567. */
  46568. protected _useAmbientInGrayScale: boolean;
  46569. /**
  46570. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46571. * The material will try to infer what glossiness each pixel should be.
  46572. */
  46573. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46574. /**
  46575. * Defines the falloff type used in this material.
  46576. * It by default is Physical.
  46577. */
  46578. protected _lightFalloff: number;
  46579. /**
  46580. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46581. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46582. */
  46583. protected _useRadianceOverAlpha: boolean;
  46584. /**
  46585. * Allows using an object space normal map (instead of tangent space).
  46586. */
  46587. protected _useObjectSpaceNormalMap: boolean;
  46588. /**
  46589. * Allows using the bump map in parallax mode.
  46590. */
  46591. protected _useParallax: boolean;
  46592. /**
  46593. * Allows using the bump map in parallax occlusion mode.
  46594. */
  46595. protected _useParallaxOcclusion: boolean;
  46596. /**
  46597. * Controls the scale bias of the parallax mode.
  46598. */
  46599. protected _parallaxScaleBias: number;
  46600. /**
  46601. * If sets to true, disables all the lights affecting the material.
  46602. */
  46603. protected _disableLighting: boolean;
  46604. /**
  46605. * Number of Simultaneous lights allowed on the material.
  46606. */
  46607. protected _maxSimultaneousLights: number;
  46608. /**
  46609. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46610. */
  46611. protected _invertNormalMapX: boolean;
  46612. /**
  46613. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46614. */
  46615. protected _invertNormalMapY: boolean;
  46616. /**
  46617. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46618. */
  46619. protected _twoSidedLighting: boolean;
  46620. /**
  46621. * Defines the alpha limits in alpha test mode.
  46622. */
  46623. protected _alphaCutOff: number;
  46624. /**
  46625. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46626. */
  46627. protected _forceAlphaTest: boolean;
  46628. /**
  46629. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46630. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46631. */
  46632. protected _useAlphaFresnel: boolean;
  46633. /**
  46634. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46635. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46636. */
  46637. protected _useLinearAlphaFresnel: boolean;
  46638. /**
  46639. * The transparency mode of the material.
  46640. */
  46641. protected _transparencyMode: Nullable<number>;
  46642. /**
  46643. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46644. * from cos thetav and roughness:
  46645. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46646. */
  46647. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46648. /**
  46649. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46650. */
  46651. protected _forceIrradianceInFragment: boolean;
  46652. /**
  46653. * Force normal to face away from face.
  46654. */
  46655. protected _forceNormalForward: boolean;
  46656. /**
  46657. * Enables specular anti aliasing in the PBR shader.
  46658. * It will both interacts on the Geometry for analytical and IBL lighting.
  46659. * It also prefilter the roughness map based on the bump values.
  46660. */
  46661. protected _enableSpecularAntiAliasing: boolean;
  46662. /**
  46663. * Default configuration related to image processing available in the PBR Material.
  46664. */
  46665. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46666. /**
  46667. * Keep track of the image processing observer to allow dispose and replace.
  46668. */
  46669. private _imageProcessingObserver;
  46670. /**
  46671. * Attaches a new image processing configuration to the PBR Material.
  46672. * @param configuration
  46673. */
  46674. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46675. /**
  46676. * Stores the available render targets.
  46677. */
  46678. private _renderTargets;
  46679. /**
  46680. * Sets the global ambient color for the material used in lighting calculations.
  46681. */
  46682. private _globalAmbientColor;
  46683. /**
  46684. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46685. */
  46686. private _useLogarithmicDepth;
  46687. /**
  46688. * If set to true, no lighting calculations will be applied.
  46689. */
  46690. private _unlit;
  46691. private _debugMode;
  46692. /**
  46693. * @hidden
  46694. * This is reserved for the inspector.
  46695. * Defines the material debug mode.
  46696. * It helps seeing only some components of the material while troubleshooting.
  46697. */
  46698. debugMode: number;
  46699. /**
  46700. * @hidden
  46701. * This is reserved for the inspector.
  46702. * Specify from where on screen the debug mode should start.
  46703. * The value goes from -1 (full screen) to 1 (not visible)
  46704. * It helps with side by side comparison against the final render
  46705. * This defaults to -1
  46706. */
  46707. private debugLimit;
  46708. /**
  46709. * @hidden
  46710. * This is reserved for the inspector.
  46711. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46712. * You can use the factor to better multiply the final value.
  46713. */
  46714. private debugFactor;
  46715. /**
  46716. * Defines the clear coat layer parameters for the material.
  46717. */
  46718. readonly clearCoat: PBRClearCoatConfiguration;
  46719. /**
  46720. * Defines the anisotropic parameters for the material.
  46721. */
  46722. readonly anisotropy: PBRAnisotropicConfiguration;
  46723. /**
  46724. * Defines the BRDF parameters for the material.
  46725. */
  46726. readonly brdf: PBRBRDFConfiguration;
  46727. /**
  46728. * Defines the Sheen parameters for the material.
  46729. */
  46730. readonly sheen: PBRSheenConfiguration;
  46731. /**
  46732. * Defines the SubSurface parameters for the material.
  46733. */
  46734. readonly subSurface: PBRSubSurfaceConfiguration;
  46735. /**
  46736. * Custom callback helping to override the default shader used in the material.
  46737. */
  46738. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46739. protected _rebuildInParallel: boolean;
  46740. /**
  46741. * Instantiates a new PBRMaterial instance.
  46742. *
  46743. * @param name The material name
  46744. * @param scene The scene the material will be use in.
  46745. */
  46746. constructor(name: string, scene: Scene);
  46747. /**
  46748. * Gets a boolean indicating that current material needs to register RTT
  46749. */
  46750. readonly hasRenderTargetTextures: boolean;
  46751. /**
  46752. * Gets the name of the material class.
  46753. */
  46754. getClassName(): string;
  46755. /**
  46756. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46757. */
  46758. /**
  46759. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46760. */
  46761. useLogarithmicDepth: boolean;
  46762. /**
  46763. * Gets the current transparency mode.
  46764. */
  46765. /**
  46766. * Sets the transparency mode of the material.
  46767. *
  46768. * | Value | Type | Description |
  46769. * | ----- | ----------------------------------- | ----------- |
  46770. * | 0 | OPAQUE | |
  46771. * | 1 | ALPHATEST | |
  46772. * | 2 | ALPHABLEND | |
  46773. * | 3 | ALPHATESTANDBLEND | |
  46774. *
  46775. */
  46776. transparencyMode: Nullable<number>;
  46777. /**
  46778. * Returns true if alpha blending should be disabled.
  46779. */
  46780. private readonly _disableAlphaBlending;
  46781. /**
  46782. * Specifies whether or not this material should be rendered in alpha blend mode.
  46783. */
  46784. needAlphaBlending(): boolean;
  46785. /**
  46786. * Specifies if the mesh will require alpha blending.
  46787. * @param mesh - BJS mesh.
  46788. */
  46789. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46790. /**
  46791. * Specifies whether or not this material should be rendered in alpha test mode.
  46792. */
  46793. needAlphaTesting(): boolean;
  46794. /**
  46795. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46796. */
  46797. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46798. /**
  46799. * Gets the texture used for the alpha test.
  46800. */
  46801. getAlphaTestTexture(): Nullable<BaseTexture>;
  46802. /**
  46803. * Specifies that the submesh is ready to be used.
  46804. * @param mesh - BJS mesh.
  46805. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46806. * @param useInstances - Specifies that instances should be used.
  46807. * @returns - boolean indicating that the submesh is ready or not.
  46808. */
  46809. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46810. /**
  46811. * Specifies if the material uses metallic roughness workflow.
  46812. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46813. */
  46814. isMetallicWorkflow(): boolean;
  46815. private _prepareEffect;
  46816. private _prepareDefines;
  46817. /**
  46818. * Force shader compilation
  46819. */
  46820. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46821. clipPlane: boolean;
  46822. }>): void;
  46823. /**
  46824. * Initializes the uniform buffer layout for the shader.
  46825. */
  46826. buildUniformLayout(): void;
  46827. /**
  46828. * Unbinds the material from the mesh
  46829. */
  46830. unbind(): void;
  46831. /**
  46832. * Binds the submesh data.
  46833. * @param world - The world matrix.
  46834. * @param mesh - The BJS mesh.
  46835. * @param subMesh - A submesh of the BJS mesh.
  46836. */
  46837. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46838. /**
  46839. * Returns the animatable textures.
  46840. * @returns - Array of animatable textures.
  46841. */
  46842. getAnimatables(): IAnimatable[];
  46843. /**
  46844. * Returns the texture used for reflections.
  46845. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46846. */
  46847. private _getReflectionTexture;
  46848. /**
  46849. * Returns an array of the actively used textures.
  46850. * @returns - Array of BaseTextures
  46851. */
  46852. getActiveTextures(): BaseTexture[];
  46853. /**
  46854. * Checks to see if a texture is used in the material.
  46855. * @param texture - Base texture to use.
  46856. * @returns - Boolean specifying if a texture is used in the material.
  46857. */
  46858. hasTexture(texture: BaseTexture): boolean;
  46859. /**
  46860. * Disposes the resources of the material.
  46861. * @param forceDisposeEffect - Forces the disposal of effects.
  46862. * @param forceDisposeTextures - Forces the disposal of all textures.
  46863. */
  46864. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46865. }
  46866. }
  46867. declare module BABYLON {
  46868. /**
  46869. * The Physically based material of BJS.
  46870. *
  46871. * This offers the main features of a standard PBR material.
  46872. * For more information, please refer to the documentation :
  46873. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46874. */
  46875. export class PBRMaterial extends PBRBaseMaterial {
  46876. /**
  46877. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46878. */
  46879. static readonly PBRMATERIAL_OPAQUE: number;
  46880. /**
  46881. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46882. */
  46883. static readonly PBRMATERIAL_ALPHATEST: number;
  46884. /**
  46885. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46886. */
  46887. static readonly PBRMATERIAL_ALPHABLEND: number;
  46888. /**
  46889. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46890. * They are also discarded below the alpha cutoff threshold to improve performances.
  46891. */
  46892. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46893. /**
  46894. * Defines the default value of how much AO map is occluding the analytical lights
  46895. * (point spot...).
  46896. */
  46897. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46898. /**
  46899. * Intensity of the direct lights e.g. the four lights available in your scene.
  46900. * This impacts both the direct diffuse and specular highlights.
  46901. */
  46902. directIntensity: number;
  46903. /**
  46904. * Intensity of the emissive part of the material.
  46905. * This helps controlling the emissive effect without modifying the emissive color.
  46906. */
  46907. emissiveIntensity: number;
  46908. /**
  46909. * Intensity of the environment e.g. how much the environment will light the object
  46910. * either through harmonics for rough material or through the refelction for shiny ones.
  46911. */
  46912. environmentIntensity: number;
  46913. /**
  46914. * This is a special control allowing the reduction of the specular highlights coming from the
  46915. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46916. */
  46917. specularIntensity: number;
  46918. /**
  46919. * Debug Control allowing disabling the bump map on this material.
  46920. */
  46921. disableBumpMap: boolean;
  46922. /**
  46923. * AKA Diffuse Texture in standard nomenclature.
  46924. */
  46925. albedoTexture: BaseTexture;
  46926. /**
  46927. * AKA Occlusion Texture in other nomenclature.
  46928. */
  46929. ambientTexture: BaseTexture;
  46930. /**
  46931. * AKA Occlusion Texture Intensity in other nomenclature.
  46932. */
  46933. ambientTextureStrength: number;
  46934. /**
  46935. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46936. * 1 means it completely occludes it
  46937. * 0 mean it has no impact
  46938. */
  46939. ambientTextureImpactOnAnalyticalLights: number;
  46940. /**
  46941. * Stores the alpha values in a texture.
  46942. */
  46943. opacityTexture: BaseTexture;
  46944. /**
  46945. * Stores the reflection values in a texture.
  46946. */
  46947. reflectionTexture: Nullable<BaseTexture>;
  46948. /**
  46949. * Stores the emissive values in a texture.
  46950. */
  46951. emissiveTexture: BaseTexture;
  46952. /**
  46953. * AKA Specular texture in other nomenclature.
  46954. */
  46955. reflectivityTexture: BaseTexture;
  46956. /**
  46957. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46958. */
  46959. metallicTexture: BaseTexture;
  46960. /**
  46961. * Specifies the metallic scalar of the metallic/roughness workflow.
  46962. * Can also be used to scale the metalness values of the metallic texture.
  46963. */
  46964. metallic: Nullable<number>;
  46965. /**
  46966. * Specifies the roughness scalar of the metallic/roughness workflow.
  46967. * Can also be used to scale the roughness values of the metallic texture.
  46968. */
  46969. roughness: Nullable<number>;
  46970. /**
  46971. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46972. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46973. */
  46974. microSurfaceTexture: BaseTexture;
  46975. /**
  46976. * Stores surface normal data used to displace a mesh in a texture.
  46977. */
  46978. bumpTexture: BaseTexture;
  46979. /**
  46980. * Stores the pre-calculated light information of a mesh in a texture.
  46981. */
  46982. lightmapTexture: BaseTexture;
  46983. /**
  46984. * Stores the refracted light information in a texture.
  46985. */
  46986. refractionTexture: Nullable<BaseTexture>;
  46987. /**
  46988. * The color of a material in ambient lighting.
  46989. */
  46990. ambientColor: Color3;
  46991. /**
  46992. * AKA Diffuse Color in other nomenclature.
  46993. */
  46994. albedoColor: Color3;
  46995. /**
  46996. * AKA Specular Color in other nomenclature.
  46997. */
  46998. reflectivityColor: Color3;
  46999. /**
  47000. * The color reflected from the material.
  47001. */
  47002. reflectionColor: Color3;
  47003. /**
  47004. * The color emitted from the material.
  47005. */
  47006. emissiveColor: Color3;
  47007. /**
  47008. * AKA Glossiness in other nomenclature.
  47009. */
  47010. microSurface: number;
  47011. /**
  47012. * source material index of refraction (IOR)' / 'destination material IOR.
  47013. */
  47014. indexOfRefraction: number;
  47015. /**
  47016. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47017. */
  47018. invertRefractionY: boolean;
  47019. /**
  47020. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47021. * Materials half opaque for instance using refraction could benefit from this control.
  47022. */
  47023. linkRefractionWithTransparency: boolean;
  47024. /**
  47025. * If true, the light map contains occlusion information instead of lighting info.
  47026. */
  47027. useLightmapAsShadowmap: boolean;
  47028. /**
  47029. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47030. */
  47031. useAlphaFromAlbedoTexture: boolean;
  47032. /**
  47033. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47034. */
  47035. forceAlphaTest: boolean;
  47036. /**
  47037. * Defines the alpha limits in alpha test mode.
  47038. */
  47039. alphaCutOff: number;
  47040. /**
  47041. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47042. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47043. */
  47044. useSpecularOverAlpha: boolean;
  47045. /**
  47046. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47047. */
  47048. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47049. /**
  47050. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47051. */
  47052. useRoughnessFromMetallicTextureAlpha: boolean;
  47053. /**
  47054. * Specifies if the metallic texture contains the roughness information in its green channel.
  47055. */
  47056. useRoughnessFromMetallicTextureGreen: boolean;
  47057. /**
  47058. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47059. */
  47060. useMetallnessFromMetallicTextureBlue: boolean;
  47061. /**
  47062. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47063. */
  47064. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47065. /**
  47066. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47067. */
  47068. useAmbientInGrayScale: boolean;
  47069. /**
  47070. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47071. * The material will try to infer what glossiness each pixel should be.
  47072. */
  47073. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47074. /**
  47075. * BJS is using an harcoded light falloff based on a manually sets up range.
  47076. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47077. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47078. */
  47079. /**
  47080. * BJS is using an harcoded light falloff based on a manually sets up range.
  47081. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47082. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47083. */
  47084. usePhysicalLightFalloff: boolean;
  47085. /**
  47086. * In order to support the falloff compatibility with gltf, a special mode has been added
  47087. * to reproduce the gltf light falloff.
  47088. */
  47089. /**
  47090. * In order to support the falloff compatibility with gltf, a special mode has been added
  47091. * to reproduce the gltf light falloff.
  47092. */
  47093. useGLTFLightFalloff: boolean;
  47094. /**
  47095. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47096. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47097. */
  47098. useRadianceOverAlpha: boolean;
  47099. /**
  47100. * Allows using an object space normal map (instead of tangent space).
  47101. */
  47102. useObjectSpaceNormalMap: boolean;
  47103. /**
  47104. * Allows using the bump map in parallax mode.
  47105. */
  47106. useParallax: boolean;
  47107. /**
  47108. * Allows using the bump map in parallax occlusion mode.
  47109. */
  47110. useParallaxOcclusion: boolean;
  47111. /**
  47112. * Controls the scale bias of the parallax mode.
  47113. */
  47114. parallaxScaleBias: number;
  47115. /**
  47116. * If sets to true, disables all the lights affecting the material.
  47117. */
  47118. disableLighting: boolean;
  47119. /**
  47120. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47121. */
  47122. forceIrradianceInFragment: boolean;
  47123. /**
  47124. * Number of Simultaneous lights allowed on the material.
  47125. */
  47126. maxSimultaneousLights: number;
  47127. /**
  47128. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47129. */
  47130. invertNormalMapX: boolean;
  47131. /**
  47132. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47133. */
  47134. invertNormalMapY: boolean;
  47135. /**
  47136. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47137. */
  47138. twoSidedLighting: boolean;
  47139. /**
  47140. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47141. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47142. */
  47143. useAlphaFresnel: boolean;
  47144. /**
  47145. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47146. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47147. */
  47148. useLinearAlphaFresnel: boolean;
  47149. /**
  47150. * Let user defines the brdf lookup texture used for IBL.
  47151. * A default 8bit version is embedded but you could point at :
  47152. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  47153. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47154. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  47155. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47156. */
  47157. environmentBRDFTexture: Nullable<BaseTexture>;
  47158. /**
  47159. * Force normal to face away from face.
  47160. */
  47161. forceNormalForward: boolean;
  47162. /**
  47163. * Enables specular anti aliasing in the PBR shader.
  47164. * It will both interacts on the Geometry for analytical and IBL lighting.
  47165. * It also prefilter the roughness map based on the bump values.
  47166. */
  47167. enableSpecularAntiAliasing: boolean;
  47168. /**
  47169. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47170. * makes the reflect vector face the model (under horizon).
  47171. */
  47172. useHorizonOcclusion: boolean;
  47173. /**
  47174. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47175. * too much the area relying on ambient texture to define their ambient occlusion.
  47176. */
  47177. useRadianceOcclusion: boolean;
  47178. /**
  47179. * If set to true, no lighting calculations will be applied.
  47180. */
  47181. unlit: boolean;
  47182. /**
  47183. * Gets the image processing configuration used either in this material.
  47184. */
  47185. /**
  47186. * Sets the Default image processing configuration used either in the this material.
  47187. *
  47188. * If sets to null, the scene one is in use.
  47189. */
  47190. imageProcessingConfiguration: ImageProcessingConfiguration;
  47191. /**
  47192. * Gets wether the color curves effect is enabled.
  47193. */
  47194. /**
  47195. * Sets wether the color curves effect is enabled.
  47196. */
  47197. cameraColorCurvesEnabled: boolean;
  47198. /**
  47199. * Gets wether the color grading effect is enabled.
  47200. */
  47201. /**
  47202. * Gets wether the color grading effect is enabled.
  47203. */
  47204. cameraColorGradingEnabled: boolean;
  47205. /**
  47206. * Gets wether tonemapping is enabled or not.
  47207. */
  47208. /**
  47209. * Sets wether tonemapping is enabled or not
  47210. */
  47211. cameraToneMappingEnabled: boolean;
  47212. /**
  47213. * The camera exposure used on this material.
  47214. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47215. * This corresponds to a photographic exposure.
  47216. */
  47217. /**
  47218. * The camera exposure used on this material.
  47219. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47220. * This corresponds to a photographic exposure.
  47221. */
  47222. cameraExposure: number;
  47223. /**
  47224. * Gets The camera contrast used on this material.
  47225. */
  47226. /**
  47227. * Sets The camera contrast used on this material.
  47228. */
  47229. cameraContrast: number;
  47230. /**
  47231. * Gets the Color Grading 2D Lookup Texture.
  47232. */
  47233. /**
  47234. * Sets the Color Grading 2D Lookup Texture.
  47235. */
  47236. cameraColorGradingTexture: Nullable<BaseTexture>;
  47237. /**
  47238. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47239. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47240. * 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;
  47241. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47242. */
  47243. /**
  47244. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47245. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47246. * 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;
  47247. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47248. */
  47249. cameraColorCurves: Nullable<ColorCurves>;
  47250. /**
  47251. * Instantiates a new PBRMaterial instance.
  47252. *
  47253. * @param name The material name
  47254. * @param scene The scene the material will be use in.
  47255. */
  47256. constructor(name: string, scene: Scene);
  47257. /**
  47258. * Returns the name of this material class.
  47259. */
  47260. getClassName(): string;
  47261. /**
  47262. * Makes a duplicate of the current material.
  47263. * @param name - name to use for the new material.
  47264. */
  47265. clone(name: string): PBRMaterial;
  47266. /**
  47267. * Serializes this PBR Material.
  47268. * @returns - An object with the serialized material.
  47269. */
  47270. serialize(): any;
  47271. /**
  47272. * Parses a PBR Material from a serialized object.
  47273. * @param source - Serialized object.
  47274. * @param scene - BJS scene instance.
  47275. * @param rootUrl - url for the scene object
  47276. * @returns - PBRMaterial
  47277. */
  47278. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47279. }
  47280. }
  47281. declare module BABYLON {
  47282. /**
  47283. * Direct draw surface info
  47284. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47285. */
  47286. export interface DDSInfo {
  47287. /**
  47288. * Width of the texture
  47289. */
  47290. width: number;
  47291. /**
  47292. * Width of the texture
  47293. */
  47294. height: number;
  47295. /**
  47296. * Number of Mipmaps for the texture
  47297. * @see https://en.wikipedia.org/wiki/Mipmap
  47298. */
  47299. mipmapCount: number;
  47300. /**
  47301. * If the textures format is a known fourCC format
  47302. * @see https://www.fourcc.org/
  47303. */
  47304. isFourCC: boolean;
  47305. /**
  47306. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47307. */
  47308. isRGB: boolean;
  47309. /**
  47310. * If the texture is a lumincance format
  47311. */
  47312. isLuminance: boolean;
  47313. /**
  47314. * If this is a cube texture
  47315. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47316. */
  47317. isCube: boolean;
  47318. /**
  47319. * If the texture is a compressed format eg. FOURCC_DXT1
  47320. */
  47321. isCompressed: boolean;
  47322. /**
  47323. * The dxgiFormat of the texture
  47324. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47325. */
  47326. dxgiFormat: number;
  47327. /**
  47328. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47329. */
  47330. textureType: number;
  47331. /**
  47332. * Sphericle polynomial created for the dds texture
  47333. */
  47334. sphericalPolynomial?: SphericalPolynomial;
  47335. }
  47336. /**
  47337. * Class used to provide DDS decompression tools
  47338. */
  47339. export class DDSTools {
  47340. /**
  47341. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47342. */
  47343. static StoreLODInAlphaChannel: boolean;
  47344. /**
  47345. * Gets DDS information from an array buffer
  47346. * @param arrayBuffer defines the array buffer to read data from
  47347. * @returns the DDS information
  47348. */
  47349. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47350. private static _FloatView;
  47351. private static _Int32View;
  47352. private static _ToHalfFloat;
  47353. private static _FromHalfFloat;
  47354. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47355. private static _GetHalfFloatRGBAArrayBuffer;
  47356. private static _GetFloatRGBAArrayBuffer;
  47357. private static _GetFloatAsUIntRGBAArrayBuffer;
  47358. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47359. private static _GetRGBAArrayBuffer;
  47360. private static _ExtractLongWordOrder;
  47361. private static _GetRGBArrayBuffer;
  47362. private static _GetLuminanceArrayBuffer;
  47363. /**
  47364. * Uploads DDS Levels to a Babylon Texture
  47365. * @hidden
  47366. */
  47367. static UploadDDSLevels(engine: BaseEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47368. }
  47369. interface BaseEngine {
  47370. /**
  47371. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47372. * @param rootUrl defines the url where the file to load is located
  47373. * @param scene defines the current scene
  47374. * @param lodScale defines scale to apply to the mip map selection
  47375. * @param lodOffset defines offset to apply to the mip map selection
  47376. * @param onLoad defines an optional callback raised when the texture is loaded
  47377. * @param onError defines an optional callback raised if there is an issue to load the texture
  47378. * @param format defines the format of the data
  47379. * @param forcedExtension defines the extension to use to pick the right loader
  47380. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47381. * @returns the cube texture as an InternalTexture
  47382. */
  47383. 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;
  47384. }
  47385. }
  47386. declare module BABYLON {
  47387. /**
  47388. * Implementation of the DDS Texture Loader.
  47389. * @hidden
  47390. */
  47391. export class _DDSTextureLoader implements IInternalTextureLoader {
  47392. /**
  47393. * Defines wether the loader supports cascade loading the different faces.
  47394. */
  47395. readonly supportCascades: boolean;
  47396. /**
  47397. * This returns if the loader support the current file information.
  47398. * @param extension defines the file extension of the file being loaded
  47399. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47400. * @param fallback defines the fallback internal texture if any
  47401. * @param isBase64 defines whether the texture is encoded as a base64
  47402. * @param isBuffer defines whether the texture data are stored as a buffer
  47403. * @returns true if the loader can load the specified file
  47404. */
  47405. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47406. /**
  47407. * Transform the url before loading if required.
  47408. * @param rootUrl the url of the texture
  47409. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47410. * @returns the transformed texture
  47411. */
  47412. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47413. /**
  47414. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47415. * @param rootUrl the url of the texture
  47416. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47417. * @returns the fallback texture
  47418. */
  47419. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47420. /**
  47421. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47422. * @param data contains the texture data
  47423. * @param texture defines the BabylonJS internal texture
  47424. * @param createPolynomials will be true if polynomials have been requested
  47425. * @param onLoad defines the callback to trigger once the texture is ready
  47426. * @param onError defines the callback to trigger in case of error
  47427. */
  47428. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47429. /**
  47430. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47431. * @param data contains the texture data
  47432. * @param texture defines the BabylonJS internal texture
  47433. * @param callback defines the method to call once ready to upload
  47434. */
  47435. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47436. }
  47437. }
  47438. declare module BABYLON {
  47439. /**
  47440. * Implementation of the ENV Texture Loader.
  47441. * @hidden
  47442. */
  47443. export class _ENVTextureLoader implements IInternalTextureLoader {
  47444. /**
  47445. * Defines wether the loader supports cascade loading the different faces.
  47446. */
  47447. readonly supportCascades: boolean;
  47448. /**
  47449. * This returns if the loader support the current file information.
  47450. * @param extension defines the file extension of the file being loaded
  47451. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47452. * @param fallback defines the fallback internal texture if any
  47453. * @param isBase64 defines whether the texture is encoded as a base64
  47454. * @param isBuffer defines whether the texture data are stored as a buffer
  47455. * @returns true if the loader can load the specified file
  47456. */
  47457. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47458. /**
  47459. * Transform the url before loading if required.
  47460. * @param rootUrl the url of the texture
  47461. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47462. * @returns the transformed texture
  47463. */
  47464. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47465. /**
  47466. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47467. * @param rootUrl the url of the texture
  47468. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47469. * @returns the fallback texture
  47470. */
  47471. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47472. /**
  47473. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47474. * @param data contains the texture data
  47475. * @param texture defines the BabylonJS internal texture
  47476. * @param createPolynomials will be true if polynomials have been requested
  47477. * @param onLoad defines the callback to trigger once the texture is ready
  47478. * @param onError defines the callback to trigger in case of error
  47479. */
  47480. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47481. /**
  47482. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47483. * @param data contains the texture data
  47484. * @param texture defines the BabylonJS internal texture
  47485. * @param callback defines the method to call once ready to upload
  47486. */
  47487. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47488. }
  47489. }
  47490. declare module BABYLON {
  47491. /**
  47492. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47493. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47494. */
  47495. export class KhronosTextureContainer {
  47496. /** contents of the KTX container file */
  47497. arrayBuffer: any;
  47498. private static HEADER_LEN;
  47499. private static COMPRESSED_2D;
  47500. private static COMPRESSED_3D;
  47501. private static TEX_2D;
  47502. private static TEX_3D;
  47503. /**
  47504. * Gets the openGL type
  47505. */
  47506. glType: number;
  47507. /**
  47508. * Gets the openGL type size
  47509. */
  47510. glTypeSize: number;
  47511. /**
  47512. * Gets the openGL format
  47513. */
  47514. glFormat: number;
  47515. /**
  47516. * Gets the openGL internal format
  47517. */
  47518. glInternalFormat: number;
  47519. /**
  47520. * Gets the base internal format
  47521. */
  47522. glBaseInternalFormat: number;
  47523. /**
  47524. * Gets image width in pixel
  47525. */
  47526. pixelWidth: number;
  47527. /**
  47528. * Gets image height in pixel
  47529. */
  47530. pixelHeight: number;
  47531. /**
  47532. * Gets image depth in pixels
  47533. */
  47534. pixelDepth: number;
  47535. /**
  47536. * Gets the number of array elements
  47537. */
  47538. numberOfArrayElements: number;
  47539. /**
  47540. * Gets the number of faces
  47541. */
  47542. numberOfFaces: number;
  47543. /**
  47544. * Gets the number of mipmap levels
  47545. */
  47546. numberOfMipmapLevels: number;
  47547. /**
  47548. * Gets the bytes of key value data
  47549. */
  47550. bytesOfKeyValueData: number;
  47551. /**
  47552. * Gets the load type
  47553. */
  47554. loadType: number;
  47555. /**
  47556. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47557. */
  47558. isInvalid: boolean;
  47559. /**
  47560. * Creates a new KhronosTextureContainer
  47561. * @param arrayBuffer contents of the KTX container file
  47562. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47563. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47564. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47565. */
  47566. constructor(
  47567. /** contents of the KTX container file */
  47568. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47569. /**
  47570. * Uploads KTX content to a Babylon Texture.
  47571. * It is assumed that the texture has already been created & is currently bound
  47572. * @hidden
  47573. */
  47574. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47575. private _upload2DCompressedLevels;
  47576. }
  47577. }
  47578. declare module BABYLON {
  47579. /**
  47580. * Implementation of the KTX Texture Loader.
  47581. * @hidden
  47582. */
  47583. export class _KTXTextureLoader implements IInternalTextureLoader {
  47584. /**
  47585. * Defines wether the loader supports cascade loading the different faces.
  47586. */
  47587. readonly supportCascades: boolean;
  47588. /**
  47589. * This returns if the loader support the current file information.
  47590. * @param extension defines the file extension of the file being loaded
  47591. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47592. * @param fallback defines the fallback internal texture if any
  47593. * @param isBase64 defines whether the texture is encoded as a base64
  47594. * @param isBuffer defines whether the texture data are stored as a buffer
  47595. * @returns true if the loader can load the specified file
  47596. */
  47597. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47598. /**
  47599. * Transform the url before loading if required.
  47600. * @param rootUrl the url of the texture
  47601. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47602. * @returns the transformed texture
  47603. */
  47604. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47605. /**
  47606. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47607. * @param rootUrl the url of the texture
  47608. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47609. * @returns the fallback texture
  47610. */
  47611. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47612. /**
  47613. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47614. * @param data contains the texture data
  47615. * @param texture defines the BabylonJS internal texture
  47616. * @param createPolynomials will be true if polynomials have been requested
  47617. * @param onLoad defines the callback to trigger once the texture is ready
  47618. * @param onError defines the callback to trigger in case of error
  47619. */
  47620. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47621. /**
  47622. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47623. * @param data contains the texture data
  47624. * @param texture defines the BabylonJS internal texture
  47625. * @param callback defines the method to call once ready to upload
  47626. */
  47627. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47628. }
  47629. }
  47630. declare module BABYLON {
  47631. /**
  47632. * Options for the default xr helper
  47633. */
  47634. export class WebXRDefaultExperienceOptions {
  47635. /**
  47636. * Floor meshes that should be used for teleporting
  47637. */
  47638. floorMeshes: Array<AbstractMesh>;
  47639. }
  47640. /**
  47641. * Default experience which provides a similar setup to the previous webVRExperience
  47642. */
  47643. export class WebXRDefaultExperience {
  47644. /**
  47645. * Base experience
  47646. */
  47647. baseExperience: WebXRExperienceHelper;
  47648. /**
  47649. * Input experience extension
  47650. */
  47651. input: WebXRInput;
  47652. /**
  47653. * Loads the controller models
  47654. */
  47655. controllerModelLoader: WebXRControllerModelLoader;
  47656. /**
  47657. * Enables laser pointer and selection
  47658. */
  47659. pointerSelection: WebXRControllerPointerSelection;
  47660. /**
  47661. * Enables teleportation
  47662. */
  47663. teleportation: WebXRControllerTeleportation;
  47664. /**
  47665. * Enables ui for enetering/exiting xr
  47666. */
  47667. enterExitUI: WebXREnterExitUI;
  47668. /**
  47669. * Default output canvas xr should render to
  47670. */
  47671. outputCanvas: WebXRManagedOutputCanvas;
  47672. /**
  47673. * Creates the default xr experience
  47674. * @param scene scene
  47675. * @param options options for basic configuration
  47676. * @returns resulting WebXRDefaultExperience
  47677. */
  47678. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47679. private constructor();
  47680. /**
  47681. * DIsposes of the experience helper
  47682. */
  47683. dispose(): void;
  47684. }
  47685. }
  47686. declare module BABYLON {
  47687. /** @hidden */
  47688. export var _forceSceneHelpersToBundle: boolean;
  47689. interface Scene {
  47690. /**
  47691. * Creates a default light for the scene.
  47692. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47693. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47694. */
  47695. createDefaultLight(replace?: boolean): void;
  47696. /**
  47697. * Creates a default camera for the scene.
  47698. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47699. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47700. * @param replace has default false, when true replaces the active camera in the scene
  47701. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47702. */
  47703. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47704. /**
  47705. * Creates a default camera and a default light.
  47706. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47707. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47708. * @param replace has the default false, when true replaces the active camera/light in the scene
  47709. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47710. */
  47711. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47712. /**
  47713. * Creates a new sky box
  47714. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47715. * @param environmentTexture defines the texture to use as environment texture
  47716. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47717. * @param scale defines the overall scale of the skybox
  47718. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47719. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47720. * @returns a new mesh holding the sky box
  47721. */
  47722. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47723. /**
  47724. * Creates a new environment
  47725. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47726. * @param options defines the options you can use to configure the environment
  47727. * @returns the new EnvironmentHelper
  47728. */
  47729. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47730. /**
  47731. * Creates a new VREXperienceHelper
  47732. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47733. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47734. * @returns a new VREXperienceHelper
  47735. */
  47736. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47737. /**
  47738. * Creates a new WebXRDefaultExperience
  47739. * @see http://doc.babylonjs.com/how_to/webxr
  47740. * @param options experience options
  47741. * @returns a promise for a new WebXRDefaultExperience
  47742. */
  47743. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47744. }
  47745. }
  47746. declare module BABYLON {
  47747. /**
  47748. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47749. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47750. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47751. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47752. */
  47753. export class VideoDome extends TransformNode {
  47754. /**
  47755. * Define the video source as a Monoscopic panoramic 360 video.
  47756. */
  47757. static readonly MODE_MONOSCOPIC: number;
  47758. /**
  47759. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47760. */
  47761. static readonly MODE_TOPBOTTOM: number;
  47762. /**
  47763. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47764. */
  47765. static readonly MODE_SIDEBYSIDE: number;
  47766. private _halfDome;
  47767. private _useDirectMapping;
  47768. /**
  47769. * The video texture being displayed on the sphere
  47770. */
  47771. protected _videoTexture: VideoTexture;
  47772. /**
  47773. * Gets the video texture being displayed on the sphere
  47774. */
  47775. readonly videoTexture: VideoTexture;
  47776. /**
  47777. * The skybox material
  47778. */
  47779. protected _material: BackgroundMaterial;
  47780. /**
  47781. * The surface used for the skybox
  47782. */
  47783. protected _mesh: Mesh;
  47784. /**
  47785. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  47786. */
  47787. private _halfDomeMask;
  47788. /**
  47789. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47790. * Also see the options.resolution property.
  47791. */
  47792. fovMultiplier: number;
  47793. private _videoMode;
  47794. /**
  47795. * Gets or set the current video mode for the video. It can be:
  47796. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47797. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47798. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47799. */
  47800. videoMode: number;
  47801. /**
  47802. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  47803. *
  47804. */
  47805. /**
  47806. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  47807. */
  47808. halfDome: boolean;
  47809. /**
  47810. * Oberserver used in Stereoscopic VR Mode.
  47811. */
  47812. private _onBeforeCameraRenderObserver;
  47813. /**
  47814. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47815. * @param name Element's name, child elements will append suffixes for their own names.
  47816. * @param urlsOrVideo defines the url(s) or the video element to use
  47817. * @param options An object containing optional or exposed sub element properties
  47818. */
  47819. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47820. resolution?: number;
  47821. clickToPlay?: boolean;
  47822. autoPlay?: boolean;
  47823. loop?: boolean;
  47824. size?: number;
  47825. poster?: string;
  47826. faceForward?: boolean;
  47827. useDirectMapping?: boolean;
  47828. halfDomeMode?: boolean;
  47829. }, scene: Scene);
  47830. private _changeVideoMode;
  47831. /**
  47832. * Releases resources associated with this node.
  47833. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47834. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47835. */
  47836. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47837. }
  47838. }
  47839. declare module BABYLON {
  47840. /**
  47841. * This class can be used to get instrumentation data from a Babylon engine
  47842. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47843. */
  47844. export class EngineInstrumentation implements IDisposable {
  47845. /**
  47846. * Define the instrumented engine.
  47847. */
  47848. engine: Engine;
  47849. private _captureGPUFrameTime;
  47850. private _gpuFrameTimeToken;
  47851. private _gpuFrameTime;
  47852. private _captureShaderCompilationTime;
  47853. private _shaderCompilationTime;
  47854. private _onBeginFrameObserver;
  47855. private _onEndFrameObserver;
  47856. private _onBeforeShaderCompilationObserver;
  47857. private _onAfterShaderCompilationObserver;
  47858. /**
  47859. * Gets the perf counter used for GPU frame time
  47860. */
  47861. readonly gpuFrameTimeCounter: PerfCounter;
  47862. /**
  47863. * Gets the GPU frame time capture status
  47864. */
  47865. /**
  47866. * Enable or disable the GPU frame time capture
  47867. */
  47868. captureGPUFrameTime: boolean;
  47869. /**
  47870. * Gets the perf counter used for shader compilation time
  47871. */
  47872. readonly shaderCompilationTimeCounter: PerfCounter;
  47873. /**
  47874. * Gets the shader compilation time capture status
  47875. */
  47876. /**
  47877. * Enable or disable the shader compilation time capture
  47878. */
  47879. captureShaderCompilationTime: boolean;
  47880. /**
  47881. * Instantiates a new engine instrumentation.
  47882. * This class can be used to get instrumentation data from a Babylon engine
  47883. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47884. * @param engine Defines the engine to instrument
  47885. */
  47886. constructor(
  47887. /**
  47888. * Define the instrumented engine.
  47889. */
  47890. engine: Engine);
  47891. /**
  47892. * Dispose and release associated resources.
  47893. */
  47894. dispose(): void;
  47895. }
  47896. }
  47897. declare module BABYLON {
  47898. /**
  47899. * This class can be used to get instrumentation data from a Babylon engine
  47900. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47901. */
  47902. export class SceneInstrumentation implements IDisposable {
  47903. /**
  47904. * Defines the scene to instrument
  47905. */
  47906. scene: Scene;
  47907. private _captureActiveMeshesEvaluationTime;
  47908. private _activeMeshesEvaluationTime;
  47909. private _captureRenderTargetsRenderTime;
  47910. private _renderTargetsRenderTime;
  47911. private _captureFrameTime;
  47912. private _frameTime;
  47913. private _captureRenderTime;
  47914. private _renderTime;
  47915. private _captureInterFrameTime;
  47916. private _interFrameTime;
  47917. private _captureParticlesRenderTime;
  47918. private _particlesRenderTime;
  47919. private _captureSpritesRenderTime;
  47920. private _spritesRenderTime;
  47921. private _capturePhysicsTime;
  47922. private _physicsTime;
  47923. private _captureAnimationsTime;
  47924. private _animationsTime;
  47925. private _captureCameraRenderTime;
  47926. private _cameraRenderTime;
  47927. private _onBeforeActiveMeshesEvaluationObserver;
  47928. private _onAfterActiveMeshesEvaluationObserver;
  47929. private _onBeforeRenderTargetsRenderObserver;
  47930. private _onAfterRenderTargetsRenderObserver;
  47931. private _onAfterRenderObserver;
  47932. private _onBeforeDrawPhaseObserver;
  47933. private _onAfterDrawPhaseObserver;
  47934. private _onBeforeAnimationsObserver;
  47935. private _onBeforeParticlesRenderingObserver;
  47936. private _onAfterParticlesRenderingObserver;
  47937. private _onBeforeSpritesRenderingObserver;
  47938. private _onAfterSpritesRenderingObserver;
  47939. private _onBeforePhysicsObserver;
  47940. private _onAfterPhysicsObserver;
  47941. private _onAfterAnimationsObserver;
  47942. private _onBeforeCameraRenderObserver;
  47943. private _onAfterCameraRenderObserver;
  47944. /**
  47945. * Gets the perf counter used for active meshes evaluation time
  47946. */
  47947. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47948. /**
  47949. * Gets the active meshes evaluation time capture status
  47950. */
  47951. /**
  47952. * Enable or disable the active meshes evaluation time capture
  47953. */
  47954. captureActiveMeshesEvaluationTime: boolean;
  47955. /**
  47956. * Gets the perf counter used for render targets render time
  47957. */
  47958. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47959. /**
  47960. * Gets the render targets render time capture status
  47961. */
  47962. /**
  47963. * Enable or disable the render targets render time capture
  47964. */
  47965. captureRenderTargetsRenderTime: boolean;
  47966. /**
  47967. * Gets the perf counter used for particles render time
  47968. */
  47969. readonly particlesRenderTimeCounter: PerfCounter;
  47970. /**
  47971. * Gets the particles render time capture status
  47972. */
  47973. /**
  47974. * Enable or disable the particles render time capture
  47975. */
  47976. captureParticlesRenderTime: boolean;
  47977. /**
  47978. * Gets the perf counter used for sprites render time
  47979. */
  47980. readonly spritesRenderTimeCounter: PerfCounter;
  47981. /**
  47982. * Gets the sprites render time capture status
  47983. */
  47984. /**
  47985. * Enable or disable the sprites render time capture
  47986. */
  47987. captureSpritesRenderTime: boolean;
  47988. /**
  47989. * Gets the perf counter used for physics time
  47990. */
  47991. readonly physicsTimeCounter: PerfCounter;
  47992. /**
  47993. * Gets the physics time capture status
  47994. */
  47995. /**
  47996. * Enable or disable the physics time capture
  47997. */
  47998. capturePhysicsTime: boolean;
  47999. /**
  48000. * Gets the perf counter used for animations time
  48001. */
  48002. readonly animationsTimeCounter: PerfCounter;
  48003. /**
  48004. * Gets the animations time capture status
  48005. */
  48006. /**
  48007. * Enable or disable the animations time capture
  48008. */
  48009. captureAnimationsTime: boolean;
  48010. /**
  48011. * Gets the perf counter used for frame time capture
  48012. */
  48013. readonly frameTimeCounter: PerfCounter;
  48014. /**
  48015. * Gets the frame time capture status
  48016. */
  48017. /**
  48018. * Enable or disable the frame time capture
  48019. */
  48020. captureFrameTime: boolean;
  48021. /**
  48022. * Gets the perf counter used for inter-frames time capture
  48023. */
  48024. readonly interFrameTimeCounter: PerfCounter;
  48025. /**
  48026. * Gets the inter-frames time capture status
  48027. */
  48028. /**
  48029. * Enable or disable the inter-frames time capture
  48030. */
  48031. captureInterFrameTime: boolean;
  48032. /**
  48033. * Gets the perf counter used for render time capture
  48034. */
  48035. readonly renderTimeCounter: PerfCounter;
  48036. /**
  48037. * Gets the render time capture status
  48038. */
  48039. /**
  48040. * Enable or disable the render time capture
  48041. */
  48042. captureRenderTime: boolean;
  48043. /**
  48044. * Gets the perf counter used for camera render time capture
  48045. */
  48046. readonly cameraRenderTimeCounter: PerfCounter;
  48047. /**
  48048. * Gets the camera render time capture status
  48049. */
  48050. /**
  48051. * Enable or disable the camera render time capture
  48052. */
  48053. captureCameraRenderTime: boolean;
  48054. /**
  48055. * Gets the perf counter used for draw calls
  48056. */
  48057. readonly drawCallsCounter: PerfCounter;
  48058. /**
  48059. * Instantiates a new scene instrumentation.
  48060. * This class can be used to get instrumentation data from a Babylon engine
  48061. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48062. * @param scene Defines the scene to instrument
  48063. */
  48064. constructor(
  48065. /**
  48066. * Defines the scene to instrument
  48067. */
  48068. scene: Scene);
  48069. /**
  48070. * Dispose and release associated resources.
  48071. */
  48072. dispose(): void;
  48073. }
  48074. }
  48075. declare module BABYLON {
  48076. /** @hidden */
  48077. export var glowMapGenerationPixelShader: {
  48078. name: string;
  48079. shader: string;
  48080. };
  48081. }
  48082. declare module BABYLON {
  48083. /** @hidden */
  48084. export var glowMapGenerationVertexShader: {
  48085. name: string;
  48086. shader: string;
  48087. };
  48088. }
  48089. declare module BABYLON {
  48090. /**
  48091. * Effect layer options. This helps customizing the behaviour
  48092. * of the effect layer.
  48093. */
  48094. export interface IEffectLayerOptions {
  48095. /**
  48096. * Multiplication factor apply to the canvas size to compute the render target size
  48097. * used to generated the objects (the smaller the faster).
  48098. */
  48099. mainTextureRatio: number;
  48100. /**
  48101. * Enforces a fixed size texture to ensure effect stability across devices.
  48102. */
  48103. mainTextureFixedSize?: number;
  48104. /**
  48105. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48106. */
  48107. alphaBlendingMode: number;
  48108. /**
  48109. * The camera attached to the layer.
  48110. */
  48111. camera: Nullable<Camera>;
  48112. /**
  48113. * The rendering group to draw the layer in.
  48114. */
  48115. renderingGroupId: number;
  48116. }
  48117. /**
  48118. * The effect layer Helps adding post process effect blended with the main pass.
  48119. *
  48120. * This can be for instance use to generate glow or higlight effects on the scene.
  48121. *
  48122. * The effect layer class can not be used directly and is intented to inherited from to be
  48123. * customized per effects.
  48124. */
  48125. export abstract class EffectLayer {
  48126. private _vertexBuffers;
  48127. private _indexBuffer;
  48128. private _cachedDefines;
  48129. private _effectLayerMapGenerationEffect;
  48130. private _effectLayerOptions;
  48131. private _mergeEffect;
  48132. protected _scene: Scene;
  48133. protected _engine: Engine;
  48134. protected _maxSize: number;
  48135. protected _mainTextureDesiredSize: ISize;
  48136. protected _mainTexture: RenderTargetTexture;
  48137. protected _shouldRender: boolean;
  48138. protected _postProcesses: PostProcess[];
  48139. protected _textures: BaseTexture[];
  48140. protected _emissiveTextureAndColor: {
  48141. texture: Nullable<BaseTexture>;
  48142. color: Color4;
  48143. };
  48144. /**
  48145. * The name of the layer
  48146. */
  48147. name: string;
  48148. /**
  48149. * The clear color of the texture used to generate the glow map.
  48150. */
  48151. neutralColor: Color4;
  48152. /**
  48153. * Specifies wether the highlight layer is enabled or not.
  48154. */
  48155. isEnabled: boolean;
  48156. /**
  48157. * Gets the camera attached to the layer.
  48158. */
  48159. readonly camera: Nullable<Camera>;
  48160. /**
  48161. * Gets the rendering group id the layer should render in.
  48162. */
  48163. renderingGroupId: number;
  48164. /**
  48165. * An event triggered when the effect layer has been disposed.
  48166. */
  48167. onDisposeObservable: Observable<EffectLayer>;
  48168. /**
  48169. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48170. */
  48171. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48172. /**
  48173. * An event triggered when the generated texture is being merged in the scene.
  48174. */
  48175. onBeforeComposeObservable: Observable<EffectLayer>;
  48176. /**
  48177. * An event triggered when the generated texture has been merged in the scene.
  48178. */
  48179. onAfterComposeObservable: Observable<EffectLayer>;
  48180. /**
  48181. * An event triggered when the efffect layer changes its size.
  48182. */
  48183. onSizeChangedObservable: Observable<EffectLayer>;
  48184. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  48185. /**
  48186. * Instantiates a new effect Layer and references it in the scene.
  48187. * @param name The name of the layer
  48188. * @param scene The scene to use the layer in
  48189. */
  48190. constructor(
  48191. /** The Friendly of the effect in the scene */
  48192. name: string, scene: Scene);
  48193. /**
  48194. * Get the effect name of the layer.
  48195. * @return The effect name
  48196. */
  48197. abstract getEffectName(): string;
  48198. /**
  48199. * Checks for the readiness of the element composing the layer.
  48200. * @param subMesh the mesh to check for
  48201. * @param useInstances specify wether or not to use instances to render the mesh
  48202. * @return true if ready otherwise, false
  48203. */
  48204. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48205. /**
  48206. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48207. * @returns true if the effect requires stencil during the main canvas render pass.
  48208. */
  48209. abstract needStencil(): boolean;
  48210. /**
  48211. * Create the merge effect. This is the shader use to blit the information back
  48212. * to the main canvas at the end of the scene rendering.
  48213. * @returns The effect containing the shader used to merge the effect on the main canvas
  48214. */
  48215. protected abstract _createMergeEffect(): Effect;
  48216. /**
  48217. * Creates the render target textures and post processes used in the effect layer.
  48218. */
  48219. protected abstract _createTextureAndPostProcesses(): void;
  48220. /**
  48221. * Implementation specific of rendering the generating effect on the main canvas.
  48222. * @param effect The effect used to render through
  48223. */
  48224. protected abstract _internalRender(effect: Effect): void;
  48225. /**
  48226. * Sets the required values for both the emissive texture and and the main color.
  48227. */
  48228. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48229. /**
  48230. * Free any resources and references associated to a mesh.
  48231. * Internal use
  48232. * @param mesh The mesh to free.
  48233. */
  48234. abstract _disposeMesh(mesh: Mesh): void;
  48235. /**
  48236. * Serializes this layer (Glow or Highlight for example)
  48237. * @returns a serialized layer object
  48238. */
  48239. abstract serialize?(): any;
  48240. /**
  48241. * Initializes the effect layer with the required options.
  48242. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48243. */
  48244. protected _init(options: Partial<IEffectLayerOptions>): void;
  48245. /**
  48246. * Generates the index buffer of the full screen quad blending to the main canvas.
  48247. */
  48248. private _generateIndexBuffer;
  48249. /**
  48250. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48251. */
  48252. private _generateVertexBuffer;
  48253. /**
  48254. * Sets the main texture desired size which is the closest power of two
  48255. * of the engine canvas size.
  48256. */
  48257. private _setMainTextureSize;
  48258. /**
  48259. * Creates the main texture for the effect layer.
  48260. */
  48261. protected _createMainTexture(): void;
  48262. /**
  48263. * Adds specific effects defines.
  48264. * @param defines The defines to add specifics to.
  48265. */
  48266. protected _addCustomEffectDefines(defines: string[]): void;
  48267. /**
  48268. * Checks for the readiness of the element composing the layer.
  48269. * @param subMesh the mesh to check for
  48270. * @param useInstances specify wether or not to use instances to render the mesh
  48271. * @param emissiveTexture the associated emissive texture used to generate the glow
  48272. * @return true if ready otherwise, false
  48273. */
  48274. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48275. /**
  48276. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48277. */
  48278. render(): void;
  48279. /**
  48280. * Determine if a given mesh will be used in the current effect.
  48281. * @param mesh mesh to test
  48282. * @returns true if the mesh will be used
  48283. */
  48284. hasMesh(mesh: AbstractMesh): boolean;
  48285. /**
  48286. * Returns true if the layer contains information to display, otherwise false.
  48287. * @returns true if the glow layer should be rendered
  48288. */
  48289. shouldRender(): boolean;
  48290. /**
  48291. * Returns true if the mesh should render, otherwise false.
  48292. * @param mesh The mesh to render
  48293. * @returns true if it should render otherwise false
  48294. */
  48295. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48296. /**
  48297. * Returns true if the mesh can be rendered, otherwise false.
  48298. * @param mesh The mesh to render
  48299. * @param material The material used on the mesh
  48300. * @returns true if it can be rendered otherwise false
  48301. */
  48302. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48303. /**
  48304. * Returns true if the mesh should render, otherwise false.
  48305. * @param mesh The mesh to render
  48306. * @returns true if it should render otherwise false
  48307. */
  48308. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48309. /**
  48310. * Renders the submesh passed in parameter to the generation map.
  48311. */
  48312. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48313. /**
  48314. * Rebuild the required buffers.
  48315. * @hidden Internal use only.
  48316. */ private _rebuild(): void;
  48317. /**
  48318. * Dispose only the render target textures and post process.
  48319. */
  48320. private _disposeTextureAndPostProcesses;
  48321. /**
  48322. * Dispose the highlight layer and free resources.
  48323. */
  48324. dispose(): void;
  48325. /**
  48326. * Gets the class name of the effect layer
  48327. * @returns the string with the class name of the effect layer
  48328. */
  48329. getClassName(): string;
  48330. /**
  48331. * Creates an effect layer from parsed effect layer data
  48332. * @param parsedEffectLayer defines effect layer data
  48333. * @param scene defines the current scene
  48334. * @param rootUrl defines the root URL containing the effect layer information
  48335. * @returns a parsed effect Layer
  48336. */
  48337. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48338. }
  48339. }
  48340. declare module BABYLON {
  48341. interface AbstractScene {
  48342. /**
  48343. * The list of effect layers (highlights/glow) added to the scene
  48344. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48345. * @see http://doc.babylonjs.com/how_to/glow_layer
  48346. */
  48347. effectLayers: Array<EffectLayer>;
  48348. /**
  48349. * Removes the given effect layer from this scene.
  48350. * @param toRemove defines the effect layer to remove
  48351. * @returns the index of the removed effect layer
  48352. */
  48353. removeEffectLayer(toRemove: EffectLayer): number;
  48354. /**
  48355. * Adds the given effect layer to this scene
  48356. * @param newEffectLayer defines the effect layer to add
  48357. */
  48358. addEffectLayer(newEffectLayer: EffectLayer): void;
  48359. }
  48360. /**
  48361. * Defines the layer scene component responsible to manage any effect layers
  48362. * in a given scene.
  48363. */
  48364. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48365. /**
  48366. * The component name helpfull to identify the component in the list of scene components.
  48367. */
  48368. readonly name: string;
  48369. /**
  48370. * The scene the component belongs to.
  48371. */
  48372. scene: Scene;
  48373. private _engine;
  48374. private _renderEffects;
  48375. private _needStencil;
  48376. private _previousStencilState;
  48377. /**
  48378. * Creates a new instance of the component for the given scene
  48379. * @param scene Defines the scene to register the component in
  48380. */
  48381. constructor(scene: Scene);
  48382. /**
  48383. * Registers the component in a given scene
  48384. */
  48385. register(): void;
  48386. /**
  48387. * Rebuilds the elements related to this component in case of
  48388. * context lost for instance.
  48389. */
  48390. rebuild(): void;
  48391. /**
  48392. * Serializes the component data to the specified json object
  48393. * @param serializationObject The object to serialize to
  48394. */
  48395. serialize(serializationObject: any): void;
  48396. /**
  48397. * Adds all the elements from the container to the scene
  48398. * @param container the container holding the elements
  48399. */
  48400. addFromContainer(container: AbstractScene): void;
  48401. /**
  48402. * Removes all the elements in the container from the scene
  48403. * @param container contains the elements to remove
  48404. * @param dispose if the removed element should be disposed (default: false)
  48405. */
  48406. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48407. /**
  48408. * Disposes the component and the associated ressources.
  48409. */
  48410. dispose(): void;
  48411. private _isReadyForMesh;
  48412. private _renderMainTexture;
  48413. private _setStencil;
  48414. private _setStencilBack;
  48415. private _draw;
  48416. private _drawCamera;
  48417. private _drawRenderingGroup;
  48418. }
  48419. }
  48420. declare module BABYLON {
  48421. /** @hidden */
  48422. export var glowMapMergePixelShader: {
  48423. name: string;
  48424. shader: string;
  48425. };
  48426. }
  48427. declare module BABYLON {
  48428. /** @hidden */
  48429. export var glowMapMergeVertexShader: {
  48430. name: string;
  48431. shader: string;
  48432. };
  48433. }
  48434. declare module BABYLON {
  48435. interface AbstractScene {
  48436. /**
  48437. * Return a the first highlight layer of the scene with a given name.
  48438. * @param name The name of the highlight layer to look for.
  48439. * @return The highlight layer if found otherwise null.
  48440. */
  48441. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48442. }
  48443. /**
  48444. * Glow layer options. This helps customizing the behaviour
  48445. * of the glow layer.
  48446. */
  48447. export interface IGlowLayerOptions {
  48448. /**
  48449. * Multiplication factor apply to the canvas size to compute the render target size
  48450. * used to generated the glowing objects (the smaller the faster).
  48451. */
  48452. mainTextureRatio: number;
  48453. /**
  48454. * Enforces a fixed size texture to ensure resize independant blur.
  48455. */
  48456. mainTextureFixedSize?: number;
  48457. /**
  48458. * How big is the kernel of the blur texture.
  48459. */
  48460. blurKernelSize: number;
  48461. /**
  48462. * The camera attached to the layer.
  48463. */
  48464. camera: Nullable<Camera>;
  48465. /**
  48466. * Enable MSAA by chosing the number of samples.
  48467. */
  48468. mainTextureSamples?: number;
  48469. /**
  48470. * The rendering group to draw the layer in.
  48471. */
  48472. renderingGroupId: number;
  48473. }
  48474. /**
  48475. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48476. *
  48477. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48478. * glowy meshes to your scene.
  48479. *
  48480. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48481. */
  48482. export class GlowLayer extends EffectLayer {
  48483. /**
  48484. * Effect Name of the layer.
  48485. */
  48486. static readonly EffectName: string;
  48487. /**
  48488. * The default blur kernel size used for the glow.
  48489. */
  48490. static DefaultBlurKernelSize: number;
  48491. /**
  48492. * The default texture size ratio used for the glow.
  48493. */
  48494. static DefaultTextureRatio: number;
  48495. /**
  48496. * Sets the kernel size of the blur.
  48497. */
  48498. /**
  48499. * Gets the kernel size of the blur.
  48500. */
  48501. blurKernelSize: number;
  48502. /**
  48503. * Sets the glow intensity.
  48504. */
  48505. /**
  48506. * Gets the glow intensity.
  48507. */
  48508. intensity: number;
  48509. private _options;
  48510. private _intensity;
  48511. private _horizontalBlurPostprocess1;
  48512. private _verticalBlurPostprocess1;
  48513. private _horizontalBlurPostprocess2;
  48514. private _verticalBlurPostprocess2;
  48515. private _blurTexture1;
  48516. private _blurTexture2;
  48517. private _postProcesses1;
  48518. private _postProcesses2;
  48519. private _includedOnlyMeshes;
  48520. private _excludedMeshes;
  48521. /**
  48522. * Callback used to let the user override the color selection on a per mesh basis
  48523. */
  48524. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48525. /**
  48526. * Callback used to let the user override the texture selection on a per mesh basis
  48527. */
  48528. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48529. /**
  48530. * Instantiates a new glow Layer and references it to the scene.
  48531. * @param name The name of the layer
  48532. * @param scene The scene to use the layer in
  48533. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48534. */
  48535. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48536. /**
  48537. * Get the effect name of the layer.
  48538. * @return The effect name
  48539. */
  48540. getEffectName(): string;
  48541. /**
  48542. * Create the merge effect. This is the shader use to blit the information back
  48543. * to the main canvas at the end of the scene rendering.
  48544. */
  48545. protected _createMergeEffect(): Effect;
  48546. /**
  48547. * Creates the render target textures and post processes used in the glow layer.
  48548. */
  48549. protected _createTextureAndPostProcesses(): void;
  48550. /**
  48551. * Checks for the readiness of the element composing the layer.
  48552. * @param subMesh the mesh to check for
  48553. * @param useInstances specify wether or not to use instances to render the mesh
  48554. * @param emissiveTexture the associated emissive texture used to generate the glow
  48555. * @return true if ready otherwise, false
  48556. */
  48557. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48558. /**
  48559. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48560. */
  48561. needStencil(): boolean;
  48562. /**
  48563. * Returns true if the mesh can be rendered, otherwise false.
  48564. * @param mesh The mesh to render
  48565. * @param material The material used on the mesh
  48566. * @returns true if it can be rendered otherwise false
  48567. */
  48568. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48569. /**
  48570. * Implementation specific of rendering the generating effect on the main canvas.
  48571. * @param effect The effect used to render through
  48572. */
  48573. protected _internalRender(effect: Effect): void;
  48574. /**
  48575. * Sets the required values for both the emissive texture and and the main color.
  48576. */
  48577. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48578. /**
  48579. * Returns true if the mesh should render, otherwise false.
  48580. * @param mesh The mesh to render
  48581. * @returns true if it should render otherwise false
  48582. */
  48583. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48584. /**
  48585. * Adds specific effects defines.
  48586. * @param defines The defines to add specifics to.
  48587. */
  48588. protected _addCustomEffectDefines(defines: string[]): void;
  48589. /**
  48590. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48591. * @param mesh The mesh to exclude from the glow layer
  48592. */
  48593. addExcludedMesh(mesh: Mesh): void;
  48594. /**
  48595. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48596. * @param mesh The mesh to remove
  48597. */
  48598. removeExcludedMesh(mesh: Mesh): void;
  48599. /**
  48600. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48601. * @param mesh The mesh to include in the glow layer
  48602. */
  48603. addIncludedOnlyMesh(mesh: Mesh): void;
  48604. /**
  48605. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48606. * @param mesh The mesh to remove
  48607. */
  48608. removeIncludedOnlyMesh(mesh: Mesh): void;
  48609. /**
  48610. * Determine if a given mesh will be used in the glow layer
  48611. * @param mesh The mesh to test
  48612. * @returns true if the mesh will be highlighted by the current glow layer
  48613. */
  48614. hasMesh(mesh: AbstractMesh): boolean;
  48615. /**
  48616. * Free any resources and references associated to a mesh.
  48617. * Internal use
  48618. * @param mesh The mesh to free.
  48619. * @hidden
  48620. */ private _disposeMesh(mesh: Mesh): void;
  48621. /**
  48622. * Gets the class name of the effect layer
  48623. * @returns the string with the class name of the effect layer
  48624. */
  48625. getClassName(): string;
  48626. /**
  48627. * Serializes this glow layer
  48628. * @returns a serialized glow layer object
  48629. */
  48630. serialize(): any;
  48631. /**
  48632. * Creates a Glow Layer from parsed glow layer data
  48633. * @param parsedGlowLayer defines glow layer data
  48634. * @param scene defines the current scene
  48635. * @param rootUrl defines the root URL containing the glow layer information
  48636. * @returns a parsed Glow Layer
  48637. */
  48638. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48639. }
  48640. }
  48641. declare module BABYLON {
  48642. /** @hidden */
  48643. export var glowBlurPostProcessPixelShader: {
  48644. name: string;
  48645. shader: string;
  48646. };
  48647. }
  48648. declare module BABYLON {
  48649. interface AbstractScene {
  48650. /**
  48651. * Return a the first highlight layer of the scene with a given name.
  48652. * @param name The name of the highlight layer to look for.
  48653. * @return The highlight layer if found otherwise null.
  48654. */
  48655. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48656. }
  48657. /**
  48658. * Highlight layer options. This helps customizing the behaviour
  48659. * of the highlight layer.
  48660. */
  48661. export interface IHighlightLayerOptions {
  48662. /**
  48663. * Multiplication factor apply to the canvas size to compute the render target size
  48664. * used to generated the glowing objects (the smaller the faster).
  48665. */
  48666. mainTextureRatio: number;
  48667. /**
  48668. * Enforces a fixed size texture to ensure resize independant blur.
  48669. */
  48670. mainTextureFixedSize?: number;
  48671. /**
  48672. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48673. * of the picture to blur (the smaller the faster).
  48674. */
  48675. blurTextureSizeRatio: number;
  48676. /**
  48677. * How big in texel of the blur texture is the vertical blur.
  48678. */
  48679. blurVerticalSize: number;
  48680. /**
  48681. * How big in texel of the blur texture is the horizontal blur.
  48682. */
  48683. blurHorizontalSize: number;
  48684. /**
  48685. * Alpha blending mode used to apply the blur. Default is combine.
  48686. */
  48687. alphaBlendingMode: number;
  48688. /**
  48689. * The camera attached to the layer.
  48690. */
  48691. camera: Nullable<Camera>;
  48692. /**
  48693. * Should we display highlight as a solid stroke?
  48694. */
  48695. isStroke?: boolean;
  48696. /**
  48697. * The rendering group to draw the layer in.
  48698. */
  48699. renderingGroupId: number;
  48700. }
  48701. /**
  48702. * The highlight layer Helps adding a glow effect around a mesh.
  48703. *
  48704. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48705. * glowy meshes to your scene.
  48706. *
  48707. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48708. */
  48709. export class HighlightLayer extends EffectLayer {
  48710. name: string;
  48711. /**
  48712. * Effect Name of the highlight layer.
  48713. */
  48714. static readonly EffectName: string;
  48715. /**
  48716. * The neutral color used during the preparation of the glow effect.
  48717. * This is black by default as the blend operation is a blend operation.
  48718. */
  48719. static NeutralColor: Color4;
  48720. /**
  48721. * Stencil value used for glowing meshes.
  48722. */
  48723. static GlowingMeshStencilReference: number;
  48724. /**
  48725. * Stencil value used for the other meshes in the scene.
  48726. */
  48727. static NormalMeshStencilReference: number;
  48728. /**
  48729. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48730. */
  48731. innerGlow: boolean;
  48732. /**
  48733. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48734. */
  48735. outerGlow: boolean;
  48736. /**
  48737. * Specifies the horizontal size of the blur.
  48738. */
  48739. /**
  48740. * Gets the horizontal size of the blur.
  48741. */
  48742. blurHorizontalSize: number;
  48743. /**
  48744. * Specifies the vertical size of the blur.
  48745. */
  48746. /**
  48747. * Gets the vertical size of the blur.
  48748. */
  48749. blurVerticalSize: number;
  48750. /**
  48751. * An event triggered when the highlight layer is being blurred.
  48752. */
  48753. onBeforeBlurObservable: Observable<HighlightLayer>;
  48754. /**
  48755. * An event triggered when the highlight layer has been blurred.
  48756. */
  48757. onAfterBlurObservable: Observable<HighlightLayer>;
  48758. private _instanceGlowingMeshStencilReference;
  48759. private _options;
  48760. private _downSamplePostprocess;
  48761. private _horizontalBlurPostprocess;
  48762. private _verticalBlurPostprocess;
  48763. private _blurTexture;
  48764. private _meshes;
  48765. private _excludedMeshes;
  48766. /**
  48767. * Instantiates a new highlight Layer and references it to the scene..
  48768. * @param name The name of the layer
  48769. * @param scene The scene to use the layer in
  48770. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48771. */
  48772. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48773. /**
  48774. * Get the effect name of the layer.
  48775. * @return The effect name
  48776. */
  48777. getEffectName(): string;
  48778. /**
  48779. * Create the merge effect. This is the shader use to blit the information back
  48780. * to the main canvas at the end of the scene rendering.
  48781. */
  48782. protected _createMergeEffect(): Effect;
  48783. /**
  48784. * Creates the render target textures and post processes used in the highlight layer.
  48785. */
  48786. protected _createTextureAndPostProcesses(): void;
  48787. /**
  48788. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48789. */
  48790. needStencil(): boolean;
  48791. /**
  48792. * Checks for the readiness of the element composing the layer.
  48793. * @param subMesh the mesh to check for
  48794. * @param useInstances specify wether or not to use instances to render the mesh
  48795. * @param emissiveTexture the associated emissive texture used to generate the glow
  48796. * @return true if ready otherwise, false
  48797. */
  48798. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48799. /**
  48800. * Implementation specific of rendering the generating effect on the main canvas.
  48801. * @param effect The effect used to render through
  48802. */
  48803. protected _internalRender(effect: Effect): void;
  48804. /**
  48805. * Returns true if the layer contains information to display, otherwise false.
  48806. */
  48807. shouldRender(): boolean;
  48808. /**
  48809. * Returns true if the mesh should render, otherwise false.
  48810. * @param mesh The mesh to render
  48811. * @returns true if it should render otherwise false
  48812. */
  48813. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48814. /**
  48815. * Sets the required values for both the emissive texture and and the main color.
  48816. */
  48817. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48818. /**
  48819. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48820. * @param mesh The mesh to exclude from the highlight layer
  48821. */
  48822. addExcludedMesh(mesh: Mesh): void;
  48823. /**
  48824. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48825. * @param mesh The mesh to highlight
  48826. */
  48827. removeExcludedMesh(mesh: Mesh): void;
  48828. /**
  48829. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48830. * @param mesh mesh to test
  48831. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48832. */
  48833. hasMesh(mesh: AbstractMesh): boolean;
  48834. /**
  48835. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48836. * @param mesh The mesh to highlight
  48837. * @param color The color of the highlight
  48838. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48839. */
  48840. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48841. /**
  48842. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48843. * @param mesh The mesh to highlight
  48844. */
  48845. removeMesh(mesh: Mesh): void;
  48846. /**
  48847. * Force the stencil to the normal expected value for none glowing parts
  48848. */
  48849. private _defaultStencilReference;
  48850. /**
  48851. * Free any resources and references associated to a mesh.
  48852. * Internal use
  48853. * @param mesh The mesh to free.
  48854. * @hidden
  48855. */ private _disposeMesh(mesh: Mesh): void;
  48856. /**
  48857. * Dispose the highlight layer and free resources.
  48858. */
  48859. dispose(): void;
  48860. /**
  48861. * Gets the class name of the effect layer
  48862. * @returns the string with the class name of the effect layer
  48863. */
  48864. getClassName(): string;
  48865. /**
  48866. * Serializes this Highlight layer
  48867. * @returns a serialized Highlight layer object
  48868. */
  48869. serialize(): any;
  48870. /**
  48871. * Creates a Highlight layer from parsed Highlight layer data
  48872. * @param parsedHightlightLayer defines the Highlight layer data
  48873. * @param scene defines the current scene
  48874. * @param rootUrl defines the root URL containing the Highlight layer information
  48875. * @returns a parsed Highlight layer
  48876. */
  48877. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48878. }
  48879. }
  48880. declare module BABYLON {
  48881. interface AbstractScene {
  48882. /**
  48883. * The list of layers (background and foreground) of the scene
  48884. */
  48885. layers: Array<Layer>;
  48886. }
  48887. /**
  48888. * Defines the layer scene component responsible to manage any layers
  48889. * in a given scene.
  48890. */
  48891. export class LayerSceneComponent implements ISceneComponent {
  48892. /**
  48893. * The component name helpfull to identify the component in the list of scene components.
  48894. */
  48895. readonly name: string;
  48896. /**
  48897. * The scene the component belongs to.
  48898. */
  48899. scene: Scene;
  48900. private _engine;
  48901. /**
  48902. * Creates a new instance of the component for the given scene
  48903. * @param scene Defines the scene to register the component in
  48904. */
  48905. constructor(scene: Scene);
  48906. /**
  48907. * Registers the component in a given scene
  48908. */
  48909. register(): void;
  48910. /**
  48911. * Rebuilds the elements related to this component in case of
  48912. * context lost for instance.
  48913. */
  48914. rebuild(): void;
  48915. /**
  48916. * Disposes the component and the associated ressources.
  48917. */
  48918. dispose(): void;
  48919. private _draw;
  48920. private _drawCameraPredicate;
  48921. private _drawCameraBackground;
  48922. private _drawCameraForeground;
  48923. private _drawRenderTargetPredicate;
  48924. private _drawRenderTargetBackground;
  48925. private _drawRenderTargetForeground;
  48926. /**
  48927. * Adds all the elements from the container to the scene
  48928. * @param container the container holding the elements
  48929. */
  48930. addFromContainer(container: AbstractScene): void;
  48931. /**
  48932. * Removes all the elements in the container from the scene
  48933. * @param container contains the elements to remove
  48934. * @param dispose if the removed element should be disposed (default: false)
  48935. */
  48936. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48937. }
  48938. }
  48939. declare module BABYLON {
  48940. /** @hidden */
  48941. export var layerPixelShader: {
  48942. name: string;
  48943. shader: string;
  48944. };
  48945. }
  48946. declare module BABYLON {
  48947. /** @hidden */
  48948. export var layerVertexShader: {
  48949. name: string;
  48950. shader: string;
  48951. };
  48952. }
  48953. declare module BABYLON {
  48954. /**
  48955. * This represents a full screen 2d layer.
  48956. * This can be useful to display a picture in the background of your scene for instance.
  48957. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48958. */
  48959. export class Layer {
  48960. /**
  48961. * Define the name of the layer.
  48962. */
  48963. name: string;
  48964. /**
  48965. * Define the texture the layer should display.
  48966. */
  48967. texture: Nullable<Texture>;
  48968. /**
  48969. * Is the layer in background or foreground.
  48970. */
  48971. isBackground: boolean;
  48972. /**
  48973. * Define the color of the layer (instead of texture).
  48974. */
  48975. color: Color4;
  48976. /**
  48977. * Define the scale of the layer in order to zoom in out of the texture.
  48978. */
  48979. scale: Vector2;
  48980. /**
  48981. * Define an offset for the layer in order to shift the texture.
  48982. */
  48983. offset: Vector2;
  48984. /**
  48985. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  48986. */
  48987. alphaBlendingMode: number;
  48988. /**
  48989. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  48990. * Alpha test will not mix with the background color in case of transparency.
  48991. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  48992. */
  48993. alphaTest: boolean;
  48994. /**
  48995. * Define a mask to restrict the layer to only some of the scene cameras.
  48996. */
  48997. layerMask: number;
  48998. /**
  48999. * Define the list of render target the layer is visible into.
  49000. */
  49001. renderTargetTextures: RenderTargetTexture[];
  49002. /**
  49003. * Define if the layer is only used in renderTarget or if it also
  49004. * renders in the main frame buffer of the canvas.
  49005. */
  49006. renderOnlyInRenderTargetTextures: boolean;
  49007. private _scene;
  49008. private _vertexBuffers;
  49009. private _indexBuffer;
  49010. private _effect;
  49011. private _alphaTestEffect;
  49012. /**
  49013. * An event triggered when the layer is disposed.
  49014. */
  49015. onDisposeObservable: Observable<Layer>;
  49016. private _onDisposeObserver;
  49017. /**
  49018. * Back compatibility with callback before the onDisposeObservable existed.
  49019. * The set callback will be triggered when the layer has been disposed.
  49020. */
  49021. onDispose: () => void;
  49022. /**
  49023. * An event triggered before rendering the scene
  49024. */
  49025. onBeforeRenderObservable: Observable<Layer>;
  49026. private _onBeforeRenderObserver;
  49027. /**
  49028. * Back compatibility with callback before the onBeforeRenderObservable existed.
  49029. * The set callback will be triggered just before rendering the layer.
  49030. */
  49031. onBeforeRender: () => void;
  49032. /**
  49033. * An event triggered after rendering the scene
  49034. */
  49035. onAfterRenderObservable: Observable<Layer>;
  49036. private _onAfterRenderObserver;
  49037. /**
  49038. * Back compatibility with callback before the onAfterRenderObservable existed.
  49039. * The set callback will be triggered just after rendering the layer.
  49040. */
  49041. onAfterRender: () => void;
  49042. /**
  49043. * Instantiates a new layer.
  49044. * This represents a full screen 2d layer.
  49045. * This can be useful to display a picture in the background of your scene for instance.
  49046. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49047. * @param name Define the name of the layer in the scene
  49048. * @param imgUrl Define the url of the texture to display in the layer
  49049. * @param scene Define the scene the layer belongs to
  49050. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  49051. * @param color Defines a color for the layer
  49052. */
  49053. constructor(
  49054. /**
  49055. * Define the name of the layer.
  49056. */
  49057. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  49058. private _createIndexBuffer;
  49059. /** @hidden */ private _rebuild(): void;
  49060. /**
  49061. * Renders the layer in the scene.
  49062. */
  49063. render(): void;
  49064. /**
  49065. * Disposes and releases the associated ressources.
  49066. */
  49067. dispose(): void;
  49068. }
  49069. }
  49070. declare module BABYLON {
  49071. /** @hidden */
  49072. export var lensFlarePixelShader: {
  49073. name: string;
  49074. shader: string;
  49075. };
  49076. }
  49077. declare module BABYLON {
  49078. /** @hidden */
  49079. export var lensFlareVertexShader: {
  49080. name: string;
  49081. shader: string;
  49082. };
  49083. }
  49084. declare module BABYLON {
  49085. /**
  49086. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49087. * It is usually composed of several `lensFlare`.
  49088. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49089. */
  49090. export class LensFlareSystem {
  49091. /**
  49092. * Define the name of the lens flare system
  49093. */
  49094. name: string;
  49095. /**
  49096. * List of lens flares used in this system.
  49097. */
  49098. lensFlares: LensFlare[];
  49099. /**
  49100. * Define a limit from the border the lens flare can be visible.
  49101. */
  49102. borderLimit: number;
  49103. /**
  49104. * Define a viewport border we do not want to see the lens flare in.
  49105. */
  49106. viewportBorder: number;
  49107. /**
  49108. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49109. */
  49110. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49111. /**
  49112. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49113. */
  49114. layerMask: number;
  49115. /**
  49116. * Define the id of the lens flare system in the scene.
  49117. * (equal to name by default)
  49118. */
  49119. id: string;
  49120. private _scene;
  49121. private _emitter;
  49122. private _vertexBuffers;
  49123. private _indexBuffer;
  49124. private _effect;
  49125. private _positionX;
  49126. private _positionY;
  49127. private _isEnabled;
  49128. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  49129. /**
  49130. * Instantiates a lens flare system.
  49131. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49132. * It is usually composed of several `lensFlare`.
  49133. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49134. * @param name Define the name of the lens flare system in the scene
  49135. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49136. * @param scene Define the scene the lens flare system belongs to
  49137. */
  49138. constructor(
  49139. /**
  49140. * Define the name of the lens flare system
  49141. */
  49142. name: string, emitter: any, scene: Scene);
  49143. /**
  49144. * Define if the lens flare system is enabled.
  49145. */
  49146. isEnabled: boolean;
  49147. /**
  49148. * Get the scene the effects belongs to.
  49149. * @returns the scene holding the lens flare system
  49150. */
  49151. getScene(): Scene;
  49152. /**
  49153. * Get the emitter of the lens flare system.
  49154. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49155. * @returns the emitter of the lens flare system
  49156. */
  49157. getEmitter(): any;
  49158. /**
  49159. * Set the emitter of the lens flare system.
  49160. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49161. * @param newEmitter Define the new emitter of the system
  49162. */
  49163. setEmitter(newEmitter: any): void;
  49164. /**
  49165. * Get the lens flare system emitter position.
  49166. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49167. * @returns the position
  49168. */
  49169. getEmitterPosition(): Vector3;
  49170. /**
  49171. * @hidden
  49172. */
  49173. computeEffectivePosition(globalViewport: Viewport): boolean;
  49174. /** @hidden */ private _isVisible(): boolean;
  49175. /**
  49176. * @hidden
  49177. */
  49178. render(): boolean;
  49179. /**
  49180. * Dispose and release the lens flare with its associated resources.
  49181. */
  49182. dispose(): void;
  49183. /**
  49184. * Parse a lens flare system from a JSON repressentation
  49185. * @param parsedLensFlareSystem Define the JSON to parse
  49186. * @param scene Define the scene the parsed system should be instantiated in
  49187. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49188. * @returns the parsed system
  49189. */
  49190. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49191. /**
  49192. * Serialize the current Lens Flare System into a JSON representation.
  49193. * @returns the serialized JSON
  49194. */
  49195. serialize(): any;
  49196. }
  49197. }
  49198. declare module BABYLON {
  49199. /**
  49200. * This represents one of the lens effect in a `lensFlareSystem`.
  49201. * It controls one of the indiviual texture used in the effect.
  49202. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49203. */
  49204. export class LensFlare {
  49205. /**
  49206. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49207. */
  49208. size: number;
  49209. /**
  49210. * 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.
  49211. */
  49212. position: number;
  49213. /**
  49214. * Define the lens color.
  49215. */
  49216. color: Color3;
  49217. /**
  49218. * Define the lens texture.
  49219. */
  49220. texture: Nullable<Texture>;
  49221. /**
  49222. * Define the alpha mode to render this particular lens.
  49223. */
  49224. alphaMode: number;
  49225. private _system;
  49226. /**
  49227. * Creates a new Lens Flare.
  49228. * This represents one of the lens effect in a `lensFlareSystem`.
  49229. * It controls one of the indiviual texture used in the effect.
  49230. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49231. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49232. * @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.
  49233. * @param color Define the lens color
  49234. * @param imgUrl Define the lens texture url
  49235. * @param system Define the `lensFlareSystem` this flare is part of
  49236. * @returns The newly created Lens Flare
  49237. */
  49238. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49239. /**
  49240. * Instantiates a new Lens Flare.
  49241. * This represents one of the lens effect in a `lensFlareSystem`.
  49242. * It controls one of the indiviual texture used in the effect.
  49243. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49244. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49245. * @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.
  49246. * @param color Define the lens color
  49247. * @param imgUrl Define the lens texture url
  49248. * @param system Define the `lensFlareSystem` this flare is part of
  49249. */
  49250. constructor(
  49251. /**
  49252. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49253. */
  49254. size: number,
  49255. /**
  49256. * 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.
  49257. */
  49258. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49259. /**
  49260. * Dispose and release the lens flare with its associated resources.
  49261. */
  49262. dispose(): void;
  49263. }
  49264. }
  49265. declare module BABYLON {
  49266. interface AbstractScene {
  49267. /**
  49268. * The list of lens flare system added to the scene
  49269. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49270. */
  49271. lensFlareSystems: Array<LensFlareSystem>;
  49272. /**
  49273. * Removes the given lens flare system from this scene.
  49274. * @param toRemove The lens flare system to remove
  49275. * @returns The index of the removed lens flare system
  49276. */
  49277. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49278. /**
  49279. * Adds the given lens flare system to this scene
  49280. * @param newLensFlareSystem The lens flare system to add
  49281. */
  49282. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49283. /**
  49284. * Gets a lens flare system using its name
  49285. * @param name defines the name to look for
  49286. * @returns the lens flare system or null if not found
  49287. */
  49288. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49289. /**
  49290. * Gets a lens flare system using its id
  49291. * @param id defines the id to look for
  49292. * @returns the lens flare system or null if not found
  49293. */
  49294. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49295. }
  49296. /**
  49297. * Defines the lens flare scene component responsible to manage any lens flares
  49298. * in a given scene.
  49299. */
  49300. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49301. /**
  49302. * The component name helpfull to identify the component in the list of scene components.
  49303. */
  49304. readonly name: string;
  49305. /**
  49306. * The scene the component belongs to.
  49307. */
  49308. scene: Scene;
  49309. /**
  49310. * Creates a new instance of the component for the given scene
  49311. * @param scene Defines the scene to register the component in
  49312. */
  49313. constructor(scene: Scene);
  49314. /**
  49315. * Registers the component in a given scene
  49316. */
  49317. register(): void;
  49318. /**
  49319. * Rebuilds the elements related to this component in case of
  49320. * context lost for instance.
  49321. */
  49322. rebuild(): void;
  49323. /**
  49324. * Adds all the elements from the container to the scene
  49325. * @param container the container holding the elements
  49326. */
  49327. addFromContainer(container: AbstractScene): void;
  49328. /**
  49329. * Removes all the elements in the container from the scene
  49330. * @param container contains the elements to remove
  49331. * @param dispose if the removed element should be disposed (default: false)
  49332. */
  49333. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49334. /**
  49335. * Serializes the component data to the specified json object
  49336. * @param serializationObject The object to serialize to
  49337. */
  49338. serialize(serializationObject: any): void;
  49339. /**
  49340. * Disposes the component and the associated ressources.
  49341. */
  49342. dispose(): void;
  49343. private _draw;
  49344. }
  49345. }
  49346. declare module BABYLON {
  49347. /**
  49348. * Defines the shadow generator component responsible to manage any shadow generators
  49349. * in a given scene.
  49350. */
  49351. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49352. /**
  49353. * The component name helpfull to identify the component in the list of scene components.
  49354. */
  49355. readonly name: string;
  49356. /**
  49357. * The scene the component belongs to.
  49358. */
  49359. scene: Scene;
  49360. /**
  49361. * Creates a new instance of the component for the given scene
  49362. * @param scene Defines the scene to register the component in
  49363. */
  49364. constructor(scene: Scene);
  49365. /**
  49366. * Registers the component in a given scene
  49367. */
  49368. register(): void;
  49369. /**
  49370. * Rebuilds the elements related to this component in case of
  49371. * context lost for instance.
  49372. */
  49373. rebuild(): void;
  49374. /**
  49375. * Serializes the component data to the specified json object
  49376. * @param serializationObject The object to serialize to
  49377. */
  49378. serialize(serializationObject: any): void;
  49379. /**
  49380. * Adds all the elements from the container to the scene
  49381. * @param container the container holding the elements
  49382. */
  49383. addFromContainer(container: AbstractScene): void;
  49384. /**
  49385. * Removes all the elements in the container from the scene
  49386. * @param container contains the elements to remove
  49387. * @param dispose if the removed element should be disposed (default: false)
  49388. */
  49389. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49390. /**
  49391. * Rebuilds the elements related to this component in case of
  49392. * context lost for instance.
  49393. */
  49394. dispose(): void;
  49395. private _gatherRenderTargets;
  49396. }
  49397. }
  49398. declare module BABYLON {
  49399. /**
  49400. * A point light is a light defined by an unique point in world space.
  49401. * The light is emitted in every direction from this point.
  49402. * A good example of a point light is a standard light bulb.
  49403. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49404. */
  49405. export class PointLight extends ShadowLight {
  49406. private _shadowAngle;
  49407. /**
  49408. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49409. * This specifies what angle the shadow will use to be created.
  49410. *
  49411. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49412. */
  49413. /**
  49414. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49415. * This specifies what angle the shadow will use to be created.
  49416. *
  49417. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49418. */
  49419. shadowAngle: number;
  49420. /**
  49421. * Gets the direction if it has been set.
  49422. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49423. */
  49424. /**
  49425. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49426. */
  49427. direction: Vector3;
  49428. /**
  49429. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49430. * A PointLight emits the light in every direction.
  49431. * It can cast shadows.
  49432. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49433. * ```javascript
  49434. * var pointLight = new PointLight("pl", camera.position, scene);
  49435. * ```
  49436. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49437. * @param name The light friendly name
  49438. * @param position The position of the point light in the scene
  49439. * @param scene The scene the lights belongs to
  49440. */
  49441. constructor(name: string, position: Vector3, scene: Scene);
  49442. /**
  49443. * Returns the string "PointLight"
  49444. * @returns the class name
  49445. */
  49446. getClassName(): string;
  49447. /**
  49448. * Returns the integer 0.
  49449. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49450. */
  49451. getTypeID(): number;
  49452. /**
  49453. * Specifies wether or not the shadowmap should be a cube texture.
  49454. * @returns true if the shadowmap needs to be a cube texture.
  49455. */
  49456. needCube(): boolean;
  49457. /**
  49458. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49459. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49460. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49461. */
  49462. getShadowDirection(faceIndex?: number): Vector3;
  49463. /**
  49464. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49465. * - fov = PI / 2
  49466. * - aspect ratio : 1.0
  49467. * - z-near and far equal to the active camera minZ and maxZ.
  49468. * Returns the PointLight.
  49469. */
  49470. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49471. protected _buildUniformLayout(): void;
  49472. /**
  49473. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49474. * @param effect The effect to update
  49475. * @param lightIndex The index of the light in the effect to update
  49476. * @returns The point light
  49477. */
  49478. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49479. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49480. /**
  49481. * Prepares the list of defines specific to the light type.
  49482. * @param defines the list of defines
  49483. * @param lightIndex defines the index of the light for the effect
  49484. */
  49485. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49486. }
  49487. }
  49488. declare module BABYLON {
  49489. /**
  49490. * Header information of HDR texture files.
  49491. */
  49492. export interface HDRInfo {
  49493. /**
  49494. * The height of the texture in pixels.
  49495. */
  49496. height: number;
  49497. /**
  49498. * The width of the texture in pixels.
  49499. */
  49500. width: number;
  49501. /**
  49502. * The index of the beginning of the data in the binary file.
  49503. */
  49504. dataPosition: number;
  49505. }
  49506. /**
  49507. * This groups tools to convert HDR texture to native colors array.
  49508. */
  49509. export class HDRTools {
  49510. private static Ldexp;
  49511. private static Rgbe2float;
  49512. private static readStringLine;
  49513. /**
  49514. * Reads header information from an RGBE texture stored in a native array.
  49515. * More information on this format are available here:
  49516. * https://en.wikipedia.org/wiki/RGBE_image_format
  49517. *
  49518. * @param uint8array The binary file stored in native array.
  49519. * @return The header information.
  49520. */
  49521. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49522. /**
  49523. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49524. * This RGBE texture needs to store the information as a panorama.
  49525. *
  49526. * More information on this format are available here:
  49527. * https://en.wikipedia.org/wiki/RGBE_image_format
  49528. *
  49529. * @param buffer The binary file stored in an array buffer.
  49530. * @param size The expected size of the extracted cubemap.
  49531. * @return The Cube Map information.
  49532. */
  49533. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49534. /**
  49535. * Returns the pixels data extracted from an RGBE texture.
  49536. * This pixels will be stored left to right up to down in the R G B order in one array.
  49537. *
  49538. * More information on this format are available here:
  49539. * https://en.wikipedia.org/wiki/RGBE_image_format
  49540. *
  49541. * @param uint8array The binary file stored in an array buffer.
  49542. * @param hdrInfo The header information of the file.
  49543. * @return The pixels data in RGB right to left up to down order.
  49544. */
  49545. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49546. private static RGBE_ReadPixels_RLE;
  49547. }
  49548. }
  49549. declare module BABYLON {
  49550. /**
  49551. * This represents a texture coming from an HDR input.
  49552. *
  49553. * The only supported format is currently panorama picture stored in RGBE format.
  49554. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49555. */
  49556. export class HDRCubeTexture extends BaseTexture {
  49557. private static _facesMapping;
  49558. private _generateHarmonics;
  49559. private _noMipmap;
  49560. private _textureMatrix;
  49561. private _size;
  49562. private _onLoad;
  49563. private _onError;
  49564. /**
  49565. * The texture URL.
  49566. */
  49567. url: string;
  49568. /**
  49569. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49570. */
  49571. coordinatesMode: number;
  49572. protected _isBlocking: boolean;
  49573. /**
  49574. * Sets wether or not the texture is blocking during loading.
  49575. */
  49576. /**
  49577. * Gets wether or not the texture is blocking during loading.
  49578. */
  49579. isBlocking: boolean;
  49580. protected _rotationY: number;
  49581. /**
  49582. * Sets texture matrix rotation angle around Y axis in radians.
  49583. */
  49584. /**
  49585. * Gets texture matrix rotation angle around Y axis radians.
  49586. */
  49587. rotationY: number;
  49588. /**
  49589. * Gets or sets the center of the bounding box associated with the cube texture
  49590. * It must define where the camera used to render the texture was set
  49591. */
  49592. boundingBoxPosition: Vector3;
  49593. private _boundingBoxSize;
  49594. /**
  49595. * Gets or sets the size of the bounding box associated with the cube texture
  49596. * When defined, the cubemap will switch to local mode
  49597. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49598. * @example https://www.babylonjs-playground.com/#RNASML
  49599. */
  49600. boundingBoxSize: Vector3;
  49601. /**
  49602. * Instantiates an HDRTexture from the following parameters.
  49603. *
  49604. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49605. * @param scene The scene the texture will be used in
  49606. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49607. * @param noMipmap Forces to not generate the mipmap if true
  49608. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49609. * @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)
  49610. * @param reserved Reserved flag for internal use.
  49611. */
  49612. 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>);
  49613. /**
  49614. * Get the current class name of the texture useful for serialization or dynamic coding.
  49615. * @returns "HDRCubeTexture"
  49616. */
  49617. getClassName(): string;
  49618. /**
  49619. * Occurs when the file is raw .hdr file.
  49620. */
  49621. private loadTexture;
  49622. clone(): HDRCubeTexture;
  49623. delayLoad(): void;
  49624. /**
  49625. * Get the texture reflection matrix used to rotate/transform the reflection.
  49626. * @returns the reflection matrix
  49627. */
  49628. getReflectionTextureMatrix(): Matrix;
  49629. /**
  49630. * Set the texture reflection matrix used to rotate/transform the reflection.
  49631. * @param value Define the reflection matrix to set
  49632. */
  49633. setReflectionTextureMatrix(value: Matrix): void;
  49634. /**
  49635. * Parses a JSON representation of an HDR Texture in order to create the texture
  49636. * @param parsedTexture Define the JSON representation
  49637. * @param scene Define the scene the texture should be created in
  49638. * @param rootUrl Define the root url in case we need to load relative dependencies
  49639. * @returns the newly created texture after parsing
  49640. */
  49641. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49642. serialize(): any;
  49643. }
  49644. }
  49645. declare module BABYLON {
  49646. /**
  49647. * Class used to control physics engine
  49648. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49649. */
  49650. export class PhysicsEngine implements IPhysicsEngine {
  49651. private _physicsPlugin;
  49652. /**
  49653. * Global value used to control the smallest number supported by the simulation
  49654. */
  49655. static Epsilon: number;
  49656. private _impostors;
  49657. private _joints;
  49658. /**
  49659. * Gets the gravity vector used by the simulation
  49660. */
  49661. gravity: Vector3;
  49662. /**
  49663. * Factory used to create the default physics plugin.
  49664. * @returns The default physics plugin
  49665. */
  49666. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49667. /**
  49668. * Creates a new Physics Engine
  49669. * @param gravity defines the gravity vector used by the simulation
  49670. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49671. */
  49672. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49673. /**
  49674. * Sets the gravity vector used by the simulation
  49675. * @param gravity defines the gravity vector to use
  49676. */
  49677. setGravity(gravity: Vector3): void;
  49678. /**
  49679. * Set the time step of the physics engine.
  49680. * Default is 1/60.
  49681. * To slow it down, enter 1/600 for example.
  49682. * To speed it up, 1/30
  49683. * @param newTimeStep defines the new timestep to apply to this world.
  49684. */
  49685. setTimeStep(newTimeStep?: number): void;
  49686. /**
  49687. * Get the time step of the physics engine.
  49688. * @returns the current time step
  49689. */
  49690. getTimeStep(): number;
  49691. /**
  49692. * Release all resources
  49693. */
  49694. dispose(): void;
  49695. /**
  49696. * Gets the name of the current physics plugin
  49697. * @returns the name of the plugin
  49698. */
  49699. getPhysicsPluginName(): string;
  49700. /**
  49701. * Adding a new impostor for the impostor tracking.
  49702. * This will be done by the impostor itself.
  49703. * @param impostor the impostor to add
  49704. */
  49705. addImpostor(impostor: PhysicsImpostor): void;
  49706. /**
  49707. * Remove an impostor from the engine.
  49708. * This impostor and its mesh will not longer be updated by the physics engine.
  49709. * @param impostor the impostor to remove
  49710. */
  49711. removeImpostor(impostor: PhysicsImpostor): void;
  49712. /**
  49713. * Add a joint to the physics engine
  49714. * @param mainImpostor defines the main impostor to which the joint is added.
  49715. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49716. * @param joint defines the joint that will connect both impostors.
  49717. */
  49718. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49719. /**
  49720. * Removes a joint from the simulation
  49721. * @param mainImpostor defines the impostor used with the joint
  49722. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49723. * @param joint defines the joint to remove
  49724. */
  49725. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49726. /**
  49727. * Called by the scene. No need to call it.
  49728. * @param delta defines the timespam between frames
  49729. */ private _step(delta: number): void;
  49730. /**
  49731. * Gets the current plugin used to run the simulation
  49732. * @returns current plugin
  49733. */
  49734. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49735. /**
  49736. * Gets the list of physic impostors
  49737. * @returns an array of PhysicsImpostor
  49738. */
  49739. getImpostors(): Array<PhysicsImpostor>;
  49740. /**
  49741. * Gets the impostor for a physics enabled object
  49742. * @param object defines the object impersonated by the impostor
  49743. * @returns the PhysicsImpostor or null if not found
  49744. */
  49745. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49746. /**
  49747. * Gets the impostor for a physics body object
  49748. * @param body defines physics body used by the impostor
  49749. * @returns the PhysicsImpostor or null if not found
  49750. */
  49751. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49752. /**
  49753. * Does a raycast in the physics world
  49754. * @param from when should the ray start?
  49755. * @param to when should the ray end?
  49756. * @returns PhysicsRaycastResult
  49757. */
  49758. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49759. }
  49760. }
  49761. declare module BABYLON {
  49762. /** @hidden */
  49763. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49764. private _useDeltaForWorldStep;
  49765. world: any;
  49766. name: string;
  49767. private _physicsMaterials;
  49768. private _fixedTimeStep;
  49769. private _cannonRaycastResult;
  49770. private _raycastResult;
  49771. private _physicsBodysToRemoveAfterStep;
  49772. BJSCANNON: any;
  49773. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49774. setGravity(gravity: Vector3): void;
  49775. setTimeStep(timeStep: number): void;
  49776. getTimeStep(): number;
  49777. executeStep(delta: number): void;
  49778. private _removeMarkedPhysicsBodiesFromWorld;
  49779. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49780. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49781. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49782. private _processChildMeshes;
  49783. removePhysicsBody(impostor: PhysicsImpostor): void;
  49784. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49785. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49786. private _addMaterial;
  49787. private _checkWithEpsilon;
  49788. private _createShape;
  49789. private _createHeightmap;
  49790. private _minus90X;
  49791. private _plus90X;
  49792. private _tmpPosition;
  49793. private _tmpDeltaPosition;
  49794. private _tmpUnityRotation;
  49795. private _updatePhysicsBodyTransformation;
  49796. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49797. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49798. isSupported(): boolean;
  49799. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49800. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49801. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49802. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49803. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49804. getBodyMass(impostor: PhysicsImpostor): number;
  49805. getBodyFriction(impostor: PhysicsImpostor): number;
  49806. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49807. getBodyRestitution(impostor: PhysicsImpostor): number;
  49808. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49809. sleepBody(impostor: PhysicsImpostor): void;
  49810. wakeUpBody(impostor: PhysicsImpostor): void;
  49811. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49812. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49813. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49814. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49815. getRadius(impostor: PhysicsImpostor): number;
  49816. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49817. dispose(): void;
  49818. private _extendNamespace;
  49819. /**
  49820. * Does a raycast in the physics world
  49821. * @param from when should the ray start?
  49822. * @param to when should the ray end?
  49823. * @returns PhysicsRaycastResult
  49824. */
  49825. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49826. }
  49827. }
  49828. declare module BABYLON {
  49829. /** @hidden */
  49830. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49831. world: any;
  49832. name: string;
  49833. BJSOIMO: any;
  49834. private _raycastResult;
  49835. constructor(iterations?: number, oimoInjection?: any);
  49836. setGravity(gravity: Vector3): void;
  49837. setTimeStep(timeStep: number): void;
  49838. getTimeStep(): number;
  49839. private _tmpImpostorsArray;
  49840. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49841. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49842. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49843. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49844. private _tmpPositionVector;
  49845. removePhysicsBody(impostor: PhysicsImpostor): void;
  49846. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49847. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49848. isSupported(): boolean;
  49849. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49850. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49851. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49852. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49853. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49854. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49855. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49856. getBodyMass(impostor: PhysicsImpostor): number;
  49857. getBodyFriction(impostor: PhysicsImpostor): number;
  49858. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49859. getBodyRestitution(impostor: PhysicsImpostor): number;
  49860. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49861. sleepBody(impostor: PhysicsImpostor): void;
  49862. wakeUpBody(impostor: PhysicsImpostor): void;
  49863. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49864. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49865. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49866. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49867. getRadius(impostor: PhysicsImpostor): number;
  49868. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49869. dispose(): void;
  49870. /**
  49871. * Does a raycast in the physics world
  49872. * @param from when should the ray start?
  49873. * @param to when should the ray end?
  49874. * @returns PhysicsRaycastResult
  49875. */
  49876. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49877. }
  49878. }
  49879. declare module BABYLON {
  49880. /**
  49881. * Class containing static functions to help procedurally build meshes
  49882. */
  49883. export class RibbonBuilder {
  49884. /**
  49885. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49886. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49887. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49888. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49889. * * 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
  49890. * * 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
  49891. * * 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
  49892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49893. * * 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
  49894. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49895. * * 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
  49896. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49897. * * 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
  49898. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49900. * @param name defines the name of the mesh
  49901. * @param options defines the options used to create the mesh
  49902. * @param scene defines the hosting scene
  49903. * @returns the ribbon mesh
  49904. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49905. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49906. */
  49907. static CreateRibbon(name: string, options: {
  49908. pathArray: Vector3[][];
  49909. closeArray?: boolean;
  49910. closePath?: boolean;
  49911. offset?: number;
  49912. updatable?: boolean;
  49913. sideOrientation?: number;
  49914. frontUVs?: Vector4;
  49915. backUVs?: Vector4;
  49916. instance?: Mesh;
  49917. invertUV?: boolean;
  49918. uvs?: Vector2[];
  49919. colors?: Color4[];
  49920. }, scene?: Nullable<Scene>): Mesh;
  49921. }
  49922. }
  49923. declare module BABYLON {
  49924. /**
  49925. * Class containing static functions to help procedurally build meshes
  49926. */
  49927. export class ShapeBuilder {
  49928. /**
  49929. * 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.
  49930. * * 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.
  49931. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49932. * * 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.
  49933. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49934. * * 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
  49935. * * 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
  49936. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49937. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49938. * * 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
  49939. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49941. * @param name defines the name of the mesh
  49942. * @param options defines the options used to create the mesh
  49943. * @param scene defines the hosting scene
  49944. * @returns the extruded shape mesh
  49945. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49946. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49947. */
  49948. static ExtrudeShape(name: string, options: {
  49949. shape: Vector3[];
  49950. path: Vector3[];
  49951. scale?: number;
  49952. rotation?: number;
  49953. cap?: number;
  49954. updatable?: boolean;
  49955. sideOrientation?: number;
  49956. frontUVs?: Vector4;
  49957. backUVs?: Vector4;
  49958. instance?: Mesh;
  49959. invertUV?: boolean;
  49960. }, scene?: Nullable<Scene>): Mesh;
  49961. /**
  49962. * Creates an custom extruded shape mesh.
  49963. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49964. * * 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.
  49965. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49966. * * 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
  49967. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49968. * * 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
  49969. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49970. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49971. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49972. * * 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
  49973. * * 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
  49974. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49975. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49976. * * 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
  49977. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49979. * @param name defines the name of the mesh
  49980. * @param options defines the options used to create the mesh
  49981. * @param scene defines the hosting scene
  49982. * @returns the custom extruded shape mesh
  49983. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49984. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49985. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49986. */
  49987. static ExtrudeShapeCustom(name: string, options: {
  49988. shape: Vector3[];
  49989. path: Vector3[];
  49990. scaleFunction?: any;
  49991. rotationFunction?: any;
  49992. ribbonCloseArray?: boolean;
  49993. ribbonClosePath?: boolean;
  49994. cap?: number;
  49995. updatable?: boolean;
  49996. sideOrientation?: number;
  49997. frontUVs?: Vector4;
  49998. backUVs?: Vector4;
  49999. instance?: Mesh;
  50000. invertUV?: boolean;
  50001. }, scene?: Nullable<Scene>): Mesh;
  50002. private static _ExtrudeShapeGeneric;
  50003. }
  50004. }
  50005. declare module BABYLON {
  50006. /**
  50007. * AmmoJS Physics plugin
  50008. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50009. * @see https://github.com/kripken/ammo.js/
  50010. */
  50011. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50012. private _useDeltaForWorldStep;
  50013. /**
  50014. * Reference to the Ammo library
  50015. */
  50016. bjsAMMO: any;
  50017. /**
  50018. * Created ammoJS world which physics bodies are added to
  50019. */
  50020. world: any;
  50021. /**
  50022. * Name of the plugin
  50023. */
  50024. name: string;
  50025. private _timeStep;
  50026. private _fixedTimeStep;
  50027. private _maxSteps;
  50028. private _tmpQuaternion;
  50029. private _tmpAmmoTransform;
  50030. private _tmpAmmoQuaternion;
  50031. private _tmpAmmoConcreteContactResultCallback;
  50032. private _collisionConfiguration;
  50033. private _dispatcher;
  50034. private _overlappingPairCache;
  50035. private _solver;
  50036. private _softBodySolver;
  50037. private _tmpAmmoVectorA;
  50038. private _tmpAmmoVectorB;
  50039. private _tmpAmmoVectorC;
  50040. private _tmpAmmoVectorD;
  50041. private _tmpContactCallbackResult;
  50042. private _tmpAmmoVectorRCA;
  50043. private _tmpAmmoVectorRCB;
  50044. private _raycastResult;
  50045. private static readonly DISABLE_COLLISION_FLAG;
  50046. private static readonly KINEMATIC_FLAG;
  50047. private static readonly DISABLE_DEACTIVATION_FLAG;
  50048. /**
  50049. * Initializes the ammoJS plugin
  50050. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50051. * @param ammoInjection can be used to inject your own ammo reference
  50052. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  50053. */
  50054. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  50055. /**
  50056. * Sets the gravity of the physics world (m/(s^2))
  50057. * @param gravity Gravity to set
  50058. */
  50059. setGravity(gravity: Vector3): void;
  50060. /**
  50061. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50062. * @param timeStep timestep to use in seconds
  50063. */
  50064. setTimeStep(timeStep: number): void;
  50065. /**
  50066. * 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)
  50067. * @param fixedTimeStep fixedTimeStep to use in seconds
  50068. */
  50069. setFixedTimeStep(fixedTimeStep: number): void;
  50070. /**
  50071. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50072. * @param maxSteps the maximum number of steps by the physics engine per frame
  50073. */
  50074. setMaxSteps(maxSteps: number): void;
  50075. /**
  50076. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50077. * @returns the current timestep in seconds
  50078. */
  50079. getTimeStep(): number;
  50080. private _isImpostorInContact;
  50081. private _isImpostorPairInContact;
  50082. private _stepSimulation;
  50083. /**
  50084. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50085. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50086. * After the step the babylon meshes are set to the position of the physics imposters
  50087. * @param delta amount of time to step forward
  50088. * @param impostors array of imposters to update before/after the step
  50089. */
  50090. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50091. /**
  50092. * Update babylon mesh to match physics world object
  50093. * @param impostor imposter to match
  50094. */
  50095. private _afterSoftStep;
  50096. /**
  50097. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50098. * @param impostor imposter to match
  50099. */
  50100. private _ropeStep;
  50101. /**
  50102. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50103. * @param impostor imposter to match
  50104. */
  50105. private _softbodyOrClothStep;
  50106. private _tmpVector;
  50107. private _tmpMatrix;
  50108. /**
  50109. * Applies an impulse on the imposter
  50110. * @param impostor imposter to apply impulse to
  50111. * @param force amount of force to be applied to the imposter
  50112. * @param contactPoint the location to apply the impulse on the imposter
  50113. */
  50114. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50115. /**
  50116. * Applies a force on the imposter
  50117. * @param impostor imposter to apply force
  50118. * @param force amount of force to be applied to the imposter
  50119. * @param contactPoint the location to apply the force on the imposter
  50120. */
  50121. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50122. /**
  50123. * Creates a physics body using the plugin
  50124. * @param impostor the imposter to create the physics body on
  50125. */
  50126. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50127. /**
  50128. * Removes the physics body from the imposter and disposes of the body's memory
  50129. * @param impostor imposter to remove the physics body from
  50130. */
  50131. removePhysicsBody(impostor: PhysicsImpostor): void;
  50132. /**
  50133. * Generates a joint
  50134. * @param impostorJoint the imposter joint to create the joint with
  50135. */
  50136. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50137. /**
  50138. * Removes a joint
  50139. * @param impostorJoint the imposter joint to remove the joint from
  50140. */
  50141. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50142. private _addMeshVerts;
  50143. /**
  50144. * Initialise the soft body vertices to match its object's (mesh) vertices
  50145. * Softbody vertices (nodes) are in world space and to match this
  50146. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50147. * @param impostor to create the softbody for
  50148. */
  50149. private _softVertexData;
  50150. /**
  50151. * Create an impostor's soft body
  50152. * @param impostor to create the softbody for
  50153. */
  50154. private _createSoftbody;
  50155. /**
  50156. * Create cloth for an impostor
  50157. * @param impostor to create the softbody for
  50158. */
  50159. private _createCloth;
  50160. /**
  50161. * Create rope for an impostor
  50162. * @param impostor to create the softbody for
  50163. */
  50164. private _createRope;
  50165. private _addHullVerts;
  50166. private _createShape;
  50167. /**
  50168. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50169. * @param impostor imposter containing the physics body and babylon object
  50170. */
  50171. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50172. /**
  50173. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50174. * @param impostor imposter containing the physics body and babylon object
  50175. * @param newPosition new position
  50176. * @param newRotation new rotation
  50177. */
  50178. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50179. /**
  50180. * If this plugin is supported
  50181. * @returns true if its supported
  50182. */
  50183. isSupported(): boolean;
  50184. /**
  50185. * Sets the linear velocity of the physics body
  50186. * @param impostor imposter to set the velocity on
  50187. * @param velocity velocity to set
  50188. */
  50189. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50190. /**
  50191. * Sets the angular velocity of the physics body
  50192. * @param impostor imposter to set the velocity on
  50193. * @param velocity velocity to set
  50194. */
  50195. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50196. /**
  50197. * gets the linear velocity
  50198. * @param impostor imposter to get linear velocity from
  50199. * @returns linear velocity
  50200. */
  50201. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50202. /**
  50203. * gets the angular velocity
  50204. * @param impostor imposter to get angular velocity from
  50205. * @returns angular velocity
  50206. */
  50207. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50208. /**
  50209. * Sets the mass of physics body
  50210. * @param impostor imposter to set the mass on
  50211. * @param mass mass to set
  50212. */
  50213. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50214. /**
  50215. * Gets the mass of the physics body
  50216. * @param impostor imposter to get the mass from
  50217. * @returns mass
  50218. */
  50219. getBodyMass(impostor: PhysicsImpostor): number;
  50220. /**
  50221. * Gets friction of the impostor
  50222. * @param impostor impostor to get friction from
  50223. * @returns friction value
  50224. */
  50225. getBodyFriction(impostor: PhysicsImpostor): number;
  50226. /**
  50227. * Sets friction of the impostor
  50228. * @param impostor impostor to set friction on
  50229. * @param friction friction value
  50230. */
  50231. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50232. /**
  50233. * Gets restitution of the impostor
  50234. * @param impostor impostor to get restitution from
  50235. * @returns restitution value
  50236. */
  50237. getBodyRestitution(impostor: PhysicsImpostor): number;
  50238. /**
  50239. * Sets resitution of the impostor
  50240. * @param impostor impostor to set resitution on
  50241. * @param restitution resitution value
  50242. */
  50243. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50244. /**
  50245. * Gets pressure inside the impostor
  50246. * @param impostor impostor to get pressure from
  50247. * @returns pressure value
  50248. */
  50249. getBodyPressure(impostor: PhysicsImpostor): number;
  50250. /**
  50251. * Sets pressure inside a soft body impostor
  50252. * Cloth and rope must remain 0 pressure
  50253. * @param impostor impostor to set pressure on
  50254. * @param pressure pressure value
  50255. */
  50256. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50257. /**
  50258. * Gets stiffness of the impostor
  50259. * @param impostor impostor to get stiffness from
  50260. * @returns pressure value
  50261. */
  50262. getBodyStiffness(impostor: PhysicsImpostor): number;
  50263. /**
  50264. * Sets stiffness of the impostor
  50265. * @param impostor impostor to set stiffness on
  50266. * @param stiffness stiffness value from 0 to 1
  50267. */
  50268. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50269. /**
  50270. * Gets velocityIterations of the impostor
  50271. * @param impostor impostor to get velocity iterations from
  50272. * @returns velocityIterations value
  50273. */
  50274. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50275. /**
  50276. * Sets velocityIterations of the impostor
  50277. * @param impostor impostor to set velocity iterations on
  50278. * @param velocityIterations velocityIterations value
  50279. */
  50280. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50281. /**
  50282. * Gets positionIterations of the impostor
  50283. * @param impostor impostor to get position iterations from
  50284. * @returns positionIterations value
  50285. */
  50286. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50287. /**
  50288. * Sets positionIterations of the impostor
  50289. * @param impostor impostor to set position on
  50290. * @param positionIterations positionIterations value
  50291. */
  50292. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50293. /**
  50294. * Append an anchor to a cloth object
  50295. * @param impostor is the cloth impostor to add anchor to
  50296. * @param otherImpostor is the rigid impostor to anchor to
  50297. * @param width ratio across width from 0 to 1
  50298. * @param height ratio up height from 0 to 1
  50299. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50300. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50301. */
  50302. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50303. /**
  50304. * Append an hook to a rope object
  50305. * @param impostor is the rope impostor to add hook to
  50306. * @param otherImpostor is the rigid impostor to hook to
  50307. * @param length ratio along the rope from 0 to 1
  50308. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50309. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50310. */
  50311. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50312. /**
  50313. * Sleeps the physics body and stops it from being active
  50314. * @param impostor impostor to sleep
  50315. */
  50316. sleepBody(impostor: PhysicsImpostor): void;
  50317. /**
  50318. * Activates the physics body
  50319. * @param impostor impostor to activate
  50320. */
  50321. wakeUpBody(impostor: PhysicsImpostor): void;
  50322. /**
  50323. * Updates the distance parameters of the joint
  50324. * @param joint joint to update
  50325. * @param maxDistance maximum distance of the joint
  50326. * @param minDistance minimum distance of the joint
  50327. */
  50328. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50329. /**
  50330. * Sets a motor on the joint
  50331. * @param joint joint to set motor on
  50332. * @param speed speed of the motor
  50333. * @param maxForce maximum force of the motor
  50334. * @param motorIndex index of the motor
  50335. */
  50336. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50337. /**
  50338. * Sets the motors limit
  50339. * @param joint joint to set limit on
  50340. * @param upperLimit upper limit
  50341. * @param lowerLimit lower limit
  50342. */
  50343. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50344. /**
  50345. * Syncs the position and rotation of a mesh with the impostor
  50346. * @param mesh mesh to sync
  50347. * @param impostor impostor to update the mesh with
  50348. */
  50349. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50350. /**
  50351. * Gets the radius of the impostor
  50352. * @param impostor impostor to get radius from
  50353. * @returns the radius
  50354. */
  50355. getRadius(impostor: PhysicsImpostor): number;
  50356. /**
  50357. * Gets the box size of the impostor
  50358. * @param impostor impostor to get box size from
  50359. * @param result the resulting box size
  50360. */
  50361. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50362. /**
  50363. * Disposes of the impostor
  50364. */
  50365. dispose(): void;
  50366. /**
  50367. * Does a raycast in the physics world
  50368. * @param from when should the ray start?
  50369. * @param to when should the ray end?
  50370. * @returns PhysicsRaycastResult
  50371. */
  50372. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50373. }
  50374. }
  50375. declare module BABYLON {
  50376. interface AbstractScene {
  50377. /**
  50378. * The list of reflection probes added to the scene
  50379. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50380. */
  50381. reflectionProbes: Array<ReflectionProbe>;
  50382. /**
  50383. * Removes the given reflection probe from this scene.
  50384. * @param toRemove The reflection probe to remove
  50385. * @returns The index of the removed reflection probe
  50386. */
  50387. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50388. /**
  50389. * Adds the given reflection probe to this scene.
  50390. * @param newReflectionProbe The reflection probe to add
  50391. */
  50392. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50393. }
  50394. /**
  50395. * Class used to generate realtime reflection / refraction cube textures
  50396. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50397. */
  50398. export class ReflectionProbe {
  50399. /** defines the name of the probe */
  50400. name: string;
  50401. private _scene;
  50402. private _renderTargetTexture;
  50403. private _projectionMatrix;
  50404. private _viewMatrix;
  50405. private _target;
  50406. private _add;
  50407. private _attachedMesh;
  50408. private _invertYAxis;
  50409. /** Gets or sets probe position (center of the cube map) */
  50410. position: Vector3;
  50411. /**
  50412. * Creates a new reflection probe
  50413. * @param name defines the name of the probe
  50414. * @param size defines the texture resolution (for each face)
  50415. * @param scene defines the hosting scene
  50416. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50417. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50418. */
  50419. constructor(
  50420. /** defines the name of the probe */
  50421. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50422. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50423. samples: number;
  50424. /** Gets or sets the refresh rate to use (on every frame by default) */
  50425. refreshRate: number;
  50426. /**
  50427. * Gets the hosting scene
  50428. * @returns a Scene
  50429. */
  50430. getScene(): Scene;
  50431. /** Gets the internal CubeTexture used to render to */
  50432. readonly cubeTexture: RenderTargetTexture;
  50433. /** Gets the list of meshes to render */
  50434. readonly renderList: Nullable<AbstractMesh[]>;
  50435. /**
  50436. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50437. * @param mesh defines the mesh to attach to
  50438. */
  50439. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50440. /**
  50441. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50442. * @param renderingGroupId The rendering group id corresponding to its index
  50443. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50444. */
  50445. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50446. /**
  50447. * Clean all associated resources
  50448. */
  50449. dispose(): void;
  50450. /**
  50451. * Converts the reflection probe information to a readable string for debug purpose.
  50452. * @param fullDetails Supports for multiple levels of logging within scene loading
  50453. * @returns the human readable reflection probe info
  50454. */
  50455. toString(fullDetails?: boolean): string;
  50456. /**
  50457. * Get the class name of the relfection probe.
  50458. * @returns "ReflectionProbe"
  50459. */
  50460. getClassName(): string;
  50461. /**
  50462. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50463. * @returns The JSON representation of the texture
  50464. */
  50465. serialize(): any;
  50466. /**
  50467. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50468. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50469. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50470. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50471. * @returns The parsed reflection probe if successful
  50472. */
  50473. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50474. }
  50475. }
  50476. declare module BABYLON {
  50477. /** @hidden */
  50478. export var _BabylonLoaderRegistered: boolean;
  50479. }
  50480. declare module BABYLON {
  50481. /**
  50482. * The Physically based simple base material of BJS.
  50483. *
  50484. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50485. * It is used as the base class for both the specGloss and metalRough conventions.
  50486. */
  50487. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50488. /**
  50489. * Number of Simultaneous lights allowed on the material.
  50490. */
  50491. maxSimultaneousLights: number;
  50492. /**
  50493. * If sets to true, disables all the lights affecting the material.
  50494. */
  50495. disableLighting: boolean;
  50496. /**
  50497. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50498. */
  50499. environmentTexture: BaseTexture;
  50500. /**
  50501. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50502. */
  50503. invertNormalMapX: boolean;
  50504. /**
  50505. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50506. */
  50507. invertNormalMapY: boolean;
  50508. /**
  50509. * Normal map used in the model.
  50510. */
  50511. normalTexture: BaseTexture;
  50512. /**
  50513. * Emissivie color used to self-illuminate the model.
  50514. */
  50515. emissiveColor: Color3;
  50516. /**
  50517. * Emissivie texture used to self-illuminate the model.
  50518. */
  50519. emissiveTexture: BaseTexture;
  50520. /**
  50521. * Occlusion Channel Strenght.
  50522. */
  50523. occlusionStrength: number;
  50524. /**
  50525. * Occlusion Texture of the material (adding extra occlusion effects).
  50526. */
  50527. occlusionTexture: BaseTexture;
  50528. /**
  50529. * Defines the alpha limits in alpha test mode.
  50530. */
  50531. alphaCutOff: number;
  50532. /**
  50533. * Gets the current double sided mode.
  50534. */
  50535. /**
  50536. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50537. */
  50538. doubleSided: boolean;
  50539. /**
  50540. * Stores the pre-calculated light information of a mesh in a texture.
  50541. */
  50542. lightmapTexture: BaseTexture;
  50543. /**
  50544. * If true, the light map contains occlusion information instead of lighting info.
  50545. */
  50546. useLightmapAsShadowmap: boolean;
  50547. /**
  50548. * Instantiates a new PBRMaterial instance.
  50549. *
  50550. * @param name The material name
  50551. * @param scene The scene the material will be use in.
  50552. */
  50553. constructor(name: string, scene: Scene);
  50554. getClassName(): string;
  50555. }
  50556. }
  50557. declare module BABYLON {
  50558. /**
  50559. * The PBR material of BJS following the metal roughness convention.
  50560. *
  50561. * This fits to the PBR convention in the GLTF definition:
  50562. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50563. */
  50564. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50565. /**
  50566. * The base color has two different interpretations depending on the value of metalness.
  50567. * When the material is a metal, the base color is the specific measured reflectance value
  50568. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50569. * of the material.
  50570. */
  50571. baseColor: Color3;
  50572. /**
  50573. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50574. * well as opacity information in the alpha channel.
  50575. */
  50576. baseTexture: BaseTexture;
  50577. /**
  50578. * Specifies the metallic scalar value of the material.
  50579. * Can also be used to scale the metalness values of the metallic texture.
  50580. */
  50581. metallic: number;
  50582. /**
  50583. * Specifies the roughness scalar value of the material.
  50584. * Can also be used to scale the roughness values of the metallic texture.
  50585. */
  50586. roughness: number;
  50587. /**
  50588. * Texture containing both the metallic value in the B channel and the
  50589. * roughness value in the G channel to keep better precision.
  50590. */
  50591. metallicRoughnessTexture: BaseTexture;
  50592. /**
  50593. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50594. *
  50595. * @param name The material name
  50596. * @param scene The scene the material will be use in.
  50597. */
  50598. constructor(name: string, scene: Scene);
  50599. /**
  50600. * Return the currrent class name of the material.
  50601. */
  50602. getClassName(): string;
  50603. /**
  50604. * Makes a duplicate of the current material.
  50605. * @param name - name to use for the new material.
  50606. */
  50607. clone(name: string): PBRMetallicRoughnessMaterial;
  50608. /**
  50609. * Serialize the material to a parsable JSON object.
  50610. */
  50611. serialize(): any;
  50612. /**
  50613. * Parses a JSON object correponding to the serialize function.
  50614. */
  50615. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50616. }
  50617. }
  50618. declare module BABYLON {
  50619. /**
  50620. * The PBR material of BJS following the specular glossiness convention.
  50621. *
  50622. * This fits to the PBR convention in the GLTF definition:
  50623. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50624. */
  50625. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50626. /**
  50627. * Specifies the diffuse color of the material.
  50628. */
  50629. diffuseColor: Color3;
  50630. /**
  50631. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50632. * channel.
  50633. */
  50634. diffuseTexture: BaseTexture;
  50635. /**
  50636. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50637. */
  50638. specularColor: Color3;
  50639. /**
  50640. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50641. */
  50642. glossiness: number;
  50643. /**
  50644. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50645. */
  50646. specularGlossinessTexture: BaseTexture;
  50647. /**
  50648. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50649. *
  50650. * @param name The material name
  50651. * @param scene The scene the material will be use in.
  50652. */
  50653. constructor(name: string, scene: Scene);
  50654. /**
  50655. * Return the currrent class name of the material.
  50656. */
  50657. getClassName(): string;
  50658. /**
  50659. * Makes a duplicate of the current material.
  50660. * @param name - name to use for the new material.
  50661. */
  50662. clone(name: string): PBRSpecularGlossinessMaterial;
  50663. /**
  50664. * Serialize the material to a parsable JSON object.
  50665. */
  50666. serialize(): any;
  50667. /**
  50668. * Parses a JSON object correponding to the serialize function.
  50669. */
  50670. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50671. }
  50672. }
  50673. declare module BABYLON {
  50674. /**
  50675. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50676. * It can help converting any input color in a desired output one. This can then be used to create effects
  50677. * from sepia, black and white to sixties or futuristic rendering...
  50678. *
  50679. * The only supported format is currently 3dl.
  50680. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50681. */
  50682. export class ColorGradingTexture extends BaseTexture {
  50683. /**
  50684. * The current texture matrix. (will always be identity in color grading texture)
  50685. */
  50686. private _textureMatrix;
  50687. /**
  50688. * The texture URL.
  50689. */
  50690. url: string;
  50691. /**
  50692. * Empty line regex stored for GC.
  50693. */
  50694. private static _noneEmptyLineRegex;
  50695. private _engine;
  50696. /**
  50697. * Instantiates a ColorGradingTexture from the following parameters.
  50698. *
  50699. * @param url The location of the color gradind data (currently only supporting 3dl)
  50700. * @param scene The scene the texture will be used in
  50701. */
  50702. constructor(url: string, scene: Scene);
  50703. /**
  50704. * Returns the texture matrix used in most of the material.
  50705. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50706. */
  50707. getTextureMatrix(): Matrix;
  50708. /**
  50709. * Occurs when the file being loaded is a .3dl LUT file.
  50710. */
  50711. private load3dlTexture;
  50712. /**
  50713. * Starts the loading process of the texture.
  50714. */
  50715. private loadTexture;
  50716. /**
  50717. * Clones the color gradind texture.
  50718. */
  50719. clone(): ColorGradingTexture;
  50720. /**
  50721. * Called during delayed load for textures.
  50722. */
  50723. delayLoad(): void;
  50724. /**
  50725. * Parses a color grading texture serialized by Babylon.
  50726. * @param parsedTexture The texture information being parsedTexture
  50727. * @param scene The scene to load the texture in
  50728. * @param rootUrl The root url of the data assets to load
  50729. * @return A color gradind texture
  50730. */
  50731. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50732. /**
  50733. * Serializes the LUT texture to json format.
  50734. */
  50735. serialize(): any;
  50736. }
  50737. }
  50738. declare module BABYLON {
  50739. /**
  50740. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50741. */
  50742. export class EquiRectangularCubeTexture extends BaseTexture {
  50743. /** The six faces of the cube. */
  50744. private static _FacesMapping;
  50745. private _noMipmap;
  50746. private _onLoad;
  50747. private _onError;
  50748. /** The size of the cubemap. */
  50749. private _size;
  50750. /** The buffer of the image. */
  50751. private _buffer;
  50752. /** The width of the input image. */
  50753. private _width;
  50754. /** The height of the input image. */
  50755. private _height;
  50756. /** The URL to the image. */
  50757. url: string;
  50758. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50759. coordinatesMode: number;
  50760. /**
  50761. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50762. * @param url The location of the image
  50763. * @param scene The scene the texture will be used in
  50764. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50765. * @param noMipmap Forces to not generate the mipmap if true
  50766. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50767. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50768. * @param onLoad — defines a callback called when texture is loaded
  50769. * @param onError — defines a callback called if there is an error
  50770. */
  50771. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50772. /**
  50773. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50774. */
  50775. private loadImage;
  50776. /**
  50777. * Convert the image buffer into a cubemap and create a CubeTexture.
  50778. */
  50779. private loadTexture;
  50780. /**
  50781. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  50782. * @param buffer The ArrayBuffer that should be converted.
  50783. * @returns The buffer as Float32Array.
  50784. */
  50785. private getFloat32ArrayFromArrayBuffer;
  50786. /**
  50787. * Get the current class name of the texture useful for serialization or dynamic coding.
  50788. * @returns "EquiRectangularCubeTexture"
  50789. */
  50790. getClassName(): string;
  50791. /**
  50792. * Create a clone of the current EquiRectangularCubeTexture and return it.
  50793. * @returns A clone of the current EquiRectangularCubeTexture.
  50794. */
  50795. clone(): EquiRectangularCubeTexture;
  50796. }
  50797. }
  50798. declare module BABYLON {
  50799. /**
  50800. * Based on jsTGALoader - Javascript loader for TGA file
  50801. * By Vincent Thibault
  50802. * @see http://blog.robrowser.com/javascript-tga-loader.html
  50803. */
  50804. export class TGATools {
  50805. private static _TYPE_INDEXED;
  50806. private static _TYPE_RGB;
  50807. private static _TYPE_GREY;
  50808. private static _TYPE_RLE_INDEXED;
  50809. private static _TYPE_RLE_RGB;
  50810. private static _TYPE_RLE_GREY;
  50811. private static _ORIGIN_MASK;
  50812. private static _ORIGIN_SHIFT;
  50813. private static _ORIGIN_BL;
  50814. private static _ORIGIN_BR;
  50815. private static _ORIGIN_UL;
  50816. private static _ORIGIN_UR;
  50817. /**
  50818. * Gets the header of a TGA file
  50819. * @param data defines the TGA data
  50820. * @returns the header
  50821. */
  50822. static GetTGAHeader(data: Uint8Array): any;
  50823. /**
  50824. * Uploads TGA content to a Babylon Texture
  50825. * @hidden
  50826. */
  50827. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  50828. /** @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;
  50829. /** @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;
  50830. /** @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;
  50831. /** @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;
  50832. /** @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;
  50833. /** @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;
  50834. }
  50835. }
  50836. declare module BABYLON {
  50837. /**
  50838. * Implementation of the TGA Texture Loader.
  50839. * @hidden
  50840. */
  50841. export class _TGATextureLoader implements IInternalTextureLoader {
  50842. /**
  50843. * Defines wether the loader supports cascade loading the different faces.
  50844. */
  50845. readonly supportCascades: boolean;
  50846. /**
  50847. * This returns if the loader support the current file information.
  50848. * @param extension defines the file extension of the file being loaded
  50849. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50850. * @param fallback defines the fallback internal texture if any
  50851. * @param isBase64 defines whether the texture is encoded as a base64
  50852. * @param isBuffer defines whether the texture data are stored as a buffer
  50853. * @returns true if the loader can load the specified file
  50854. */
  50855. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50856. /**
  50857. * Transform the url before loading if required.
  50858. * @param rootUrl the url of the texture
  50859. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50860. * @returns the transformed texture
  50861. */
  50862. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50863. /**
  50864. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50865. * @param rootUrl the url of the texture
  50866. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50867. * @returns the fallback texture
  50868. */
  50869. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50870. /**
  50871. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50872. * @param data contains the texture data
  50873. * @param texture defines the BabylonJS internal texture
  50874. * @param createPolynomials will be true if polynomials have been requested
  50875. * @param onLoad defines the callback to trigger once the texture is ready
  50876. * @param onError defines the callback to trigger in case of error
  50877. */
  50878. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50879. /**
  50880. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50881. * @param data contains the texture data
  50882. * @param texture defines the BabylonJS internal texture
  50883. * @param callback defines the method to call once ready to upload
  50884. */
  50885. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50886. }
  50887. }
  50888. declare module BABYLON {
  50889. /**
  50890. * Info about the .basis files
  50891. */
  50892. class BasisFileInfo {
  50893. /**
  50894. * If the file has alpha
  50895. */
  50896. hasAlpha: boolean;
  50897. /**
  50898. * Info about each image of the basis file
  50899. */
  50900. images: Array<{
  50901. levels: Array<{
  50902. width: number;
  50903. height: number;
  50904. transcodedPixels: ArrayBufferView;
  50905. }>;
  50906. }>;
  50907. }
  50908. /**
  50909. * Result of transcoding a basis file
  50910. */
  50911. class TranscodeResult {
  50912. /**
  50913. * Info about the .basis file
  50914. */
  50915. fileInfo: BasisFileInfo;
  50916. /**
  50917. * Format to use when loading the file
  50918. */
  50919. format: number;
  50920. }
  50921. /**
  50922. * Configuration options for the Basis transcoder
  50923. */
  50924. export class BasisTranscodeConfiguration {
  50925. /**
  50926. * Supported compression formats used to determine the supported output format of the transcoder
  50927. */
  50928. supportedCompressionFormats?: {
  50929. /**
  50930. * etc1 compression format
  50931. */
  50932. etc1?: boolean;
  50933. /**
  50934. * s3tc compression format
  50935. */
  50936. s3tc?: boolean;
  50937. /**
  50938. * pvrtc compression format
  50939. */
  50940. pvrtc?: boolean;
  50941. /**
  50942. * etc2 compression format
  50943. */
  50944. etc2?: boolean;
  50945. };
  50946. /**
  50947. * If mipmap levels should be loaded for transcoded images (Default: true)
  50948. */
  50949. loadMipmapLevels?: boolean;
  50950. /**
  50951. * Index of a single image to load (Default: all images)
  50952. */
  50953. loadSingleImage?: number;
  50954. }
  50955. /**
  50956. * Used to load .Basis files
  50957. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  50958. */
  50959. export class BasisTools {
  50960. private static _IgnoreSupportedFormats;
  50961. /**
  50962. * URL to use when loading the basis transcoder
  50963. */
  50964. static JSModuleURL: string;
  50965. /**
  50966. * URL to use when loading the wasm module for the transcoder
  50967. */
  50968. static WasmModuleURL: string;
  50969. /**
  50970. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  50971. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  50972. * @returns internal format corresponding to the Basis format
  50973. */
  50974. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  50975. private static _WorkerPromise;
  50976. private static _Worker;
  50977. private static _actionId;
  50978. private static _CreateWorkerAsync;
  50979. /**
  50980. * Transcodes a loaded image file to compressed pixel data
  50981. * @param imageData image data to transcode
  50982. * @param config configuration options for the transcoding
  50983. * @returns a promise resulting in the transcoded image
  50984. */
  50985. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  50986. /**
  50987. * Loads a texture from the transcode result
  50988. * @param texture texture load to
  50989. * @param transcodeResult the result of transcoding the basis file to load from
  50990. */
  50991. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  50992. }
  50993. }
  50994. declare module BABYLON {
  50995. /**
  50996. * Loader for .basis file format
  50997. */
  50998. export class _BasisTextureLoader implements IInternalTextureLoader {
  50999. /**
  51000. * Defines whether the loader supports cascade loading the different faces.
  51001. */
  51002. readonly supportCascades: boolean;
  51003. /**
  51004. * This returns if the loader support the current file information.
  51005. * @param extension defines the file extension of the file being loaded
  51006. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51007. * @param fallback defines the fallback internal texture if any
  51008. * @param isBase64 defines whether the texture is encoded as a base64
  51009. * @param isBuffer defines whether the texture data are stored as a buffer
  51010. * @returns true if the loader can load the specified file
  51011. */
  51012. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51013. /**
  51014. * Transform the url before loading if required.
  51015. * @param rootUrl the url of the texture
  51016. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51017. * @returns the transformed texture
  51018. */
  51019. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51020. /**
  51021. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51022. * @param rootUrl the url of the texture
  51023. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51024. * @returns the fallback texture
  51025. */
  51026. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51027. /**
  51028. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  51029. * @param data contains the texture data
  51030. * @param texture defines the BabylonJS internal texture
  51031. * @param createPolynomials will be true if polynomials have been requested
  51032. * @param onLoad defines the callback to trigger once the texture is ready
  51033. * @param onError defines the callback to trigger in case of error
  51034. */
  51035. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51036. /**
  51037. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51038. * @param data contains the texture data
  51039. * @param texture defines the BabylonJS internal texture
  51040. * @param callback defines the method to call once ready to upload
  51041. */
  51042. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51043. }
  51044. }
  51045. declare module BABYLON {
  51046. /**
  51047. * 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.
  51048. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51049. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51050. */
  51051. export class CustomProceduralTexture extends ProceduralTexture {
  51052. private _animate;
  51053. private _time;
  51054. private _config;
  51055. private _texturePath;
  51056. /**
  51057. * Instantiates a new Custom Procedural Texture.
  51058. * 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.
  51059. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51060. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51061. * @param name Define the name of the texture
  51062. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51063. * @param size Define the size of the texture to create
  51064. * @param scene Define the scene the texture belongs to
  51065. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51066. * @param generateMipMaps Define if the texture should creates mip maps or not
  51067. */
  51068. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51069. private _loadJson;
  51070. /**
  51071. * Is the texture ready to be used ? (rendered at least once)
  51072. * @returns true if ready, otherwise, false.
  51073. */
  51074. isReady(): boolean;
  51075. /**
  51076. * Render the texture to its associated render target.
  51077. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51078. */
  51079. render(useCameraPostProcess?: boolean): void;
  51080. /**
  51081. * Update the list of dependant textures samplers in the shader.
  51082. */
  51083. updateTextures(): void;
  51084. /**
  51085. * Update the uniform values of the procedural texture in the shader.
  51086. */
  51087. updateShaderUniforms(): void;
  51088. /**
  51089. * Define if the texture animates or not.
  51090. */
  51091. animate: boolean;
  51092. }
  51093. }
  51094. declare module BABYLON {
  51095. /** @hidden */
  51096. export var noisePixelShader: {
  51097. name: string;
  51098. shader: string;
  51099. };
  51100. }
  51101. declare module BABYLON {
  51102. /**
  51103. * Class used to generate noise procedural textures
  51104. */
  51105. export class NoiseProceduralTexture extends ProceduralTexture {
  51106. private _time;
  51107. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51108. brightness: number;
  51109. /** Defines the number of octaves to process */
  51110. octaves: number;
  51111. /** Defines the level of persistence (0.8 by default) */
  51112. persistence: number;
  51113. /** Gets or sets animation speed factor (default is 1) */
  51114. animationSpeedFactor: number;
  51115. /**
  51116. * Creates a new NoiseProceduralTexture
  51117. * @param name defines the name fo the texture
  51118. * @param size defines the size of the texture (default is 256)
  51119. * @param scene defines the hosting scene
  51120. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51121. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51122. */
  51123. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51124. private _updateShaderUniforms;
  51125. protected _getDefines(): string;
  51126. /** Generate the current state of the procedural texture */
  51127. render(useCameraPostProcess?: boolean): void;
  51128. /**
  51129. * Serializes this noise procedural texture
  51130. * @returns a serialized noise procedural texture object
  51131. */
  51132. serialize(): any;
  51133. /**
  51134. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51135. * @param parsedTexture defines parsed texture data
  51136. * @param scene defines the current scene
  51137. * @param rootUrl defines the root URL containing noise procedural texture information
  51138. * @returns a parsed NoiseProceduralTexture
  51139. */
  51140. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51141. }
  51142. }
  51143. declare module BABYLON {
  51144. /**
  51145. * Raw cube texture where the raw buffers are passed in
  51146. */
  51147. export class RawCubeTexture extends CubeTexture {
  51148. /**
  51149. * Creates a cube texture where the raw buffers are passed in.
  51150. * @param scene defines the scene the texture is attached to
  51151. * @param data defines the array of data to use to create each face
  51152. * @param size defines the size of the textures
  51153. * @param format defines the format of the data
  51154. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51155. * @param generateMipMaps defines if the engine should generate the mip levels
  51156. * @param invertY defines if data must be stored with Y axis inverted
  51157. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51158. * @param compression defines the compression used (null by default)
  51159. */
  51160. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51161. /**
  51162. * Updates the raw cube texture.
  51163. * @param data defines the data to store
  51164. * @param format defines the data format
  51165. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51166. * @param invertY defines if data must be stored with Y axis inverted
  51167. * @param compression defines the compression used (null by default)
  51168. * @param level defines which level of the texture to update
  51169. */
  51170. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51171. /**
  51172. * Updates a raw cube texture with RGBD encoded data.
  51173. * @param data defines the array of data [mipmap][face] to use to create each face
  51174. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51175. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51176. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51177. * @returns a promsie that resolves when the operation is complete
  51178. */
  51179. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51180. /**
  51181. * Clones the raw cube texture.
  51182. * @return a new cube texture
  51183. */
  51184. clone(): CubeTexture;
  51185. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51186. }
  51187. }
  51188. declare module BABYLON {
  51189. /**
  51190. * Class used to store 3D textures containing user data
  51191. */
  51192. export class RawTexture3D extends Texture {
  51193. /** Gets or sets the texture format to use */
  51194. format: number;
  51195. private _engine;
  51196. /**
  51197. * Create a new RawTexture3D
  51198. * @param data defines the data of the texture
  51199. * @param width defines the width of the texture
  51200. * @param height defines the height of the texture
  51201. * @param depth defines the depth of the texture
  51202. * @param format defines the texture format to use
  51203. * @param scene defines the hosting scene
  51204. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51205. * @param invertY defines if texture must be stored with Y axis inverted
  51206. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51207. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51208. */
  51209. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51210. /** Gets or sets the texture format to use */
  51211. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51212. /**
  51213. * Update the texture with new data
  51214. * @param data defines the data to store in the texture
  51215. */
  51216. update(data: ArrayBufferView): void;
  51217. }
  51218. }
  51219. declare module BABYLON {
  51220. /**
  51221. * Creates a refraction texture used by refraction channel of the standard material.
  51222. * It is like a mirror but to see through a material.
  51223. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51224. */
  51225. export class RefractionTexture extends RenderTargetTexture {
  51226. /**
  51227. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51228. * 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.
  51229. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51230. */
  51231. refractionPlane: Plane;
  51232. /**
  51233. * Define how deep under the surface we should see.
  51234. */
  51235. depth: number;
  51236. /**
  51237. * Creates a refraction texture used by refraction channel of the standard material.
  51238. * It is like a mirror but to see through a material.
  51239. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51240. * @param name Define the texture name
  51241. * @param size Define the size of the underlying texture
  51242. * @param scene Define the scene the refraction belongs to
  51243. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51244. */
  51245. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51246. /**
  51247. * Clone the refraction texture.
  51248. * @returns the cloned texture
  51249. */
  51250. clone(): RefractionTexture;
  51251. /**
  51252. * Serialize the texture to a JSON representation you could use in Parse later on
  51253. * @returns the serialized JSON representation
  51254. */
  51255. serialize(): any;
  51256. }
  51257. }
  51258. declare module BABYLON {
  51259. /**
  51260. * Defines the options related to the creation of an HtmlElementTexture
  51261. */
  51262. export interface IHtmlElementTextureOptions {
  51263. /**
  51264. * Defines wether mip maps should be created or not.
  51265. */
  51266. generateMipMaps?: boolean;
  51267. /**
  51268. * Defines the sampling mode of the texture.
  51269. */
  51270. samplingMode?: number;
  51271. /**
  51272. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51273. */
  51274. engine: Nullable<Engine>;
  51275. /**
  51276. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51277. */
  51278. scene: Nullable<Scene>;
  51279. }
  51280. /**
  51281. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51282. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51283. * is automatically managed.
  51284. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51285. * in your application.
  51286. *
  51287. * As the update is not automatic, you need to call them manually.
  51288. */
  51289. export class HtmlElementTexture extends BaseTexture {
  51290. /**
  51291. * The texture URL.
  51292. */
  51293. element: HTMLVideoElement | HTMLCanvasElement;
  51294. private static readonly DefaultOptions;
  51295. private _textureMatrix;
  51296. private _engine;
  51297. private _isVideo;
  51298. private _generateMipMaps;
  51299. private _samplingMode;
  51300. /**
  51301. * Instantiates a HtmlElementTexture from the following parameters.
  51302. *
  51303. * @param name Defines the name of the texture
  51304. * @param element Defines the video or canvas the texture is filled with
  51305. * @param options Defines the other none mandatory texture creation options
  51306. */
  51307. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51308. private _createInternalTexture;
  51309. /**
  51310. * Returns the texture matrix used in most of the material.
  51311. */
  51312. getTextureMatrix(): Matrix;
  51313. /**
  51314. * Updates the content of the texture.
  51315. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51316. */
  51317. update(invertY?: Nullable<boolean>): void;
  51318. }
  51319. }
  51320. declare module BABYLON {
  51321. /**
  51322. * Enum used to define the target of a block
  51323. */
  51324. export enum NodeMaterialBlockTargets {
  51325. /** Vertex shader */
  51326. Vertex = 1,
  51327. /** Fragment shader */
  51328. Fragment = 2,
  51329. /** Neutral */
  51330. Neutral = 4,
  51331. /** Vertex and Fragment */
  51332. VertexAndFragment = 3
  51333. }
  51334. }
  51335. declare module BABYLON {
  51336. /**
  51337. * Defines the kind of connection point for node based material
  51338. */
  51339. export enum NodeMaterialBlockConnectionPointTypes {
  51340. /** Float */
  51341. Float = 1,
  51342. /** Int */
  51343. Int = 2,
  51344. /** Vector2 */
  51345. Vector2 = 4,
  51346. /** Vector3 */
  51347. Vector3 = 8,
  51348. /** Vector4 */
  51349. Vector4 = 16,
  51350. /** Color3 */
  51351. Color3 = 32,
  51352. /** Color4 */
  51353. Color4 = 64,
  51354. /** Matrix */
  51355. Matrix = 128,
  51356. /** Detect type based on connection */
  51357. AutoDetect = 1024,
  51358. /** Output type that will be defined by input type */
  51359. BasedOnInput = 2048
  51360. }
  51361. }
  51362. declare module BABYLON {
  51363. /**
  51364. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  51365. */
  51366. export enum NodeMaterialBlockConnectionPointMode {
  51367. /** Value is an uniform */
  51368. Uniform = 0,
  51369. /** Value is a mesh attribute */
  51370. Attribute = 1,
  51371. /** Value is a varying between vertex and fragment shaders */
  51372. Varying = 2,
  51373. /** Mode is undefined */
  51374. Undefined = 3
  51375. }
  51376. }
  51377. declare module BABYLON {
  51378. /**
  51379. * Enum used to define system values e.g. values automatically provided by the system
  51380. */
  51381. export enum NodeMaterialSystemValues {
  51382. /** World */
  51383. World = 1,
  51384. /** View */
  51385. View = 2,
  51386. /** Projection */
  51387. Projection = 3,
  51388. /** ViewProjection */
  51389. ViewProjection = 4,
  51390. /** WorldView */
  51391. WorldView = 5,
  51392. /** WorldViewProjection */
  51393. WorldViewProjection = 6,
  51394. /** CameraPosition */
  51395. CameraPosition = 7,
  51396. /** Fog Color */
  51397. FogColor = 8
  51398. }
  51399. }
  51400. declare module BABYLON {
  51401. /**
  51402. * Root class for all node material optimizers
  51403. */
  51404. export class NodeMaterialOptimizer {
  51405. /**
  51406. * Function used to optimize a NodeMaterial graph
  51407. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  51408. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  51409. */
  51410. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  51411. }
  51412. }
  51413. declare module BABYLON {
  51414. /**
  51415. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  51416. */
  51417. export class TransformBlock extends NodeMaterialBlock {
  51418. /**
  51419. * Defines the value to use to complement W value to transform it to a Vector4
  51420. */
  51421. complementW: number;
  51422. /**
  51423. * Defines the value to use to complement z value to transform it to a Vector4
  51424. */
  51425. complementZ: number;
  51426. /**
  51427. * Creates a new TransformBlock
  51428. * @param name defines the block name
  51429. */
  51430. constructor(name: string);
  51431. /**
  51432. * Gets the current class name
  51433. * @returns the class name
  51434. */
  51435. getClassName(): string;
  51436. /**
  51437. * Gets the vector input
  51438. */
  51439. readonly vector: NodeMaterialConnectionPoint;
  51440. /**
  51441. * Gets the output component
  51442. */
  51443. readonly output: NodeMaterialConnectionPoint;
  51444. /**
  51445. * Gets the matrix transform input
  51446. */
  51447. readonly transform: NodeMaterialConnectionPoint;
  51448. protected _buildBlock(state: NodeMaterialBuildState): this;
  51449. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51450. protected _dumpPropertiesCode(): string;
  51451. }
  51452. }
  51453. declare module BABYLON {
  51454. /**
  51455. * Block used to output the vertex position
  51456. */
  51457. export class VertexOutputBlock extends NodeMaterialBlock {
  51458. /**
  51459. * Creates a new VertexOutputBlock
  51460. * @param name defines the block name
  51461. */
  51462. constructor(name: string);
  51463. /**
  51464. * Gets the current class name
  51465. * @returns the class name
  51466. */
  51467. getClassName(): string;
  51468. /**
  51469. * Gets the vector input component
  51470. */
  51471. readonly vector: NodeMaterialConnectionPoint;
  51472. protected _buildBlock(state: NodeMaterialBuildState): this;
  51473. }
  51474. }
  51475. declare module BABYLON {
  51476. /**
  51477. * Block used to output the final color
  51478. */
  51479. export class FragmentOutputBlock extends NodeMaterialBlock {
  51480. /**
  51481. * Create a new FragmentOutputBlock
  51482. * @param name defines the block name
  51483. */
  51484. constructor(name: string);
  51485. /**
  51486. * Gets the current class name
  51487. * @returns the class name
  51488. */
  51489. getClassName(): string;
  51490. /**
  51491. * Gets the rgba input component
  51492. */
  51493. readonly rgba: NodeMaterialConnectionPoint;
  51494. /**
  51495. * Gets the rgb input component
  51496. */
  51497. readonly rgb: NodeMaterialConnectionPoint;
  51498. /**
  51499. * Gets the a input component
  51500. */
  51501. readonly a: NodeMaterialConnectionPoint;
  51502. protected _buildBlock(state: NodeMaterialBuildState): this;
  51503. }
  51504. }
  51505. declare module BABYLON {
  51506. /**
  51507. * Block used to read a reflection texture from a sampler
  51508. */
  51509. export class ReflectionTextureBlock extends NodeMaterialBlock {
  51510. private _define3DName;
  51511. private _defineCubicName;
  51512. private _defineExplicitName;
  51513. private _defineProjectionName;
  51514. private _defineLocalCubicName;
  51515. private _defineSphericalName;
  51516. private _definePlanarName;
  51517. private _defineEquirectangularName;
  51518. private _defineMirroredEquirectangularFixedName;
  51519. private _defineEquirectangularFixedName;
  51520. private _defineSkyboxName;
  51521. private _cubeSamplerName;
  51522. private _2DSamplerName;
  51523. private _positionUVWName;
  51524. private _directionWName;
  51525. private _reflectionCoordsName;
  51526. private _reflection2DCoordsName;
  51527. private _reflectionColorName;
  51528. private _reflectionMatrixName;
  51529. /**
  51530. * Gets or sets the texture associated with the node
  51531. */
  51532. texture: Nullable<BaseTexture>;
  51533. /**
  51534. * Create a new TextureBlock
  51535. * @param name defines the block name
  51536. */
  51537. constructor(name: string);
  51538. /**
  51539. * Gets the current class name
  51540. * @returns the class name
  51541. */
  51542. getClassName(): string;
  51543. /**
  51544. * Gets the world position input component
  51545. */
  51546. readonly position: NodeMaterialConnectionPoint;
  51547. /**
  51548. * Gets the world position input component
  51549. */
  51550. readonly worldPosition: NodeMaterialConnectionPoint;
  51551. /**
  51552. * Gets the world normal input component
  51553. */
  51554. readonly worldNormal: NodeMaterialConnectionPoint;
  51555. /**
  51556. * Gets the world input component
  51557. */
  51558. readonly world: NodeMaterialConnectionPoint;
  51559. /**
  51560. * Gets the camera (or eye) position component
  51561. */
  51562. readonly cameraPosition: NodeMaterialConnectionPoint;
  51563. /**
  51564. * Gets the view input component
  51565. */
  51566. readonly view: NodeMaterialConnectionPoint;
  51567. /**
  51568. * Gets the rgb output component
  51569. */
  51570. readonly rgb: NodeMaterialConnectionPoint;
  51571. /**
  51572. * Gets the r output component
  51573. */
  51574. readonly r: NodeMaterialConnectionPoint;
  51575. /**
  51576. * Gets the g output component
  51577. */
  51578. readonly g: NodeMaterialConnectionPoint;
  51579. /**
  51580. * Gets the b output component
  51581. */
  51582. readonly b: NodeMaterialConnectionPoint;
  51583. autoConfigure(material: NodeMaterial): void;
  51584. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51585. isReady(): boolean;
  51586. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51587. private _injectVertexCode;
  51588. private _writeOutput;
  51589. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51590. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51591. }
  51592. }
  51593. declare module BABYLON {
  51594. /**
  51595. * Interface used to configure the node material editor
  51596. */
  51597. export interface INodeMaterialEditorOptions {
  51598. /** Define the URl to load node editor script */
  51599. editorURL?: string;
  51600. }
  51601. /** @hidden */
  51602. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  51603. /** BONES */
  51604. NUM_BONE_INFLUENCERS: number;
  51605. BonesPerMesh: number;
  51606. BONETEXTURE: boolean;
  51607. /** MORPH TARGETS */
  51608. MORPHTARGETS: boolean;
  51609. MORPHTARGETS_NORMAL: boolean;
  51610. MORPHTARGETS_TANGENT: boolean;
  51611. MORPHTARGETS_UV: boolean;
  51612. NUM_MORPH_INFLUENCERS: number;
  51613. /** IMAGE PROCESSING */
  51614. IMAGEPROCESSING: boolean;
  51615. VIGNETTE: boolean;
  51616. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51617. VIGNETTEBLENDMODEOPAQUE: boolean;
  51618. TONEMAPPING: boolean;
  51619. TONEMAPPING_ACES: boolean;
  51620. CONTRAST: boolean;
  51621. EXPOSURE: boolean;
  51622. COLORCURVES: boolean;
  51623. COLORGRADING: boolean;
  51624. COLORGRADING3D: boolean;
  51625. SAMPLER3DGREENDEPTH: boolean;
  51626. SAMPLER3DBGRMAP: boolean;
  51627. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51628. /** MISC. */
  51629. BUMPDIRECTUV: number;
  51630. constructor();
  51631. setValue(name: string, value: boolean): void;
  51632. }
  51633. /**
  51634. * Class used to configure NodeMaterial
  51635. */
  51636. export interface INodeMaterialOptions {
  51637. /**
  51638. * Defines if blocks should emit comments
  51639. */
  51640. emitComments: boolean;
  51641. }
  51642. /**
  51643. * Class used to create a node based material built by assembling shader blocks
  51644. */
  51645. export class NodeMaterial extends PushMaterial {
  51646. private static _BuildIdGenerator;
  51647. private _options;
  51648. private _vertexCompilationState;
  51649. private _fragmentCompilationState;
  51650. private _sharedData;
  51651. private _buildId;
  51652. private _buildWasSuccessful;
  51653. private _cachedWorldViewMatrix;
  51654. private _cachedWorldViewProjectionMatrix;
  51655. private _optimizers;
  51656. private _animationFrame;
  51657. /** Define the URl to load node editor script */
  51658. static EditorURL: string;
  51659. private BJSNODEMATERIALEDITOR;
  51660. /** Get the inspector from bundle or global */
  51661. private _getGlobalNodeMaterialEditor;
  51662. /**
  51663. * 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)
  51664. */
  51665. ignoreAlpha: boolean;
  51666. /**
  51667. * Defines the maximum number of lights that can be used in the material
  51668. */
  51669. maxSimultaneousLights: number;
  51670. /**
  51671. * Observable raised when the material is built
  51672. */
  51673. onBuildObservable: Observable<NodeMaterial>;
  51674. /**
  51675. * Gets or sets the root nodes of the material vertex shader
  51676. */ private _vertexOutputNodes: NodeMaterialBlock[];
  51677. /**
  51678. * Gets or sets the root nodes of the material fragment (pixel) shader
  51679. */ private _fragmentOutputNodes: NodeMaterialBlock[];
  51680. /** Gets or sets options to control the node material overall behavior */
  51681. options: INodeMaterialOptions;
  51682. /**
  51683. * Default configuration related to image processing available in the standard Material.
  51684. */
  51685. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51686. /**
  51687. * Gets the image processing configuration used either in this material.
  51688. */
  51689. /**
  51690. * Sets the Default image processing configuration used either in the this material.
  51691. *
  51692. * If sets to null, the scene one is in use.
  51693. */
  51694. imageProcessingConfiguration: ImageProcessingConfiguration;
  51695. /**
  51696. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  51697. */
  51698. attachedBlocks: NodeMaterialBlock[];
  51699. /**
  51700. * Create a new node based material
  51701. * @param name defines the material name
  51702. * @param scene defines the hosting scene
  51703. * @param options defines creation option
  51704. */
  51705. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  51706. /**
  51707. * Gets the current class name of the material e.g. "NodeMaterial"
  51708. * @returns the class name
  51709. */
  51710. getClassName(): string;
  51711. /**
  51712. * Keep track of the image processing observer to allow dispose and replace.
  51713. */
  51714. private _imageProcessingObserver;
  51715. /**
  51716. * Attaches a new image processing configuration to the Standard Material.
  51717. * @param configuration
  51718. */
  51719. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51720. /**
  51721. * Get a block by its name
  51722. * @param name defines the name of the block to retrieve
  51723. * @returns the required block or null if not found
  51724. */
  51725. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  51726. /**
  51727. * Get a block by its name
  51728. * @param predicate defines the predicate used to find the good candidate
  51729. * @returns the required block or null if not found
  51730. */
  51731. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  51732. /**
  51733. * Get an input block by its name
  51734. * @param predicate defines the predicate used to find the good candidate
  51735. * @returns the required input block or null if not found
  51736. */
  51737. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  51738. /**
  51739. * Gets the list of input blocks attached to this material
  51740. * @returns an array of InputBlocks
  51741. */
  51742. getInputBlocks(): InputBlock[];
  51743. /**
  51744. * Adds a new optimizer to the list of optimizers
  51745. * @param optimizer defines the optimizers to add
  51746. * @returns the current material
  51747. */
  51748. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51749. /**
  51750. * Remove an optimizer from the list of optimizers
  51751. * @param optimizer defines the optimizers to remove
  51752. * @returns the current material
  51753. */
  51754. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51755. /**
  51756. * Add a new block to the list of output nodes
  51757. * @param node defines the node to add
  51758. * @returns the current material
  51759. */
  51760. addOutputNode(node: NodeMaterialBlock): this;
  51761. /**
  51762. * Remove a block from the list of root nodes
  51763. * @param node defines the node to remove
  51764. * @returns the current material
  51765. */
  51766. removeOutputNode(node: NodeMaterialBlock): this;
  51767. private _addVertexOutputNode;
  51768. private _removeVertexOutputNode;
  51769. private _addFragmentOutputNode;
  51770. private _removeFragmentOutputNode;
  51771. /**
  51772. * Specifies if the material will require alpha blending
  51773. * @returns a boolean specifying if alpha blending is needed
  51774. */
  51775. needAlphaBlending(): boolean;
  51776. /**
  51777. * Specifies if this material should be rendered in alpha test mode
  51778. * @returns a boolean specifying if an alpha test is needed.
  51779. */
  51780. needAlphaTesting(): boolean;
  51781. private _initializeBlock;
  51782. private _resetDualBlocks;
  51783. /**
  51784. * Build the material and generates the inner effect
  51785. * @param verbose defines if the build should log activity
  51786. */
  51787. build(verbose?: boolean): void;
  51788. /**
  51789. * Runs an otpimization phase to try to improve the shader code
  51790. */
  51791. optimize(): void;
  51792. private _prepareDefinesForAttributes;
  51793. /**
  51794. * Get if the submesh is ready to be used and all its information available.
  51795. * Child classes can use it to update shaders
  51796. * @param mesh defines the mesh to check
  51797. * @param subMesh defines which submesh to check
  51798. * @param useInstances specifies that instances should be used
  51799. * @returns a boolean indicating that the submesh is ready or not
  51800. */
  51801. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51802. /**
  51803. * Get a string representing the shaders built by the current node graph
  51804. */
  51805. readonly compiledShaders: string;
  51806. /**
  51807. * Binds the world matrix to the material
  51808. * @param world defines the world transformation matrix
  51809. */
  51810. bindOnlyWorldMatrix(world: Matrix): void;
  51811. /**
  51812. * Binds the submesh to this material by preparing the effect and shader to draw
  51813. * @param world defines the world transformation matrix
  51814. * @param mesh defines the mesh containing the submesh
  51815. * @param subMesh defines the submesh to bind the material to
  51816. */
  51817. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51818. /**
  51819. * Gets the active textures from the material
  51820. * @returns an array of textures
  51821. */
  51822. getActiveTextures(): BaseTexture[];
  51823. /**
  51824. * Gets the list of texture blocks
  51825. * @returns an array of texture blocks
  51826. */
  51827. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  51828. /**
  51829. * Specifies if the material uses a texture
  51830. * @param texture defines the texture to check against the material
  51831. * @returns a boolean specifying if the material uses the texture
  51832. */
  51833. hasTexture(texture: BaseTexture): boolean;
  51834. /**
  51835. * Disposes the material
  51836. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  51837. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  51838. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  51839. */
  51840. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  51841. /** Creates the node editor window. */
  51842. private _createNodeEditor;
  51843. /**
  51844. * Launch the node material editor
  51845. * @param config Define the configuration of the editor
  51846. * @return a promise fulfilled when the node editor is visible
  51847. */
  51848. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  51849. /**
  51850. * Clear the current material
  51851. */
  51852. clear(): void;
  51853. /**
  51854. * Clear the current material and set it to a default state
  51855. */
  51856. setToDefault(): void;
  51857. /**
  51858. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  51859. * @param url defines the url to load from
  51860. * @returns a promise that will fullfil when the material is fully loaded
  51861. */
  51862. loadAsync(url: string): Promise<unknown>;
  51863. private _gatherBlocks;
  51864. /**
  51865. * Generate a string containing the code declaration required to create an equivalent of this material
  51866. * @returns a string
  51867. */
  51868. generateCode(): string;
  51869. /**
  51870. * Serializes this material in a JSON representation
  51871. * @returns the serialized material object
  51872. */
  51873. serialize(): any;
  51874. private _restoreConnections;
  51875. /**
  51876. * Clear the current graph and load a new one from a serialization object
  51877. * @param source defines the JSON representation of the material
  51878. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51879. */
  51880. loadFromSerialization(source: any, rootUrl?: string): void;
  51881. /**
  51882. * Creates a node material from parsed material data
  51883. * @param source defines the JSON representation of the material
  51884. * @param scene defines the hosting scene
  51885. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51886. * @returns a new node material
  51887. */
  51888. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  51889. /**
  51890. * Creates a new node material set to default basic configuration
  51891. * @param name defines the name of the material
  51892. * @param scene defines the hosting scene
  51893. * @returns a new NodeMaterial
  51894. */
  51895. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  51896. }
  51897. }
  51898. declare module BABYLON {
  51899. /**
  51900. * Block used to read a texture from a sampler
  51901. */
  51902. export class TextureBlock extends NodeMaterialBlock {
  51903. private _defineName;
  51904. private _samplerName;
  51905. private _transformedUVName;
  51906. private _textureTransformName;
  51907. private _textureInfoName;
  51908. private _mainUVName;
  51909. private _mainUVDefineName;
  51910. /**
  51911. * Gets or sets the texture associated with the node
  51912. */
  51913. texture: Nullable<Texture>;
  51914. /**
  51915. * Create a new TextureBlock
  51916. * @param name defines the block name
  51917. */
  51918. constructor(name: string);
  51919. /**
  51920. * Gets the current class name
  51921. * @returns the class name
  51922. */
  51923. getClassName(): string;
  51924. /**
  51925. * Gets the uv input component
  51926. */
  51927. readonly uv: NodeMaterialConnectionPoint;
  51928. /**
  51929. * Gets the rgba output component
  51930. */
  51931. readonly rgba: NodeMaterialConnectionPoint;
  51932. /**
  51933. * Gets the rgb output component
  51934. */
  51935. readonly rgb: NodeMaterialConnectionPoint;
  51936. /**
  51937. * Gets the r output component
  51938. */
  51939. readonly r: NodeMaterialConnectionPoint;
  51940. /**
  51941. * Gets the g output component
  51942. */
  51943. readonly g: NodeMaterialConnectionPoint;
  51944. /**
  51945. * Gets the b output component
  51946. */
  51947. readonly b: NodeMaterialConnectionPoint;
  51948. /**
  51949. * Gets the a output component
  51950. */
  51951. readonly a: NodeMaterialConnectionPoint;
  51952. readonly target: NodeMaterialBlockTargets;
  51953. autoConfigure(material: NodeMaterial): void;
  51954. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51955. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51956. isReady(): boolean;
  51957. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51958. private readonly _isMixed;
  51959. private _injectVertexCode;
  51960. private _writeOutput;
  51961. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51962. protected _dumpPropertiesCode(): string;
  51963. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51964. }
  51965. }
  51966. declare module BABYLON {
  51967. /**
  51968. * Class used to store shared data between 2 NodeMaterialBuildState
  51969. */
  51970. export class NodeMaterialBuildStateSharedData {
  51971. /**
  51972. * Gets the list of emitted varyings
  51973. */
  51974. temps: string[];
  51975. /**
  51976. * Gets the list of emitted varyings
  51977. */
  51978. varyings: string[];
  51979. /**
  51980. * Gets the varying declaration string
  51981. */
  51982. varyingDeclaration: string;
  51983. /**
  51984. * Input blocks
  51985. */
  51986. inputBlocks: InputBlock[];
  51987. /**
  51988. * Input blocks
  51989. */
  51990. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  51991. /**
  51992. * Bindable blocks (Blocks that need to set data to the effect)
  51993. */
  51994. bindableBlocks: NodeMaterialBlock[];
  51995. /**
  51996. * List of blocks that can provide a compilation fallback
  51997. */
  51998. blocksWithFallbacks: NodeMaterialBlock[];
  51999. /**
  52000. * List of blocks that can provide a define update
  52001. */
  52002. blocksWithDefines: NodeMaterialBlock[];
  52003. /**
  52004. * List of blocks that can provide a repeatable content
  52005. */
  52006. repeatableContentBlocks: NodeMaterialBlock[];
  52007. /**
  52008. * List of blocks that can provide a dynamic list of uniforms
  52009. */
  52010. dynamicUniformBlocks: NodeMaterialBlock[];
  52011. /**
  52012. * List of blocks that can block the isReady function for the material
  52013. */
  52014. blockingBlocks: NodeMaterialBlock[];
  52015. /**
  52016. * Gets the list of animated inputs
  52017. */
  52018. animatedInputs: InputBlock[];
  52019. /**
  52020. * Build Id used to avoid multiple recompilations
  52021. */
  52022. buildId: number;
  52023. /** List of emitted variables */
  52024. variableNames: {
  52025. [key: string]: number;
  52026. };
  52027. /** List of emitted defines */
  52028. defineNames: {
  52029. [key: string]: number;
  52030. };
  52031. /** Should emit comments? */
  52032. emitComments: boolean;
  52033. /** Emit build activity */
  52034. verbose: boolean;
  52035. /** Gets or sets the hosting scene */
  52036. scene: Scene;
  52037. /**
  52038. * Gets the compilation hints emitted at compilation time
  52039. */
  52040. hints: {
  52041. needWorldViewMatrix: boolean;
  52042. needWorldViewProjectionMatrix: boolean;
  52043. needAlphaBlending: boolean;
  52044. needAlphaTesting: boolean;
  52045. };
  52046. /**
  52047. * List of compilation checks
  52048. */
  52049. checks: {
  52050. emitVertex: boolean;
  52051. emitFragment: boolean;
  52052. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52053. };
  52054. /** Creates a new shared data */
  52055. constructor();
  52056. /**
  52057. * Emits console errors and exceptions if there is a failing check
  52058. */
  52059. emitErrors(): void;
  52060. }
  52061. }
  52062. declare module BABYLON {
  52063. /**
  52064. * Class used to store node based material build state
  52065. */
  52066. export class NodeMaterialBuildState {
  52067. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  52068. supportUniformBuffers: boolean;
  52069. /**
  52070. * Gets the list of emitted attributes
  52071. */
  52072. attributes: string[];
  52073. /**
  52074. * Gets the list of emitted uniforms
  52075. */
  52076. uniforms: string[];
  52077. /**
  52078. * Gets the list of emitted constants
  52079. */
  52080. constants: string[];
  52081. /**
  52082. * Gets the list of emitted uniform buffers
  52083. */
  52084. uniformBuffers: string[];
  52085. /**
  52086. * Gets the list of emitted samplers
  52087. */
  52088. samplers: string[];
  52089. /**
  52090. * Gets the list of emitted functions
  52091. */
  52092. functions: {
  52093. [key: string]: string;
  52094. };
  52095. /**
  52096. * Gets the list of emitted extensions
  52097. */
  52098. extensions: {
  52099. [key: string]: string;
  52100. };
  52101. /**
  52102. * Gets the target of the compilation state
  52103. */
  52104. target: NodeMaterialBlockTargets;
  52105. /**
  52106. * Gets the list of emitted counters
  52107. */
  52108. counters: {
  52109. [key: string]: number;
  52110. };
  52111. /**
  52112. * Shared data between multiple NodeMaterialBuildState instances
  52113. */
  52114. sharedData: NodeMaterialBuildStateSharedData;
  52115. /** @hidden */ private _vertexState: NodeMaterialBuildState;
  52116. /** @hidden */ private _attributeDeclaration: string;
  52117. /** @hidden */ private _uniformDeclaration: string;
  52118. /** @hidden */ private _constantDeclaration: string;
  52119. /** @hidden */ private _samplerDeclaration: string;
  52120. /** @hidden */ private _varyingTransfer: string;
  52121. private _repeatableContentAnchorIndex;
  52122. /** @hidden */ private _builtCompilationString: string;
  52123. /**
  52124. * Gets the emitted compilation strings
  52125. */
  52126. compilationString: string;
  52127. /**
  52128. * Finalize the compilation strings
  52129. * @param state defines the current compilation state
  52130. */
  52131. finalize(state: NodeMaterialBuildState): void;
  52132. /** @hidden */ protected readonly _repeatableContentAnchor: string;
  52133. /** @hidden */ private _getFreeVariableName(prefix: string): string;
  52134. /** @hidden */ private _getFreeDefineName(prefix: string): string;
  52135. /** @hidden */ private _excludeVariableName(name: string): void;
  52136. /** @hidden */ private _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52137. /** @hidden */ private _emitExtension(name: string, extension: string): void;
  52138. /** @hidden */ private _emitFunction(name: string, code: string, comments: string): void;
  52139. /** @hidden */ private _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52140. replaceStrings?: {
  52141. search: RegExp;
  52142. replace: string;
  52143. }[];
  52144. repeatKey?: string;
  52145. }): string;
  52146. /** @hidden */ private _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52147. repeatKey?: string;
  52148. removeAttributes?: boolean;
  52149. removeUniforms?: boolean;
  52150. removeVaryings?: boolean;
  52151. removeIfDef?: boolean;
  52152. replaceStrings?: {
  52153. search: RegExp;
  52154. replace: string;
  52155. }[];
  52156. }, storeKey?: string): void;
  52157. /** @hidden */ private _registerTempVariable(name: string): boolean;
  52158. /** @hidden */ private _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  52159. /** @hidden */ private _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  52160. }
  52161. }
  52162. declare module BABYLON {
  52163. /**
  52164. * Defines a block that can be used inside a node based material
  52165. */
  52166. export class NodeMaterialBlock {
  52167. private _buildId;
  52168. private _buildTarget;
  52169. private _target;
  52170. private _isFinalMerger;
  52171. private _isInput;
  52172. /** @hidden */ private _codeVariableName: string;
  52173. /** @hidden */ private _inputs: NodeMaterialConnectionPoint[];
  52174. /** @hidden */ private _outputs: NodeMaterialConnectionPoint[];
  52175. /** @hidden */ private _preparationId: number;
  52176. /**
  52177. * Gets or sets the name of the block
  52178. */
  52179. name: string;
  52180. /**
  52181. * Gets or sets the unique id of the node
  52182. */
  52183. uniqueId: number;
  52184. /**
  52185. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  52186. */
  52187. readonly isFinalMerger: boolean;
  52188. /**
  52189. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  52190. */
  52191. readonly isInput: boolean;
  52192. /**
  52193. * Gets or sets the build Id
  52194. */
  52195. buildId: number;
  52196. /**
  52197. * Gets or sets the target of the block
  52198. */
  52199. target: NodeMaterialBlockTargets;
  52200. /**
  52201. * Gets the list of input points
  52202. */
  52203. readonly inputs: NodeMaterialConnectionPoint[];
  52204. /** Gets the list of output points */
  52205. readonly outputs: NodeMaterialConnectionPoint[];
  52206. /**
  52207. * Find an input by its name
  52208. * @param name defines the name of the input to look for
  52209. * @returns the input or null if not found
  52210. */
  52211. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52212. /**
  52213. * Find an output by its name
  52214. * @param name defines the name of the outputto look for
  52215. * @returns the output or null if not found
  52216. */
  52217. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52218. /**
  52219. * Creates a new NodeMaterialBlock
  52220. * @param name defines the block name
  52221. * @param target defines the target of that block (Vertex by default)
  52222. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  52223. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  52224. */
  52225. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  52226. /**
  52227. * Initialize the block and prepare the context for build
  52228. * @param state defines the state that will be used for the build
  52229. */
  52230. initialize(state: NodeMaterialBuildState): void;
  52231. /**
  52232. * Bind data to effect. Will only be called for blocks with isBindable === true
  52233. * @param effect defines the effect to bind data to
  52234. * @param nodeMaterial defines the hosting NodeMaterial
  52235. * @param mesh defines the mesh that will be rendered
  52236. */
  52237. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52238. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  52239. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  52240. protected _writeFloat(value: number): string;
  52241. /**
  52242. * Gets the current class name e.g. "NodeMaterialBlock"
  52243. * @returns the class name
  52244. */
  52245. getClassName(): string;
  52246. /**
  52247. * Register a new input. Must be called inside a block constructor
  52248. * @param name defines the connection point name
  52249. * @param type defines the connection point type
  52250. * @param isOptional defines a boolean indicating that this input can be omitted
  52251. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52252. * @returns the current block
  52253. */
  52254. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  52255. /**
  52256. * Register a new output. Must be called inside a block constructor
  52257. * @param name defines the connection point name
  52258. * @param type defines the connection point type
  52259. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52260. * @returns the current block
  52261. */
  52262. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  52263. /**
  52264. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  52265. * @param forOutput defines an optional connection point to check compatibility with
  52266. * @returns the first available input or null
  52267. */
  52268. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  52269. /**
  52270. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  52271. * @param forBlock defines an optional block to check compatibility with
  52272. * @returns the first available input or null
  52273. */
  52274. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  52275. /**
  52276. * Gets the sibling of the given output
  52277. * @param current defines the current output
  52278. * @returns the next output in the list or null
  52279. */
  52280. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  52281. /**
  52282. * Connect current block with another block
  52283. * @param other defines the block to connect with
  52284. * @param options define the various options to help pick the right connections
  52285. * @returns the current block
  52286. */
  52287. connectTo(other: NodeMaterialBlock, options?: {
  52288. input?: string;
  52289. output?: string;
  52290. outputSwizzle?: string;
  52291. }): this | undefined;
  52292. protected _buildBlock(state: NodeMaterialBuildState): void;
  52293. /**
  52294. * Add uniforms, samplers and uniform buffers at compilation time
  52295. * @param state defines the state to update
  52296. * @param nodeMaterial defines the node material requesting the update
  52297. * @param defines defines the material defines to update
  52298. */
  52299. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52300. /**
  52301. * Add potential fallbacks if shader compilation fails
  52302. * @param mesh defines the mesh to be rendered
  52303. * @param fallbacks defines the current prioritized list of fallbacks
  52304. */
  52305. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52306. /**
  52307. * Initialize defines for shader compilation
  52308. * @param mesh defines the mesh to be rendered
  52309. * @param nodeMaterial defines the node material requesting the update
  52310. * @param defines defines the material defines to update
  52311. * @param useInstances specifies that instances should be used
  52312. */
  52313. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52314. /**
  52315. * Update defines for shader compilation
  52316. * @param mesh defines the mesh to be rendered
  52317. * @param nodeMaterial defines the node material requesting the update
  52318. * @param defines defines the material defines to update
  52319. * @param useInstances specifies that instances should be used
  52320. */
  52321. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52322. /**
  52323. * Lets the block try to connect some inputs automatically
  52324. * @param material defines the hosting NodeMaterial
  52325. */
  52326. autoConfigure(material: NodeMaterial): void;
  52327. /**
  52328. * Function called when a block is declared as repeatable content generator
  52329. * @param vertexShaderState defines the current compilation state for the vertex shader
  52330. * @param fragmentShaderState defines the current compilation state for the fragment shader
  52331. * @param mesh defines the mesh to be rendered
  52332. * @param defines defines the material defines to update
  52333. */
  52334. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52335. /**
  52336. * Checks if the block is ready
  52337. * @param mesh defines the mesh to be rendered
  52338. * @param nodeMaterial defines the node material requesting the update
  52339. * @param defines defines the material defines to update
  52340. * @param useInstances specifies that instances should be used
  52341. * @returns true if the block is ready
  52342. */
  52343. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  52344. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  52345. private _processBuild;
  52346. /**
  52347. * Compile the current node and generate the shader code
  52348. * @param state defines the current compilation state (uniforms, samplers, current string)
  52349. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  52350. * @returns true if already built
  52351. */
  52352. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  52353. protected _inputRename(name: string): string;
  52354. protected _outputRename(name: string): string;
  52355. protected _dumpPropertiesCode(): string;
  52356. /** @hidden */ private _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  52357. /**
  52358. * Clone the current block to a new identical block
  52359. * @param scene defines the hosting scene
  52360. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52361. * @returns a copy of the current block
  52362. */
  52363. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  52364. /**
  52365. * Serializes this block in a JSON representation
  52366. * @returns the serialized block object
  52367. */
  52368. serialize(): any;
  52369. /** @hidden */ private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52370. }
  52371. }
  52372. declare module BABYLON {
  52373. /**
  52374. * Enum defining the type of animations supported by InputBlock
  52375. */
  52376. export enum AnimatedInputBlockTypes {
  52377. /** No animation */
  52378. None = 0,
  52379. /** Time based animation. Will only work for floats */
  52380. Time = 1
  52381. }
  52382. }
  52383. declare module BABYLON {
  52384. /**
  52385. * Block used to expose an input value
  52386. */
  52387. export class InputBlock extends NodeMaterialBlock {
  52388. private _mode;
  52389. private _associatedVariableName;
  52390. private _storedValue;
  52391. private _valueCallback;
  52392. private _type;
  52393. private _animationType;
  52394. /** Gets or set a value used to limit the range of float values */
  52395. min: number;
  52396. /** Gets or set a value used to limit the range of float values */
  52397. max: number;
  52398. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  52399. matrixMode: number;
  52400. /** @hidden */ private _systemValue: Nullable<NodeMaterialSystemValues>;
  52401. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  52402. visibleInInspector: boolean;
  52403. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  52404. isConstant: boolean;
  52405. /**
  52406. * Gets or sets the connection point type (default is float)
  52407. */
  52408. readonly type: NodeMaterialBlockConnectionPointTypes;
  52409. /**
  52410. * Creates a new InputBlock
  52411. * @param name defines the block name
  52412. * @param target defines the target of that block (Vertex by default)
  52413. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  52414. */
  52415. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  52416. /**
  52417. * Gets the output component
  52418. */
  52419. readonly output: NodeMaterialConnectionPoint;
  52420. /**
  52421. * Set the source of this connection point to a vertex attribute
  52422. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  52423. * @returns the current connection point
  52424. */
  52425. setAsAttribute(attributeName?: string): InputBlock;
  52426. /**
  52427. * Set the source of this connection point to a system value
  52428. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  52429. * @returns the current connection point
  52430. */
  52431. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  52432. /**
  52433. * Gets or sets the value of that point.
  52434. * Please note that this value will be ignored if valueCallback is defined
  52435. */
  52436. value: any;
  52437. /**
  52438. * Gets or sets a callback used to get the value of that point.
  52439. * Please note that setting this value will force the connection point to ignore the value property
  52440. */
  52441. valueCallback: () => any;
  52442. /**
  52443. * Gets or sets the associated variable name in the shader
  52444. */
  52445. associatedVariableName: string;
  52446. /** Gets or sets the type of animation applied to the input */
  52447. animationType: AnimatedInputBlockTypes;
  52448. /**
  52449. * Gets a boolean indicating that this connection point not defined yet
  52450. */
  52451. readonly isUndefined: boolean;
  52452. /**
  52453. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  52454. * In this case the connection point name must be the name of the uniform to use.
  52455. * Can only be set on inputs
  52456. */
  52457. isUniform: boolean;
  52458. /**
  52459. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  52460. * In this case the connection point name must be the name of the attribute to use
  52461. * Can only be set on inputs
  52462. */
  52463. isAttribute: boolean;
  52464. /**
  52465. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  52466. * Can only be set on exit points
  52467. */
  52468. isVarying: boolean;
  52469. /**
  52470. * Gets a boolean indicating that the current connection point is a system value
  52471. */
  52472. readonly isSystemValue: boolean;
  52473. /**
  52474. * Gets or sets the current well known value or null if not defined as a system value
  52475. */
  52476. systemValue: Nullable<NodeMaterialSystemValues>;
  52477. /**
  52478. * Gets the current class name
  52479. * @returns the class name
  52480. */
  52481. getClassName(): string;
  52482. /**
  52483. * Animate the input if animationType !== None
  52484. * @param scene defines the rendering scene
  52485. */
  52486. animate(scene: Scene): void;
  52487. private _emitDefine;
  52488. initialize(state: NodeMaterialBuildState): void;
  52489. /**
  52490. * Set the input block to its default value (based on its type)
  52491. */
  52492. setDefaultValue(): void;
  52493. private _emitConstant;
  52494. private _emit;
  52495. /** @hidden */ private _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  52496. /** @hidden */ private _transmit(effect: Effect, scene: Scene): void;
  52497. protected _buildBlock(state: NodeMaterialBuildState): void;
  52498. protected _dumpPropertiesCode(): string;
  52499. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52500. }
  52501. }
  52502. declare module BABYLON {
  52503. /**
  52504. * Defines a connection point for a block
  52505. */
  52506. export class NodeMaterialConnectionPoint {
  52507. /** @hidden */ private _ownerBlock: NodeMaterialBlock;
  52508. /** @hidden */ private _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52509. private _endpoints;
  52510. private _associatedVariableName;
  52511. /** @hidden */ private _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  52512. /** @hidden */ private _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  52513. private _type;
  52514. /** @hidden */ private _enforceAssociatedVariableName: boolean;
  52515. /**
  52516. * Gets or sets the additional types supported by this connection point
  52517. */
  52518. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  52519. /**
  52520. * Gets or sets the additional types excluded by this connection point
  52521. */
  52522. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  52523. /**
  52524. * Gets or sets the associated variable name in the shader
  52525. */
  52526. associatedVariableName: string;
  52527. /**
  52528. * Gets or sets the connection point type (default is float)
  52529. */
  52530. type: NodeMaterialBlockConnectionPointTypes;
  52531. /**
  52532. * Gets or sets the connection point name
  52533. */
  52534. name: string;
  52535. /**
  52536. * Gets or sets a boolean indicating that this connection point can be omitted
  52537. */
  52538. isOptional: boolean;
  52539. /**
  52540. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  52541. */
  52542. define: string;
  52543. /** Gets or sets the target of that connection point */
  52544. target: NodeMaterialBlockTargets;
  52545. /**
  52546. * Gets a boolean indicating that the current point is connected
  52547. */
  52548. readonly isConnected: boolean;
  52549. /**
  52550. * Gets a boolean indicating that the current point is connected to an input block
  52551. */
  52552. readonly isConnectedToInputBlock: boolean;
  52553. /**
  52554. * Gets a the connected input block (if any)
  52555. */
  52556. readonly connectInputBlock: Nullable<InputBlock>;
  52557. /** Get the other side of the connection (if any) */
  52558. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52559. /** Get the block that owns this connection point */
  52560. readonly ownerBlock: NodeMaterialBlock;
  52561. /** Get the block connected on the other side of this connection (if any) */
  52562. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  52563. /** Get the block connected on the endpoints of this connection (if any) */
  52564. readonly connectedBlocks: Array<NodeMaterialBlock>;
  52565. /** Gets the list of connected endpoints */
  52566. readonly endpoints: NodeMaterialConnectionPoint[];
  52567. /** Gets a boolean indicating if that output point is connected to at least one input */
  52568. readonly hasEndpoints: boolean;
  52569. /**
  52570. * Creates a new connection point
  52571. * @param name defines the connection point name
  52572. * @param ownerBlock defines the block hosting this connection point
  52573. */
  52574. constructor(name: string, ownerBlock: NodeMaterialBlock);
  52575. /**
  52576. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  52577. * @returns the class name
  52578. */
  52579. getClassName(): string;
  52580. /**
  52581. * Gets an boolean indicating if the current point can be connected to another point
  52582. * @param connectionPoint defines the other connection point
  52583. * @returns true if the connection is possible
  52584. */
  52585. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  52586. /**
  52587. * Connect this point to another connection point
  52588. * @param connectionPoint defines the other connection point
  52589. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  52590. * @returns the current connection point
  52591. */
  52592. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  52593. /**
  52594. * Disconnect this point from one of his endpoint
  52595. * @param endpoint defines the other connection point
  52596. * @returns the current connection point
  52597. */
  52598. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52599. /**
  52600. * Serializes this point in a JSON representation
  52601. * @returns the serialized point object
  52602. */
  52603. serialize(): any;
  52604. }
  52605. }
  52606. declare module BABYLON {
  52607. /**
  52608. * Block used to add support for vertex skinning (bones)
  52609. */
  52610. export class BonesBlock extends NodeMaterialBlock {
  52611. /**
  52612. * Creates a new BonesBlock
  52613. * @param name defines the block name
  52614. */
  52615. constructor(name: string);
  52616. /**
  52617. * Initialize the block and prepare the context for build
  52618. * @param state defines the state that will be used for the build
  52619. */
  52620. initialize(state: NodeMaterialBuildState): void;
  52621. /**
  52622. * Gets the current class name
  52623. * @returns the class name
  52624. */
  52625. getClassName(): string;
  52626. /**
  52627. * Gets the matrix indices input component
  52628. */
  52629. readonly matricesIndices: NodeMaterialConnectionPoint;
  52630. /**
  52631. * Gets the matrix weights input component
  52632. */
  52633. readonly matricesWeights: NodeMaterialConnectionPoint;
  52634. /**
  52635. * Gets the extra matrix indices input component
  52636. */
  52637. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  52638. /**
  52639. * Gets the extra matrix weights input component
  52640. */
  52641. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  52642. /**
  52643. * Gets the world input component
  52644. */
  52645. readonly world: NodeMaterialConnectionPoint;
  52646. /**
  52647. * Gets the output component
  52648. */
  52649. readonly output: NodeMaterialConnectionPoint;
  52650. autoConfigure(material: NodeMaterial): void;
  52651. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52652. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52653. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52654. protected _buildBlock(state: NodeMaterialBuildState): this;
  52655. }
  52656. }
  52657. declare module BABYLON {
  52658. /**
  52659. * Block used to add support for instances
  52660. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  52661. */
  52662. export class InstancesBlock extends NodeMaterialBlock {
  52663. /**
  52664. * Creates a new InstancesBlock
  52665. * @param name defines the block name
  52666. */
  52667. constructor(name: string);
  52668. /**
  52669. * Gets the current class name
  52670. * @returns the class name
  52671. */
  52672. getClassName(): string;
  52673. /**
  52674. * Gets the first world row input component
  52675. */
  52676. readonly world0: NodeMaterialConnectionPoint;
  52677. /**
  52678. * Gets the second world row input component
  52679. */
  52680. readonly world1: NodeMaterialConnectionPoint;
  52681. /**
  52682. * Gets the third world row input component
  52683. */
  52684. readonly world2: NodeMaterialConnectionPoint;
  52685. /**
  52686. * Gets the forth world row input component
  52687. */
  52688. readonly world3: NodeMaterialConnectionPoint;
  52689. /**
  52690. * Gets the world input component
  52691. */
  52692. readonly world: NodeMaterialConnectionPoint;
  52693. /**
  52694. * Gets the output component
  52695. */
  52696. readonly output: NodeMaterialConnectionPoint;
  52697. autoConfigure(material: NodeMaterial): void;
  52698. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52699. protected _buildBlock(state: NodeMaterialBuildState): this;
  52700. }
  52701. }
  52702. declare module BABYLON {
  52703. /**
  52704. * Block used to add morph targets support to vertex shader
  52705. */
  52706. export class MorphTargetsBlock extends NodeMaterialBlock {
  52707. private _repeatableContentAnchor;
  52708. private _repeatebleContentGenerated;
  52709. /**
  52710. * Create a new MorphTargetsBlock
  52711. * @param name defines the block name
  52712. */
  52713. constructor(name: string);
  52714. /**
  52715. * Gets the current class name
  52716. * @returns the class name
  52717. */
  52718. getClassName(): string;
  52719. /**
  52720. * Gets the position input component
  52721. */
  52722. readonly position: NodeMaterialConnectionPoint;
  52723. /**
  52724. * Gets the normal input component
  52725. */
  52726. readonly normal: NodeMaterialConnectionPoint;
  52727. /**
  52728. * Gets the tangent input component
  52729. */
  52730. readonly tangent: NodeMaterialConnectionPoint;
  52731. /**
  52732. * Gets the tangent input component
  52733. */
  52734. readonly uv: NodeMaterialConnectionPoint;
  52735. /**
  52736. * Gets the position output component
  52737. */
  52738. readonly positionOutput: NodeMaterialConnectionPoint;
  52739. /**
  52740. * Gets the normal output component
  52741. */
  52742. readonly normalOutput: NodeMaterialConnectionPoint;
  52743. /**
  52744. * Gets the tangent output component
  52745. */
  52746. readonly tangentOutput: NodeMaterialConnectionPoint;
  52747. /**
  52748. * Gets the tangent output component
  52749. */
  52750. readonly uvOutput: NodeMaterialConnectionPoint;
  52751. initialize(state: NodeMaterialBuildState): void;
  52752. autoConfigure(material: NodeMaterial): void;
  52753. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52754. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52755. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52756. protected _buildBlock(state: NodeMaterialBuildState): this;
  52757. }
  52758. }
  52759. declare module BABYLON {
  52760. /**
  52761. * Block used to get data information from a light
  52762. */
  52763. export class LightInformationBlock extends NodeMaterialBlock {
  52764. private _lightDataUniformName;
  52765. private _lightColorUniformName;
  52766. private _lightTypeDefineName;
  52767. /**
  52768. * Gets or sets the light associated with this block
  52769. */
  52770. light: Nullable<Light>;
  52771. /**
  52772. * Creates a new LightInformationBlock
  52773. * @param name defines the block name
  52774. */
  52775. constructor(name: string);
  52776. /**
  52777. * Gets the current class name
  52778. * @returns the class name
  52779. */
  52780. getClassName(): string;
  52781. /**
  52782. * Gets the world position input component
  52783. */
  52784. readonly worldPosition: NodeMaterialConnectionPoint;
  52785. /**
  52786. * Gets the direction output component
  52787. */
  52788. readonly direction: NodeMaterialConnectionPoint;
  52789. /**
  52790. * Gets the direction output component
  52791. */
  52792. readonly color: NodeMaterialConnectionPoint;
  52793. /**
  52794. * Gets the direction output component
  52795. */
  52796. readonly intensity: NodeMaterialConnectionPoint;
  52797. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52798. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52799. protected _buildBlock(state: NodeMaterialBuildState): this;
  52800. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52801. }
  52802. }
  52803. declare module BABYLON {
  52804. /**
  52805. * Block used to add image processing support to fragment shader
  52806. */
  52807. export class ImageProcessingBlock extends NodeMaterialBlock {
  52808. /**
  52809. * Create a new ImageProcessingBlock
  52810. * @param name defines the block name
  52811. */
  52812. constructor(name: string);
  52813. /**
  52814. * Gets the current class name
  52815. * @returns the class name
  52816. */
  52817. getClassName(): string;
  52818. /**
  52819. * Gets the color input component
  52820. */
  52821. readonly color: NodeMaterialConnectionPoint;
  52822. /**
  52823. * Gets the output component
  52824. */
  52825. readonly output: NodeMaterialConnectionPoint;
  52826. /**
  52827. * Initialize the block and prepare the context for build
  52828. * @param state defines the state that will be used for the build
  52829. */
  52830. initialize(state: NodeMaterialBuildState): void;
  52831. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  52832. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52833. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52834. protected _buildBlock(state: NodeMaterialBuildState): this;
  52835. }
  52836. }
  52837. declare module BABYLON {
  52838. /**
  52839. * Block used to pertub normals based on a normal map
  52840. */
  52841. export class PerturbNormalBlock extends NodeMaterialBlock {
  52842. private _tangentSpaceParameterName;
  52843. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  52844. invertX: boolean;
  52845. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  52846. invertY: boolean;
  52847. /**
  52848. * Create a new PerturbNormalBlock
  52849. * @param name defines the block name
  52850. */
  52851. constructor(name: string);
  52852. /**
  52853. * Gets the current class name
  52854. * @returns the class name
  52855. */
  52856. getClassName(): string;
  52857. /**
  52858. * Gets the world position input component
  52859. */
  52860. readonly worldPosition: NodeMaterialConnectionPoint;
  52861. /**
  52862. * Gets the world normal input component
  52863. */
  52864. readonly worldNormal: NodeMaterialConnectionPoint;
  52865. /**
  52866. * Gets the uv input component
  52867. */
  52868. readonly uv: NodeMaterialConnectionPoint;
  52869. /**
  52870. * Gets the normal map color input component
  52871. */
  52872. readonly normalMapColor: NodeMaterialConnectionPoint;
  52873. /**
  52874. * Gets the strength input component
  52875. */
  52876. readonly strength: NodeMaterialConnectionPoint;
  52877. /**
  52878. * Gets the output component
  52879. */
  52880. readonly output: NodeMaterialConnectionPoint;
  52881. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52882. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52883. autoConfigure(material: NodeMaterial): void;
  52884. protected _buildBlock(state: NodeMaterialBuildState): this;
  52885. protected _dumpPropertiesCode(): string;
  52886. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52887. }
  52888. }
  52889. declare module BABYLON {
  52890. /**
  52891. * Block used to discard a pixel if a value is smaller than a cutoff
  52892. */
  52893. export class DiscardBlock extends NodeMaterialBlock {
  52894. /**
  52895. * Create a new DiscardBlock
  52896. * @param name defines the block name
  52897. */
  52898. constructor(name: string);
  52899. /**
  52900. * Gets the current class name
  52901. * @returns the class name
  52902. */
  52903. getClassName(): string;
  52904. /**
  52905. * Gets the color input component
  52906. */
  52907. readonly value: NodeMaterialConnectionPoint;
  52908. /**
  52909. * Gets the cutoff input component
  52910. */
  52911. readonly cutoff: NodeMaterialConnectionPoint;
  52912. protected _buildBlock(state: NodeMaterialBuildState): this;
  52913. }
  52914. }
  52915. declare module BABYLON {
  52916. /**
  52917. * Block used to add support for scene fog
  52918. */
  52919. export class FogBlock extends NodeMaterialBlock {
  52920. private _fogDistanceName;
  52921. private _fogParameters;
  52922. /**
  52923. * Create a new FogBlock
  52924. * @param name defines the block name
  52925. */
  52926. constructor(name: string);
  52927. /**
  52928. * Gets the current class name
  52929. * @returns the class name
  52930. */
  52931. getClassName(): string;
  52932. /**
  52933. * Gets the world position input component
  52934. */
  52935. readonly worldPosition: NodeMaterialConnectionPoint;
  52936. /**
  52937. * Gets the view input component
  52938. */
  52939. readonly view: NodeMaterialConnectionPoint;
  52940. /**
  52941. * Gets the color input component
  52942. */
  52943. readonly input: NodeMaterialConnectionPoint;
  52944. /**
  52945. * Gets the fog color input component
  52946. */
  52947. readonly fogColor: NodeMaterialConnectionPoint;
  52948. /**
  52949. * Gets the output component
  52950. */
  52951. readonly output: NodeMaterialConnectionPoint;
  52952. autoConfigure(material: NodeMaterial): void;
  52953. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52954. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52955. protected _buildBlock(state: NodeMaterialBuildState): this;
  52956. }
  52957. }
  52958. declare module BABYLON {
  52959. /**
  52960. * Block used to add light in the fragment shader
  52961. */
  52962. export class LightBlock extends NodeMaterialBlock {
  52963. private _lightId;
  52964. /**
  52965. * Gets or sets the light associated with this block
  52966. */
  52967. light: Nullable<Light>;
  52968. /**
  52969. * Create a new LightBlock
  52970. * @param name defines the block name
  52971. */
  52972. constructor(name: string);
  52973. /**
  52974. * Gets the current class name
  52975. * @returns the class name
  52976. */
  52977. getClassName(): string;
  52978. /**
  52979. * Gets the world position input component
  52980. */
  52981. readonly worldPosition: NodeMaterialConnectionPoint;
  52982. /**
  52983. * Gets the world normal input component
  52984. */
  52985. readonly worldNormal: NodeMaterialConnectionPoint;
  52986. /**
  52987. * Gets the camera (or eye) position component
  52988. */
  52989. readonly cameraPosition: NodeMaterialConnectionPoint;
  52990. /**
  52991. * Gets the diffuse output component
  52992. */
  52993. readonly diffuseOutput: NodeMaterialConnectionPoint;
  52994. /**
  52995. * Gets the specular output component
  52996. */
  52997. readonly specularOutput: NodeMaterialConnectionPoint;
  52998. autoConfigure(material: NodeMaterial): void;
  52999. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53000. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53001. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53002. private _injectVertexCode;
  53003. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53004. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53005. }
  53006. }
  53007. declare module BABYLON {
  53008. /**
  53009. * Block used to multiply 2 values
  53010. */
  53011. export class MultiplyBlock extends NodeMaterialBlock {
  53012. /**
  53013. * Creates a new MultiplyBlock
  53014. * @param name defines the block name
  53015. */
  53016. constructor(name: string);
  53017. /**
  53018. * Gets the current class name
  53019. * @returns the class name
  53020. */
  53021. getClassName(): string;
  53022. /**
  53023. * Gets the left operand input component
  53024. */
  53025. readonly left: NodeMaterialConnectionPoint;
  53026. /**
  53027. * Gets the right operand input component
  53028. */
  53029. readonly right: NodeMaterialConnectionPoint;
  53030. /**
  53031. * Gets the output component
  53032. */
  53033. readonly output: NodeMaterialConnectionPoint;
  53034. protected _buildBlock(state: NodeMaterialBuildState): this;
  53035. }
  53036. }
  53037. declare module BABYLON {
  53038. /**
  53039. * Block used to add 2 vectors
  53040. */
  53041. export class AddBlock extends NodeMaterialBlock {
  53042. /**
  53043. * Creates a new AddBlock
  53044. * @param name defines the block name
  53045. */
  53046. constructor(name: string);
  53047. /**
  53048. * Gets the current class name
  53049. * @returns the class name
  53050. */
  53051. getClassName(): string;
  53052. /**
  53053. * Gets the left operand input component
  53054. */
  53055. readonly left: NodeMaterialConnectionPoint;
  53056. /**
  53057. * Gets the right operand input component
  53058. */
  53059. readonly right: NodeMaterialConnectionPoint;
  53060. /**
  53061. * Gets the output component
  53062. */
  53063. readonly output: NodeMaterialConnectionPoint;
  53064. protected _buildBlock(state: NodeMaterialBuildState): this;
  53065. }
  53066. }
  53067. declare module BABYLON {
  53068. /**
  53069. * Block used to scale a vector by a float
  53070. */
  53071. export class ScaleBlock extends NodeMaterialBlock {
  53072. /**
  53073. * Creates a new ScaleBlock
  53074. * @param name defines the block name
  53075. */
  53076. constructor(name: string);
  53077. /**
  53078. * Gets the current class name
  53079. * @returns the class name
  53080. */
  53081. getClassName(): string;
  53082. /**
  53083. * Gets the input component
  53084. */
  53085. readonly input: NodeMaterialConnectionPoint;
  53086. /**
  53087. * Gets the factor input component
  53088. */
  53089. readonly factor: NodeMaterialConnectionPoint;
  53090. /**
  53091. * Gets the output component
  53092. */
  53093. readonly output: NodeMaterialConnectionPoint;
  53094. protected _buildBlock(state: NodeMaterialBuildState): this;
  53095. }
  53096. }
  53097. declare module BABYLON {
  53098. /**
  53099. * Block used to clamp a float
  53100. */
  53101. export class ClampBlock extends NodeMaterialBlock {
  53102. /** Gets or sets the minimum range */
  53103. minimum: number;
  53104. /** Gets or sets the maximum range */
  53105. maximum: number;
  53106. /**
  53107. * Creates a new ClampBlock
  53108. * @param name defines the block name
  53109. */
  53110. constructor(name: string);
  53111. /**
  53112. * Gets the current class name
  53113. * @returns the class name
  53114. */
  53115. getClassName(): string;
  53116. /**
  53117. * Gets the value input component
  53118. */
  53119. readonly value: NodeMaterialConnectionPoint;
  53120. /**
  53121. * Gets the output component
  53122. */
  53123. readonly output: NodeMaterialConnectionPoint;
  53124. protected _buildBlock(state: NodeMaterialBuildState): this;
  53125. protected _dumpPropertiesCode(): string;
  53126. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53127. }
  53128. }
  53129. declare module BABYLON {
  53130. /**
  53131. * Block used to apply a cross product between 2 vectors
  53132. */
  53133. export class CrossBlock extends NodeMaterialBlock {
  53134. /**
  53135. * Creates a new CrossBlock
  53136. * @param name defines the block name
  53137. */
  53138. constructor(name: string);
  53139. /**
  53140. * Gets the current class name
  53141. * @returns the class name
  53142. */
  53143. getClassName(): string;
  53144. /**
  53145. * Gets the left operand input component
  53146. */
  53147. readonly left: NodeMaterialConnectionPoint;
  53148. /**
  53149. * Gets the right operand input component
  53150. */
  53151. readonly right: NodeMaterialConnectionPoint;
  53152. /**
  53153. * Gets the output component
  53154. */
  53155. readonly output: NodeMaterialConnectionPoint;
  53156. protected _buildBlock(state: NodeMaterialBuildState): this;
  53157. }
  53158. }
  53159. declare module BABYLON {
  53160. /**
  53161. * Block used to apply a dot product between 2 vectors
  53162. */
  53163. export class DotBlock extends NodeMaterialBlock {
  53164. /**
  53165. * Creates a new DotBlock
  53166. * @param name defines the block name
  53167. */
  53168. constructor(name: string);
  53169. /**
  53170. * Gets the current class name
  53171. * @returns the class name
  53172. */
  53173. getClassName(): string;
  53174. /**
  53175. * Gets the left operand input component
  53176. */
  53177. readonly left: NodeMaterialConnectionPoint;
  53178. /**
  53179. * Gets the right operand input component
  53180. */
  53181. readonly right: NodeMaterialConnectionPoint;
  53182. /**
  53183. * Gets the output component
  53184. */
  53185. readonly output: NodeMaterialConnectionPoint;
  53186. protected _buildBlock(state: NodeMaterialBuildState): this;
  53187. }
  53188. }
  53189. declare module BABYLON {
  53190. /**
  53191. * Block used to remap a float from a range to a new one
  53192. */
  53193. export class RemapBlock extends NodeMaterialBlock {
  53194. /**
  53195. * Gets or sets the source range
  53196. */
  53197. sourceRange: Vector2;
  53198. /**
  53199. * Gets or sets the target range
  53200. */
  53201. targetRange: Vector2;
  53202. /**
  53203. * Creates a new RemapBlock
  53204. * @param name defines the block name
  53205. */
  53206. constructor(name: string);
  53207. /**
  53208. * Gets the current class name
  53209. * @returns the class name
  53210. */
  53211. getClassName(): string;
  53212. /**
  53213. * Gets the input component
  53214. */
  53215. readonly input: NodeMaterialConnectionPoint;
  53216. /**
  53217. * Gets the source min input component
  53218. */
  53219. readonly sourceMin: NodeMaterialConnectionPoint;
  53220. /**
  53221. * Gets the source max input component
  53222. */
  53223. readonly sourceMax: NodeMaterialConnectionPoint;
  53224. /**
  53225. * Gets the target min input component
  53226. */
  53227. readonly targetMin: NodeMaterialConnectionPoint;
  53228. /**
  53229. * Gets the target max input component
  53230. */
  53231. readonly targetMax: NodeMaterialConnectionPoint;
  53232. /**
  53233. * Gets the output component
  53234. */
  53235. readonly output: NodeMaterialConnectionPoint;
  53236. protected _buildBlock(state: NodeMaterialBuildState): this;
  53237. protected _dumpPropertiesCode(): string;
  53238. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53239. }
  53240. }
  53241. declare module BABYLON {
  53242. /**
  53243. * Block used to normalize a vector
  53244. */
  53245. export class NormalizeBlock extends NodeMaterialBlock {
  53246. /**
  53247. * Creates a new NormalizeBlock
  53248. * @param name defines the block name
  53249. */
  53250. constructor(name: string);
  53251. /**
  53252. * Gets the current class name
  53253. * @returns the class name
  53254. */
  53255. getClassName(): string;
  53256. /**
  53257. * Gets the input component
  53258. */
  53259. readonly input: NodeMaterialConnectionPoint;
  53260. /**
  53261. * Gets the output component
  53262. */
  53263. readonly output: NodeMaterialConnectionPoint;
  53264. protected _buildBlock(state: NodeMaterialBuildState): this;
  53265. }
  53266. }
  53267. declare module BABYLON {
  53268. /**
  53269. * Operations supported by the Trigonometry block
  53270. */
  53271. export enum TrigonometryBlockOperations {
  53272. /** Cos */
  53273. Cos = 0,
  53274. /** Sin */
  53275. Sin = 1,
  53276. /** Abs */
  53277. Abs = 2,
  53278. /** Exp */
  53279. Exp = 3,
  53280. /** Exp2 */
  53281. Exp2 = 4,
  53282. /** Round */
  53283. Round = 5,
  53284. /** Floor */
  53285. Floor = 6,
  53286. /** Ceiling */
  53287. Ceiling = 7,
  53288. /** Square root */
  53289. Sqrt = 8
  53290. }
  53291. /**
  53292. * Block used to apply trigonometry operation to floats
  53293. */
  53294. export class TrigonometryBlock extends NodeMaterialBlock {
  53295. /**
  53296. * Gets or sets the operation applied by the block
  53297. */
  53298. operation: TrigonometryBlockOperations;
  53299. /**
  53300. * Creates a new TrigonometryBlock
  53301. * @param name defines the block name
  53302. */
  53303. constructor(name: string);
  53304. /**
  53305. * Gets the current class name
  53306. * @returns the class name
  53307. */
  53308. getClassName(): string;
  53309. /**
  53310. * Gets the input component
  53311. */
  53312. readonly input: NodeMaterialConnectionPoint;
  53313. /**
  53314. * Gets the output component
  53315. */
  53316. readonly output: NodeMaterialConnectionPoint;
  53317. protected _buildBlock(state: NodeMaterialBuildState): this;
  53318. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53319. }
  53320. }
  53321. declare module BABYLON {
  53322. /**
  53323. * Block used to create a Color3/4 out of individual inputs (one for each component)
  53324. */
  53325. export class ColorMergerBlock extends NodeMaterialBlock {
  53326. /**
  53327. * Create a new ColorMergerBlock
  53328. * @param name defines the block name
  53329. */
  53330. constructor(name: string);
  53331. /**
  53332. * Gets the current class name
  53333. * @returns the class name
  53334. */
  53335. getClassName(): string;
  53336. /**
  53337. * Gets the r component (input)
  53338. */
  53339. readonly r: NodeMaterialConnectionPoint;
  53340. /**
  53341. * Gets the g component (input)
  53342. */
  53343. readonly g: NodeMaterialConnectionPoint;
  53344. /**
  53345. * Gets the b component (input)
  53346. */
  53347. readonly b: NodeMaterialConnectionPoint;
  53348. /**
  53349. * Gets the a component (input)
  53350. */
  53351. readonly a: NodeMaterialConnectionPoint;
  53352. /**
  53353. * Gets the rgba component (output)
  53354. */
  53355. readonly rgba: NodeMaterialConnectionPoint;
  53356. /**
  53357. * Gets the rgb component (output)
  53358. */
  53359. readonly rgb: NodeMaterialConnectionPoint;
  53360. protected _buildBlock(state: NodeMaterialBuildState): this;
  53361. }
  53362. }
  53363. declare module BABYLON {
  53364. /**
  53365. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  53366. */
  53367. export class VectorMergerBlock extends NodeMaterialBlock {
  53368. /**
  53369. * Create a new VectorMergerBlock
  53370. * @param name defines the block name
  53371. */
  53372. constructor(name: string);
  53373. /**
  53374. * Gets the current class name
  53375. * @returns the class name
  53376. */
  53377. getClassName(): string;
  53378. /**
  53379. * Gets the x component (input)
  53380. */
  53381. readonly x: NodeMaterialConnectionPoint;
  53382. /**
  53383. * Gets the y component (input)
  53384. */
  53385. readonly y: NodeMaterialConnectionPoint;
  53386. /**
  53387. * Gets the z component (input)
  53388. */
  53389. readonly z: NodeMaterialConnectionPoint;
  53390. /**
  53391. * Gets the w component (input)
  53392. */
  53393. readonly w: NodeMaterialConnectionPoint;
  53394. /**
  53395. * Gets the xyzw component (output)
  53396. */
  53397. readonly xyzw: NodeMaterialConnectionPoint;
  53398. /**
  53399. * Gets the xyz component (output)
  53400. */
  53401. readonly xyz: NodeMaterialConnectionPoint;
  53402. /**
  53403. * Gets the xy component (output)
  53404. */
  53405. readonly xy: NodeMaterialConnectionPoint;
  53406. protected _buildBlock(state: NodeMaterialBuildState): this;
  53407. }
  53408. }
  53409. declare module BABYLON {
  53410. /**
  53411. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  53412. */
  53413. export class ColorSplitterBlock extends NodeMaterialBlock {
  53414. /**
  53415. * Create a new ColorSplitterBlock
  53416. * @param name defines the block name
  53417. */
  53418. constructor(name: string);
  53419. /**
  53420. * Gets the current class name
  53421. * @returns the class name
  53422. */
  53423. getClassName(): string;
  53424. /**
  53425. * Gets the rgba component (input)
  53426. */
  53427. readonly rgba: NodeMaterialConnectionPoint;
  53428. /**
  53429. * Gets the rgb component (input)
  53430. */
  53431. readonly rgbIn: NodeMaterialConnectionPoint;
  53432. /**
  53433. * Gets the rgb component (output)
  53434. */
  53435. readonly rgbOut: NodeMaterialConnectionPoint;
  53436. /**
  53437. * Gets the r component (output)
  53438. */
  53439. readonly r: NodeMaterialConnectionPoint;
  53440. /**
  53441. * Gets the g component (output)
  53442. */
  53443. readonly g: NodeMaterialConnectionPoint;
  53444. /**
  53445. * Gets the b component (output)
  53446. */
  53447. readonly b: NodeMaterialConnectionPoint;
  53448. /**
  53449. * Gets the a component (output)
  53450. */
  53451. readonly a: NodeMaterialConnectionPoint;
  53452. protected _inputRename(name: string): string;
  53453. protected _outputRename(name: string): string;
  53454. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53455. }
  53456. }
  53457. declare module BABYLON {
  53458. /**
  53459. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  53460. */
  53461. export class VectorSplitterBlock extends NodeMaterialBlock {
  53462. /**
  53463. * Create a new VectorSplitterBlock
  53464. * @param name defines the block name
  53465. */
  53466. constructor(name: string);
  53467. /**
  53468. * Gets the current class name
  53469. * @returns the class name
  53470. */
  53471. getClassName(): string;
  53472. /**
  53473. * Gets the xyzw component (input)
  53474. */
  53475. readonly xyzw: NodeMaterialConnectionPoint;
  53476. /**
  53477. * Gets the xyz component (input)
  53478. */
  53479. readonly xyzIn: NodeMaterialConnectionPoint;
  53480. /**
  53481. * Gets the xy component (input)
  53482. */
  53483. readonly xyIn: NodeMaterialConnectionPoint;
  53484. /**
  53485. * Gets the xyz component (output)
  53486. */
  53487. readonly xyzOut: NodeMaterialConnectionPoint;
  53488. /**
  53489. * Gets the xy component (output)
  53490. */
  53491. readonly xyOut: NodeMaterialConnectionPoint;
  53492. /**
  53493. * Gets the x component (output)
  53494. */
  53495. readonly x: NodeMaterialConnectionPoint;
  53496. /**
  53497. * Gets the y component (output)
  53498. */
  53499. readonly y: NodeMaterialConnectionPoint;
  53500. /**
  53501. * Gets the z component (output)
  53502. */
  53503. readonly z: NodeMaterialConnectionPoint;
  53504. /**
  53505. * Gets the w component (output)
  53506. */
  53507. readonly w: NodeMaterialConnectionPoint;
  53508. protected _inputRename(name: string): string;
  53509. protected _outputRename(name: string): string;
  53510. protected _buildBlock(state: NodeMaterialBuildState): this;
  53511. }
  53512. }
  53513. declare module BABYLON {
  53514. /**
  53515. * Block used to lerp 2 values
  53516. */
  53517. export class LerpBlock extends NodeMaterialBlock {
  53518. /**
  53519. * Creates a new LerpBlock
  53520. * @param name defines the block name
  53521. */
  53522. constructor(name: string);
  53523. /**
  53524. * Gets the current class name
  53525. * @returns the class name
  53526. */
  53527. getClassName(): string;
  53528. /**
  53529. * Gets the left operand input component
  53530. */
  53531. readonly left: NodeMaterialConnectionPoint;
  53532. /**
  53533. * Gets the right operand input component
  53534. */
  53535. readonly right: NodeMaterialConnectionPoint;
  53536. /**
  53537. * Gets the gradient operand input component
  53538. */
  53539. readonly gradient: NodeMaterialConnectionPoint;
  53540. /**
  53541. * Gets the output component
  53542. */
  53543. readonly output: NodeMaterialConnectionPoint;
  53544. protected _buildBlock(state: NodeMaterialBuildState): this;
  53545. }
  53546. }
  53547. declare module BABYLON {
  53548. /**
  53549. * Block used to divide 2 vectors
  53550. */
  53551. export class DivideBlock extends NodeMaterialBlock {
  53552. /**
  53553. * Creates a new DivideBlock
  53554. * @param name defines the block name
  53555. */
  53556. constructor(name: string);
  53557. /**
  53558. * Gets the current class name
  53559. * @returns the class name
  53560. */
  53561. getClassName(): string;
  53562. /**
  53563. * Gets the left operand input component
  53564. */
  53565. readonly left: NodeMaterialConnectionPoint;
  53566. /**
  53567. * Gets the right operand input component
  53568. */
  53569. readonly right: NodeMaterialConnectionPoint;
  53570. /**
  53571. * Gets the output component
  53572. */
  53573. readonly output: NodeMaterialConnectionPoint;
  53574. protected _buildBlock(state: NodeMaterialBuildState): this;
  53575. }
  53576. }
  53577. declare module BABYLON {
  53578. /**
  53579. * Block used to subtract 2 vectors
  53580. */
  53581. export class SubtractBlock extends NodeMaterialBlock {
  53582. /**
  53583. * Creates a new SubtractBlock
  53584. * @param name defines the block name
  53585. */
  53586. constructor(name: string);
  53587. /**
  53588. * Gets the current class name
  53589. * @returns the class name
  53590. */
  53591. getClassName(): string;
  53592. /**
  53593. * Gets the left operand input component
  53594. */
  53595. readonly left: NodeMaterialConnectionPoint;
  53596. /**
  53597. * Gets the right operand input component
  53598. */
  53599. readonly right: NodeMaterialConnectionPoint;
  53600. /**
  53601. * Gets the output component
  53602. */
  53603. readonly output: NodeMaterialConnectionPoint;
  53604. protected _buildBlock(state: NodeMaterialBuildState): this;
  53605. }
  53606. }
  53607. declare module BABYLON {
  53608. /**
  53609. * Block used to step a value
  53610. */
  53611. export class StepBlock extends NodeMaterialBlock {
  53612. /**
  53613. * Creates a new AddBlock
  53614. * @param name defines the block name
  53615. */
  53616. constructor(name: string);
  53617. /**
  53618. * Gets the current class name
  53619. * @returns the class name
  53620. */
  53621. getClassName(): string;
  53622. /**
  53623. * Gets the value operand input component
  53624. */
  53625. readonly value: NodeMaterialConnectionPoint;
  53626. /**
  53627. * Gets the edge operand input component
  53628. */
  53629. readonly edge: NodeMaterialConnectionPoint;
  53630. /**
  53631. * Gets the output component
  53632. */
  53633. readonly output: NodeMaterialConnectionPoint;
  53634. protected _buildBlock(state: NodeMaterialBuildState): this;
  53635. }
  53636. }
  53637. declare module BABYLON {
  53638. /**
  53639. * Block used to get the opposite (1 - x) of a value
  53640. */
  53641. export class OneMinusBlock extends NodeMaterialBlock {
  53642. /**
  53643. * Creates a new OneMinusBlock
  53644. * @param name defines the block name
  53645. */
  53646. constructor(name: string);
  53647. /**
  53648. * Gets the current class name
  53649. * @returns the class name
  53650. */
  53651. getClassName(): string;
  53652. /**
  53653. * Gets the input component
  53654. */
  53655. readonly input: NodeMaterialConnectionPoint;
  53656. /**
  53657. * Gets the output component
  53658. */
  53659. readonly output: NodeMaterialConnectionPoint;
  53660. protected _buildBlock(state: NodeMaterialBuildState): this;
  53661. }
  53662. }
  53663. declare module BABYLON {
  53664. /**
  53665. * Block used to get the view direction
  53666. */
  53667. export class ViewDirectionBlock extends NodeMaterialBlock {
  53668. /**
  53669. * Creates a new ViewDirectionBlock
  53670. * @param name defines the block name
  53671. */
  53672. constructor(name: string);
  53673. /**
  53674. * Gets the current class name
  53675. * @returns the class name
  53676. */
  53677. getClassName(): string;
  53678. /**
  53679. * Gets the world position component
  53680. */
  53681. readonly worldPosition: NodeMaterialConnectionPoint;
  53682. /**
  53683. * Gets the camera position component
  53684. */
  53685. readonly cameraPosition: NodeMaterialConnectionPoint;
  53686. /**
  53687. * Gets the output component
  53688. */
  53689. readonly output: NodeMaterialConnectionPoint;
  53690. autoConfigure(material: NodeMaterial): void;
  53691. protected _buildBlock(state: NodeMaterialBuildState): this;
  53692. }
  53693. }
  53694. declare module BABYLON {
  53695. /**
  53696. * Block used to compute fresnel value
  53697. */
  53698. export class FresnelBlock extends NodeMaterialBlock {
  53699. /**
  53700. * Create a new FresnelBlock
  53701. * @param name defines the block name
  53702. */
  53703. constructor(name: string);
  53704. /**
  53705. * Gets the current class name
  53706. * @returns the class name
  53707. */
  53708. getClassName(): string;
  53709. /**
  53710. * Gets the world normal input component
  53711. */
  53712. readonly worldNormal: NodeMaterialConnectionPoint;
  53713. /**
  53714. * Gets the view direction input component
  53715. */
  53716. readonly viewDirection: NodeMaterialConnectionPoint;
  53717. /**
  53718. * Gets the bias input component
  53719. */
  53720. readonly bias: NodeMaterialConnectionPoint;
  53721. /**
  53722. * Gets the camera (or eye) position component
  53723. */
  53724. readonly power: NodeMaterialConnectionPoint;
  53725. /**
  53726. * Gets the fresnel output component
  53727. */
  53728. readonly fresnel: NodeMaterialConnectionPoint;
  53729. autoConfigure(material: NodeMaterial): void;
  53730. protected _buildBlock(state: NodeMaterialBuildState): this;
  53731. }
  53732. }
  53733. declare module BABYLON {
  53734. /**
  53735. * Block used to get the max of 2 values
  53736. */
  53737. export class MaxBlock extends NodeMaterialBlock {
  53738. /**
  53739. * Creates a new MaxBlock
  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 left operand input component
  53750. */
  53751. readonly left: NodeMaterialConnectionPoint;
  53752. /**
  53753. * Gets the right operand input component
  53754. */
  53755. readonly right: NodeMaterialConnectionPoint;
  53756. /**
  53757. * Gets the output component
  53758. */
  53759. readonly output: NodeMaterialConnectionPoint;
  53760. protected _buildBlock(state: NodeMaterialBuildState): this;
  53761. }
  53762. }
  53763. declare module BABYLON {
  53764. /**
  53765. * Block used to get the min of 2 values
  53766. */
  53767. export class MinBlock extends NodeMaterialBlock {
  53768. /**
  53769. * Creates a new MinBlock
  53770. * @param name defines the block name
  53771. */
  53772. constructor(name: string);
  53773. /**
  53774. * Gets the current class name
  53775. * @returns the class name
  53776. */
  53777. getClassName(): string;
  53778. /**
  53779. * Gets the left operand input component
  53780. */
  53781. readonly left: NodeMaterialConnectionPoint;
  53782. /**
  53783. * Gets the right operand input component
  53784. */
  53785. readonly right: NodeMaterialConnectionPoint;
  53786. /**
  53787. * Gets the output component
  53788. */
  53789. readonly output: NodeMaterialConnectionPoint;
  53790. protected _buildBlock(state: NodeMaterialBuildState): this;
  53791. }
  53792. }
  53793. declare module BABYLON {
  53794. /**
  53795. * Block used to get the distance between 2 values
  53796. */
  53797. export class DistanceBlock extends NodeMaterialBlock {
  53798. /**
  53799. * Creates a new DistanceBlock
  53800. * @param name defines the block name
  53801. */
  53802. constructor(name: string);
  53803. /**
  53804. * Gets the current class name
  53805. * @returns the class name
  53806. */
  53807. getClassName(): string;
  53808. /**
  53809. * Gets the left operand input component
  53810. */
  53811. readonly left: NodeMaterialConnectionPoint;
  53812. /**
  53813. * Gets the right operand input component
  53814. */
  53815. readonly right: NodeMaterialConnectionPoint;
  53816. /**
  53817. * Gets the output component
  53818. */
  53819. readonly output: NodeMaterialConnectionPoint;
  53820. protected _buildBlock(state: NodeMaterialBuildState): this;
  53821. }
  53822. }
  53823. declare module BABYLON {
  53824. /**
  53825. * Block used to get the length of a vector
  53826. */
  53827. export class LengthBlock extends NodeMaterialBlock {
  53828. /**
  53829. * Creates a new LengthBlock
  53830. * @param name defines the block name
  53831. */
  53832. constructor(name: string);
  53833. /**
  53834. * Gets the current class name
  53835. * @returns the class name
  53836. */
  53837. getClassName(): string;
  53838. /**
  53839. * Gets the value input component
  53840. */
  53841. readonly value: NodeMaterialConnectionPoint;
  53842. /**
  53843. * Gets the output component
  53844. */
  53845. readonly output: NodeMaterialConnectionPoint;
  53846. protected _buildBlock(state: NodeMaterialBuildState): this;
  53847. }
  53848. }
  53849. declare module BABYLON {
  53850. /**
  53851. * Block used to get negative version of a value (i.e. x * -1)
  53852. */
  53853. export class NegateBlock extends NodeMaterialBlock {
  53854. /**
  53855. * Creates a new NegateBlock
  53856. * @param name defines the block name
  53857. */
  53858. constructor(name: string);
  53859. /**
  53860. * Gets the current class name
  53861. * @returns the class name
  53862. */
  53863. getClassName(): string;
  53864. /**
  53865. * Gets the value input component
  53866. */
  53867. readonly value: NodeMaterialConnectionPoint;
  53868. /**
  53869. * Gets the output component
  53870. */
  53871. readonly output: NodeMaterialConnectionPoint;
  53872. protected _buildBlock(state: NodeMaterialBuildState): this;
  53873. }
  53874. }
  53875. declare module BABYLON {
  53876. /**
  53877. * Block used to get the value of the first parameter raised to the power of the second
  53878. */
  53879. export class PowBlock extends NodeMaterialBlock {
  53880. /**
  53881. * Creates a new PowBlock
  53882. * @param name defines the block name
  53883. */
  53884. constructor(name: string);
  53885. /**
  53886. * Gets the current class name
  53887. * @returns the class name
  53888. */
  53889. getClassName(): string;
  53890. /**
  53891. * Gets the value operand input component
  53892. */
  53893. readonly value: NodeMaterialConnectionPoint;
  53894. /**
  53895. * Gets the power operand input component
  53896. */
  53897. readonly power: NodeMaterialConnectionPoint;
  53898. /**
  53899. * Gets the output component
  53900. */
  53901. readonly output: NodeMaterialConnectionPoint;
  53902. protected _buildBlock(state: NodeMaterialBuildState): this;
  53903. }
  53904. }
  53905. declare module BABYLON {
  53906. /**
  53907. * Block used to get a random number
  53908. */
  53909. export class RandomNumberBlock extends NodeMaterialBlock {
  53910. /**
  53911. * Creates a new RandomNumberBlock
  53912. * @param name defines the block name
  53913. */
  53914. constructor(name: string);
  53915. /**
  53916. * Gets the current class name
  53917. * @returns the class name
  53918. */
  53919. getClassName(): string;
  53920. /**
  53921. * Gets the seed input component
  53922. */
  53923. readonly seed: NodeMaterialConnectionPoint;
  53924. /**
  53925. * Gets the output component
  53926. */
  53927. readonly output: NodeMaterialConnectionPoint;
  53928. protected _buildBlock(state: NodeMaterialBuildState): this;
  53929. }
  53930. }
  53931. declare module BABYLON {
  53932. /**
  53933. * Effect Render Options
  53934. */
  53935. export interface IEffectRendererOptions {
  53936. /**
  53937. * Defines the vertices positions.
  53938. */
  53939. positions?: number[];
  53940. /**
  53941. * Defines the indices.
  53942. */
  53943. indices?: number[];
  53944. }
  53945. /**
  53946. * Helper class to render one or more effects
  53947. */
  53948. export class EffectRenderer {
  53949. private engine;
  53950. private static _DefaultOptions;
  53951. private _vertexBuffers;
  53952. private _indexBuffer;
  53953. private _ringBufferIndex;
  53954. private _ringScreenBuffer;
  53955. private _fullscreenViewport;
  53956. private _getNextFrameBuffer;
  53957. /**
  53958. * Creates an effect renderer
  53959. * @param engine the engine to use for rendering
  53960. * @param options defines the options of the effect renderer
  53961. */
  53962. constructor(engine: Engine, options?: IEffectRendererOptions);
  53963. /**
  53964. * Sets the current viewport in normalized coordinates 0-1
  53965. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  53966. */
  53967. setViewport(viewport?: Viewport): void;
  53968. /**
  53969. * Binds the embedded attributes buffer to the effect.
  53970. * @param effect Defines the effect to bind the attributes for
  53971. */
  53972. bindBuffers(effect: Effect): void;
  53973. /**
  53974. * Sets the current effect wrapper to use during draw.
  53975. * The effect needs to be ready before calling this api.
  53976. * This also sets the default full screen position attribute.
  53977. * @param effectWrapper Defines the effect to draw with
  53978. */
  53979. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  53980. /**
  53981. * Draws a full screen quad.
  53982. */
  53983. draw(): void;
  53984. /**
  53985. * renders one or more effects to a specified texture
  53986. * @param effectWrappers list of effects to renderer
  53987. * @param outputTexture texture to draw to, if null it will render to the screen
  53988. */
  53989. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  53990. /**
  53991. * Disposes of the effect renderer
  53992. */
  53993. dispose(): void;
  53994. }
  53995. /**
  53996. * Options to create an EffectWrapper
  53997. */
  53998. interface EffectWrapperCreationOptions {
  53999. /**
  54000. * Engine to use to create the effect
  54001. */
  54002. engine: Engine;
  54003. /**
  54004. * Fragment shader for the effect
  54005. */
  54006. fragmentShader: string;
  54007. /**
  54008. * Vertex shader for the effect
  54009. */
  54010. vertexShader?: string;
  54011. /**
  54012. * Attributes to use in the shader
  54013. */
  54014. attributeNames?: Array<string>;
  54015. /**
  54016. * Uniforms to use in the shader
  54017. */
  54018. uniformNames?: Array<string>;
  54019. /**
  54020. * Texture sampler names to use in the shader
  54021. */
  54022. samplerNames?: Array<string>;
  54023. /**
  54024. * The friendly name of the effect displayed in Spector.
  54025. */
  54026. name?: string;
  54027. }
  54028. /**
  54029. * Wraps an effect to be used for rendering
  54030. */
  54031. export class EffectWrapper {
  54032. /**
  54033. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  54034. */
  54035. onApplyObservable: Observable<{}>;
  54036. /**
  54037. * The underlying effect
  54038. */
  54039. effect: Effect;
  54040. /**
  54041. * Creates an effect to be renderer
  54042. * @param creationOptions options to create the effect
  54043. */
  54044. constructor(creationOptions: EffectWrapperCreationOptions);
  54045. /**
  54046. * Disposes of the effect wrapper
  54047. */
  54048. dispose(): void;
  54049. }
  54050. }
  54051. declare module BABYLON {
  54052. /**
  54053. * Helper class to push actions to a pool of workers.
  54054. */
  54055. export class WorkerPool implements IDisposable {
  54056. private _workerInfos;
  54057. private _pendingActions;
  54058. /**
  54059. * Constructor
  54060. * @param workers Array of workers to use for actions
  54061. */
  54062. constructor(workers: Array<Worker>);
  54063. /**
  54064. * Terminates all workers and clears any pending actions.
  54065. */
  54066. dispose(): void;
  54067. /**
  54068. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54069. * pended until a worker has completed its action.
  54070. * @param action The action to perform. Call onComplete when the action is complete.
  54071. */
  54072. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54073. private _execute;
  54074. }
  54075. }
  54076. declare module BABYLON {
  54077. /**
  54078. * Configuration for Draco compression
  54079. */
  54080. export interface IDracoCompressionConfiguration {
  54081. /**
  54082. * Configuration for the decoder.
  54083. */
  54084. decoder: {
  54085. /**
  54086. * The url to the WebAssembly module.
  54087. */
  54088. wasmUrl?: string;
  54089. /**
  54090. * The url to the WebAssembly binary.
  54091. */
  54092. wasmBinaryUrl?: string;
  54093. /**
  54094. * The url to the fallback JavaScript module.
  54095. */
  54096. fallbackUrl?: string;
  54097. };
  54098. }
  54099. /**
  54100. * Draco compression (https://google.github.io/draco/)
  54101. *
  54102. * This class wraps the Draco module.
  54103. *
  54104. * **Encoder**
  54105. *
  54106. * The encoder is not currently implemented.
  54107. *
  54108. * **Decoder**
  54109. *
  54110. * 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.
  54111. *
  54112. * To update the configuration, use the following code:
  54113. * ```javascript
  54114. * DracoCompression.Configuration = {
  54115. * decoder: {
  54116. * wasmUrl: "<url to the WebAssembly library>",
  54117. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54118. * fallbackUrl: "<url to the fallback JavaScript library>",
  54119. * }
  54120. * };
  54121. * ```
  54122. *
  54123. * 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.
  54124. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54125. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54126. *
  54127. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54128. * ```javascript
  54129. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54130. * ```
  54131. *
  54132. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54133. */
  54134. export class DracoCompression implements IDisposable {
  54135. private _workerPoolPromise?;
  54136. private _decoderModulePromise?;
  54137. /**
  54138. * The configuration. Defaults to the following urls:
  54139. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54140. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54141. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54142. */
  54143. static Configuration: IDracoCompressionConfiguration;
  54144. /**
  54145. * Returns true if the decoder configuration is available.
  54146. */
  54147. static readonly DecoderAvailable: boolean;
  54148. /**
  54149. * Default number of workers to create when creating the draco compression object.
  54150. */
  54151. static DefaultNumWorkers: number;
  54152. private static GetDefaultNumWorkers;
  54153. private static _Default;
  54154. /**
  54155. * Default instance for the draco compression object.
  54156. */
  54157. static readonly Default: DracoCompression;
  54158. /**
  54159. * Constructor
  54160. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54161. */
  54162. constructor(numWorkers?: number);
  54163. /**
  54164. * Stop all async operations and release resources.
  54165. */
  54166. dispose(): void;
  54167. /**
  54168. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54169. * @returns a promise that resolves when ready
  54170. */
  54171. whenReadyAsync(): Promise<void>;
  54172. /**
  54173. * Decode Draco compressed mesh data to vertex data.
  54174. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54175. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54176. * @returns A promise that resolves with the decoded vertex data
  54177. */
  54178. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54179. [kind: string]: number;
  54180. }): Promise<VertexData>;
  54181. }
  54182. }
  54183. declare module BABYLON {
  54184. /**
  54185. * Class for building Constructive Solid Geometry
  54186. */
  54187. export class CSG {
  54188. private polygons;
  54189. /**
  54190. * The world matrix
  54191. */
  54192. matrix: Matrix;
  54193. /**
  54194. * Stores the position
  54195. */
  54196. position: Vector3;
  54197. /**
  54198. * Stores the rotation
  54199. */
  54200. rotation: Vector3;
  54201. /**
  54202. * Stores the rotation quaternion
  54203. */
  54204. rotationQuaternion: Nullable<Quaternion>;
  54205. /**
  54206. * Stores the scaling vector
  54207. */
  54208. scaling: Vector3;
  54209. /**
  54210. * Convert the Mesh to CSG
  54211. * @param mesh The Mesh to convert to CSG
  54212. * @returns A new CSG from the Mesh
  54213. */
  54214. static FromMesh(mesh: Mesh): CSG;
  54215. /**
  54216. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54217. * @param polygons Polygons used to construct a CSG solid
  54218. */
  54219. private static FromPolygons;
  54220. /**
  54221. * Clones, or makes a deep copy, of the CSG
  54222. * @returns A new CSG
  54223. */
  54224. clone(): CSG;
  54225. /**
  54226. * Unions this CSG with another CSG
  54227. * @param csg The CSG to union against this CSG
  54228. * @returns The unioned CSG
  54229. */
  54230. union(csg: CSG): CSG;
  54231. /**
  54232. * Unions this CSG with another CSG in place
  54233. * @param csg The CSG to union against this CSG
  54234. */
  54235. unionInPlace(csg: CSG): void;
  54236. /**
  54237. * Subtracts this CSG with another CSG
  54238. * @param csg The CSG to subtract against this CSG
  54239. * @returns A new CSG
  54240. */
  54241. subtract(csg: CSG): CSG;
  54242. /**
  54243. * Subtracts this CSG with another CSG in place
  54244. * @param csg The CSG to subtact against this CSG
  54245. */
  54246. subtractInPlace(csg: CSG): void;
  54247. /**
  54248. * Intersect this CSG with another CSG
  54249. * @param csg The CSG to intersect against this CSG
  54250. * @returns A new CSG
  54251. */
  54252. intersect(csg: CSG): CSG;
  54253. /**
  54254. * Intersects this CSG with another CSG in place
  54255. * @param csg The CSG to intersect against this CSG
  54256. */
  54257. intersectInPlace(csg: CSG): void;
  54258. /**
  54259. * Return a new CSG solid with solid and empty space switched. This solid is
  54260. * not modified.
  54261. * @returns A new CSG solid with solid and empty space switched
  54262. */
  54263. inverse(): CSG;
  54264. /**
  54265. * Inverses the CSG in place
  54266. */
  54267. inverseInPlace(): void;
  54268. /**
  54269. * This is used to keep meshes transformations so they can be restored
  54270. * when we build back a Babylon Mesh
  54271. * NB : All CSG operations are performed in world coordinates
  54272. * @param csg The CSG to copy the transform attributes from
  54273. * @returns This CSG
  54274. */
  54275. copyTransformAttributes(csg: CSG): CSG;
  54276. /**
  54277. * Build Raw mesh from CSG
  54278. * Coordinates here are in world space
  54279. * @param name The name of the mesh geometry
  54280. * @param scene The Scene
  54281. * @param keepSubMeshes Specifies if the submeshes should be kept
  54282. * @returns A new Mesh
  54283. */
  54284. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54285. /**
  54286. * Build Mesh from CSG taking material and transforms into account
  54287. * @param name The name of the Mesh
  54288. * @param material The material of the Mesh
  54289. * @param scene The Scene
  54290. * @param keepSubMeshes Specifies if submeshes should be kept
  54291. * @returns The new Mesh
  54292. */
  54293. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54294. }
  54295. }
  54296. declare module BABYLON {
  54297. /**
  54298. * Class used to create a trail following a mesh
  54299. */
  54300. export class TrailMesh extends Mesh {
  54301. private _generator;
  54302. private _autoStart;
  54303. private _running;
  54304. private _diameter;
  54305. private _length;
  54306. private _sectionPolygonPointsCount;
  54307. private _sectionVectors;
  54308. private _sectionNormalVectors;
  54309. private _beforeRenderObserver;
  54310. /**
  54311. * @constructor
  54312. * @param name The value used by scene.getMeshByName() to do a lookup.
  54313. * @param generator The mesh to generate a trail.
  54314. * @param scene The scene to add this mesh to.
  54315. * @param diameter Diameter of trailing mesh. Default is 1.
  54316. * @param length Length of trailing mesh. Default is 60.
  54317. * @param autoStart Automatically start trailing mesh. Default true.
  54318. */
  54319. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  54320. /**
  54321. * "TrailMesh"
  54322. * @returns "TrailMesh"
  54323. */
  54324. getClassName(): string;
  54325. private _createMesh;
  54326. /**
  54327. * Start trailing mesh.
  54328. */
  54329. start(): void;
  54330. /**
  54331. * Stop trailing mesh.
  54332. */
  54333. stop(): void;
  54334. /**
  54335. * Update trailing mesh geometry.
  54336. */
  54337. update(): void;
  54338. /**
  54339. * Returns a new TrailMesh object.
  54340. * @param name is a string, the name given to the new mesh
  54341. * @param newGenerator use new generator object for cloned trail mesh
  54342. * @returns a new mesh
  54343. */
  54344. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  54345. /**
  54346. * Serializes this trail mesh
  54347. * @param serializationObject object to write serialization to
  54348. */
  54349. serialize(serializationObject: any): void;
  54350. /**
  54351. * Parses a serialized trail mesh
  54352. * @param parsedMesh the serialized mesh
  54353. * @param scene the scene to create the trail mesh in
  54354. * @returns the created trail mesh
  54355. */
  54356. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  54357. }
  54358. }
  54359. declare module BABYLON {
  54360. /**
  54361. * Class containing static functions to help procedurally build meshes
  54362. */
  54363. export class TiledBoxBuilder {
  54364. /**
  54365. * Creates a box mesh
  54366. * 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)
  54367. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54368. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54369. * * 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
  54370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54371. * @param name defines the name of the mesh
  54372. * @param options defines the options used to create the mesh
  54373. * @param scene defines the hosting scene
  54374. * @returns the box mesh
  54375. */
  54376. static CreateTiledBox(name: string, options: {
  54377. pattern?: number;
  54378. width?: number;
  54379. height?: number;
  54380. depth?: number;
  54381. tileSize?: number;
  54382. tileWidth?: number;
  54383. tileHeight?: number;
  54384. alignHorizontal?: number;
  54385. alignVertical?: number;
  54386. faceUV?: Vector4[];
  54387. faceColors?: Color4[];
  54388. sideOrientation?: number;
  54389. updatable?: boolean;
  54390. }, scene?: Nullable<Scene>): Mesh;
  54391. }
  54392. }
  54393. declare module BABYLON {
  54394. /**
  54395. * Class containing static functions to help procedurally build meshes
  54396. */
  54397. export class TorusKnotBuilder {
  54398. /**
  54399. * Creates a torus knot mesh
  54400. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54401. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54402. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54403. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54404. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54405. * * 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
  54406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54407. * @param name defines the name of the mesh
  54408. * @param options defines the options used to create the mesh
  54409. * @param scene defines the hosting scene
  54410. * @returns the torus knot mesh
  54411. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54412. */
  54413. static CreateTorusKnot(name: string, options: {
  54414. radius?: number;
  54415. tube?: number;
  54416. radialSegments?: number;
  54417. tubularSegments?: number;
  54418. p?: number;
  54419. q?: number;
  54420. updatable?: boolean;
  54421. sideOrientation?: number;
  54422. frontUVs?: Vector4;
  54423. backUVs?: Vector4;
  54424. }, scene: any): Mesh;
  54425. }
  54426. }
  54427. declare module BABYLON {
  54428. /**
  54429. * Polygon
  54430. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  54431. */
  54432. export class Polygon {
  54433. /**
  54434. * Creates a rectangle
  54435. * @param xmin bottom X coord
  54436. * @param ymin bottom Y coord
  54437. * @param xmax top X coord
  54438. * @param ymax top Y coord
  54439. * @returns points that make the resulting rectation
  54440. */
  54441. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  54442. /**
  54443. * Creates a circle
  54444. * @param radius radius of circle
  54445. * @param cx scale in x
  54446. * @param cy scale in y
  54447. * @param numberOfSides number of sides that make up the circle
  54448. * @returns points that make the resulting circle
  54449. */
  54450. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  54451. /**
  54452. * Creates a polygon from input string
  54453. * @param input Input polygon data
  54454. * @returns the parsed points
  54455. */
  54456. static Parse(input: string): Vector2[];
  54457. /**
  54458. * Starts building a polygon from x and y coordinates
  54459. * @param x x coordinate
  54460. * @param y y coordinate
  54461. * @returns the started path2
  54462. */
  54463. static StartingAt(x: number, y: number): Path2;
  54464. }
  54465. /**
  54466. * Builds a polygon
  54467. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  54468. */
  54469. export class PolygonMeshBuilder {
  54470. private _points;
  54471. private _outlinepoints;
  54472. private _holes;
  54473. private _name;
  54474. private _scene;
  54475. private _epoints;
  54476. private _eholes;
  54477. private _addToepoint;
  54478. /**
  54479. * Babylon reference to the earcut plugin.
  54480. */
  54481. bjsEarcut: any;
  54482. /**
  54483. * Creates a PolygonMeshBuilder
  54484. * @param name name of the builder
  54485. * @param contours Path of the polygon
  54486. * @param scene scene to add to when creating the mesh
  54487. * @param earcutInjection can be used to inject your own earcut reference
  54488. */
  54489. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  54490. /**
  54491. * Adds a whole within the polygon
  54492. * @param hole Array of points defining the hole
  54493. * @returns this
  54494. */
  54495. addHole(hole: Vector2[]): PolygonMeshBuilder;
  54496. /**
  54497. * Creates the polygon
  54498. * @param updatable If the mesh should be updatable
  54499. * @param depth The depth of the mesh created
  54500. * @returns the created mesh
  54501. */
  54502. build(updatable?: boolean, depth?: number): Mesh;
  54503. /**
  54504. * Creates the polygon
  54505. * @param depth The depth of the mesh created
  54506. * @returns the created VertexData
  54507. */
  54508. buildVertexData(depth?: number): VertexData;
  54509. /**
  54510. * Adds a side to the polygon
  54511. * @param positions points that make the polygon
  54512. * @param normals normals of the polygon
  54513. * @param uvs uvs of the polygon
  54514. * @param indices indices of the polygon
  54515. * @param bounds bounds of the polygon
  54516. * @param points points of the polygon
  54517. * @param depth depth of the polygon
  54518. * @param flip flip of the polygon
  54519. */
  54520. private addSide;
  54521. }
  54522. }
  54523. declare module BABYLON {
  54524. /**
  54525. * Class containing static functions to help procedurally build meshes
  54526. */
  54527. export class PolygonBuilder {
  54528. /**
  54529. * Creates a polygon mesh
  54530. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54531. * * 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
  54532. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54534. * * 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)
  54535. * * Remember you can only change the shape positions, not their number when updating a polygon
  54536. * @param name defines the name of the mesh
  54537. * @param options defines the options used to create the mesh
  54538. * @param scene defines the hosting scene
  54539. * @param earcutInjection can be used to inject your own earcut reference
  54540. * @returns the polygon mesh
  54541. */
  54542. static CreatePolygon(name: string, options: {
  54543. shape: Vector3[];
  54544. holes?: Vector3[][];
  54545. depth?: number;
  54546. faceUV?: Vector4[];
  54547. faceColors?: Color4[];
  54548. updatable?: boolean;
  54549. sideOrientation?: number;
  54550. frontUVs?: Vector4;
  54551. backUVs?: Vector4;
  54552. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54553. /**
  54554. * Creates an extruded polygon mesh, with depth in the Y direction.
  54555. * * 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)
  54556. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54557. * @param name defines the name of the mesh
  54558. * @param options defines the options used to create the mesh
  54559. * @param scene defines the hosting scene
  54560. * @param earcutInjection can be used to inject your own earcut reference
  54561. * @returns the polygon mesh
  54562. */
  54563. static ExtrudePolygon(name: string, options: {
  54564. shape: Vector3[];
  54565. holes?: Vector3[][];
  54566. depth?: number;
  54567. faceUV?: Vector4[];
  54568. faceColors?: Color4[];
  54569. updatable?: boolean;
  54570. sideOrientation?: number;
  54571. frontUVs?: Vector4;
  54572. backUVs?: Vector4;
  54573. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54574. }
  54575. }
  54576. declare module BABYLON {
  54577. /**
  54578. * Class containing static functions to help procedurally build meshes
  54579. */
  54580. export class LatheBuilder {
  54581. /**
  54582. * Creates lathe mesh.
  54583. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54584. * * 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
  54585. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54586. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54587. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54588. * * 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
  54589. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54590. * * 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
  54591. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54592. * * 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
  54593. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54595. * @param name defines the name of the mesh
  54596. * @param options defines the options used to create the mesh
  54597. * @param scene defines the hosting scene
  54598. * @returns the lathe mesh
  54599. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54600. */
  54601. static CreateLathe(name: string, options: {
  54602. shape: Vector3[];
  54603. radius?: number;
  54604. tessellation?: number;
  54605. clip?: number;
  54606. arc?: number;
  54607. closed?: boolean;
  54608. updatable?: boolean;
  54609. sideOrientation?: number;
  54610. frontUVs?: Vector4;
  54611. backUVs?: Vector4;
  54612. cap?: number;
  54613. invertUV?: boolean;
  54614. }, scene?: Nullable<Scene>): Mesh;
  54615. }
  54616. }
  54617. declare module BABYLON {
  54618. /**
  54619. * Class containing static functions to help procedurally build meshes
  54620. */
  54621. export class TiledPlaneBuilder {
  54622. /**
  54623. * Creates a tiled plane mesh
  54624. * * The parameter `pattern` will, depending on value, do nothing or
  54625. * * * flip (reflect about central vertical) alternate tiles across and up
  54626. * * * flip every tile on alternate rows
  54627. * * * rotate (180 degs) alternate tiles across and up
  54628. * * * rotate every tile on alternate rows
  54629. * * * flip and rotate alternate tiles across and up
  54630. * * * flip and rotate every tile on alternate rows
  54631. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  54632. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  54633. * * 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
  54634. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54635. * * 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)
  54636. * * 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)
  54637. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54638. * @param name defines the name of the mesh
  54639. * @param options defines the options used to create the mesh
  54640. * @param scene defines the hosting scene
  54641. * @returns the box mesh
  54642. */
  54643. static CreateTiledPlane(name: string, options: {
  54644. pattern?: number;
  54645. tileSize?: number;
  54646. tileWidth?: number;
  54647. tileHeight?: number;
  54648. size?: number;
  54649. width?: number;
  54650. height?: number;
  54651. alignHorizontal?: number;
  54652. alignVertical?: number;
  54653. sideOrientation?: number;
  54654. frontUVs?: Vector4;
  54655. backUVs?: Vector4;
  54656. updatable?: boolean;
  54657. }, scene?: Nullable<Scene>): Mesh;
  54658. }
  54659. }
  54660. declare module BABYLON {
  54661. /**
  54662. * Class containing static functions to help procedurally build meshes
  54663. */
  54664. export class TubeBuilder {
  54665. /**
  54666. * Creates a tube mesh.
  54667. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54668. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  54669. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  54670. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  54671. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  54672. * * 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)
  54673. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  54674. * * 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
  54675. * * 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
  54676. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54677. * * 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
  54678. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54680. * @param name defines the name of the mesh
  54681. * @param options defines the options used to create the mesh
  54682. * @param scene defines the hosting scene
  54683. * @returns the tube mesh
  54684. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54685. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  54686. */
  54687. static CreateTube(name: string, options: {
  54688. path: Vector3[];
  54689. radius?: number;
  54690. tessellation?: number;
  54691. radiusFunction?: {
  54692. (i: number, distance: number): number;
  54693. };
  54694. cap?: number;
  54695. arc?: number;
  54696. updatable?: boolean;
  54697. sideOrientation?: number;
  54698. frontUVs?: Vector4;
  54699. backUVs?: Vector4;
  54700. instance?: Mesh;
  54701. invertUV?: boolean;
  54702. }, scene?: Nullable<Scene>): Mesh;
  54703. }
  54704. }
  54705. declare module BABYLON {
  54706. /**
  54707. * Class containing static functions to help procedurally build meshes
  54708. */
  54709. export class IcoSphereBuilder {
  54710. /**
  54711. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54712. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54713. * * 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`)
  54714. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54715. * * 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
  54716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54717. * * 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
  54718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54719. * @param name defines the name of the mesh
  54720. * @param options defines the options used to create the mesh
  54721. * @param scene defines the hosting scene
  54722. * @returns the icosahedron mesh
  54723. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54724. */
  54725. static CreateIcoSphere(name: string, options: {
  54726. radius?: number;
  54727. radiusX?: number;
  54728. radiusY?: number;
  54729. radiusZ?: number;
  54730. flat?: boolean;
  54731. subdivisions?: number;
  54732. sideOrientation?: number;
  54733. frontUVs?: Vector4;
  54734. backUVs?: Vector4;
  54735. updatable?: boolean;
  54736. }, scene?: Nullable<Scene>): Mesh;
  54737. }
  54738. }
  54739. declare module BABYLON {
  54740. /**
  54741. * Class containing static functions to help procedurally build meshes
  54742. */
  54743. export class DecalBuilder {
  54744. /**
  54745. * Creates a decal mesh.
  54746. * 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
  54747. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  54748. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  54749. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  54750. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  54751. * @param name defines the name of the mesh
  54752. * @param sourceMesh defines the mesh where the decal must be applied
  54753. * @param options defines the options used to create the mesh
  54754. * @param scene defines the hosting scene
  54755. * @returns the decal mesh
  54756. * @see https://doc.babylonjs.com/how_to/decals
  54757. */
  54758. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  54759. position?: Vector3;
  54760. normal?: Vector3;
  54761. size?: Vector3;
  54762. angle?: number;
  54763. }): Mesh;
  54764. }
  54765. }
  54766. declare module BABYLON {
  54767. /**
  54768. * Class containing static functions to help procedurally build meshes
  54769. */
  54770. export class MeshBuilder {
  54771. /**
  54772. * Creates a box mesh
  54773. * * The parameter `size` sets the size (float) of each box side (default 1)
  54774. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54775. * * 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)
  54776. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54777. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54778. * * 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
  54779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54780. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54781. * @param name defines the name of the mesh
  54782. * @param options defines the options used to create the mesh
  54783. * @param scene defines the hosting scene
  54784. * @returns the box mesh
  54785. */
  54786. static CreateBox(name: string, options: {
  54787. size?: number;
  54788. width?: number;
  54789. height?: number;
  54790. depth?: number;
  54791. faceUV?: Vector4[];
  54792. faceColors?: Color4[];
  54793. sideOrientation?: number;
  54794. frontUVs?: Vector4;
  54795. backUVs?: Vector4;
  54796. updatable?: boolean;
  54797. }, scene?: Nullable<Scene>): Mesh;
  54798. /**
  54799. * Creates a tiled box mesh
  54800. * * faceTiles sets the pattern, tile size and number of tiles for a face
  54801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54802. * @param name defines the name of the mesh
  54803. * @param options defines the options used to create the mesh
  54804. * @param scene defines the hosting scene
  54805. * @returns the tiled box mesh
  54806. */
  54807. static CreateTiledBox(name: string, options: {
  54808. pattern?: number;
  54809. size?: number;
  54810. width?: number;
  54811. height?: number;
  54812. depth: number;
  54813. tileSize?: number;
  54814. tileWidth?: number;
  54815. tileHeight?: number;
  54816. faceUV?: Vector4[];
  54817. faceColors?: Color4[];
  54818. alignHorizontal?: number;
  54819. alignVertical?: number;
  54820. sideOrientation?: number;
  54821. updatable?: boolean;
  54822. }, scene?: Nullable<Scene>): Mesh;
  54823. /**
  54824. * Creates a sphere mesh
  54825. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  54826. * * 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`)
  54827. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  54828. * * 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
  54829. * * 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)
  54830. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54831. * * 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
  54832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54833. * @param name defines the name of the mesh
  54834. * @param options defines the options used to create the mesh
  54835. * @param scene defines the hosting scene
  54836. * @returns the sphere mesh
  54837. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  54838. */
  54839. static CreateSphere(name: string, options: {
  54840. segments?: number;
  54841. diameter?: number;
  54842. diameterX?: number;
  54843. diameterY?: number;
  54844. diameterZ?: number;
  54845. arc?: number;
  54846. slice?: number;
  54847. sideOrientation?: number;
  54848. frontUVs?: Vector4;
  54849. backUVs?: Vector4;
  54850. updatable?: boolean;
  54851. }, scene?: Nullable<Scene>): Mesh;
  54852. /**
  54853. * Creates a plane polygonal mesh. By default, this is a disc
  54854. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  54855. * * 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
  54856. * * 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
  54857. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54858. * * 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
  54859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54860. * @param name defines the name of the mesh
  54861. * @param options defines the options used to create the mesh
  54862. * @param scene defines the hosting scene
  54863. * @returns the plane polygonal mesh
  54864. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  54865. */
  54866. static CreateDisc(name: string, options: {
  54867. radius?: number;
  54868. tessellation?: number;
  54869. arc?: number;
  54870. updatable?: boolean;
  54871. sideOrientation?: number;
  54872. frontUVs?: Vector4;
  54873. backUVs?: Vector4;
  54874. }, scene?: Nullable<Scene>): Mesh;
  54875. /**
  54876. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54877. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54878. * * 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`)
  54879. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54880. * * 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
  54881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54882. * * 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
  54883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54884. * @param name defines the name of the mesh
  54885. * @param options defines the options used to create the mesh
  54886. * @param scene defines the hosting scene
  54887. * @returns the icosahedron mesh
  54888. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54889. */
  54890. static CreateIcoSphere(name: string, options: {
  54891. radius?: number;
  54892. radiusX?: number;
  54893. radiusY?: number;
  54894. radiusZ?: number;
  54895. flat?: boolean;
  54896. subdivisions?: number;
  54897. sideOrientation?: number;
  54898. frontUVs?: Vector4;
  54899. backUVs?: Vector4;
  54900. updatable?: boolean;
  54901. }, scene?: Nullable<Scene>): Mesh;
  54902. /**
  54903. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54904. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54905. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54906. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54907. * * 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
  54908. * * 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
  54909. * * 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
  54910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54911. * * 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
  54912. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54913. * * 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
  54914. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54915. * * 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
  54916. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54918. * @param name defines the name of the mesh
  54919. * @param options defines the options used to create the mesh
  54920. * @param scene defines the hosting scene
  54921. * @returns the ribbon mesh
  54922. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54923. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54924. */
  54925. static CreateRibbon(name: string, options: {
  54926. pathArray: Vector3[][];
  54927. closeArray?: boolean;
  54928. closePath?: boolean;
  54929. offset?: number;
  54930. updatable?: boolean;
  54931. sideOrientation?: number;
  54932. frontUVs?: Vector4;
  54933. backUVs?: Vector4;
  54934. instance?: Mesh;
  54935. invertUV?: boolean;
  54936. uvs?: Vector2[];
  54937. colors?: Color4[];
  54938. }, scene?: Nullable<Scene>): Mesh;
  54939. /**
  54940. * Creates a cylinder or a cone mesh
  54941. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  54942. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  54943. * * 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.
  54944. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  54945. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  54946. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  54947. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  54948. * * 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).
  54949. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  54950. * * 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).
  54951. * * 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
  54952. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  54953. * * 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
  54954. * * 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.
  54955. * * If `enclose` is false, a ring surface is one element.
  54956. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  54957. * * 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
  54958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54959. * * 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
  54960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54961. * @param name defines the name of the mesh
  54962. * @param options defines the options used to create the mesh
  54963. * @param scene defines the hosting scene
  54964. * @returns the cylinder mesh
  54965. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  54966. */
  54967. static CreateCylinder(name: string, options: {
  54968. height?: number;
  54969. diameterTop?: number;
  54970. diameterBottom?: number;
  54971. diameter?: number;
  54972. tessellation?: number;
  54973. subdivisions?: number;
  54974. arc?: number;
  54975. faceColors?: Color4[];
  54976. faceUV?: Vector4[];
  54977. updatable?: boolean;
  54978. hasRings?: boolean;
  54979. enclose?: boolean;
  54980. cap?: number;
  54981. sideOrientation?: number;
  54982. frontUVs?: Vector4;
  54983. backUVs?: Vector4;
  54984. }, scene?: Nullable<Scene>): Mesh;
  54985. /**
  54986. * Creates a torus mesh
  54987. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  54988. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  54989. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  54990. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54991. * * 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
  54992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54993. * @param name defines the name of the mesh
  54994. * @param options defines the options used to create the mesh
  54995. * @param scene defines the hosting scene
  54996. * @returns the torus mesh
  54997. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  54998. */
  54999. static CreateTorus(name: string, options: {
  55000. diameter?: number;
  55001. thickness?: number;
  55002. tessellation?: number;
  55003. updatable?: boolean;
  55004. sideOrientation?: number;
  55005. frontUVs?: Vector4;
  55006. backUVs?: Vector4;
  55007. }, scene?: Nullable<Scene>): Mesh;
  55008. /**
  55009. * Creates a torus knot mesh
  55010. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55011. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55012. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55013. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55014. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55015. * * 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
  55016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55017. * @param name defines the name of the mesh
  55018. * @param options defines the options used to create the mesh
  55019. * @param scene defines the hosting scene
  55020. * @returns the torus knot mesh
  55021. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55022. */
  55023. static CreateTorusKnot(name: string, options: {
  55024. radius?: number;
  55025. tube?: number;
  55026. radialSegments?: number;
  55027. tubularSegments?: number;
  55028. p?: number;
  55029. q?: number;
  55030. updatable?: boolean;
  55031. sideOrientation?: number;
  55032. frontUVs?: Vector4;
  55033. backUVs?: Vector4;
  55034. }, scene?: Nullable<Scene>): Mesh;
  55035. /**
  55036. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55037. * * 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
  55038. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55039. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55040. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55041. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55042. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55043. * * 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
  55044. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55046. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55047. * @param name defines the name of the new line system
  55048. * @param options defines the options used to create the line system
  55049. * @param scene defines the hosting scene
  55050. * @returns a new line system mesh
  55051. */
  55052. static CreateLineSystem(name: string, options: {
  55053. lines: Vector3[][];
  55054. updatable?: boolean;
  55055. instance?: Nullable<LinesMesh>;
  55056. colors?: Nullable<Color4[][]>;
  55057. useVertexAlpha?: boolean;
  55058. }, scene: Nullable<Scene>): LinesMesh;
  55059. /**
  55060. * Creates a line mesh
  55061. * 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
  55062. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55063. * * The parameter `points` is an array successive Vector3
  55064. * * 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
  55065. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55066. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55067. * * When updating an instance, remember that only point positions can change, not the number of points
  55068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55069. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55070. * @param name defines the name of the new line system
  55071. * @param options defines the options used to create the line system
  55072. * @param scene defines the hosting scene
  55073. * @returns a new line mesh
  55074. */
  55075. static CreateLines(name: string, options: {
  55076. points: Vector3[];
  55077. updatable?: boolean;
  55078. instance?: Nullable<LinesMesh>;
  55079. colors?: Color4[];
  55080. useVertexAlpha?: boolean;
  55081. }, scene?: Nullable<Scene>): LinesMesh;
  55082. /**
  55083. * Creates a dashed line mesh
  55084. * * 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
  55085. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55086. * * The parameter `points` is an array successive Vector3
  55087. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55088. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55089. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55090. * * 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
  55091. * * When updating an instance, remember that only point positions can change, not the number of points
  55092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55093. * @param name defines the name of the mesh
  55094. * @param options defines the options used to create the mesh
  55095. * @param scene defines the hosting scene
  55096. * @returns the dashed line mesh
  55097. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55098. */
  55099. static CreateDashedLines(name: string, options: {
  55100. points: Vector3[];
  55101. dashSize?: number;
  55102. gapSize?: number;
  55103. dashNb?: number;
  55104. updatable?: boolean;
  55105. instance?: LinesMesh;
  55106. }, scene?: Nullable<Scene>): LinesMesh;
  55107. /**
  55108. * 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.
  55109. * * 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.
  55110. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55111. * * 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.
  55112. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55113. * * 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
  55114. * * 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
  55115. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55117. * * 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
  55118. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55120. * @param name defines the name of the mesh
  55121. * @param options defines the options used to create the mesh
  55122. * @param scene defines the hosting scene
  55123. * @returns the extruded shape mesh
  55124. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55125. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55126. */
  55127. static ExtrudeShape(name: string, options: {
  55128. shape: Vector3[];
  55129. path: Vector3[];
  55130. scale?: number;
  55131. rotation?: number;
  55132. cap?: number;
  55133. updatable?: boolean;
  55134. sideOrientation?: number;
  55135. frontUVs?: Vector4;
  55136. backUVs?: Vector4;
  55137. instance?: Mesh;
  55138. invertUV?: boolean;
  55139. }, scene?: Nullable<Scene>): Mesh;
  55140. /**
  55141. * Creates an custom extruded shape mesh.
  55142. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55143. * * 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.
  55144. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55145. * * 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
  55146. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55147. * * 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
  55148. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55149. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55150. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55151. * * 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
  55152. * * 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
  55153. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55155. * * 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
  55156. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55158. * @param name defines the name of the mesh
  55159. * @param options defines the options used to create the mesh
  55160. * @param scene defines the hosting scene
  55161. * @returns the custom extruded shape mesh
  55162. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55163. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55164. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55165. */
  55166. static ExtrudeShapeCustom(name: string, options: {
  55167. shape: Vector3[];
  55168. path: Vector3[];
  55169. scaleFunction?: any;
  55170. rotationFunction?: any;
  55171. ribbonCloseArray?: boolean;
  55172. ribbonClosePath?: boolean;
  55173. cap?: number;
  55174. updatable?: boolean;
  55175. sideOrientation?: number;
  55176. frontUVs?: Vector4;
  55177. backUVs?: Vector4;
  55178. instance?: Mesh;
  55179. invertUV?: boolean;
  55180. }, scene?: Nullable<Scene>): Mesh;
  55181. /**
  55182. * Creates lathe mesh.
  55183. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55184. * * 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
  55185. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55186. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55187. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55188. * * 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
  55189. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55190. * * 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
  55191. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55192. * * 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
  55193. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55195. * @param name defines the name of the mesh
  55196. * @param options defines the options used to create the mesh
  55197. * @param scene defines the hosting scene
  55198. * @returns the lathe mesh
  55199. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55200. */
  55201. static CreateLathe(name: string, options: {
  55202. shape: Vector3[];
  55203. radius?: number;
  55204. tessellation?: number;
  55205. clip?: number;
  55206. arc?: number;
  55207. closed?: boolean;
  55208. updatable?: boolean;
  55209. sideOrientation?: number;
  55210. frontUVs?: Vector4;
  55211. backUVs?: Vector4;
  55212. cap?: number;
  55213. invertUV?: boolean;
  55214. }, scene?: Nullable<Scene>): Mesh;
  55215. /**
  55216. * Creates a tiled plane mesh
  55217. * * You can set a limited pattern arrangement with the tiles
  55218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55219. * * 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
  55220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55221. * @param name defines the name of the mesh
  55222. * @param options defines the options used to create the mesh
  55223. * @param scene defines the hosting scene
  55224. * @returns the plane mesh
  55225. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55226. */
  55227. static CreateTiledPlane(name: string, options: {
  55228. pattern?: number;
  55229. tileSize?: number;
  55230. tileWidth?: number;
  55231. tileHeight?: number;
  55232. size?: number;
  55233. width?: number;
  55234. height?: number;
  55235. alignHorizontal?: number;
  55236. alignVertical?: number;
  55237. sideOrientation?: number;
  55238. frontUVs?: Vector4;
  55239. backUVs?: Vector4;
  55240. updatable?: boolean;
  55241. }, scene?: Nullable<Scene>): Mesh;
  55242. /**
  55243. * Creates a plane mesh
  55244. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55245. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55246. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55248. * * 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
  55249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55250. * @param name defines the name of the mesh
  55251. * @param options defines the options used to create the mesh
  55252. * @param scene defines the hosting scene
  55253. * @returns the plane mesh
  55254. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55255. */
  55256. static CreatePlane(name: string, options: {
  55257. size?: number;
  55258. width?: number;
  55259. height?: number;
  55260. sideOrientation?: number;
  55261. frontUVs?: Vector4;
  55262. backUVs?: Vector4;
  55263. updatable?: boolean;
  55264. sourcePlane?: Plane;
  55265. }, scene?: Nullable<Scene>): Mesh;
  55266. /**
  55267. * Creates a ground mesh
  55268. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55269. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55271. * @param name defines the name of the mesh
  55272. * @param options defines the options used to create the mesh
  55273. * @param scene defines the hosting scene
  55274. * @returns the ground mesh
  55275. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55276. */
  55277. static CreateGround(name: string, options: {
  55278. width?: number;
  55279. height?: number;
  55280. subdivisions?: number;
  55281. subdivisionsX?: number;
  55282. subdivisionsY?: number;
  55283. updatable?: boolean;
  55284. }, scene?: Nullable<Scene>): Mesh;
  55285. /**
  55286. * Creates a tiled ground mesh
  55287. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55288. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55289. * * 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
  55290. * * 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
  55291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55292. * @param name defines the name of the mesh
  55293. * @param options defines the options used to create the mesh
  55294. * @param scene defines the hosting scene
  55295. * @returns the tiled ground mesh
  55296. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55297. */
  55298. static CreateTiledGround(name: string, options: {
  55299. xmin: number;
  55300. zmin: number;
  55301. xmax: number;
  55302. zmax: number;
  55303. subdivisions?: {
  55304. w: number;
  55305. h: number;
  55306. };
  55307. precision?: {
  55308. w: number;
  55309. h: number;
  55310. };
  55311. updatable?: boolean;
  55312. }, scene?: Nullable<Scene>): Mesh;
  55313. /**
  55314. * Creates a ground mesh from a height map
  55315. * * The parameter `url` sets the URL of the height map image resource.
  55316. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55317. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55318. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55319. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55320. * * 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.
  55321. * * 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).
  55322. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55324. * @param name defines the name of the mesh
  55325. * @param url defines the url to the height map
  55326. * @param options defines the options used to create the mesh
  55327. * @param scene defines the hosting scene
  55328. * @returns the ground mesh
  55329. * @see https://doc.babylonjs.com/babylon101/height_map
  55330. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55331. */
  55332. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55333. width?: number;
  55334. height?: number;
  55335. subdivisions?: number;
  55336. minHeight?: number;
  55337. maxHeight?: number;
  55338. colorFilter?: Color3;
  55339. alphaFilter?: number;
  55340. updatable?: boolean;
  55341. onReady?: (mesh: GroundMesh) => void;
  55342. }, scene?: Nullable<Scene>): GroundMesh;
  55343. /**
  55344. * Creates a polygon mesh
  55345. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55346. * * 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
  55347. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55349. * * 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)
  55350. * * Remember you can only change the shape positions, not their number when updating a polygon
  55351. * @param name defines the name of the mesh
  55352. * @param options defines the options used to create the mesh
  55353. * @param scene defines the hosting scene
  55354. * @param earcutInjection can be used to inject your own earcut reference
  55355. * @returns the polygon mesh
  55356. */
  55357. static CreatePolygon(name: string, options: {
  55358. shape: Vector3[];
  55359. holes?: Vector3[][];
  55360. depth?: number;
  55361. faceUV?: Vector4[];
  55362. faceColors?: Color4[];
  55363. updatable?: boolean;
  55364. sideOrientation?: number;
  55365. frontUVs?: Vector4;
  55366. backUVs?: Vector4;
  55367. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55368. /**
  55369. * Creates an extruded polygon mesh, with depth in the Y direction.
  55370. * * 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)
  55371. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55372. * @param name defines the name of the mesh
  55373. * @param options defines the options used to create the mesh
  55374. * @param scene defines the hosting scene
  55375. * @param earcutInjection can be used to inject your own earcut reference
  55376. * @returns the polygon mesh
  55377. */
  55378. static ExtrudePolygon(name: string, options: {
  55379. shape: Vector3[];
  55380. holes?: Vector3[][];
  55381. depth?: number;
  55382. faceUV?: Vector4[];
  55383. faceColors?: Color4[];
  55384. updatable?: boolean;
  55385. sideOrientation?: number;
  55386. frontUVs?: Vector4;
  55387. backUVs?: Vector4;
  55388. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55389. /**
  55390. * Creates a tube mesh.
  55391. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55392. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55393. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55394. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55395. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55396. * * 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)
  55397. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55398. * * 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
  55399. * * 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
  55400. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55401. * * 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
  55402. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55404. * @param name defines the name of the mesh
  55405. * @param options defines the options used to create the mesh
  55406. * @param scene defines the hosting scene
  55407. * @returns the tube mesh
  55408. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55409. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55410. */
  55411. static CreateTube(name: string, options: {
  55412. path: Vector3[];
  55413. radius?: number;
  55414. tessellation?: number;
  55415. radiusFunction?: {
  55416. (i: number, distance: number): number;
  55417. };
  55418. cap?: number;
  55419. arc?: number;
  55420. updatable?: boolean;
  55421. sideOrientation?: number;
  55422. frontUVs?: Vector4;
  55423. backUVs?: Vector4;
  55424. instance?: Mesh;
  55425. invertUV?: boolean;
  55426. }, scene?: Nullable<Scene>): Mesh;
  55427. /**
  55428. * Creates a polyhedron mesh
  55429. * * 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
  55430. * * The parameter `size` (positive float, default 1) sets the polygon size
  55431. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55432. * * 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`
  55433. * * 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
  55434. * * 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)`)
  55435. * * 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
  55436. * * 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
  55437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55438. * * 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
  55439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55440. * @param name defines the name of the mesh
  55441. * @param options defines the options used to create the mesh
  55442. * @param scene defines the hosting scene
  55443. * @returns the polyhedron mesh
  55444. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55445. */
  55446. static CreatePolyhedron(name: string, options: {
  55447. type?: number;
  55448. size?: number;
  55449. sizeX?: number;
  55450. sizeY?: number;
  55451. sizeZ?: number;
  55452. custom?: any;
  55453. faceUV?: Vector4[];
  55454. faceColors?: Color4[];
  55455. flat?: boolean;
  55456. updatable?: boolean;
  55457. sideOrientation?: number;
  55458. frontUVs?: Vector4;
  55459. backUVs?: Vector4;
  55460. }, scene?: Nullable<Scene>): Mesh;
  55461. /**
  55462. * Creates a decal mesh.
  55463. * 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
  55464. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55465. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55466. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55467. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55468. * @param name defines the name of the mesh
  55469. * @param sourceMesh defines the mesh where the decal must be applied
  55470. * @param options defines the options used to create the mesh
  55471. * @param scene defines the hosting scene
  55472. * @returns the decal mesh
  55473. * @see https://doc.babylonjs.com/how_to/decals
  55474. */
  55475. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55476. position?: Vector3;
  55477. normal?: Vector3;
  55478. size?: Vector3;
  55479. angle?: number;
  55480. }): Mesh;
  55481. }
  55482. }
  55483. declare module BABYLON {
  55484. /**
  55485. * A simplifier interface for future simplification implementations
  55486. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55487. */
  55488. export interface ISimplifier {
  55489. /**
  55490. * Simplification of a given mesh according to the given settings.
  55491. * Since this requires computation, it is assumed that the function runs async.
  55492. * @param settings The settings of the simplification, including quality and distance
  55493. * @param successCallback A callback that will be called after the mesh was simplified.
  55494. * @param errorCallback in case of an error, this callback will be called. optional.
  55495. */
  55496. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  55497. }
  55498. /**
  55499. * Expected simplification settings.
  55500. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  55501. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55502. */
  55503. export interface ISimplificationSettings {
  55504. /**
  55505. * Gets or sets the expected quality
  55506. */
  55507. quality: number;
  55508. /**
  55509. * Gets or sets the distance when this optimized version should be used
  55510. */
  55511. distance: number;
  55512. /**
  55513. * Gets an already optimized mesh
  55514. */
  55515. optimizeMesh?: boolean;
  55516. }
  55517. /**
  55518. * Class used to specify simplification options
  55519. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55520. */
  55521. export class SimplificationSettings implements ISimplificationSettings {
  55522. /** expected quality */
  55523. quality: number;
  55524. /** distance when this optimized version should be used */
  55525. distance: number;
  55526. /** already optimized mesh */
  55527. optimizeMesh?: boolean | undefined;
  55528. /**
  55529. * Creates a SimplificationSettings
  55530. * @param quality expected quality
  55531. * @param distance distance when this optimized version should be used
  55532. * @param optimizeMesh already optimized mesh
  55533. */
  55534. constructor(
  55535. /** expected quality */
  55536. quality: number,
  55537. /** distance when this optimized version should be used */
  55538. distance: number,
  55539. /** already optimized mesh */
  55540. optimizeMesh?: boolean | undefined);
  55541. }
  55542. /**
  55543. * Interface used to define a simplification task
  55544. */
  55545. export interface ISimplificationTask {
  55546. /**
  55547. * Array of settings
  55548. */
  55549. settings: Array<ISimplificationSettings>;
  55550. /**
  55551. * Simplification type
  55552. */
  55553. simplificationType: SimplificationType;
  55554. /**
  55555. * Mesh to simplify
  55556. */
  55557. mesh: Mesh;
  55558. /**
  55559. * Callback called on success
  55560. */
  55561. successCallback?: () => void;
  55562. /**
  55563. * Defines if parallel processing can be used
  55564. */
  55565. parallelProcessing: boolean;
  55566. }
  55567. /**
  55568. * Queue used to order the simplification tasks
  55569. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55570. */
  55571. export class SimplificationQueue {
  55572. private _simplificationArray;
  55573. /**
  55574. * Gets a boolean indicating that the process is still running
  55575. */
  55576. running: boolean;
  55577. /**
  55578. * Creates a new queue
  55579. */
  55580. constructor();
  55581. /**
  55582. * Adds a new simplification task
  55583. * @param task defines a task to add
  55584. */
  55585. addTask(task: ISimplificationTask): void;
  55586. /**
  55587. * Execute next task
  55588. */
  55589. executeNext(): void;
  55590. /**
  55591. * Execute a simplification task
  55592. * @param task defines the task to run
  55593. */
  55594. runSimplification(task: ISimplificationTask): void;
  55595. private getSimplifier;
  55596. }
  55597. /**
  55598. * The implemented types of simplification
  55599. * At the moment only Quadratic Error Decimation is implemented
  55600. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55601. */
  55602. export enum SimplificationType {
  55603. /** Quadratic error decimation */
  55604. QUADRATIC = 0
  55605. }
  55606. }
  55607. declare module BABYLON {
  55608. interface Scene {
  55609. /** @hidden (Backing field) */ private _simplificationQueue: SimplificationQueue;
  55610. /**
  55611. * Gets or sets the simplification queue attached to the scene
  55612. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55613. */
  55614. simplificationQueue: SimplificationQueue;
  55615. }
  55616. interface Mesh {
  55617. /**
  55618. * Simplify the mesh according to the given array of settings.
  55619. * Function will return immediately and will simplify async
  55620. * @param settings a collection of simplification settings
  55621. * @param parallelProcessing should all levels calculate parallel or one after the other
  55622. * @param simplificationType the type of simplification to run
  55623. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  55624. * @returns the current mesh
  55625. */
  55626. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  55627. }
  55628. /**
  55629. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  55630. * created in a scene
  55631. */
  55632. export class SimplicationQueueSceneComponent implements ISceneComponent {
  55633. /**
  55634. * The component name helpfull to identify the component in the list of scene components.
  55635. */
  55636. readonly name: string;
  55637. /**
  55638. * The scene the component belongs to.
  55639. */
  55640. scene: Scene;
  55641. /**
  55642. * Creates a new instance of the component for the given scene
  55643. * @param scene Defines the scene to register the component in
  55644. */
  55645. constructor(scene: Scene);
  55646. /**
  55647. * Registers the component in a given scene
  55648. */
  55649. register(): void;
  55650. /**
  55651. * Rebuilds the elements related to this component in case of
  55652. * context lost for instance.
  55653. */
  55654. rebuild(): void;
  55655. /**
  55656. * Disposes the component and the associated ressources
  55657. */
  55658. dispose(): void;
  55659. private _beforeCameraUpdate;
  55660. }
  55661. }
  55662. declare module BABYLON {
  55663. /**
  55664. * Navigation plugin interface to add navigation constrained by a navigation mesh
  55665. */
  55666. export interface INavigationEnginePlugin {
  55667. /**
  55668. * plugin name
  55669. */
  55670. name: string;
  55671. /**
  55672. * Creates a navigation mesh
  55673. * @param meshes array of all the geometry used to compute the navigatio mesh
  55674. * @param parameters bunch of parameters used to filter geometry
  55675. */
  55676. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  55677. /**
  55678. * Create a navigation mesh debug mesh
  55679. * @param scene is where the mesh will be added
  55680. * @returns debug display mesh
  55681. */
  55682. createDebugNavMesh(scene: Scene): Mesh;
  55683. /**
  55684. * Get a navigation mesh constrained position, closest to the parameter position
  55685. * @param position world position
  55686. * @returns the closest point to position constrained by the navigation mesh
  55687. */
  55688. getClosestPoint(position: Vector3): Vector3;
  55689. /**
  55690. * Get a navigation mesh constrained position, within a particular radius
  55691. * @param position world position
  55692. * @param maxRadius the maximum distance to the constrained world position
  55693. * @returns the closest point to position constrained by the navigation mesh
  55694. */
  55695. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  55696. /**
  55697. * Compute the final position from a segment made of destination-position
  55698. * @param position world position
  55699. * @param destination world position
  55700. * @returns the resulting point along the navmesh
  55701. */
  55702. moveAlong(position: Vector3, destination: Vector3): Vector3;
  55703. /**
  55704. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  55705. * @param start world position
  55706. * @param end world position
  55707. * @returns array containing world position composing the path
  55708. */
  55709. computePath(start: Vector3, end: Vector3): Vector3[];
  55710. /**
  55711. * If this plugin is supported
  55712. * @returns true if plugin is supported
  55713. */
  55714. isSupported(): boolean;
  55715. /**
  55716. * Create a new Crowd so you can add agents
  55717. * @param maxAgents the maximum agent count in the crowd
  55718. * @param maxAgentRadius the maximum radius an agent can have
  55719. * @param scene to attach the crowd to
  55720. * @returns the crowd you can add agents to
  55721. */
  55722. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  55723. /**
  55724. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  55725. * The queries will try to find a solution within those bounds
  55726. * default is (1,1,1)
  55727. * @param extent x,y,z value that define the extent around the queries point of reference
  55728. */
  55729. setDefaultQueryExtent(extent: Vector3): void;
  55730. /**
  55731. * Get the Bounding box extent specified by setDefaultQueryExtent
  55732. * @returns the box extent values
  55733. */
  55734. getDefaultQueryExtent(): Vector3;
  55735. /**
  55736. * Release all resources
  55737. */
  55738. dispose(): void;
  55739. }
  55740. /**
  55741. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  55742. */
  55743. export interface ICrowd {
  55744. /**
  55745. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  55746. * You can attach anything to that node. The node position is updated in the scene update tick.
  55747. * @param pos world position that will be constrained by the navigation mesh
  55748. * @param parameters agent parameters
  55749. * @param transform hooked to the agent that will be update by the scene
  55750. * @returns agent index
  55751. */
  55752. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  55753. /**
  55754. * Returns the agent position in world space
  55755. * @param index agent index returned by addAgent
  55756. * @returns world space position
  55757. */
  55758. getAgentPosition(index: number): Vector3;
  55759. /**
  55760. * Gets the agent velocity in world space
  55761. * @param index agent index returned by addAgent
  55762. * @returns world space velocity
  55763. */
  55764. getAgentVelocity(index: number): Vector3;
  55765. /**
  55766. * remove a particular agent previously created
  55767. * @param index agent index returned by addAgent
  55768. */
  55769. removeAgent(index: number): void;
  55770. /**
  55771. * get the list of all agents attached to this crowd
  55772. * @returns list of agent indices
  55773. */
  55774. getAgents(): number[];
  55775. /**
  55776. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  55777. * @param deltaTime in seconds
  55778. */
  55779. update(deltaTime: number): void;
  55780. /**
  55781. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  55782. * @param index agent index returned by addAgent
  55783. * @param destination targeted world position
  55784. */
  55785. agentGoto(index: number, destination: Vector3): void;
  55786. /**
  55787. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  55788. * The queries will try to find a solution within those bounds
  55789. * default is (1,1,1)
  55790. * @param extent x,y,z value that define the extent around the queries point of reference
  55791. */
  55792. setDefaultQueryExtent(extent: Vector3): void;
  55793. /**
  55794. * Get the Bounding box extent specified by setDefaultQueryExtent
  55795. * @returns the box extent values
  55796. */
  55797. getDefaultQueryExtent(): Vector3;
  55798. /**
  55799. * Release all resources
  55800. */
  55801. dispose(): void;
  55802. }
  55803. /**
  55804. * Configures an agent
  55805. */
  55806. export interface IAgentParameters {
  55807. /**
  55808. * Agent radius. [Limit: >= 0]
  55809. */
  55810. radius: number;
  55811. /**
  55812. * Agent height. [Limit: > 0]
  55813. */
  55814. height: number;
  55815. /**
  55816. * Maximum allowed acceleration. [Limit: >= 0]
  55817. */
  55818. maxAcceleration: number;
  55819. /**
  55820. * Maximum allowed speed. [Limit: >= 0]
  55821. */
  55822. maxSpeed: number;
  55823. /**
  55824. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  55825. */
  55826. collisionQueryRange: number;
  55827. /**
  55828. * The path visibility optimization range. [Limit: > 0]
  55829. */
  55830. pathOptimizationRange: number;
  55831. /**
  55832. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  55833. */
  55834. separationWeight: number;
  55835. }
  55836. /**
  55837. * Configures the navigation mesh creation
  55838. */
  55839. export interface INavMeshParameters {
  55840. /**
  55841. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  55842. */
  55843. cs: number;
  55844. /**
  55845. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  55846. */
  55847. ch: number;
  55848. /**
  55849. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  55850. */
  55851. walkableSlopeAngle: number;
  55852. /**
  55853. * Minimum floor to 'ceiling' height that will still allow the floor area to
  55854. * be considered walkable. [Limit: >= 3] [Units: vx]
  55855. */
  55856. walkableHeight: number;
  55857. /**
  55858. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  55859. */
  55860. walkableClimb: number;
  55861. /**
  55862. * The distance to erode/shrink the walkable area of the heightfield away from
  55863. * obstructions. [Limit: >=0] [Units: vx]
  55864. */
  55865. walkableRadius: number;
  55866. /**
  55867. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  55868. */
  55869. maxEdgeLen: number;
  55870. /**
  55871. * The maximum distance a simplfied contour's border edges should deviate
  55872. * the original raw contour. [Limit: >=0] [Units: vx]
  55873. */
  55874. maxSimplificationError: number;
  55875. /**
  55876. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  55877. */
  55878. minRegionArea: number;
  55879. /**
  55880. * Any regions with a span count smaller than this value will, if possible,
  55881. * be merged with larger regions. [Limit: >=0] [Units: vx]
  55882. */
  55883. mergeRegionArea: number;
  55884. /**
  55885. * The maximum number of vertices allowed for polygons generated during the
  55886. * contour to polygon conversion process. [Limit: >= 3]
  55887. */
  55888. maxVertsPerPoly: number;
  55889. /**
  55890. * Sets the sampling distance to use when generating the detail mesh.
  55891. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  55892. */
  55893. detailSampleDist: number;
  55894. /**
  55895. * The maximum distance the detail mesh surface should deviate from heightfield
  55896. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  55897. */
  55898. detailSampleMaxError: number;
  55899. }
  55900. }
  55901. declare module BABYLON {
  55902. /**
  55903. * RecastJS navigation plugin
  55904. */
  55905. export class RecastJSPlugin implements INavigationEnginePlugin {
  55906. /**
  55907. * Reference to the Recast library
  55908. */
  55909. bjsRECAST: any;
  55910. /**
  55911. * plugin name
  55912. */
  55913. name: string;
  55914. /**
  55915. * the first navmesh created. We might extend this to support multiple navmeshes
  55916. */
  55917. navMesh: any;
  55918. /**
  55919. * Initializes the recastJS plugin
  55920. * @param recastInjection can be used to inject your own recast reference
  55921. */
  55922. constructor(recastInjection?: any);
  55923. /**
  55924. * Creates a navigation mesh
  55925. * @param meshes array of all the geometry used to compute the navigatio mesh
  55926. * @param parameters bunch of parameters used to filter geometry
  55927. */
  55928. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  55929. /**
  55930. * Create a navigation mesh debug mesh
  55931. * @param scene is where the mesh will be added
  55932. * @returns debug display mesh
  55933. */
  55934. createDebugNavMesh(scene: Scene): Mesh;
  55935. /**
  55936. * Get a navigation mesh constrained position, closest to the parameter position
  55937. * @param position world position
  55938. * @returns the closest point to position constrained by the navigation mesh
  55939. */
  55940. getClosestPoint(position: Vector3): Vector3;
  55941. /**
  55942. * Get a navigation mesh constrained position, within a particular radius
  55943. * @param position world position
  55944. * @param maxRadius the maximum distance to the constrained world position
  55945. * @returns the closest point to position constrained by the navigation mesh
  55946. */
  55947. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  55948. /**
  55949. * Compute the final position from a segment made of destination-position
  55950. * @param position world position
  55951. * @param destination world position
  55952. * @returns the resulting point along the navmesh
  55953. */
  55954. moveAlong(position: Vector3, destination: Vector3): Vector3;
  55955. /**
  55956. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  55957. * @param start world position
  55958. * @param end world position
  55959. * @returns array containing world position composing the path
  55960. */
  55961. computePath(start: Vector3, end: Vector3): Vector3[];
  55962. /**
  55963. * Create a new Crowd so you can add agents
  55964. * @param maxAgents the maximum agent count in the crowd
  55965. * @param maxAgentRadius the maximum radius an agent can have
  55966. * @param scene to attach the crowd to
  55967. * @returns the crowd you can add agents to
  55968. */
  55969. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  55970. /**
  55971. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  55972. * The queries will try to find a solution within those bounds
  55973. * default is (1,1,1)
  55974. * @param extent x,y,z value that define the extent around the queries point of reference
  55975. */
  55976. setDefaultQueryExtent(extent: Vector3): void;
  55977. /**
  55978. * Get the Bounding box extent specified by setDefaultQueryExtent
  55979. * @returns the box extent values
  55980. */
  55981. getDefaultQueryExtent(): Vector3;
  55982. /**
  55983. * Disposes
  55984. */
  55985. dispose(): void;
  55986. /**
  55987. * If this plugin is supported
  55988. * @returns true if plugin is supported
  55989. */
  55990. isSupported(): boolean;
  55991. }
  55992. /**
  55993. * Recast detour crowd implementation
  55994. */
  55995. export class RecastJSCrowd implements ICrowd {
  55996. /**
  55997. * Recast/detour plugin
  55998. */
  55999. bjsRECASTPlugin: RecastJSPlugin;
  56000. /**
  56001. * Link to the detour crowd
  56002. */
  56003. recastCrowd: any;
  56004. /**
  56005. * One transform per agent
  56006. */
  56007. transforms: TransformNode[];
  56008. /**
  56009. * All agents created
  56010. */
  56011. agents: number[];
  56012. /**
  56013. * Link to the scene is kept to unregister the crowd from the scene
  56014. */
  56015. private _scene;
  56016. /**
  56017. * Observer for crowd updates
  56018. */
  56019. private _onBeforeAnimationsObserver;
  56020. /**
  56021. * Constructor
  56022. * @param plugin recastJS plugin
  56023. * @param maxAgents the maximum agent count in the crowd
  56024. * @param maxAgentRadius the maximum radius an agent can have
  56025. * @param scene to attach the crowd to
  56026. * @returns the crowd you can add agents to
  56027. */
  56028. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  56029. /**
  56030. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56031. * You can attach anything to that node. The node position is updated in the scene update tick.
  56032. * @param pos world position that will be constrained by the navigation mesh
  56033. * @param parameters agent parameters
  56034. * @param transform hooked to the agent that will be update by the scene
  56035. * @returns agent index
  56036. */
  56037. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56038. /**
  56039. * Returns the agent position in world space
  56040. * @param index agent index returned by addAgent
  56041. * @returns world space position
  56042. */
  56043. getAgentPosition(index: number): Vector3;
  56044. /**
  56045. * Returns the agent velocity in world space
  56046. * @param index agent index returned by addAgent
  56047. * @returns world space velocity
  56048. */
  56049. getAgentVelocity(index: number): Vector3;
  56050. /**
  56051. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56052. * @param index agent index returned by addAgent
  56053. * @param destination targeted world position
  56054. */
  56055. agentGoto(index: number, destination: Vector3): void;
  56056. /**
  56057. * remove a particular agent previously created
  56058. * @param index agent index returned by addAgent
  56059. */
  56060. removeAgent(index: number): void;
  56061. /**
  56062. * get the list of all agents attached to this crowd
  56063. * @returns list of agent indices
  56064. */
  56065. getAgents(): number[];
  56066. /**
  56067. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56068. * @param deltaTime in seconds
  56069. */
  56070. update(deltaTime: number): void;
  56071. /**
  56072. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56073. * The queries will try to find a solution within those bounds
  56074. * default is (1,1,1)
  56075. * @param extent x,y,z value that define the extent around the queries point of reference
  56076. */
  56077. setDefaultQueryExtent(extent: Vector3): void;
  56078. /**
  56079. * Get the Bounding box extent specified by setDefaultQueryExtent
  56080. * @returns the box extent values
  56081. */
  56082. getDefaultQueryExtent(): Vector3;
  56083. /**
  56084. * Release all resources
  56085. */
  56086. dispose(): void;
  56087. }
  56088. }
  56089. declare module BABYLON {
  56090. /**
  56091. * Class used to enable access to IndexedDB
  56092. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56093. */
  56094. export class Database implements IOfflineProvider {
  56095. private _callbackManifestChecked;
  56096. private _currentSceneUrl;
  56097. private _db;
  56098. private _enableSceneOffline;
  56099. private _enableTexturesOffline;
  56100. private _manifestVersionFound;
  56101. private _mustUpdateRessources;
  56102. private _hasReachedQuota;
  56103. private _isSupported;
  56104. private _idbFactory;
  56105. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56106. private static IsUASupportingBlobStorage;
  56107. /**
  56108. * Gets a boolean indicating if Database storate is enabled (off by default)
  56109. */
  56110. static IDBStorageEnabled: boolean;
  56111. /**
  56112. * Gets a boolean indicating if scene must be saved in the database
  56113. */
  56114. readonly enableSceneOffline: boolean;
  56115. /**
  56116. * Gets a boolean indicating if textures must be saved in the database
  56117. */
  56118. readonly enableTexturesOffline: boolean;
  56119. /**
  56120. * Creates a new Database
  56121. * @param urlToScene defines the url to load the scene
  56122. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56123. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56124. */
  56125. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56126. private static _ParseURL;
  56127. private static _ReturnFullUrlLocation;
  56128. private _checkManifestFile;
  56129. /**
  56130. * Open the database and make it available
  56131. * @param successCallback defines the callback to call on success
  56132. * @param errorCallback defines the callback to call on error
  56133. */
  56134. open(successCallback: () => void, errorCallback: () => void): void;
  56135. /**
  56136. * Loads an image from the database
  56137. * @param url defines the url to load from
  56138. * @param image defines the target DOM image
  56139. */
  56140. loadImage(url: string, image: HTMLImageElement): void;
  56141. private _loadImageFromDBAsync;
  56142. private _saveImageIntoDBAsync;
  56143. private _checkVersionFromDB;
  56144. private _loadVersionFromDBAsync;
  56145. private _saveVersionIntoDBAsync;
  56146. /**
  56147. * Loads a file from database
  56148. * @param url defines the URL to load from
  56149. * @param sceneLoaded defines a callback to call on success
  56150. * @param progressCallBack defines a callback to call when progress changed
  56151. * @param errorCallback defines a callback to call on error
  56152. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56153. */
  56154. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56155. private _loadFileAsync;
  56156. private _saveFileAsync;
  56157. /**
  56158. * Validates if xhr data is correct
  56159. * @param xhr defines the request to validate
  56160. * @param dataType defines the expected data type
  56161. * @returns true if data is correct
  56162. */
  56163. private static _ValidateXHRData;
  56164. }
  56165. }
  56166. declare module BABYLON {
  56167. /** @hidden */
  56168. export var gpuUpdateParticlesPixelShader: {
  56169. name: string;
  56170. shader: string;
  56171. };
  56172. }
  56173. declare module BABYLON {
  56174. /** @hidden */
  56175. export var gpuUpdateParticlesVertexShader: {
  56176. name: string;
  56177. shader: string;
  56178. };
  56179. }
  56180. declare module BABYLON {
  56181. /** @hidden */
  56182. export var clipPlaneFragmentDeclaration2: {
  56183. name: string;
  56184. shader: string;
  56185. };
  56186. }
  56187. declare module BABYLON {
  56188. /** @hidden */
  56189. export var gpuRenderParticlesPixelShader: {
  56190. name: string;
  56191. shader: string;
  56192. };
  56193. }
  56194. declare module BABYLON {
  56195. /** @hidden */
  56196. export var clipPlaneVertexDeclaration2: {
  56197. name: string;
  56198. shader: string;
  56199. };
  56200. }
  56201. declare module BABYLON {
  56202. /** @hidden */
  56203. export var gpuRenderParticlesVertexShader: {
  56204. name: string;
  56205. shader: string;
  56206. };
  56207. }
  56208. declare module BABYLON {
  56209. /**
  56210. * This represents a GPU particle system in Babylon
  56211. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56212. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56213. */
  56214. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56215. /**
  56216. * The layer mask we are rendering the particles through.
  56217. */
  56218. layerMask: number;
  56219. private _capacity;
  56220. private _activeCount;
  56221. private _currentActiveCount;
  56222. private _accumulatedCount;
  56223. private _renderEffect;
  56224. private _updateEffect;
  56225. private _buffer0;
  56226. private _buffer1;
  56227. private _spriteBuffer;
  56228. private _updateVAO;
  56229. private _renderVAO;
  56230. private _targetIndex;
  56231. private _sourceBuffer;
  56232. private _targetBuffer;
  56233. private _engine;
  56234. private _currentRenderId;
  56235. private _started;
  56236. private _stopped;
  56237. private _timeDelta;
  56238. private _randomTexture;
  56239. private _randomTexture2;
  56240. private _attributesStrideSize;
  56241. private _updateEffectOptions;
  56242. private _randomTextureSize;
  56243. private _actualFrame;
  56244. private readonly _rawTextureWidth;
  56245. /**
  56246. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56247. */
  56248. static readonly IsSupported: boolean;
  56249. /**
  56250. * An event triggered when the system is disposed.
  56251. */
  56252. onDisposeObservable: Observable<GPUParticleSystem>;
  56253. /**
  56254. * Gets the maximum number of particles active at the same time.
  56255. * @returns The max number of active particles.
  56256. */
  56257. getCapacity(): number;
  56258. /**
  56259. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56260. * to override the particles.
  56261. */
  56262. forceDepthWrite: boolean;
  56263. /**
  56264. * Gets or set the number of active particles
  56265. */
  56266. activeParticleCount: number;
  56267. private _preWarmDone;
  56268. /**
  56269. * Is this system ready to be used/rendered
  56270. * @return true if the system is ready
  56271. */
  56272. isReady(): boolean;
  56273. /**
  56274. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56275. * @returns True if it has been started, otherwise false.
  56276. */
  56277. isStarted(): boolean;
  56278. /**
  56279. * Starts the particle system and begins to emit
  56280. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56281. */
  56282. start(delay?: number): void;
  56283. /**
  56284. * Stops the particle system.
  56285. */
  56286. stop(): void;
  56287. /**
  56288. * Remove all active particles
  56289. */
  56290. reset(): void;
  56291. /**
  56292. * Returns the string "GPUParticleSystem"
  56293. * @returns a string containing the class name
  56294. */
  56295. getClassName(): string;
  56296. private _colorGradientsTexture;
  56297. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56298. /**
  56299. * Adds a new color gradient
  56300. * @param gradient defines the gradient to use (between 0 and 1)
  56301. * @param color1 defines the color to affect to the specified gradient
  56302. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56303. * @returns the current particle system
  56304. */
  56305. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56306. /**
  56307. * Remove a specific color gradient
  56308. * @param gradient defines the gradient to remove
  56309. * @returns the current particle system
  56310. */
  56311. removeColorGradient(gradient: number): GPUParticleSystem;
  56312. private _angularSpeedGradientsTexture;
  56313. private _sizeGradientsTexture;
  56314. private _velocityGradientsTexture;
  56315. private _limitVelocityGradientsTexture;
  56316. private _dragGradientsTexture;
  56317. private _addFactorGradient;
  56318. /**
  56319. * Adds a new size gradient
  56320. * @param gradient defines the gradient to use (between 0 and 1)
  56321. * @param factor defines the size factor to affect to the specified gradient
  56322. * @returns the current particle system
  56323. */
  56324. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56325. /**
  56326. * Remove a specific size gradient
  56327. * @param gradient defines the gradient to remove
  56328. * @returns the current particle system
  56329. */
  56330. removeSizeGradient(gradient: number): GPUParticleSystem;
  56331. /**
  56332. * Adds a new angular speed gradient
  56333. * @param gradient defines the gradient to use (between 0 and 1)
  56334. * @param factor defines the angular speed to affect to the specified gradient
  56335. * @returns the current particle system
  56336. */
  56337. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56338. /**
  56339. * Remove a specific angular speed gradient
  56340. * @param gradient defines the gradient to remove
  56341. * @returns the current particle system
  56342. */
  56343. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56344. /**
  56345. * Adds a new velocity gradient
  56346. * @param gradient defines the gradient to use (between 0 and 1)
  56347. * @param factor defines the velocity to affect to the specified gradient
  56348. * @returns the current particle system
  56349. */
  56350. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56351. /**
  56352. * Remove a specific velocity gradient
  56353. * @param gradient defines the gradient to remove
  56354. * @returns the current particle system
  56355. */
  56356. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56357. /**
  56358. * Adds a new limit velocity gradient
  56359. * @param gradient defines the gradient to use (between 0 and 1)
  56360. * @param factor defines the limit velocity value to affect to the specified gradient
  56361. * @returns the current particle system
  56362. */
  56363. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56364. /**
  56365. * Remove a specific limit velocity gradient
  56366. * @param gradient defines the gradient to remove
  56367. * @returns the current particle system
  56368. */
  56369. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56370. /**
  56371. * Adds a new drag gradient
  56372. * @param gradient defines the gradient to use (between 0 and 1)
  56373. * @param factor defines the drag value to affect to the specified gradient
  56374. * @returns the current particle system
  56375. */
  56376. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56377. /**
  56378. * Remove a specific drag gradient
  56379. * @param gradient defines the gradient to remove
  56380. * @returns the current particle system
  56381. */
  56382. removeDragGradient(gradient: number): GPUParticleSystem;
  56383. /**
  56384. * Not supported by GPUParticleSystem
  56385. * @param gradient defines the gradient to use (between 0 and 1)
  56386. * @param factor defines the emit rate value to affect to the specified gradient
  56387. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56388. * @returns the current particle system
  56389. */
  56390. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56391. /**
  56392. * Not supported by GPUParticleSystem
  56393. * @param gradient defines the gradient to remove
  56394. * @returns the current particle system
  56395. */
  56396. removeEmitRateGradient(gradient: number): IParticleSystem;
  56397. /**
  56398. * Not supported by GPUParticleSystem
  56399. * @param gradient defines the gradient to use (between 0 and 1)
  56400. * @param factor defines the start size value to affect to the specified gradient
  56401. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56402. * @returns the current particle system
  56403. */
  56404. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56405. /**
  56406. * Not supported by GPUParticleSystem
  56407. * @param gradient defines the gradient to remove
  56408. * @returns the current particle system
  56409. */
  56410. removeStartSizeGradient(gradient: number): IParticleSystem;
  56411. /**
  56412. * Not supported by GPUParticleSystem
  56413. * @param gradient defines the gradient to use (between 0 and 1)
  56414. * @param min defines the color remap minimal range
  56415. * @param max defines the color remap maximal range
  56416. * @returns the current particle system
  56417. */
  56418. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56419. /**
  56420. * Not supported by GPUParticleSystem
  56421. * @param gradient defines the gradient to remove
  56422. * @returns the current particle system
  56423. */
  56424. removeColorRemapGradient(): IParticleSystem;
  56425. /**
  56426. * Not supported by GPUParticleSystem
  56427. * @param gradient defines the gradient to use (between 0 and 1)
  56428. * @param min defines the alpha remap minimal range
  56429. * @param max defines the alpha remap maximal range
  56430. * @returns the current particle system
  56431. */
  56432. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56433. /**
  56434. * Not supported by GPUParticleSystem
  56435. * @param gradient defines the gradient to remove
  56436. * @returns the current particle system
  56437. */
  56438. removeAlphaRemapGradient(): IParticleSystem;
  56439. /**
  56440. * Not supported by GPUParticleSystem
  56441. * @param gradient defines the gradient to use (between 0 and 1)
  56442. * @param color defines the color to affect to the specified gradient
  56443. * @returns the current particle system
  56444. */
  56445. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56446. /**
  56447. * Not supported by GPUParticleSystem
  56448. * @param gradient defines the gradient to remove
  56449. * @returns the current particle system
  56450. */
  56451. removeRampGradient(): IParticleSystem;
  56452. /**
  56453. * Not supported by GPUParticleSystem
  56454. * @returns the list of ramp gradients
  56455. */
  56456. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56457. /**
  56458. * Not supported by GPUParticleSystem
  56459. * Gets or sets a boolean indicating that ramp gradients must be used
  56460. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56461. */
  56462. useRampGradients: boolean;
  56463. /**
  56464. * Not supported by GPUParticleSystem
  56465. * @param gradient defines the gradient to use (between 0 and 1)
  56466. * @param factor defines the life time factor to affect to the specified gradient
  56467. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56468. * @returns the current particle system
  56469. */
  56470. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56471. /**
  56472. * Not supported by GPUParticleSystem
  56473. * @param gradient defines the gradient to remove
  56474. * @returns the current particle system
  56475. */
  56476. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56477. /**
  56478. * Instantiates a GPU particle system.
  56479. * 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.
  56480. * @param name The name of the particle system
  56481. * @param options The options used to create the system
  56482. * @param scene The scene the particle system belongs to
  56483. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56484. */
  56485. constructor(name: string, options: Partial<{
  56486. capacity: number;
  56487. randomTextureSize: number;
  56488. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56489. protected _reset(): void;
  56490. private _createUpdateVAO;
  56491. private _createRenderVAO;
  56492. private _initialize;
  56493. /** @hidden */ private _recreateUpdateEffect(): void;
  56494. /** @hidden */ private _recreateRenderEffect(): void;
  56495. /**
  56496. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56497. * @param preWarm defines if we are in the pre-warmimg phase
  56498. */
  56499. animate(preWarm?: boolean): void;
  56500. private _createFactorGradientTexture;
  56501. private _createSizeGradientTexture;
  56502. private _createAngularSpeedGradientTexture;
  56503. private _createVelocityGradientTexture;
  56504. private _createLimitVelocityGradientTexture;
  56505. private _createDragGradientTexture;
  56506. private _createColorGradientTexture;
  56507. /**
  56508. * Renders the particle system in its current state
  56509. * @param preWarm defines if the system should only update the particles but not render them
  56510. * @returns the current number of particles
  56511. */
  56512. render(preWarm?: boolean): number;
  56513. /**
  56514. * Rebuilds the particle system
  56515. */
  56516. rebuild(): void;
  56517. private _releaseBuffers;
  56518. private _releaseVAOs;
  56519. /**
  56520. * Disposes the particle system and free the associated resources
  56521. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56522. */
  56523. dispose(disposeTexture?: boolean): void;
  56524. /**
  56525. * Clones the particle system.
  56526. * @param name The name of the cloned object
  56527. * @param newEmitter The new emitter to use
  56528. * @returns the cloned particle system
  56529. */
  56530. clone(name: string, newEmitter: any): GPUParticleSystem;
  56531. /**
  56532. * Serializes the particle system to a JSON object.
  56533. * @returns the JSON object
  56534. */
  56535. serialize(): any;
  56536. /**
  56537. * Parses a JSON object to create a GPU particle system.
  56538. * @param parsedParticleSystem The JSON object to parse
  56539. * @param scene The scene to create the particle system in
  56540. * @param rootUrl The root url to use to load external dependencies like texture
  56541. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56542. * @returns the parsed GPU particle system
  56543. */
  56544. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56545. }
  56546. }
  56547. declare module BABYLON {
  56548. /**
  56549. * Represents a set of particle systems working together to create a specific effect
  56550. */
  56551. export class ParticleSystemSet implements IDisposable {
  56552. private _emitterCreationOptions;
  56553. private _emitterNode;
  56554. /**
  56555. * Gets the particle system list
  56556. */
  56557. systems: IParticleSystem[];
  56558. /**
  56559. * Gets the emitter node used with this set
  56560. */
  56561. readonly emitterNode: Nullable<TransformNode>;
  56562. /**
  56563. * Creates a new emitter mesh as a sphere
  56564. * @param options defines the options used to create the sphere
  56565. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  56566. * @param scene defines the hosting scene
  56567. */
  56568. setEmitterAsSphere(options: {
  56569. diameter: number;
  56570. segments: number;
  56571. color: Color3;
  56572. }, renderingGroupId: number, scene: Scene): void;
  56573. /**
  56574. * Starts all particle systems of the set
  56575. * @param emitter defines an optional mesh to use as emitter for the particle systems
  56576. */
  56577. start(emitter?: AbstractMesh): void;
  56578. /**
  56579. * Release all associated resources
  56580. */
  56581. dispose(): void;
  56582. /**
  56583. * Serialize the set into a JSON compatible object
  56584. * @returns a JSON compatible representation of the set
  56585. */
  56586. serialize(): any;
  56587. /**
  56588. * Parse a new ParticleSystemSet from a serialized source
  56589. * @param data defines a JSON compatible representation of the set
  56590. * @param scene defines the hosting scene
  56591. * @param gpu defines if we want GPU particles or CPU particles
  56592. * @returns a new ParticleSystemSet
  56593. */
  56594. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  56595. }
  56596. }
  56597. declare module BABYLON {
  56598. /**
  56599. * This class is made for on one-liner static method to help creating particle system set.
  56600. */
  56601. export class ParticleHelper {
  56602. /**
  56603. * Gets or sets base Assets URL
  56604. */
  56605. static BaseAssetsUrl: string;
  56606. /**
  56607. * Create a default particle system that you can tweak
  56608. * @param emitter defines the emitter to use
  56609. * @param capacity defines the system capacity (default is 500 particles)
  56610. * @param scene defines the hosting scene
  56611. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  56612. * @returns the new Particle system
  56613. */
  56614. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  56615. /**
  56616. * This is the main static method (one-liner) of this helper to create different particle systems
  56617. * @param type This string represents the type to the particle system to create
  56618. * @param scene The scene where the particle system should live
  56619. * @param gpu If the system will use gpu
  56620. * @returns the ParticleSystemSet created
  56621. */
  56622. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  56623. /**
  56624. * Static function used to export a particle system to a ParticleSystemSet variable.
  56625. * Please note that the emitter shape is not exported
  56626. * @param systems defines the particle systems to export
  56627. * @returns the created particle system set
  56628. */
  56629. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  56630. }
  56631. }
  56632. declare module BABYLON {
  56633. interface Engine {
  56634. /**
  56635. * Create an effect to use with particle systems.
  56636. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  56637. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  56638. * @param uniformsNames defines a list of attribute names
  56639. * @param samplers defines an array of string used to represent textures
  56640. * @param defines defines the string containing the defines to use to compile the shaders
  56641. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  56642. * @param onCompiled defines a function to call when the effect creation is successful
  56643. * @param onError defines a function to call when the effect creation has failed
  56644. * @returns the new Effect
  56645. */
  56646. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  56647. }
  56648. interface Mesh {
  56649. /**
  56650. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  56651. * @returns an array of IParticleSystem
  56652. */
  56653. getEmittedParticleSystems(): IParticleSystem[];
  56654. /**
  56655. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  56656. * @returns an array of IParticleSystem
  56657. */
  56658. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  56659. }
  56660. /**
  56661. * @hidden
  56662. */
  56663. export var _IDoNeedToBeInTheBuild: number;
  56664. }
  56665. declare module BABYLON {
  56666. interface Scene {
  56667. /** @hidden (Backing field) */ private _physicsEngine: Nullable<IPhysicsEngine>;
  56668. /**
  56669. * Gets the current physics engine
  56670. * @returns a IPhysicsEngine or null if none attached
  56671. */
  56672. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  56673. /**
  56674. * Enables physics to the current scene
  56675. * @param gravity defines the scene's gravity for the physics engine
  56676. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  56677. * @return a boolean indicating if the physics engine was initialized
  56678. */
  56679. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  56680. /**
  56681. * Disables and disposes the physics engine associated with the scene
  56682. */
  56683. disablePhysicsEngine(): void;
  56684. /**
  56685. * Gets a boolean indicating if there is an active physics engine
  56686. * @returns a boolean indicating if there is an active physics engine
  56687. */
  56688. isPhysicsEnabled(): boolean;
  56689. /**
  56690. * Deletes a physics compound impostor
  56691. * @param compound defines the compound to delete
  56692. */
  56693. deleteCompoundImpostor(compound: any): void;
  56694. /**
  56695. * An event triggered when physic simulation is about to be run
  56696. */
  56697. onBeforePhysicsObservable: Observable<Scene>;
  56698. /**
  56699. * An event triggered when physic simulation has been done
  56700. */
  56701. onAfterPhysicsObservable: Observable<Scene>;
  56702. }
  56703. interface AbstractMesh {
  56704. /** @hidden */ private _physicsImpostor: Nullable<PhysicsImpostor>;
  56705. /**
  56706. * Gets or sets impostor used for physic simulation
  56707. * @see http://doc.babylonjs.com/features/physics_engine
  56708. */
  56709. physicsImpostor: Nullable<PhysicsImpostor>;
  56710. /**
  56711. * Gets the current physics impostor
  56712. * @see http://doc.babylonjs.com/features/physics_engine
  56713. * @returns a physics impostor or null
  56714. */
  56715. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  56716. /** Apply a physic impulse to the mesh
  56717. * @param force defines the force to apply
  56718. * @param contactPoint defines where to apply the force
  56719. * @returns the current mesh
  56720. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  56721. */
  56722. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  56723. /**
  56724. * Creates a physic joint between two meshes
  56725. * @param otherMesh defines the other mesh to use
  56726. * @param pivot1 defines the pivot to use on this mesh
  56727. * @param pivot2 defines the pivot to use on the other mesh
  56728. * @param options defines additional options (can be plugin dependent)
  56729. * @returns the current mesh
  56730. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  56731. */
  56732. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  56733. /** @hidden */ private _disposePhysicsObserver: Nullable<Observer<Node>>;
  56734. }
  56735. /**
  56736. * Defines the physics engine scene component responsible to manage a physics engine
  56737. */
  56738. export class PhysicsEngineSceneComponent implements ISceneComponent {
  56739. /**
  56740. * The component name helpful to identify the component in the list of scene components.
  56741. */
  56742. readonly name: string;
  56743. /**
  56744. * The scene the component belongs to.
  56745. */
  56746. scene: Scene;
  56747. /**
  56748. * Creates a new instance of the component for the given scene
  56749. * @param scene Defines the scene to register the component in
  56750. */
  56751. constructor(scene: Scene);
  56752. /**
  56753. * Registers the component in a given scene
  56754. */
  56755. register(): void;
  56756. /**
  56757. * Rebuilds the elements related to this component in case of
  56758. * context lost for instance.
  56759. */
  56760. rebuild(): void;
  56761. /**
  56762. * Disposes the component and the associated ressources
  56763. */
  56764. dispose(): void;
  56765. }
  56766. }
  56767. declare module BABYLON {
  56768. /**
  56769. * A helper for physics simulations
  56770. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56771. */
  56772. export class PhysicsHelper {
  56773. private _scene;
  56774. private _physicsEngine;
  56775. /**
  56776. * Initializes the Physics helper
  56777. * @param scene Babylon.js scene
  56778. */
  56779. constructor(scene: Scene);
  56780. /**
  56781. * Applies a radial explosion impulse
  56782. * @param origin the origin of the explosion
  56783. * @param radiusOrEventOptions the radius or the options of radial explosion
  56784. * @param strength the explosion strength
  56785. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56786. * @returns A physics radial explosion event, or null
  56787. */
  56788. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56789. /**
  56790. * Applies a radial explosion force
  56791. * @param origin the origin of the explosion
  56792. * @param radiusOrEventOptions the radius or the options of radial explosion
  56793. * @param strength the explosion strength
  56794. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56795. * @returns A physics radial explosion event, or null
  56796. */
  56797. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56798. /**
  56799. * Creates a gravitational field
  56800. * @param origin the origin of the explosion
  56801. * @param radiusOrEventOptions the radius or the options of radial explosion
  56802. * @param strength the explosion strength
  56803. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56804. * @returns A physics gravitational field event, or null
  56805. */
  56806. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  56807. /**
  56808. * Creates a physics updraft event
  56809. * @param origin the origin of the updraft
  56810. * @param radiusOrEventOptions the radius or the options of the updraft
  56811. * @param strength the strength of the updraft
  56812. * @param height the height of the updraft
  56813. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  56814. * @returns A physics updraft event, or null
  56815. */
  56816. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  56817. /**
  56818. * Creates a physics vortex event
  56819. * @param origin the of the vortex
  56820. * @param radiusOrEventOptions the radius or the options of the vortex
  56821. * @param strength the strength of the vortex
  56822. * @param height the height of the vortex
  56823. * @returns a Physics vortex event, or null
  56824. * A physics vortex event or null
  56825. */
  56826. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  56827. }
  56828. /**
  56829. * Represents a physics radial explosion event
  56830. */
  56831. class PhysicsRadialExplosionEvent {
  56832. private _scene;
  56833. private _options;
  56834. private _sphere;
  56835. private _dataFetched;
  56836. /**
  56837. * Initializes a radial explosioin event
  56838. * @param _scene BabylonJS scene
  56839. * @param _options The options for the vortex event
  56840. */
  56841. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  56842. /**
  56843. * Returns the data related to the radial explosion event (sphere).
  56844. * @returns The radial explosion event data
  56845. */
  56846. getData(): PhysicsRadialExplosionEventData;
  56847. /**
  56848. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  56849. * @param impostor A physics imposter
  56850. * @param origin the origin of the explosion
  56851. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  56852. */
  56853. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  56854. /**
  56855. * Triggers affecterd impostors callbacks
  56856. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  56857. */
  56858. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  56859. /**
  56860. * Disposes the sphere.
  56861. * @param force Specifies if the sphere should be disposed by force
  56862. */
  56863. dispose(force?: boolean): void;
  56864. /*** Helpers ***/
  56865. private _prepareSphere;
  56866. private _intersectsWithSphere;
  56867. }
  56868. /**
  56869. * Represents a gravitational field event
  56870. */
  56871. class PhysicsGravitationalFieldEvent {
  56872. private _physicsHelper;
  56873. private _scene;
  56874. private _origin;
  56875. private _options;
  56876. private _tickCallback;
  56877. private _sphere;
  56878. private _dataFetched;
  56879. /**
  56880. * Initializes the physics gravitational field event
  56881. * @param _physicsHelper A physics helper
  56882. * @param _scene BabylonJS scene
  56883. * @param _origin The origin position of the gravitational field event
  56884. * @param _options The options for the vortex event
  56885. */
  56886. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  56887. /**
  56888. * Returns the data related to the gravitational field event (sphere).
  56889. * @returns A gravitational field event
  56890. */
  56891. getData(): PhysicsGravitationalFieldEventData;
  56892. /**
  56893. * Enables the gravitational field.
  56894. */
  56895. enable(): void;
  56896. /**
  56897. * Disables the gravitational field.
  56898. */
  56899. disable(): void;
  56900. /**
  56901. * Disposes the sphere.
  56902. * @param force The force to dispose from the gravitational field event
  56903. */
  56904. dispose(force?: boolean): void;
  56905. private _tick;
  56906. }
  56907. /**
  56908. * Represents a physics updraft event
  56909. */
  56910. class PhysicsUpdraftEvent {
  56911. private _scene;
  56912. private _origin;
  56913. private _options;
  56914. private _physicsEngine;
  56915. private _originTop;
  56916. private _originDirection;
  56917. private _tickCallback;
  56918. private _cylinder;
  56919. private _cylinderPosition;
  56920. private _dataFetched;
  56921. /**
  56922. * Initializes the physics updraft event
  56923. * @param _scene BabylonJS scene
  56924. * @param _origin The origin position of the updraft
  56925. * @param _options The options for the updraft event
  56926. */
  56927. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  56928. /**
  56929. * Returns the data related to the updraft event (cylinder).
  56930. * @returns A physics updraft event
  56931. */
  56932. getData(): PhysicsUpdraftEventData;
  56933. /**
  56934. * Enables the updraft.
  56935. */
  56936. enable(): void;
  56937. /**
  56938. * Disables the updraft.
  56939. */
  56940. disable(): void;
  56941. /**
  56942. * Disposes the cylinder.
  56943. * @param force Specifies if the updraft should be disposed by force
  56944. */
  56945. dispose(force?: boolean): void;
  56946. private getImpostorHitData;
  56947. private _tick;
  56948. /*** Helpers ***/
  56949. private _prepareCylinder;
  56950. private _intersectsWithCylinder;
  56951. }
  56952. /**
  56953. * Represents a physics vortex event
  56954. */
  56955. class PhysicsVortexEvent {
  56956. private _scene;
  56957. private _origin;
  56958. private _options;
  56959. private _physicsEngine;
  56960. private _originTop;
  56961. private _tickCallback;
  56962. private _cylinder;
  56963. private _cylinderPosition;
  56964. private _dataFetched;
  56965. /**
  56966. * Initializes the physics vortex event
  56967. * @param _scene The BabylonJS scene
  56968. * @param _origin The origin position of the vortex
  56969. * @param _options The options for the vortex event
  56970. */
  56971. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  56972. /**
  56973. * Returns the data related to the vortex event (cylinder).
  56974. * @returns The physics vortex event data
  56975. */
  56976. getData(): PhysicsVortexEventData;
  56977. /**
  56978. * Enables the vortex.
  56979. */
  56980. enable(): void;
  56981. /**
  56982. * Disables the cortex.
  56983. */
  56984. disable(): void;
  56985. /**
  56986. * Disposes the sphere.
  56987. * @param force
  56988. */
  56989. dispose(force?: boolean): void;
  56990. private getImpostorHitData;
  56991. private _tick;
  56992. /*** Helpers ***/
  56993. private _prepareCylinder;
  56994. private _intersectsWithCylinder;
  56995. }
  56996. /**
  56997. * Options fot the radial explosion event
  56998. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56999. */
  57000. export class PhysicsRadialExplosionEventOptions {
  57001. /**
  57002. * The radius of the sphere for the radial explosion.
  57003. */
  57004. radius: number;
  57005. /**
  57006. * The strenth of the explosion.
  57007. */
  57008. strength: number;
  57009. /**
  57010. * The strenght of the force in correspondence to the distance of the affected object
  57011. */
  57012. falloff: PhysicsRadialImpulseFalloff;
  57013. /**
  57014. * Sphere options for the radial explosion.
  57015. */
  57016. sphere: {
  57017. segments: number;
  57018. diameter: number;
  57019. };
  57020. /**
  57021. * Sphere options for the radial explosion.
  57022. */
  57023. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57024. }
  57025. /**
  57026. * Options fot the updraft event
  57027. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57028. */
  57029. export class PhysicsUpdraftEventOptions {
  57030. /**
  57031. * The radius of the cylinder for the vortex
  57032. */
  57033. radius: number;
  57034. /**
  57035. * The strenth of the updraft.
  57036. */
  57037. strength: number;
  57038. /**
  57039. * The height of the cylinder for the updraft.
  57040. */
  57041. height: number;
  57042. /**
  57043. * The mode for the the updraft.
  57044. */
  57045. updraftMode: PhysicsUpdraftMode;
  57046. }
  57047. /**
  57048. * Options fot the vortex event
  57049. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57050. */
  57051. export class PhysicsVortexEventOptions {
  57052. /**
  57053. * The radius of the cylinder for the vortex
  57054. */
  57055. radius: number;
  57056. /**
  57057. * The strenth of the vortex.
  57058. */
  57059. strength: number;
  57060. /**
  57061. * The height of the cylinder for the vortex.
  57062. */
  57063. height: number;
  57064. /**
  57065. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57066. */
  57067. centripetalForceThreshold: number;
  57068. /**
  57069. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57070. */
  57071. centripetalForceMultiplier: number;
  57072. /**
  57073. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57074. */
  57075. centrifugalForceMultiplier: number;
  57076. /**
  57077. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57078. */
  57079. updraftForceMultiplier: number;
  57080. }
  57081. /**
  57082. * The strenght of the force in correspondence to the distance of the affected object
  57083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57084. */
  57085. export enum PhysicsRadialImpulseFalloff {
  57086. /** Defines that impulse is constant in strength across it's whole radius */
  57087. Constant = 0,
  57088. /** Defines that impulse gets weaker if it's further from the origin */
  57089. Linear = 1
  57090. }
  57091. /**
  57092. * The strength of the force in correspondence to the distance of the affected object
  57093. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57094. */
  57095. export enum PhysicsUpdraftMode {
  57096. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57097. Center = 0,
  57098. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57099. Perpendicular = 1
  57100. }
  57101. /**
  57102. * Interface for a physics hit data
  57103. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57104. */
  57105. export interface PhysicsHitData {
  57106. /**
  57107. * The force applied at the contact point
  57108. */
  57109. force: Vector3;
  57110. /**
  57111. * The contact point
  57112. */
  57113. contactPoint: Vector3;
  57114. /**
  57115. * The distance from the origin to the contact point
  57116. */
  57117. distanceFromOrigin: number;
  57118. }
  57119. /**
  57120. * Interface for radial explosion event data
  57121. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57122. */
  57123. export interface PhysicsRadialExplosionEventData {
  57124. /**
  57125. * A sphere used for the radial explosion event
  57126. */
  57127. sphere: Mesh;
  57128. }
  57129. /**
  57130. * Interface for gravitational field event data
  57131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57132. */
  57133. export interface PhysicsGravitationalFieldEventData {
  57134. /**
  57135. * A sphere mesh used for the gravitational field event
  57136. */
  57137. sphere: Mesh;
  57138. }
  57139. /**
  57140. * Interface for updraft event data
  57141. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57142. */
  57143. export interface PhysicsUpdraftEventData {
  57144. /**
  57145. * A cylinder used for the updraft event
  57146. */
  57147. cylinder: Mesh;
  57148. }
  57149. /**
  57150. * Interface for vortex event data
  57151. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57152. */
  57153. export interface PhysicsVortexEventData {
  57154. /**
  57155. * A cylinder used for the vortex event
  57156. */
  57157. cylinder: Mesh;
  57158. }
  57159. /**
  57160. * Interface for an affected physics impostor
  57161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57162. */
  57163. export interface PhysicsAffectedImpostorWithData {
  57164. /**
  57165. * The impostor affected by the effect
  57166. */
  57167. impostor: PhysicsImpostor;
  57168. /**
  57169. * The data about the hit/horce from the explosion
  57170. */
  57171. hitData: PhysicsHitData;
  57172. }
  57173. }
  57174. declare module BABYLON {
  57175. /** @hidden */
  57176. export var blackAndWhitePixelShader: {
  57177. name: string;
  57178. shader: string;
  57179. };
  57180. }
  57181. declare module BABYLON {
  57182. /**
  57183. * Post process used to render in black and white
  57184. */
  57185. export class BlackAndWhitePostProcess extends PostProcess {
  57186. /**
  57187. * Linear about to convert he result to black and white (default: 1)
  57188. */
  57189. degree: number;
  57190. /**
  57191. * Creates a black and white post process
  57192. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57193. * @param name The name of the effect.
  57194. * @param options The required width/height ratio to downsize to before computing the render pass.
  57195. * @param camera The camera to apply the render pass to.
  57196. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57197. * @param engine The engine which the post process will be applied. (default: current engine)
  57198. * @param reusable If the post process can be reused on the same frame. (default: false)
  57199. */
  57200. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57201. }
  57202. }
  57203. declare module BABYLON {
  57204. /**
  57205. * This represents a set of one or more post processes in Babylon.
  57206. * A post process can be used to apply a shader to a texture after it is rendered.
  57207. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57208. */
  57209. export class PostProcessRenderEffect {
  57210. private _postProcesses;
  57211. private _getPostProcesses;
  57212. private _singleInstance;
  57213. private _cameras;
  57214. private _indicesForCamera;
  57215. /**
  57216. * Name of the effect
  57217. * @hidden
  57218. */ private _name: string;
  57219. /**
  57220. * Instantiates a post process render effect.
  57221. * A post process can be used to apply a shader to a texture after it is rendered.
  57222. * @param engine The engine the effect is tied to
  57223. * @param name The name of the effect
  57224. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57225. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57226. */
  57227. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57228. /**
  57229. * Checks if all the post processes in the effect are supported.
  57230. */
  57231. readonly isSupported: boolean;
  57232. /**
  57233. * Updates the current state of the effect
  57234. * @hidden
  57235. */ private _update(): void;
  57236. /**
  57237. * Attaches the effect on cameras
  57238. * @param cameras The camera to attach to.
  57239. * @hidden
  57240. */ private _attachCameras(cameras: Camera): void;
  57241. /**
  57242. * Attaches the effect on cameras
  57243. * @param cameras The camera to attach to.
  57244. * @hidden
  57245. */ private _attachCameras(cameras: Camera[]): void;
  57246. /**
  57247. * Detaches the effect on cameras
  57248. * @param cameras The camera to detatch from.
  57249. * @hidden
  57250. */ private _detachCameras(cameras: Camera): void;
  57251. /**
  57252. * Detatches the effect on cameras
  57253. * @param cameras The camera to detatch from.
  57254. * @hidden
  57255. */ private _detachCameras(cameras: Camera[]): void;
  57256. /**
  57257. * Enables the effect on given cameras
  57258. * @param cameras The camera to enable.
  57259. * @hidden
  57260. */ private _enable(cameras: Camera): void;
  57261. /**
  57262. * Enables the effect on given cameras
  57263. * @param cameras The camera to enable.
  57264. * @hidden
  57265. */ private _enable(cameras: Nullable<Camera[]>): void;
  57266. /**
  57267. * Disables the effect on the given cameras
  57268. * @param cameras The camera to disable.
  57269. * @hidden
  57270. */ private _disable(cameras: Camera): void;
  57271. /**
  57272. * Disables the effect on the given cameras
  57273. * @param cameras The camera to disable.
  57274. * @hidden
  57275. */ private _disable(cameras: Nullable<Camera[]>): void;
  57276. /**
  57277. * Gets a list of the post processes contained in the effect.
  57278. * @param camera The camera to get the post processes on.
  57279. * @returns The list of the post processes in the effect.
  57280. */
  57281. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57282. }
  57283. }
  57284. declare module BABYLON {
  57285. /** @hidden */
  57286. export var extractHighlightsPixelShader: {
  57287. name: string;
  57288. shader: string;
  57289. };
  57290. }
  57291. declare module BABYLON {
  57292. /**
  57293. * 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.
  57294. */
  57295. export class ExtractHighlightsPostProcess extends PostProcess {
  57296. /**
  57297. * The luminance threshold, pixels below this value will be set to black.
  57298. */
  57299. threshold: number;
  57300. /** @hidden */ private _exposure: number;
  57301. /**
  57302. * Post process which has the input texture to be used when performing highlight extraction
  57303. * @hidden
  57304. */ private _inputPostProcess: Nullable<PostProcess>;
  57305. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57306. }
  57307. }
  57308. declare module BABYLON {
  57309. /** @hidden */
  57310. export var bloomMergePixelShader: {
  57311. name: string;
  57312. shader: string;
  57313. };
  57314. }
  57315. declare module BABYLON {
  57316. /**
  57317. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57318. */
  57319. export class BloomMergePostProcess extends PostProcess {
  57320. /** Weight of the bloom to be added to the original input. */
  57321. weight: number;
  57322. /**
  57323. * Creates a new instance of @see BloomMergePostProcess
  57324. * @param name The name of the effect.
  57325. * @param originalFromInput Post process which's input will be used for the merge.
  57326. * @param blurred Blurred highlights post process which's output will be used.
  57327. * @param weight Weight of the bloom to be added to the original input.
  57328. * @param options The required width/height ratio to downsize to before computing the render pass.
  57329. * @param camera The camera to apply the render pass to.
  57330. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57331. * @param engine The engine which the post process will be applied. (default: current engine)
  57332. * @param reusable If the post process can be reused on the same frame. (default: false)
  57333. * @param textureType Type of textures used when performing the post process. (default: 0)
  57334. * @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)
  57335. */
  57336. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57337. /** Weight of the bloom to be added to the original input. */
  57338. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57339. }
  57340. }
  57341. declare module BABYLON {
  57342. /**
  57343. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57344. */
  57345. export class BloomEffect extends PostProcessRenderEffect {
  57346. private bloomScale;
  57347. /**
  57348. * @hidden Internal
  57349. */ private _effects: Array<PostProcess>;
  57350. /**
  57351. * @hidden Internal
  57352. */ private _downscale: ExtractHighlightsPostProcess;
  57353. private _blurX;
  57354. private _blurY;
  57355. private _merge;
  57356. /**
  57357. * The luminance threshold to find bright areas of the image to bloom.
  57358. */
  57359. threshold: number;
  57360. /**
  57361. * The strength of the bloom.
  57362. */
  57363. weight: number;
  57364. /**
  57365. * Specifies the size of the bloom blur kernel, relative to the final output size
  57366. */
  57367. kernel: number;
  57368. /**
  57369. * Creates a new instance of @see BloomEffect
  57370. * @param scene The scene the effect belongs to.
  57371. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57372. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57373. * @param bloomWeight The the strength of bloom.
  57374. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57375. * @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)
  57376. */
  57377. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57378. /**
  57379. * Disposes each of the internal effects for a given camera.
  57380. * @param camera The camera to dispose the effect on.
  57381. */
  57382. disposeEffects(camera: Camera): void;
  57383. /**
  57384. * @hidden Internal
  57385. */ private _updateEffects(): void;
  57386. /**
  57387. * Internal
  57388. * @returns if all the contained post processes are ready.
  57389. * @hidden
  57390. */ private _isReady(): boolean;
  57391. }
  57392. }
  57393. declare module BABYLON {
  57394. /** @hidden */
  57395. export var chromaticAberrationPixelShader: {
  57396. name: string;
  57397. shader: string;
  57398. };
  57399. }
  57400. declare module BABYLON {
  57401. /**
  57402. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  57403. */
  57404. export class ChromaticAberrationPostProcess extends PostProcess {
  57405. /**
  57406. * The amount of seperation of rgb channels (default: 30)
  57407. */
  57408. aberrationAmount: number;
  57409. /**
  57410. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  57411. */
  57412. radialIntensity: number;
  57413. /**
  57414. * 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))
  57415. */
  57416. direction: Vector2;
  57417. /**
  57418. * 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))
  57419. */
  57420. centerPosition: Vector2;
  57421. /**
  57422. * Creates a new instance ChromaticAberrationPostProcess
  57423. * @param name The name of the effect.
  57424. * @param screenWidth The width of the screen to apply the effect on.
  57425. * @param screenHeight The height of the screen to apply the effect on.
  57426. * @param options The required width/height ratio to downsize to before computing the render pass.
  57427. * @param camera The camera to apply the render pass to.
  57428. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57429. * @param engine The engine which the post process will be applied. (default: current engine)
  57430. * @param reusable If the post process can be reused on the same frame. (default: false)
  57431. * @param textureType Type of textures used when performing the post process. (default: 0)
  57432. * @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)
  57433. */
  57434. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57435. }
  57436. }
  57437. declare module BABYLON {
  57438. /** @hidden */
  57439. export var circleOfConfusionPixelShader: {
  57440. name: string;
  57441. shader: string;
  57442. };
  57443. }
  57444. declare module BABYLON {
  57445. /**
  57446. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57447. */
  57448. export class CircleOfConfusionPostProcess extends PostProcess {
  57449. /**
  57450. * 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.
  57451. */
  57452. lensSize: number;
  57453. /**
  57454. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57455. */
  57456. fStop: number;
  57457. /**
  57458. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57459. */
  57460. focusDistance: number;
  57461. /**
  57462. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  57463. */
  57464. focalLength: number;
  57465. private _depthTexture;
  57466. /**
  57467. * Creates a new instance CircleOfConfusionPostProcess
  57468. * @param name The name of the effect.
  57469. * @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.
  57470. * @param options The required width/height ratio to downsize to before computing the render pass.
  57471. * @param camera The camera to apply the render pass to.
  57472. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57473. * @param engine The engine which the post process will be applied. (default: current engine)
  57474. * @param reusable If the post process can be reused on the same frame. (default: false)
  57475. * @param textureType Type of textures used when performing the post process. (default: 0)
  57476. * @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)
  57477. */
  57478. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57479. /**
  57480. * 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.
  57481. */
  57482. depthTexture: RenderTargetTexture;
  57483. }
  57484. }
  57485. declare module BABYLON {
  57486. /** @hidden */
  57487. export var colorCorrectionPixelShader: {
  57488. name: string;
  57489. shader: string;
  57490. };
  57491. }
  57492. declare module BABYLON {
  57493. /**
  57494. *
  57495. * This post-process allows the modification of rendered colors by using
  57496. * a 'look-up table' (LUT). This effect is also called Color Grading.
  57497. *
  57498. * The object needs to be provided an url to a texture containing the color
  57499. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  57500. * Use an image editing software to tweak the LUT to match your needs.
  57501. *
  57502. * For an example of a color LUT, see here:
  57503. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  57504. * For explanations on color grading, see here:
  57505. * @see http://udn.epicgames.com/Three/ColorGrading.html
  57506. *
  57507. */
  57508. export class ColorCorrectionPostProcess extends PostProcess {
  57509. private _colorTableTexture;
  57510. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57511. }
  57512. }
  57513. declare module BABYLON {
  57514. /** @hidden */
  57515. export var convolutionPixelShader: {
  57516. name: string;
  57517. shader: string;
  57518. };
  57519. }
  57520. declare module BABYLON {
  57521. /**
  57522. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  57523. * input texture to perform effects such as edge detection or sharpening
  57524. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57525. */
  57526. export class ConvolutionPostProcess extends PostProcess {
  57527. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57528. kernel: number[];
  57529. /**
  57530. * Creates a new instance ConvolutionPostProcess
  57531. * @param name The name of the effect.
  57532. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  57533. * @param options The required width/height ratio to downsize to before computing the render pass.
  57534. * @param camera The camera to apply the render pass to.
  57535. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57536. * @param engine The engine which the post process will be applied. (default: current engine)
  57537. * @param reusable If the post process can be reused on the same frame. (default: false)
  57538. * @param textureType Type of textures used when performing the post process. (default: 0)
  57539. */
  57540. constructor(name: string,
  57541. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57542. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57543. /**
  57544. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57545. */
  57546. static EdgeDetect0Kernel: number[];
  57547. /**
  57548. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57549. */
  57550. static EdgeDetect1Kernel: number[];
  57551. /**
  57552. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57553. */
  57554. static EdgeDetect2Kernel: number[];
  57555. /**
  57556. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57557. */
  57558. static SharpenKernel: number[];
  57559. /**
  57560. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57561. */
  57562. static EmbossKernel: number[];
  57563. /**
  57564. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57565. */
  57566. static GaussianKernel: number[];
  57567. }
  57568. }
  57569. declare module BABYLON {
  57570. /**
  57571. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  57572. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  57573. * based on samples that have a large difference in distance than the center pixel.
  57574. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  57575. */
  57576. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  57577. direction: Vector2;
  57578. /**
  57579. * Creates a new instance CircleOfConfusionPostProcess
  57580. * @param name The name of the effect.
  57581. * @param scene The scene the effect belongs to.
  57582. * @param direction The direction the blur should be applied.
  57583. * @param kernel The size of the kernel used to blur.
  57584. * @param options The required width/height ratio to downsize to before computing the render pass.
  57585. * @param camera The camera to apply the render pass to.
  57586. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  57587. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  57588. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57589. * @param engine The engine which the post process will be applied. (default: current engine)
  57590. * @param reusable If the post process can be reused on the same frame. (default: false)
  57591. * @param textureType Type of textures used when performing the post process. (default: 0)
  57592. * @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)
  57593. */
  57594. 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);
  57595. }
  57596. }
  57597. declare module BABYLON {
  57598. /** @hidden */
  57599. export var depthOfFieldMergePixelShader: {
  57600. name: string;
  57601. shader: string;
  57602. };
  57603. }
  57604. declare module BABYLON {
  57605. /**
  57606. * Options to be set when merging outputs from the default pipeline.
  57607. */
  57608. export class DepthOfFieldMergePostProcessOptions {
  57609. /**
  57610. * The original image to merge on top of
  57611. */
  57612. originalFromInput: PostProcess;
  57613. /**
  57614. * Parameters to perform the merge of the depth of field effect
  57615. */
  57616. depthOfField?: {
  57617. circleOfConfusion: PostProcess;
  57618. blurSteps: Array<PostProcess>;
  57619. };
  57620. /**
  57621. * Parameters to perform the merge of bloom effect
  57622. */
  57623. bloom?: {
  57624. blurred: PostProcess;
  57625. weight: number;
  57626. };
  57627. }
  57628. /**
  57629. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57630. */
  57631. export class DepthOfFieldMergePostProcess extends PostProcess {
  57632. private blurSteps;
  57633. /**
  57634. * Creates a new instance of DepthOfFieldMergePostProcess
  57635. * @param name The name of the effect.
  57636. * @param originalFromInput Post process which's input will be used for the merge.
  57637. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  57638. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  57639. * @param options The required width/height ratio to downsize to before computing the render pass.
  57640. * @param camera The camera to apply the render pass to.
  57641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57642. * @param engine The engine which the post process will be applied. (default: current engine)
  57643. * @param reusable If the post process can be reused on the same frame. (default: false)
  57644. * @param textureType Type of textures used when performing the post process. (default: 0)
  57645. * @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)
  57646. */
  57647. 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);
  57648. /**
  57649. * Updates the effect with the current post process compile time values and recompiles the shader.
  57650. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  57651. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  57652. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  57653. * @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
  57654. * @param onCompiled Called when the shader has been compiled.
  57655. * @param onError Called if there is an error when compiling a shader.
  57656. */
  57657. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  57658. }
  57659. }
  57660. declare module BABYLON {
  57661. /**
  57662. * Specifies the level of max blur that should be applied when using the depth of field effect
  57663. */
  57664. export enum DepthOfFieldEffectBlurLevel {
  57665. /**
  57666. * Subtle blur
  57667. */
  57668. Low = 0,
  57669. /**
  57670. * Medium blur
  57671. */
  57672. Medium = 1,
  57673. /**
  57674. * Large blur
  57675. */
  57676. High = 2
  57677. }
  57678. /**
  57679. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  57680. */
  57681. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  57682. private _circleOfConfusion;
  57683. /**
  57684. * @hidden Internal, blurs from high to low
  57685. */ private _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  57686. private _depthOfFieldBlurY;
  57687. private _dofMerge;
  57688. /**
  57689. * @hidden Internal post processes in depth of field effect
  57690. */ private _effects: Array<PostProcess>;
  57691. /**
  57692. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  57693. */
  57694. focalLength: number;
  57695. /**
  57696. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57697. */
  57698. fStop: number;
  57699. /**
  57700. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57701. */
  57702. focusDistance: number;
  57703. /**
  57704. * 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.
  57705. */
  57706. lensSize: number;
  57707. /**
  57708. * Creates a new instance DepthOfFieldEffect
  57709. * @param scene The scene the effect belongs to.
  57710. * @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.
  57711. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57712. * @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)
  57713. */
  57714. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  57715. /**
  57716. * Get the current class name of the current effet
  57717. * @returns "DepthOfFieldEffect"
  57718. */
  57719. getClassName(): string;
  57720. /**
  57721. * 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.
  57722. */
  57723. depthTexture: RenderTargetTexture;
  57724. /**
  57725. * Disposes each of the internal effects for a given camera.
  57726. * @param camera The camera to dispose the effect on.
  57727. */
  57728. disposeEffects(camera: Camera): void;
  57729. /**
  57730. * @hidden Internal
  57731. */ private _updateEffects(): void;
  57732. /**
  57733. * Internal
  57734. * @returns if all the contained post processes are ready.
  57735. * @hidden
  57736. */ private _isReady(): boolean;
  57737. }
  57738. }
  57739. declare module BABYLON {
  57740. /** @hidden */
  57741. export var displayPassPixelShader: {
  57742. name: string;
  57743. shader: string;
  57744. };
  57745. }
  57746. declare module BABYLON {
  57747. /**
  57748. * DisplayPassPostProcess which produces an output the same as it's input
  57749. */
  57750. export class DisplayPassPostProcess extends PostProcess {
  57751. /**
  57752. * Creates the DisplayPassPostProcess
  57753. * @param name The name of the effect.
  57754. * @param options The required width/height ratio to downsize to before computing the render pass.
  57755. * @param camera The camera to apply the render pass to.
  57756. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57757. * @param engine The engine which the post process will be applied. (default: current engine)
  57758. * @param reusable If the post process can be reused on the same frame. (default: false)
  57759. */
  57760. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57761. }
  57762. }
  57763. declare module BABYLON {
  57764. /** @hidden */
  57765. export var filterPixelShader: {
  57766. name: string;
  57767. shader: string;
  57768. };
  57769. }
  57770. declare module BABYLON {
  57771. /**
  57772. * Applies a kernel filter to the image
  57773. */
  57774. export class FilterPostProcess extends PostProcess {
  57775. /** The matrix to be applied to the image */
  57776. kernelMatrix: Matrix;
  57777. /**
  57778. *
  57779. * @param name The name of the effect.
  57780. * @param kernelMatrix The matrix to be applied to the image
  57781. * @param options The required width/height ratio to downsize to before computing the render pass.
  57782. * @param camera The camera to apply the render pass to.
  57783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57784. * @param engine The engine which the post process will be applied. (default: current engine)
  57785. * @param reusable If the post process can be reused on the same frame. (default: false)
  57786. */
  57787. constructor(name: string,
  57788. /** The matrix to be applied to the image */
  57789. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57790. }
  57791. }
  57792. declare module BABYLON {
  57793. /** @hidden */
  57794. export var fxaaPixelShader: {
  57795. name: string;
  57796. shader: string;
  57797. };
  57798. }
  57799. declare module BABYLON {
  57800. /** @hidden */
  57801. export var fxaaVertexShader: {
  57802. name: string;
  57803. shader: string;
  57804. };
  57805. }
  57806. declare module BABYLON {
  57807. /**
  57808. * Fxaa post process
  57809. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  57810. */
  57811. export class FxaaPostProcess extends PostProcess {
  57812. /** @hidden */
  57813. texelWidth: number;
  57814. /** @hidden */
  57815. texelHeight: number;
  57816. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57817. private _getDefines;
  57818. }
  57819. }
  57820. declare module BABYLON {
  57821. /** @hidden */
  57822. export var grainPixelShader: {
  57823. name: string;
  57824. shader: string;
  57825. };
  57826. }
  57827. declare module BABYLON {
  57828. /**
  57829. * The GrainPostProcess adds noise to the image at mid luminance levels
  57830. */
  57831. export class GrainPostProcess extends PostProcess {
  57832. /**
  57833. * The intensity of the grain added (default: 30)
  57834. */
  57835. intensity: number;
  57836. /**
  57837. * If the grain should be randomized on every frame
  57838. */
  57839. animated: boolean;
  57840. /**
  57841. * Creates a new instance of @see GrainPostProcess
  57842. * @param name The name of the effect.
  57843. * @param options The required width/height ratio to downsize to before computing the render pass.
  57844. * @param camera The camera to apply the render pass to.
  57845. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57846. * @param engine The engine which the post process will be applied. (default: current engine)
  57847. * @param reusable If the post process can be reused on the same frame. (default: false)
  57848. * @param textureType Type of textures used when performing the post process. (default: 0)
  57849. * @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)
  57850. */
  57851. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57852. }
  57853. }
  57854. declare module BABYLON {
  57855. /** @hidden */
  57856. export var highlightsPixelShader: {
  57857. name: string;
  57858. shader: string;
  57859. };
  57860. }
  57861. declare module BABYLON {
  57862. /**
  57863. * Extracts highlights from the image
  57864. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57865. */
  57866. export class HighlightsPostProcess extends PostProcess {
  57867. /**
  57868. * Extracts highlights from the image
  57869. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57870. * @param name The name of the effect.
  57871. * @param options The required width/height ratio to downsize to before computing the render pass.
  57872. * @param camera The camera to apply the render pass to.
  57873. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57874. * @param engine The engine which the post process will be applied. (default: current engine)
  57875. * @param reusable If the post process can be reused on the same frame. (default: false)
  57876. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  57877. */
  57878. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57879. }
  57880. }
  57881. declare module BABYLON {
  57882. /** @hidden */
  57883. export var mrtFragmentDeclaration: {
  57884. name: string;
  57885. shader: string;
  57886. };
  57887. }
  57888. declare module BABYLON {
  57889. /** @hidden */
  57890. export var geometryPixelShader: {
  57891. name: string;
  57892. shader: string;
  57893. };
  57894. }
  57895. declare module BABYLON {
  57896. /** @hidden */
  57897. export var geometryVertexShader: {
  57898. name: string;
  57899. shader: string;
  57900. };
  57901. }
  57902. declare module BABYLON {
  57903. /** @hidden */
  57904. interface ISavedTransformationMatrix {
  57905. world: Matrix;
  57906. viewProjection: Matrix;
  57907. }
  57908. /**
  57909. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  57910. */
  57911. export class GeometryBufferRenderer {
  57912. /**
  57913. * Constant used to retrieve the position texture index in the G-Buffer textures array
  57914. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  57915. */
  57916. static readonly POSITION_TEXTURE_TYPE: number;
  57917. /**
  57918. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  57919. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  57920. */
  57921. static readonly VELOCITY_TEXTURE_TYPE: number;
  57922. /**
  57923. * Dictionary used to store the previous transformation matrices of each rendered mesh
  57924. * in order to compute objects velocities when enableVelocity is set to "true"
  57925. * @hidden
  57926. */ private _previousTransformationMatrices: {
  57927. [index: number]: ISavedTransformationMatrix;
  57928. };
  57929. /**
  57930. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  57931. * in order to compute objects velocities when enableVelocity is set to "true"
  57932. * @hidden
  57933. */ private _previousBonesTransformationMatrices: {
  57934. [index: number]: Float32Array;
  57935. };
  57936. /**
  57937. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  57938. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  57939. */
  57940. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  57941. private _scene;
  57942. private _multiRenderTarget;
  57943. private _ratio;
  57944. private _enablePosition;
  57945. private _enableVelocity;
  57946. private _positionIndex;
  57947. private _velocityIndex;
  57948. protected _effect: Effect;
  57949. protected _cachedDefines: string;
  57950. /**
  57951. * Set the render list (meshes to be rendered) used in the G buffer.
  57952. */
  57953. renderList: Mesh[];
  57954. /**
  57955. * Gets wether or not G buffer are supported by the running hardware.
  57956. * This requires draw buffer supports
  57957. */
  57958. readonly isSupported: boolean;
  57959. /**
  57960. * Returns the index of the given texture type in the G-Buffer textures array
  57961. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  57962. * @returns the index of the given texture type in the G-Buffer textures array
  57963. */
  57964. getTextureIndex(textureType: number): number;
  57965. /**
  57966. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  57967. */
  57968. /**
  57969. * Sets whether or not objects positions are enabled for the G buffer.
  57970. */
  57971. enablePosition: boolean;
  57972. /**
  57973. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  57974. */
  57975. /**
  57976. * Sets wether or not objects velocities are enabled for the G buffer.
  57977. */
  57978. enableVelocity: boolean;
  57979. /**
  57980. * Gets the scene associated with the buffer.
  57981. */
  57982. readonly scene: Scene;
  57983. /**
  57984. * Gets the ratio used by the buffer during its creation.
  57985. * How big is the buffer related to the main canvas.
  57986. */
  57987. readonly ratio: number;
  57988. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  57989. /**
  57990. * Creates a new G Buffer for the scene
  57991. * @param scene The scene the buffer belongs to
  57992. * @param ratio How big is the buffer related to the main canvas.
  57993. */
  57994. constructor(scene: Scene, ratio?: number);
  57995. /**
  57996. * Checks wether everything is ready to render a submesh to the G buffer.
  57997. * @param subMesh the submesh to check readiness for
  57998. * @param useInstances is the mesh drawn using instance or not
  57999. * @returns true if ready otherwise false
  58000. */
  58001. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58002. /**
  58003. * Gets the current underlying G Buffer.
  58004. * @returns the buffer
  58005. */
  58006. getGBuffer(): MultiRenderTarget;
  58007. /**
  58008. * Gets the number of samples used to render the buffer (anti aliasing).
  58009. */
  58010. /**
  58011. * Sets the number of samples used to render the buffer (anti aliasing).
  58012. */
  58013. samples: number;
  58014. /**
  58015. * Disposes the renderer and frees up associated resources.
  58016. */
  58017. dispose(): void;
  58018. protected _createRenderTargets(): void;
  58019. private _copyBonesTransformationMatrices;
  58020. }
  58021. }
  58022. declare module BABYLON {
  58023. interface Scene {
  58024. /** @hidden (Backing field) */ private _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58025. /**
  58026. * Gets or Sets the current geometry buffer associated to the scene.
  58027. */
  58028. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58029. /**
  58030. * Enables a GeometryBufferRender and associates it with the scene
  58031. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58032. * @returns the GeometryBufferRenderer
  58033. */
  58034. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58035. /**
  58036. * Disables the GeometryBufferRender associated with the scene
  58037. */
  58038. disableGeometryBufferRenderer(): void;
  58039. }
  58040. /**
  58041. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58042. * in several rendering techniques.
  58043. */
  58044. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58045. /**
  58046. * The component name helpful to identify the component in the list of scene components.
  58047. */
  58048. readonly name: string;
  58049. /**
  58050. * The scene the component belongs to.
  58051. */
  58052. scene: Scene;
  58053. /**
  58054. * Creates a new instance of the component for the given scene
  58055. * @param scene Defines the scene to register the component in
  58056. */
  58057. constructor(scene: Scene);
  58058. /**
  58059. * Registers the component in a given scene
  58060. */
  58061. register(): void;
  58062. /**
  58063. * Rebuilds the elements related to this component in case of
  58064. * context lost for instance.
  58065. */
  58066. rebuild(): void;
  58067. /**
  58068. * Disposes the component and the associated ressources
  58069. */
  58070. dispose(): void;
  58071. private _gatherRenderTargets;
  58072. }
  58073. }
  58074. declare module BABYLON {
  58075. /** @hidden */
  58076. export var motionBlurPixelShader: {
  58077. name: string;
  58078. shader: string;
  58079. };
  58080. }
  58081. declare module BABYLON {
  58082. /**
  58083. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58084. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58085. * As an example, all you have to do is to create the post-process:
  58086. * var mb = new BABYLON.MotionBlurPostProcess(
  58087. * 'mb', // The name of the effect.
  58088. * scene, // The scene containing the objects to blur according to their velocity.
  58089. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58090. * camera // The camera to apply the render pass to.
  58091. * );
  58092. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58093. */
  58094. export class MotionBlurPostProcess extends PostProcess {
  58095. /**
  58096. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58097. */
  58098. motionStrength: number;
  58099. /**
  58100. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58101. */
  58102. /**
  58103. * Sets the number of iterations to be used for motion blur quality
  58104. */
  58105. motionBlurSamples: number;
  58106. private _motionBlurSamples;
  58107. private _geometryBufferRenderer;
  58108. /**
  58109. * Creates a new instance MotionBlurPostProcess
  58110. * @param name The name of the effect.
  58111. * @param scene The scene containing the objects to blur according to their velocity.
  58112. * @param options The required width/height ratio to downsize to before computing the render pass.
  58113. * @param camera The camera to apply the render pass to.
  58114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58115. * @param engine The engine which the post process will be applied. (default: current engine)
  58116. * @param reusable If the post process can be reused on the same frame. (default: false)
  58117. * @param textureType Type of textures used when performing the post process. (default: 0)
  58118. * @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)
  58119. */
  58120. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58121. /**
  58122. * Excludes the given skinned mesh from computing bones velocities.
  58123. * 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.
  58124. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58125. */
  58126. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58127. /**
  58128. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58129. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58130. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58131. */
  58132. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58133. /**
  58134. * Disposes the post process.
  58135. * @param camera The camera to dispose the post process on.
  58136. */
  58137. dispose(camera?: Camera): void;
  58138. }
  58139. }
  58140. declare module BABYLON {
  58141. /** @hidden */
  58142. export var refractionPixelShader: {
  58143. name: string;
  58144. shader: string;
  58145. };
  58146. }
  58147. declare module BABYLON {
  58148. /**
  58149. * Post process which applies a refractin texture
  58150. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58151. */
  58152. export class RefractionPostProcess extends PostProcess {
  58153. /** the base color of the refraction (used to taint the rendering) */
  58154. color: Color3;
  58155. /** simulated refraction depth */
  58156. depth: number;
  58157. /** the coefficient of the base color (0 to remove base color tainting) */
  58158. colorLevel: number;
  58159. private _refTexture;
  58160. private _ownRefractionTexture;
  58161. /**
  58162. * Gets or sets the refraction texture
  58163. * Please note that you are responsible for disposing the texture if you set it manually
  58164. */
  58165. refractionTexture: Texture;
  58166. /**
  58167. * Initializes the RefractionPostProcess
  58168. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58169. * @param name The name of the effect.
  58170. * @param refractionTextureUrl Url of the refraction texture to use
  58171. * @param color the base color of the refraction (used to taint the rendering)
  58172. * @param depth simulated refraction depth
  58173. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58174. * @param camera The camera to apply the render pass to.
  58175. * @param options The required width/height ratio to downsize to before computing the render pass.
  58176. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58177. * @param engine The engine which the post process will be applied. (default: current engine)
  58178. * @param reusable If the post process can be reused on the same frame. (default: false)
  58179. */
  58180. constructor(name: string, refractionTextureUrl: string,
  58181. /** the base color of the refraction (used to taint the rendering) */
  58182. color: Color3,
  58183. /** simulated refraction depth */
  58184. depth: number,
  58185. /** the coefficient of the base color (0 to remove base color tainting) */
  58186. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58187. /**
  58188. * Disposes of the post process
  58189. * @param camera Camera to dispose post process on
  58190. */
  58191. dispose(camera: Camera): void;
  58192. }
  58193. }
  58194. declare module BABYLON {
  58195. /** @hidden */
  58196. export var sharpenPixelShader: {
  58197. name: string;
  58198. shader: string;
  58199. };
  58200. }
  58201. declare module BABYLON {
  58202. /**
  58203. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58204. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58205. */
  58206. export class SharpenPostProcess extends PostProcess {
  58207. /**
  58208. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58209. */
  58210. colorAmount: number;
  58211. /**
  58212. * How much sharpness should be applied (default: 0.3)
  58213. */
  58214. edgeAmount: number;
  58215. /**
  58216. * Creates a new instance ConvolutionPostProcess
  58217. * @param name The name of the effect.
  58218. * @param options The required width/height ratio to downsize to before computing the render pass.
  58219. * @param camera The camera to apply the render pass to.
  58220. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58221. * @param engine The engine which the post process will be applied. (default: current engine)
  58222. * @param reusable If the post process can be reused on the same frame. (default: false)
  58223. * @param textureType Type of textures used when performing the post process. (default: 0)
  58224. * @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)
  58225. */
  58226. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58227. }
  58228. }
  58229. declare module BABYLON {
  58230. /**
  58231. * PostProcessRenderPipeline
  58232. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58233. */
  58234. export class PostProcessRenderPipeline {
  58235. private engine;
  58236. private _renderEffects;
  58237. private _renderEffectsForIsolatedPass;
  58238. /**
  58239. * List of inspectable custom properties (used by the Inspector)
  58240. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58241. */
  58242. inspectableCustomProperties: IInspectable[];
  58243. /**
  58244. * @hidden
  58245. */
  58246. protected _cameras: Camera[];
  58247. /** @hidden */ private _name: string;
  58248. /**
  58249. * Gets pipeline name
  58250. */
  58251. readonly name: string;
  58252. /**
  58253. * Initializes a PostProcessRenderPipeline
  58254. * @param engine engine to add the pipeline to
  58255. * @param name name of the pipeline
  58256. */
  58257. constructor(engine: Engine, name: string);
  58258. /**
  58259. * Gets the class name
  58260. * @returns "PostProcessRenderPipeline"
  58261. */
  58262. getClassName(): string;
  58263. /**
  58264. * If all the render effects in the pipeline are supported
  58265. */
  58266. readonly isSupported: boolean;
  58267. /**
  58268. * Adds an effect to the pipeline
  58269. * @param renderEffect the effect to add
  58270. */
  58271. addEffect(renderEffect: PostProcessRenderEffect): void;
  58272. /** @hidden */ private _rebuild(): void;
  58273. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera): void;
  58274. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58275. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58276. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58277. /** @hidden */ private _attachCameras(cameras: Camera, unique: boolean): void;
  58278. /** @hidden */ private _attachCameras(cameras: Camera[], unique: boolean): void;
  58279. /** @hidden */ private _detachCameras(cameras: Camera): void;
  58280. /** @hidden */ private _detachCameras(cameras: Nullable<Camera[]>): void;
  58281. /** @hidden */ private _update(): void;
  58282. /** @hidden */ private _reset(): void;
  58283. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58284. /**
  58285. * Disposes of the pipeline
  58286. */
  58287. dispose(): void;
  58288. }
  58289. }
  58290. declare module BABYLON {
  58291. /**
  58292. * PostProcessRenderPipelineManager class
  58293. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58294. */
  58295. export class PostProcessRenderPipelineManager {
  58296. private _renderPipelines;
  58297. /**
  58298. * Initializes a PostProcessRenderPipelineManager
  58299. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58300. */
  58301. constructor();
  58302. /**
  58303. * Gets the list of supported render pipelines
  58304. */
  58305. readonly supportedPipelines: PostProcessRenderPipeline[];
  58306. /**
  58307. * Adds a pipeline to the manager
  58308. * @param renderPipeline The pipeline to add
  58309. */
  58310. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58311. /**
  58312. * Attaches a camera to the pipeline
  58313. * @param renderPipelineName The name of the pipeline to attach to
  58314. * @param cameras the camera to attach
  58315. * @param unique if the camera can be attached multiple times to the pipeline
  58316. */
  58317. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58318. /**
  58319. * Detaches a camera from the pipeline
  58320. * @param renderPipelineName The name of the pipeline to detach from
  58321. * @param cameras the camera to detach
  58322. */
  58323. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  58324. /**
  58325. * Enables an effect by name on a pipeline
  58326. * @param renderPipelineName the name of the pipeline to enable the effect in
  58327. * @param renderEffectName the name of the effect to enable
  58328. * @param cameras the cameras that the effect should be enabled on
  58329. */
  58330. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58331. /**
  58332. * Disables an effect by name on a pipeline
  58333. * @param renderPipelineName the name of the pipeline to disable the effect in
  58334. * @param renderEffectName the name of the effect to disable
  58335. * @param cameras the cameras that the effect should be disabled on
  58336. */
  58337. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58338. /**
  58339. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  58340. */
  58341. update(): void;
  58342. /** @hidden */ private _rebuild(): void;
  58343. /**
  58344. * Disposes of the manager and pipelines
  58345. */
  58346. dispose(): void;
  58347. }
  58348. }
  58349. declare module BABYLON {
  58350. interface Scene {
  58351. /** @hidden (Backing field) */ private _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58352. /**
  58353. * Gets the postprocess render pipeline manager
  58354. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58355. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58356. */
  58357. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58358. }
  58359. /**
  58360. * Defines the Render Pipeline scene component responsible to rendering pipelines
  58361. */
  58362. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  58363. /**
  58364. * The component name helpfull to identify the component in the list of scene components.
  58365. */
  58366. readonly name: string;
  58367. /**
  58368. * The scene the component belongs to.
  58369. */
  58370. scene: Scene;
  58371. /**
  58372. * Creates a new instance of the component for the given scene
  58373. * @param scene Defines the scene to register the component in
  58374. */
  58375. constructor(scene: Scene);
  58376. /**
  58377. * Registers the component in a given scene
  58378. */
  58379. register(): void;
  58380. /**
  58381. * Rebuilds the elements related to this component in case of
  58382. * context lost for instance.
  58383. */
  58384. rebuild(): void;
  58385. /**
  58386. * Disposes the component and the associated ressources
  58387. */
  58388. dispose(): void;
  58389. private _gatherRenderTargets;
  58390. }
  58391. }
  58392. declare module BABYLON {
  58393. /**
  58394. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  58395. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58396. */
  58397. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58398. private _scene;
  58399. private _camerasToBeAttached;
  58400. /**
  58401. * ID of the sharpen post process,
  58402. */
  58403. private readonly SharpenPostProcessId;
  58404. /**
  58405. * @ignore
  58406. * ID of the image processing post process;
  58407. */
  58408. readonly ImageProcessingPostProcessId: string;
  58409. /**
  58410. * @ignore
  58411. * ID of the Fast Approximate Anti-Aliasing post process;
  58412. */
  58413. readonly FxaaPostProcessId: string;
  58414. /**
  58415. * ID of the chromatic aberration post process,
  58416. */
  58417. private readonly ChromaticAberrationPostProcessId;
  58418. /**
  58419. * ID of the grain post process
  58420. */
  58421. private readonly GrainPostProcessId;
  58422. /**
  58423. * Sharpen post process which will apply a sharpen convolution to enhance edges
  58424. */
  58425. sharpen: SharpenPostProcess;
  58426. private _sharpenEffect;
  58427. private bloom;
  58428. /**
  58429. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  58430. */
  58431. depthOfField: DepthOfFieldEffect;
  58432. /**
  58433. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58434. */
  58435. fxaa: FxaaPostProcess;
  58436. /**
  58437. * Image post processing pass used to perform operations such as tone mapping or color grading.
  58438. */
  58439. imageProcessing: ImageProcessingPostProcess;
  58440. /**
  58441. * Chromatic aberration post process which will shift rgb colors in the image
  58442. */
  58443. chromaticAberration: ChromaticAberrationPostProcess;
  58444. private _chromaticAberrationEffect;
  58445. /**
  58446. * Grain post process which add noise to the image
  58447. */
  58448. grain: GrainPostProcess;
  58449. private _grainEffect;
  58450. /**
  58451. * Glow post process which adds a glow to emissive areas of the image
  58452. */
  58453. private _glowLayer;
  58454. /**
  58455. * Animations which can be used to tweak settings over a period of time
  58456. */
  58457. animations: Animation[];
  58458. private _imageProcessingConfigurationObserver;
  58459. private _sharpenEnabled;
  58460. private _bloomEnabled;
  58461. private _depthOfFieldEnabled;
  58462. private _depthOfFieldBlurLevel;
  58463. private _fxaaEnabled;
  58464. private _imageProcessingEnabled;
  58465. private _defaultPipelineTextureType;
  58466. private _bloomScale;
  58467. private _chromaticAberrationEnabled;
  58468. private _grainEnabled;
  58469. private _buildAllowed;
  58470. /**
  58471. * Gets active scene
  58472. */
  58473. readonly scene: Scene;
  58474. /**
  58475. * Enable or disable the sharpen process from the pipeline
  58476. */
  58477. sharpenEnabled: boolean;
  58478. private _resizeObserver;
  58479. private _hardwareScaleLevel;
  58480. private _bloomKernel;
  58481. /**
  58482. * Specifies the size of the bloom blur kernel, relative to the final output size
  58483. */
  58484. bloomKernel: number;
  58485. /**
  58486. * Specifies the weight of the bloom in the final rendering
  58487. */
  58488. private _bloomWeight;
  58489. /**
  58490. * Specifies the luma threshold for the area that will be blurred by the bloom
  58491. */
  58492. private _bloomThreshold;
  58493. private _hdr;
  58494. /**
  58495. * The strength of the bloom.
  58496. */
  58497. bloomWeight: number;
  58498. /**
  58499. * The strength of the bloom.
  58500. */
  58501. bloomThreshold: number;
  58502. /**
  58503. * The scale of the bloom, lower value will provide better performance.
  58504. */
  58505. bloomScale: number;
  58506. /**
  58507. * Enable or disable the bloom from the pipeline
  58508. */
  58509. bloomEnabled: boolean;
  58510. private _rebuildBloom;
  58511. /**
  58512. * If the depth of field is enabled.
  58513. */
  58514. depthOfFieldEnabled: boolean;
  58515. /**
  58516. * Blur level of the depth of field effect. (Higher blur will effect performance)
  58517. */
  58518. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  58519. /**
  58520. * If the anti aliasing is enabled.
  58521. */
  58522. fxaaEnabled: boolean;
  58523. private _samples;
  58524. /**
  58525. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58526. */
  58527. samples: number;
  58528. /**
  58529. * If image processing is enabled.
  58530. */
  58531. imageProcessingEnabled: boolean;
  58532. /**
  58533. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  58534. */
  58535. glowLayerEnabled: boolean;
  58536. /**
  58537. * Gets the glow layer (or null if not defined)
  58538. */
  58539. readonly glowLayer: Nullable<GlowLayer>;
  58540. /**
  58541. * Enable or disable the chromaticAberration process from the pipeline
  58542. */
  58543. chromaticAberrationEnabled: boolean;
  58544. /**
  58545. * Enable or disable the grain process from the pipeline
  58546. */
  58547. grainEnabled: boolean;
  58548. /**
  58549. * @constructor
  58550. * @param name - The rendering pipeline name (default: "")
  58551. * @param hdr - If high dynamic range textures should be used (default: true)
  58552. * @param scene - The scene linked to this pipeline (default: the last created scene)
  58553. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  58554. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  58555. */
  58556. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  58557. /**
  58558. * Get the class name
  58559. * @returns "DefaultRenderingPipeline"
  58560. */
  58561. getClassName(): string;
  58562. /**
  58563. * Force the compilation of the entire pipeline.
  58564. */
  58565. prepare(): void;
  58566. private _hasCleared;
  58567. private _prevPostProcess;
  58568. private _prevPrevPostProcess;
  58569. private _setAutoClearAndTextureSharing;
  58570. private _depthOfFieldSceneObserver;
  58571. private _buildPipeline;
  58572. private _disposePostProcesses;
  58573. /**
  58574. * Adds a camera to the pipeline
  58575. * @param camera the camera to be added
  58576. */
  58577. addCamera(camera: Camera): void;
  58578. /**
  58579. * Removes a camera from the pipeline
  58580. * @param camera the camera to remove
  58581. */
  58582. removeCamera(camera: Camera): void;
  58583. /**
  58584. * Dispose of the pipeline and stop all post processes
  58585. */
  58586. dispose(): void;
  58587. /**
  58588. * Serialize the rendering pipeline (Used when exporting)
  58589. * @returns the serialized object
  58590. */
  58591. serialize(): any;
  58592. /**
  58593. * Parse the serialized pipeline
  58594. * @param source Source pipeline.
  58595. * @param scene The scene to load the pipeline to.
  58596. * @param rootUrl The URL of the serialized pipeline.
  58597. * @returns An instantiated pipeline from the serialized object.
  58598. */
  58599. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  58600. }
  58601. }
  58602. declare module BABYLON {
  58603. /** @hidden */
  58604. export var lensHighlightsPixelShader: {
  58605. name: string;
  58606. shader: string;
  58607. };
  58608. }
  58609. declare module BABYLON {
  58610. /** @hidden */
  58611. export var depthOfFieldPixelShader: {
  58612. name: string;
  58613. shader: string;
  58614. };
  58615. }
  58616. declare module BABYLON {
  58617. /**
  58618. * BABYLON.JS Chromatic Aberration GLSL Shader
  58619. * Author: Olivier Guyot
  58620. * Separates very slightly R, G and B colors on the edges of the screen
  58621. * Inspired by Francois Tarlier & Martins Upitis
  58622. */
  58623. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  58624. /**
  58625. * @ignore
  58626. * The chromatic aberration PostProcess id in the pipeline
  58627. */
  58628. LensChromaticAberrationEffect: string;
  58629. /**
  58630. * @ignore
  58631. * The highlights enhancing PostProcess id in the pipeline
  58632. */
  58633. HighlightsEnhancingEffect: string;
  58634. /**
  58635. * @ignore
  58636. * The depth-of-field PostProcess id in the pipeline
  58637. */
  58638. LensDepthOfFieldEffect: string;
  58639. private _scene;
  58640. private _depthTexture;
  58641. private _grainTexture;
  58642. private _chromaticAberrationPostProcess;
  58643. private _highlightsPostProcess;
  58644. private _depthOfFieldPostProcess;
  58645. private _edgeBlur;
  58646. private _grainAmount;
  58647. private _chromaticAberration;
  58648. private _distortion;
  58649. private _highlightsGain;
  58650. private _highlightsThreshold;
  58651. private _dofDistance;
  58652. private _dofAperture;
  58653. private _dofDarken;
  58654. private _dofPentagon;
  58655. private _blurNoise;
  58656. /**
  58657. * @constructor
  58658. *
  58659. * Effect parameters are as follow:
  58660. * {
  58661. * chromatic_aberration: number; // from 0 to x (1 for realism)
  58662. * edge_blur: number; // from 0 to x (1 for realism)
  58663. * distortion: number; // from 0 to x (1 for realism)
  58664. * grain_amount: number; // from 0 to 1
  58665. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  58666. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  58667. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  58668. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  58669. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  58670. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  58671. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  58672. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  58673. * }
  58674. * Note: if an effect parameter is unset, effect is disabled
  58675. *
  58676. * @param name The rendering pipeline name
  58677. * @param parameters - An object containing all parameters (see above)
  58678. * @param scene The scene linked to this pipeline
  58679. * @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)
  58680. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58681. */
  58682. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  58683. /**
  58684. * Get the class name
  58685. * @returns "LensRenderingPipeline"
  58686. */
  58687. getClassName(): string;
  58688. /**
  58689. * Gets associated scene
  58690. */
  58691. readonly scene: Scene;
  58692. /**
  58693. * Gets or sets the edge blur
  58694. */
  58695. edgeBlur: number;
  58696. /**
  58697. * Gets or sets the grain amount
  58698. */
  58699. grainAmount: number;
  58700. /**
  58701. * Gets or sets the chromatic aberration amount
  58702. */
  58703. chromaticAberration: number;
  58704. /**
  58705. * Gets or sets the depth of field aperture
  58706. */
  58707. dofAperture: number;
  58708. /**
  58709. * Gets or sets the edge distortion
  58710. */
  58711. edgeDistortion: number;
  58712. /**
  58713. * Gets or sets the depth of field distortion
  58714. */
  58715. dofDistortion: number;
  58716. /**
  58717. * Gets or sets the darken out of focus amount
  58718. */
  58719. darkenOutOfFocus: number;
  58720. /**
  58721. * Gets or sets a boolean indicating if blur noise is enabled
  58722. */
  58723. blurNoise: boolean;
  58724. /**
  58725. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  58726. */
  58727. pentagonBokeh: boolean;
  58728. /**
  58729. * Gets or sets the highlight grain amount
  58730. */
  58731. highlightsGain: number;
  58732. /**
  58733. * Gets or sets the highlight threshold
  58734. */
  58735. highlightsThreshold: number;
  58736. /**
  58737. * Sets the amount of blur at the edges
  58738. * @param amount blur amount
  58739. */
  58740. setEdgeBlur(amount: number): void;
  58741. /**
  58742. * Sets edge blur to 0
  58743. */
  58744. disableEdgeBlur(): void;
  58745. /**
  58746. * Sets the amout of grain
  58747. * @param amount Amount of grain
  58748. */
  58749. setGrainAmount(amount: number): void;
  58750. /**
  58751. * Set grain amount to 0
  58752. */
  58753. disableGrain(): void;
  58754. /**
  58755. * Sets the chromatic aberration amount
  58756. * @param amount amount of chromatic aberration
  58757. */
  58758. setChromaticAberration(amount: number): void;
  58759. /**
  58760. * Sets chromatic aberration amount to 0
  58761. */
  58762. disableChromaticAberration(): void;
  58763. /**
  58764. * Sets the EdgeDistortion amount
  58765. * @param amount amount of EdgeDistortion
  58766. */
  58767. setEdgeDistortion(amount: number): void;
  58768. /**
  58769. * Sets edge distortion to 0
  58770. */
  58771. disableEdgeDistortion(): void;
  58772. /**
  58773. * Sets the FocusDistance amount
  58774. * @param amount amount of FocusDistance
  58775. */
  58776. setFocusDistance(amount: number): void;
  58777. /**
  58778. * Disables depth of field
  58779. */
  58780. disableDepthOfField(): void;
  58781. /**
  58782. * Sets the Aperture amount
  58783. * @param amount amount of Aperture
  58784. */
  58785. setAperture(amount: number): void;
  58786. /**
  58787. * Sets the DarkenOutOfFocus amount
  58788. * @param amount amount of DarkenOutOfFocus
  58789. */
  58790. setDarkenOutOfFocus(amount: number): void;
  58791. private _pentagonBokehIsEnabled;
  58792. /**
  58793. * Creates a pentagon bokeh effect
  58794. */
  58795. enablePentagonBokeh(): void;
  58796. /**
  58797. * Disables the pentagon bokeh effect
  58798. */
  58799. disablePentagonBokeh(): void;
  58800. /**
  58801. * Enables noise blur
  58802. */
  58803. enableNoiseBlur(): void;
  58804. /**
  58805. * Disables noise blur
  58806. */
  58807. disableNoiseBlur(): void;
  58808. /**
  58809. * Sets the HighlightsGain amount
  58810. * @param amount amount of HighlightsGain
  58811. */
  58812. setHighlightsGain(amount: number): void;
  58813. /**
  58814. * Sets the HighlightsThreshold amount
  58815. * @param amount amount of HighlightsThreshold
  58816. */
  58817. setHighlightsThreshold(amount: number): void;
  58818. /**
  58819. * Disables highlights
  58820. */
  58821. disableHighlights(): void;
  58822. /**
  58823. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  58824. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  58825. */
  58826. dispose(disableDepthRender?: boolean): void;
  58827. private _createChromaticAberrationPostProcess;
  58828. private _createHighlightsPostProcess;
  58829. private _createDepthOfFieldPostProcess;
  58830. private _createGrainTexture;
  58831. }
  58832. }
  58833. declare module BABYLON {
  58834. /** @hidden */
  58835. export var ssao2PixelShader: {
  58836. name: string;
  58837. shader: string;
  58838. };
  58839. }
  58840. declare module BABYLON {
  58841. /** @hidden */
  58842. export var ssaoCombinePixelShader: {
  58843. name: string;
  58844. shader: string;
  58845. };
  58846. }
  58847. declare module BABYLON {
  58848. /**
  58849. * Render pipeline to produce ssao effect
  58850. */
  58851. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  58852. /**
  58853. * @ignore
  58854. * The PassPostProcess id in the pipeline that contains the original scene color
  58855. */
  58856. SSAOOriginalSceneColorEffect: string;
  58857. /**
  58858. * @ignore
  58859. * The SSAO PostProcess id in the pipeline
  58860. */
  58861. SSAORenderEffect: string;
  58862. /**
  58863. * @ignore
  58864. * The horizontal blur PostProcess id in the pipeline
  58865. */
  58866. SSAOBlurHRenderEffect: string;
  58867. /**
  58868. * @ignore
  58869. * The vertical blur PostProcess id in the pipeline
  58870. */
  58871. SSAOBlurVRenderEffect: string;
  58872. /**
  58873. * @ignore
  58874. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58875. */
  58876. SSAOCombineRenderEffect: string;
  58877. /**
  58878. * The output strength of the SSAO post-process. Default value is 1.0.
  58879. */
  58880. totalStrength: number;
  58881. /**
  58882. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  58883. */
  58884. maxZ: number;
  58885. /**
  58886. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  58887. */
  58888. minZAspect: number;
  58889. private _samples;
  58890. /**
  58891. * Number of samples used for the SSAO calculations. Default value is 8
  58892. */
  58893. samples: number;
  58894. private _textureSamples;
  58895. /**
  58896. * Number of samples to use for antialiasing
  58897. */
  58898. textureSamples: number;
  58899. /**
  58900. * Ratio object used for SSAO ratio and blur ratio
  58901. */
  58902. private _ratio;
  58903. /**
  58904. * Dynamically generated sphere sampler.
  58905. */
  58906. private _sampleSphere;
  58907. /**
  58908. * Blur filter offsets
  58909. */
  58910. private _samplerOffsets;
  58911. private _expensiveBlur;
  58912. /**
  58913. * If bilateral blur should be used
  58914. */
  58915. expensiveBlur: boolean;
  58916. /**
  58917. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  58918. */
  58919. radius: number;
  58920. /**
  58921. * The base color of the SSAO post-process
  58922. * The final result is "base + ssao" between [0, 1]
  58923. */
  58924. base: number;
  58925. /**
  58926. * Support test.
  58927. */
  58928. static readonly IsSupported: boolean;
  58929. private _scene;
  58930. private _depthTexture;
  58931. private _normalTexture;
  58932. private _randomTexture;
  58933. private _originalColorPostProcess;
  58934. private _ssaoPostProcess;
  58935. private _blurHPostProcess;
  58936. private _blurVPostProcess;
  58937. private _ssaoCombinePostProcess;
  58938. private _firstUpdate;
  58939. /**
  58940. * Gets active scene
  58941. */
  58942. readonly scene: Scene;
  58943. /**
  58944. * @constructor
  58945. * @param name The rendering pipeline name
  58946. * @param scene The scene linked to this pipeline
  58947. * @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 }
  58948. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58949. */
  58950. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  58951. /**
  58952. * Get the class name
  58953. * @returns "SSAO2RenderingPipeline"
  58954. */
  58955. getClassName(): string;
  58956. /**
  58957. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  58958. */
  58959. dispose(disableGeometryBufferRenderer?: boolean): void;
  58960. private _createBlurPostProcess;
  58961. /** @hidden */ private _rebuild(): void;
  58962. private _bits;
  58963. private _radicalInverse_VdC;
  58964. private _hammersley;
  58965. private _hemisphereSample_uniform;
  58966. private _generateHemisphere;
  58967. private _createSSAOPostProcess;
  58968. private _createSSAOCombinePostProcess;
  58969. private _createRandomTexture;
  58970. /**
  58971. * Serialize the rendering pipeline (Used when exporting)
  58972. * @returns the serialized object
  58973. */
  58974. serialize(): any;
  58975. /**
  58976. * Parse the serialized pipeline
  58977. * @param source Source pipeline.
  58978. * @param scene The scene to load the pipeline to.
  58979. * @param rootUrl The URL of the serialized pipeline.
  58980. * @returns An instantiated pipeline from the serialized object.
  58981. */
  58982. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  58983. }
  58984. }
  58985. declare module BABYLON {
  58986. /** @hidden */
  58987. export var ssaoPixelShader: {
  58988. name: string;
  58989. shader: string;
  58990. };
  58991. }
  58992. declare module BABYLON {
  58993. /**
  58994. * Render pipeline to produce ssao effect
  58995. */
  58996. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  58997. /**
  58998. * @ignore
  58999. * The PassPostProcess id in the pipeline that contains the original scene color
  59000. */
  59001. SSAOOriginalSceneColorEffect: string;
  59002. /**
  59003. * @ignore
  59004. * The SSAO PostProcess id in the pipeline
  59005. */
  59006. SSAORenderEffect: string;
  59007. /**
  59008. * @ignore
  59009. * The horizontal blur PostProcess id in the pipeline
  59010. */
  59011. SSAOBlurHRenderEffect: string;
  59012. /**
  59013. * @ignore
  59014. * The vertical blur PostProcess id in the pipeline
  59015. */
  59016. SSAOBlurVRenderEffect: string;
  59017. /**
  59018. * @ignore
  59019. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59020. */
  59021. SSAOCombineRenderEffect: string;
  59022. /**
  59023. * The output strength of the SSAO post-process. Default value is 1.0.
  59024. */
  59025. totalStrength: number;
  59026. /**
  59027. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59028. */
  59029. radius: number;
  59030. /**
  59031. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59032. * Must not be equal to fallOff and superior to fallOff.
  59033. * Default value is 0.0075
  59034. */
  59035. area: number;
  59036. /**
  59037. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59038. * Must not be equal to area and inferior to area.
  59039. * Default value is 0.000001
  59040. */
  59041. fallOff: number;
  59042. /**
  59043. * The base color of the SSAO post-process
  59044. * The final result is "base + ssao" between [0, 1]
  59045. */
  59046. base: number;
  59047. private _scene;
  59048. private _depthTexture;
  59049. private _randomTexture;
  59050. private _originalColorPostProcess;
  59051. private _ssaoPostProcess;
  59052. private _blurHPostProcess;
  59053. private _blurVPostProcess;
  59054. private _ssaoCombinePostProcess;
  59055. private _firstUpdate;
  59056. /**
  59057. * Gets active scene
  59058. */
  59059. readonly scene: Scene;
  59060. /**
  59061. * @constructor
  59062. * @param name - The rendering pipeline name
  59063. * @param scene - The scene linked to this pipeline
  59064. * @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 }
  59065. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59066. */
  59067. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59068. /**
  59069. * Get the class name
  59070. * @returns "SSAORenderingPipeline"
  59071. */
  59072. getClassName(): string;
  59073. /**
  59074. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59075. */
  59076. dispose(disableDepthRender?: boolean): void;
  59077. private _createBlurPostProcess;
  59078. /** @hidden */ private _rebuild(): void;
  59079. private _createSSAOPostProcess;
  59080. private _createSSAOCombinePostProcess;
  59081. private _createRandomTexture;
  59082. }
  59083. }
  59084. declare module BABYLON {
  59085. /** @hidden */
  59086. export var standardPixelShader: {
  59087. name: string;
  59088. shader: string;
  59089. };
  59090. }
  59091. declare module BABYLON {
  59092. /**
  59093. * Standard rendering pipeline
  59094. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59095. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59096. */
  59097. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59098. /**
  59099. * Public members
  59100. */
  59101. /**
  59102. * Post-process which contains the original scene color before the pipeline applies all the effects
  59103. */
  59104. originalPostProcess: Nullable<PostProcess>;
  59105. /**
  59106. * Post-process used to down scale an image x4
  59107. */
  59108. downSampleX4PostProcess: Nullable<PostProcess>;
  59109. /**
  59110. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59111. */
  59112. brightPassPostProcess: Nullable<PostProcess>;
  59113. /**
  59114. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59115. */
  59116. blurHPostProcesses: PostProcess[];
  59117. /**
  59118. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59119. */
  59120. blurVPostProcesses: PostProcess[];
  59121. /**
  59122. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59123. */
  59124. textureAdderPostProcess: Nullable<PostProcess>;
  59125. /**
  59126. * Post-process used to create volumetric lighting effect
  59127. */
  59128. volumetricLightPostProcess: Nullable<PostProcess>;
  59129. /**
  59130. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59131. */
  59132. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59133. /**
  59134. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59135. */
  59136. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59137. /**
  59138. * Post-process used to merge the volumetric light effect and the real scene color
  59139. */
  59140. volumetricLightMergePostProces: Nullable<PostProcess>;
  59141. /**
  59142. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59143. */
  59144. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59145. /**
  59146. * Base post-process used to calculate the average luminance of the final image for HDR
  59147. */
  59148. luminancePostProcess: Nullable<PostProcess>;
  59149. /**
  59150. * Post-processes used to create down sample post-processes in order to get
  59151. * the average luminance of the final image for HDR
  59152. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59153. */
  59154. luminanceDownSamplePostProcesses: PostProcess[];
  59155. /**
  59156. * Post-process used to create a HDR effect (light adaptation)
  59157. */
  59158. hdrPostProcess: Nullable<PostProcess>;
  59159. /**
  59160. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59161. */
  59162. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59163. /**
  59164. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59165. */
  59166. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59167. /**
  59168. * Post-process used to merge the final HDR post-process and the real scene color
  59169. */
  59170. hdrFinalPostProcess: Nullable<PostProcess>;
  59171. /**
  59172. * Post-process used to create a lens flare effect
  59173. */
  59174. lensFlarePostProcess: Nullable<PostProcess>;
  59175. /**
  59176. * Post-process that merges the result of the lens flare post-process and the real scene color
  59177. */
  59178. lensFlareComposePostProcess: Nullable<PostProcess>;
  59179. /**
  59180. * Post-process used to create a motion blur effect
  59181. */
  59182. motionBlurPostProcess: Nullable<PostProcess>;
  59183. /**
  59184. * Post-process used to create a depth of field effect
  59185. */
  59186. depthOfFieldPostProcess: Nullable<PostProcess>;
  59187. /**
  59188. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59189. */
  59190. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59191. /**
  59192. * Represents the brightness threshold in order to configure the illuminated surfaces
  59193. */
  59194. brightThreshold: number;
  59195. /**
  59196. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59197. */
  59198. blurWidth: number;
  59199. /**
  59200. * Sets if the blur for highlighted surfaces must be only horizontal
  59201. */
  59202. horizontalBlur: boolean;
  59203. /**
  59204. * Gets the overall exposure used by the pipeline
  59205. */
  59206. /**
  59207. * Sets the overall exposure used by the pipeline
  59208. */
  59209. exposure: number;
  59210. /**
  59211. * Texture used typically to simulate "dirty" on camera lens
  59212. */
  59213. lensTexture: Nullable<Texture>;
  59214. /**
  59215. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59216. */
  59217. volumetricLightCoefficient: number;
  59218. /**
  59219. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59220. */
  59221. volumetricLightPower: number;
  59222. /**
  59223. * Used the set the blur intensity to smooth the volumetric lights
  59224. */
  59225. volumetricLightBlurScale: number;
  59226. /**
  59227. * Light (spot or directional) used to generate the volumetric lights rays
  59228. * The source light must have a shadow generate so the pipeline can get its
  59229. * depth map
  59230. */
  59231. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59232. /**
  59233. * For eye adaptation, represents the minimum luminance the eye can see
  59234. */
  59235. hdrMinimumLuminance: number;
  59236. /**
  59237. * For eye adaptation, represents the decrease luminance speed
  59238. */
  59239. hdrDecreaseRate: number;
  59240. /**
  59241. * For eye adaptation, represents the increase luminance speed
  59242. */
  59243. hdrIncreaseRate: number;
  59244. /**
  59245. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59246. */
  59247. /**
  59248. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59249. */
  59250. hdrAutoExposure: boolean;
  59251. /**
  59252. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59253. */
  59254. lensColorTexture: Nullable<Texture>;
  59255. /**
  59256. * The overall strengh for the lens flare effect
  59257. */
  59258. lensFlareStrength: number;
  59259. /**
  59260. * Dispersion coefficient for lens flare ghosts
  59261. */
  59262. lensFlareGhostDispersal: number;
  59263. /**
  59264. * Main lens flare halo width
  59265. */
  59266. lensFlareHaloWidth: number;
  59267. /**
  59268. * Based on the lens distortion effect, defines how much the lens flare result
  59269. * is distorted
  59270. */
  59271. lensFlareDistortionStrength: number;
  59272. /**
  59273. * Configures the blur intensity used for for lens flare (halo)
  59274. */
  59275. lensFlareBlurWidth: number;
  59276. /**
  59277. * Lens star texture must be used to simulate rays on the flares and is available
  59278. * in the documentation
  59279. */
  59280. lensStarTexture: Nullable<Texture>;
  59281. /**
  59282. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  59283. * flare effect by taking account of the dirt texture
  59284. */
  59285. lensFlareDirtTexture: Nullable<Texture>;
  59286. /**
  59287. * Represents the focal length for the depth of field effect
  59288. */
  59289. depthOfFieldDistance: number;
  59290. /**
  59291. * Represents the blur intensity for the blurred part of the depth of field effect
  59292. */
  59293. depthOfFieldBlurWidth: number;
  59294. /**
  59295. * Gets how much the image is blurred by the movement while using the motion blur post-process
  59296. */
  59297. /**
  59298. * Sets how much the image is blurred by the movement while using the motion blur post-process
  59299. */
  59300. motionStrength: number;
  59301. /**
  59302. * Gets wether or not the motion blur post-process is object based or screen based.
  59303. */
  59304. /**
  59305. * Sets wether or not the motion blur post-process should be object based or screen based
  59306. */
  59307. objectBasedMotionBlur: boolean;
  59308. /**
  59309. * List of animations for the pipeline (IAnimatable implementation)
  59310. */
  59311. animations: Animation[];
  59312. /**
  59313. * Private members
  59314. */
  59315. private _scene;
  59316. private _currentDepthOfFieldSource;
  59317. private _basePostProcess;
  59318. private _fixedExposure;
  59319. private _currentExposure;
  59320. private _hdrAutoExposure;
  59321. private _hdrCurrentLuminance;
  59322. private _motionStrength;
  59323. private _isObjectBasedMotionBlur;
  59324. private _floatTextureType;
  59325. private _camerasToBeAttached;
  59326. private _ratio;
  59327. private _bloomEnabled;
  59328. private _depthOfFieldEnabled;
  59329. private _vlsEnabled;
  59330. private _lensFlareEnabled;
  59331. private _hdrEnabled;
  59332. private _motionBlurEnabled;
  59333. private _fxaaEnabled;
  59334. private _motionBlurSamples;
  59335. private _volumetricLightStepsCount;
  59336. private _samples;
  59337. /**
  59338. * @ignore
  59339. * Specifies if the bloom pipeline is enabled
  59340. */
  59341. BloomEnabled: boolean;
  59342. /**
  59343. * @ignore
  59344. * Specifies if the depth of field pipeline is enabed
  59345. */
  59346. DepthOfFieldEnabled: boolean;
  59347. /**
  59348. * @ignore
  59349. * Specifies if the lens flare pipeline is enabed
  59350. */
  59351. LensFlareEnabled: boolean;
  59352. /**
  59353. * @ignore
  59354. * Specifies if the HDR pipeline is enabled
  59355. */
  59356. HDREnabled: boolean;
  59357. /**
  59358. * @ignore
  59359. * Specifies if the volumetric lights scattering effect is enabled
  59360. */
  59361. VLSEnabled: boolean;
  59362. /**
  59363. * @ignore
  59364. * Specifies if the motion blur effect is enabled
  59365. */
  59366. MotionBlurEnabled: boolean;
  59367. /**
  59368. * Specifies if anti-aliasing is enabled
  59369. */
  59370. fxaaEnabled: boolean;
  59371. /**
  59372. * Specifies the number of steps used to calculate the volumetric lights
  59373. * Typically in interval [50, 200]
  59374. */
  59375. volumetricLightStepsCount: number;
  59376. /**
  59377. * Specifies the number of samples used for the motion blur effect
  59378. * Typically in interval [16, 64]
  59379. */
  59380. motionBlurSamples: number;
  59381. /**
  59382. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59383. */
  59384. samples: number;
  59385. /**
  59386. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59387. * @constructor
  59388. * @param name The rendering pipeline name
  59389. * @param scene The scene linked to this pipeline
  59390. * @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)
  59391. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  59392. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59393. */
  59394. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  59395. private _buildPipeline;
  59396. private _createDownSampleX4PostProcess;
  59397. private _createBrightPassPostProcess;
  59398. private _createBlurPostProcesses;
  59399. private _createTextureAdderPostProcess;
  59400. private _createVolumetricLightPostProcess;
  59401. private _createLuminancePostProcesses;
  59402. private _createHdrPostProcess;
  59403. private _createLensFlarePostProcess;
  59404. private _createDepthOfFieldPostProcess;
  59405. private _createMotionBlurPostProcess;
  59406. private _getDepthTexture;
  59407. private _disposePostProcesses;
  59408. /**
  59409. * Dispose of the pipeline and stop all post processes
  59410. */
  59411. dispose(): void;
  59412. /**
  59413. * Serialize the rendering pipeline (Used when exporting)
  59414. * @returns the serialized object
  59415. */
  59416. serialize(): any;
  59417. /**
  59418. * Parse the serialized pipeline
  59419. * @param source Source pipeline.
  59420. * @param scene The scene to load the pipeline to.
  59421. * @param rootUrl The URL of the serialized pipeline.
  59422. * @returns An instantiated pipeline from the serialized object.
  59423. */
  59424. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  59425. /**
  59426. * Luminance steps
  59427. */
  59428. static LuminanceSteps: number;
  59429. }
  59430. }
  59431. declare module BABYLON {
  59432. /** @hidden */
  59433. export var tonemapPixelShader: {
  59434. name: string;
  59435. shader: string;
  59436. };
  59437. }
  59438. declare module BABYLON {
  59439. /** Defines operator used for tonemapping */
  59440. export enum TonemappingOperator {
  59441. /** Hable */
  59442. Hable = 0,
  59443. /** Reinhard */
  59444. Reinhard = 1,
  59445. /** HejiDawson */
  59446. HejiDawson = 2,
  59447. /** Photographic */
  59448. Photographic = 3
  59449. }
  59450. /**
  59451. * Defines a post process to apply tone mapping
  59452. */
  59453. export class TonemapPostProcess extends PostProcess {
  59454. private _operator;
  59455. /** Defines the required exposure adjustement */
  59456. exposureAdjustment: number;
  59457. /**
  59458. * Creates a new TonemapPostProcess
  59459. * @param name defines the name of the postprocess
  59460. * @param _operator defines the operator to use
  59461. * @param exposureAdjustment defines the required exposure adjustement
  59462. * @param camera defines the camera to use (can be null)
  59463. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  59464. * @param engine defines the hosting engine (can be ignore if camera is set)
  59465. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59466. */
  59467. constructor(name: string, _operator: TonemappingOperator,
  59468. /** Defines the required exposure adjustement */
  59469. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  59470. }
  59471. }
  59472. declare module BABYLON {
  59473. /** @hidden */
  59474. export var depthVertexShader: {
  59475. name: string;
  59476. shader: string;
  59477. };
  59478. }
  59479. declare module BABYLON {
  59480. /** @hidden */
  59481. export var volumetricLightScatteringPixelShader: {
  59482. name: string;
  59483. shader: string;
  59484. };
  59485. }
  59486. declare module BABYLON {
  59487. /** @hidden */
  59488. export var volumetricLightScatteringPassVertexShader: {
  59489. name: string;
  59490. shader: string;
  59491. };
  59492. }
  59493. declare module BABYLON {
  59494. /** @hidden */
  59495. export var volumetricLightScatteringPassPixelShader: {
  59496. name: string;
  59497. shader: string;
  59498. };
  59499. }
  59500. declare module BABYLON {
  59501. /**
  59502. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  59503. */
  59504. export class VolumetricLightScatteringPostProcess extends PostProcess {
  59505. private _volumetricLightScatteringPass;
  59506. private _volumetricLightScatteringRTT;
  59507. private _viewPort;
  59508. private _screenCoordinates;
  59509. private _cachedDefines;
  59510. /**
  59511. * If not undefined, the mesh position is computed from the attached node position
  59512. */
  59513. attachedNode: {
  59514. position: Vector3;
  59515. };
  59516. /**
  59517. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  59518. */
  59519. customMeshPosition: Vector3;
  59520. /**
  59521. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  59522. */
  59523. useCustomMeshPosition: boolean;
  59524. /**
  59525. * If the post-process should inverse the light scattering direction
  59526. */
  59527. invert: boolean;
  59528. /**
  59529. * The internal mesh used by the post-process
  59530. */
  59531. mesh: Mesh;
  59532. /**
  59533. * @hidden
  59534. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  59535. */
  59536. useDiffuseColor: boolean;
  59537. /**
  59538. * Array containing the excluded meshes not rendered in the internal pass
  59539. */
  59540. excludedMeshes: AbstractMesh[];
  59541. /**
  59542. * Controls the overall intensity of the post-process
  59543. */
  59544. exposure: number;
  59545. /**
  59546. * Dissipates each sample's contribution in range [0, 1]
  59547. */
  59548. decay: number;
  59549. /**
  59550. * Controls the overall intensity of each sample
  59551. */
  59552. weight: number;
  59553. /**
  59554. * Controls the density of each sample
  59555. */
  59556. density: number;
  59557. /**
  59558. * @constructor
  59559. * @param name The post-process name
  59560. * @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)
  59561. * @param camera The camera that the post-process will be attached to
  59562. * @param mesh The mesh used to create the light scattering
  59563. * @param samples The post-process quality, default 100
  59564. * @param samplingModeThe post-process filtering mode
  59565. * @param engine The babylon engine
  59566. * @param reusable If the post-process is reusable
  59567. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  59568. */
  59569. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  59570. /**
  59571. * Returns the string "VolumetricLightScatteringPostProcess"
  59572. * @returns "VolumetricLightScatteringPostProcess"
  59573. */
  59574. getClassName(): string;
  59575. private _isReady;
  59576. /**
  59577. * Sets the new light position for light scattering effect
  59578. * @param position The new custom light position
  59579. */
  59580. setCustomMeshPosition(position: Vector3): void;
  59581. /**
  59582. * Returns the light position for light scattering effect
  59583. * @return Vector3 The custom light position
  59584. */
  59585. getCustomMeshPosition(): Vector3;
  59586. /**
  59587. * Disposes the internal assets and detaches the post-process from the camera
  59588. */
  59589. dispose(camera: Camera): void;
  59590. /**
  59591. * Returns the render target texture used by the post-process
  59592. * @return the render target texture used by the post-process
  59593. */
  59594. getPass(): RenderTargetTexture;
  59595. private _meshExcluded;
  59596. private _createPass;
  59597. private _updateMeshScreenCoordinates;
  59598. /**
  59599. * Creates a default mesh for the Volumeric Light Scattering post-process
  59600. * @param name The mesh name
  59601. * @param scene The scene where to create the mesh
  59602. * @return the default mesh
  59603. */
  59604. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  59605. }
  59606. }
  59607. declare module BABYLON {
  59608. interface Scene {
  59609. /** @hidden (Backing field) */ private _boundingBoxRenderer: BoundingBoxRenderer;
  59610. /** @hidden (Backing field) */ private _forceShowBoundingBoxes: boolean;
  59611. /**
  59612. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  59613. */
  59614. forceShowBoundingBoxes: boolean;
  59615. /**
  59616. * Gets the bounding box renderer associated with the scene
  59617. * @returns a BoundingBoxRenderer
  59618. */
  59619. getBoundingBoxRenderer(): BoundingBoxRenderer;
  59620. }
  59621. interface AbstractMesh {
  59622. /** @hidden (Backing field) */ private _showBoundingBox: boolean;
  59623. /**
  59624. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  59625. */
  59626. showBoundingBox: boolean;
  59627. }
  59628. /**
  59629. * Component responsible of rendering the bounding box of the meshes in a scene.
  59630. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  59631. */
  59632. export class BoundingBoxRenderer implements ISceneComponent {
  59633. /**
  59634. * The component name helpfull to identify the component in the list of scene components.
  59635. */
  59636. readonly name: string;
  59637. /**
  59638. * The scene the component belongs to.
  59639. */
  59640. scene: Scene;
  59641. /**
  59642. * Color of the bounding box lines placed in front of an object
  59643. */
  59644. frontColor: Color3;
  59645. /**
  59646. * Color of the bounding box lines placed behind an object
  59647. */
  59648. backColor: Color3;
  59649. /**
  59650. * Defines if the renderer should show the back lines or not
  59651. */
  59652. showBackLines: boolean;
  59653. /**
  59654. * @hidden
  59655. */
  59656. renderList: SmartArray<BoundingBox>;
  59657. private _colorShader;
  59658. private _vertexBuffers;
  59659. private _indexBuffer;
  59660. private _fillIndexBuffer;
  59661. private _fillIndexData;
  59662. /**
  59663. * Instantiates a new bounding box renderer in a scene.
  59664. * @param scene the scene the renderer renders in
  59665. */
  59666. constructor(scene: Scene);
  59667. /**
  59668. * Registers the component in a given scene
  59669. */
  59670. register(): void;
  59671. private _evaluateSubMesh;
  59672. private _activeMesh;
  59673. private _prepareRessources;
  59674. private _createIndexBuffer;
  59675. /**
  59676. * Rebuilds the elements related to this component in case of
  59677. * context lost for instance.
  59678. */
  59679. rebuild(): void;
  59680. /**
  59681. * @hidden
  59682. */
  59683. reset(): void;
  59684. /**
  59685. * Render the bounding boxes of a specific rendering group
  59686. * @param renderingGroupId defines the rendering group to render
  59687. */
  59688. render(renderingGroupId: number): void;
  59689. /**
  59690. * In case of occlusion queries, we can render the occlusion bounding box through this method
  59691. * @param mesh Define the mesh to render the occlusion bounding box for
  59692. */
  59693. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  59694. /**
  59695. * Dispose and release the resources attached to this renderer.
  59696. */
  59697. dispose(): void;
  59698. }
  59699. }
  59700. declare module BABYLON {
  59701. /** @hidden */
  59702. export var depthPixelShader: {
  59703. name: string;
  59704. shader: string;
  59705. };
  59706. }
  59707. declare module BABYLON {
  59708. /**
  59709. * This represents a depth renderer in Babylon.
  59710. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59711. */
  59712. export class DepthRenderer {
  59713. private _scene;
  59714. private _depthMap;
  59715. private _effect;
  59716. private readonly _storeNonLinearDepth;
  59717. private readonly _clearColor;
  59718. /** Get if the depth renderer is using packed depth or not */
  59719. readonly isPacked: boolean;
  59720. private _cachedDefines;
  59721. private _camera;
  59722. /**
  59723. * Specifiess that the depth renderer will only be used within
  59724. * the camera it is created for.
  59725. * This can help forcing its rendering during the camera processing.
  59726. */
  59727. useOnlyInActiveCamera: boolean;
  59728. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  59729. /**
  59730. * Instantiates a depth renderer
  59731. * @param scene The scene the renderer belongs to
  59732. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59733. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59734. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59735. */
  59736. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59737. /**
  59738. * Creates the depth rendering effect and checks if the effect is ready.
  59739. * @param subMesh The submesh to be used to render the depth map of
  59740. * @param useInstances If multiple world instances should be used
  59741. * @returns if the depth renderer is ready to render the depth map
  59742. */
  59743. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59744. /**
  59745. * Gets the texture which the depth map will be written to.
  59746. * @returns The depth map texture
  59747. */
  59748. getDepthMap(): RenderTargetTexture;
  59749. /**
  59750. * Disposes of the depth renderer.
  59751. */
  59752. dispose(): void;
  59753. }
  59754. }
  59755. declare module BABYLON {
  59756. interface Scene {
  59757. /** @hidden (Backing field) */ private _depthRenderer: {
  59758. [id: string]: DepthRenderer;
  59759. };
  59760. /**
  59761. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  59762. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  59763. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59764. * @returns the created depth renderer
  59765. */
  59766. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  59767. /**
  59768. * Disables a depth renderer for a given camera
  59769. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  59770. */
  59771. disableDepthRenderer(camera?: Nullable<Camera>): void;
  59772. }
  59773. /**
  59774. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  59775. * in several rendering techniques.
  59776. */
  59777. export class DepthRendererSceneComponent implements ISceneComponent {
  59778. /**
  59779. * The component name helpfull to identify the component in the list of scene components.
  59780. */
  59781. readonly name: string;
  59782. /**
  59783. * The scene the component belongs to.
  59784. */
  59785. scene: Scene;
  59786. /**
  59787. * Creates a new instance of the component for the given scene
  59788. * @param scene Defines the scene to register the component in
  59789. */
  59790. constructor(scene: Scene);
  59791. /**
  59792. * Registers the component in a given scene
  59793. */
  59794. register(): void;
  59795. /**
  59796. * Rebuilds the elements related to this component in case of
  59797. * context lost for instance.
  59798. */
  59799. rebuild(): void;
  59800. /**
  59801. * Disposes the component and the associated ressources
  59802. */
  59803. dispose(): void;
  59804. private _gatherRenderTargets;
  59805. private _gatherActiveCameraRenderTargets;
  59806. }
  59807. }
  59808. declare module BABYLON {
  59809. /** @hidden */
  59810. export var outlinePixelShader: {
  59811. name: string;
  59812. shader: string;
  59813. };
  59814. }
  59815. declare module BABYLON {
  59816. /** @hidden */
  59817. export var outlineVertexShader: {
  59818. name: string;
  59819. shader: string;
  59820. };
  59821. }
  59822. declare module BABYLON {
  59823. interface Scene {
  59824. /** @hidden */ private _outlineRenderer: OutlineRenderer;
  59825. /**
  59826. * Gets the outline renderer associated with the scene
  59827. * @returns a OutlineRenderer
  59828. */
  59829. getOutlineRenderer(): OutlineRenderer;
  59830. }
  59831. interface AbstractMesh {
  59832. /** @hidden (Backing field) */ private _renderOutline: boolean;
  59833. /**
  59834. * Gets or sets a boolean indicating if the outline must be rendered as well
  59835. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  59836. */
  59837. renderOutline: boolean;
  59838. /** @hidden (Backing field) */ private _renderOverlay: boolean;
  59839. /**
  59840. * Gets or sets a boolean indicating if the overlay must be rendered as well
  59841. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  59842. */
  59843. renderOverlay: boolean;
  59844. }
  59845. /**
  59846. * This class is responsible to draw bothe outline/overlay of meshes.
  59847. * It should not be used directly but through the available method on mesh.
  59848. */
  59849. export class OutlineRenderer implements ISceneComponent {
  59850. /**
  59851. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  59852. */
  59853. private static _StencilReference;
  59854. /**
  59855. * The name of the component. Each component must have a unique name.
  59856. */
  59857. name: string;
  59858. /**
  59859. * The scene the component belongs to.
  59860. */
  59861. scene: Scene;
  59862. /**
  59863. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  59864. */
  59865. zOffset: number;
  59866. private _engine;
  59867. private _effect;
  59868. private _cachedDefines;
  59869. private _savedDepthWrite;
  59870. /**
  59871. * Instantiates a new outline renderer. (There could be only one per scene).
  59872. * @param scene Defines the scene it belongs to
  59873. */
  59874. constructor(scene: Scene);
  59875. /**
  59876. * Register the component to one instance of a scene.
  59877. */
  59878. register(): void;
  59879. /**
  59880. * Rebuilds the elements related to this component in case of
  59881. * context lost for instance.
  59882. */
  59883. rebuild(): void;
  59884. /**
  59885. * Disposes the component and the associated ressources.
  59886. */
  59887. dispose(): void;
  59888. /**
  59889. * Renders the outline in the canvas.
  59890. * @param subMesh Defines the sumesh to render
  59891. * @param batch Defines the batch of meshes in case of instances
  59892. * @param useOverlay Defines if the rendering is for the overlay or the outline
  59893. */
  59894. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  59895. /**
  59896. * Returns whether or not the outline renderer is ready for a given submesh.
  59897. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  59898. * @param subMesh Defines the submesh to check readyness for
  59899. * @param useInstances Defines wheter wee are trying to render instances or not
  59900. * @returns true if ready otherwise false
  59901. */
  59902. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59903. private _beforeRenderingMesh;
  59904. private _afterRenderingMesh;
  59905. }
  59906. }
  59907. declare module BABYLON {
  59908. /**
  59909. * Class used to manage multiple sprites of different sizes on the same spritesheet
  59910. * @see http://doc.babylonjs.com/babylon101/sprites
  59911. */
  59912. export class SpritePackedManager extends SpriteManager {
  59913. /** defines the packed manager's name */
  59914. name: string;
  59915. /**
  59916. * Creates a new sprite manager from a packed sprite sheet
  59917. * @param name defines the manager's name
  59918. * @param imgUrl defines the sprite sheet url
  59919. * @param capacity defines the maximum allowed number of sprites
  59920. * @param scene defines the hosting scene
  59921. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  59922. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  59923. * @param samplingMode defines the smapling mode to use with spritesheet
  59924. * @param fromPacked set to true; do not alter
  59925. */
  59926. constructor(
  59927. /** defines the packed manager's name */
  59928. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  59929. }
  59930. }
  59931. declare module BABYLON {
  59932. /**
  59933. * Defines the list of states available for a task inside a AssetsManager
  59934. */
  59935. export enum AssetTaskState {
  59936. /**
  59937. * Initialization
  59938. */
  59939. INIT = 0,
  59940. /**
  59941. * Running
  59942. */
  59943. RUNNING = 1,
  59944. /**
  59945. * Done
  59946. */
  59947. DONE = 2,
  59948. /**
  59949. * Error
  59950. */
  59951. ERROR = 3
  59952. }
  59953. /**
  59954. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  59955. */
  59956. export abstract class AbstractAssetTask {
  59957. /**
  59958. * Task name
  59959. */ name: string;
  59960. /**
  59961. * Callback called when the task is successful
  59962. */
  59963. onSuccess: (task: any) => void;
  59964. /**
  59965. * Callback called when the task is not successful
  59966. */
  59967. onError: (task: any, message?: string, exception?: any) => void;
  59968. /**
  59969. * Creates a new AssetsManager
  59970. * @param name defines the name of the task
  59971. */
  59972. constructor(
  59973. /**
  59974. * Task name
  59975. */ name: string);
  59976. private _isCompleted;
  59977. private _taskState;
  59978. private _errorObject;
  59979. /**
  59980. * Get if the task is completed
  59981. */
  59982. readonly isCompleted: boolean;
  59983. /**
  59984. * Gets the current state of the task
  59985. */
  59986. readonly taskState: AssetTaskState;
  59987. /**
  59988. * Gets the current error object (if task is in error)
  59989. */
  59990. readonly errorObject: {
  59991. message?: string;
  59992. exception?: any;
  59993. };
  59994. /**
  59995. * Internal only
  59996. * @hidden
  59997. */ private _setErrorObject(message?: string, exception?: any): void;
  59998. /**
  59999. * Execute the current task
  60000. * @param scene defines the scene where you want your assets to be loaded
  60001. * @param onSuccess is a callback called when the task is successfully executed
  60002. * @param onError is a callback called if an error occurs
  60003. */
  60004. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60005. /**
  60006. * Execute the current task
  60007. * @param scene defines the scene where you want your assets to be loaded
  60008. * @param onSuccess is a callback called when the task is successfully executed
  60009. * @param onError is a callback called if an error occurs
  60010. */
  60011. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60012. /**
  60013. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60014. * This can be used with failed tasks that have the reason for failure fixed.
  60015. */
  60016. reset(): void;
  60017. private onErrorCallback;
  60018. private onDoneCallback;
  60019. }
  60020. /**
  60021. * Define the interface used by progress events raised during assets loading
  60022. */
  60023. export interface IAssetsProgressEvent {
  60024. /**
  60025. * Defines the number of remaining tasks to process
  60026. */
  60027. remainingCount: number;
  60028. /**
  60029. * Defines the total number of tasks
  60030. */
  60031. totalCount: number;
  60032. /**
  60033. * Defines the task that was just processed
  60034. */
  60035. task: AbstractAssetTask;
  60036. }
  60037. /**
  60038. * Class used to share progress information about assets loading
  60039. */
  60040. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60041. /**
  60042. * Defines the number of remaining tasks to process
  60043. */
  60044. remainingCount: number;
  60045. /**
  60046. * Defines the total number of tasks
  60047. */
  60048. totalCount: number;
  60049. /**
  60050. * Defines the task that was just processed
  60051. */
  60052. task: AbstractAssetTask;
  60053. /**
  60054. * Creates a AssetsProgressEvent
  60055. * @param remainingCount defines the number of remaining tasks to process
  60056. * @param totalCount defines the total number of tasks
  60057. * @param task defines the task that was just processed
  60058. */
  60059. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60060. }
  60061. /**
  60062. * Define a task used by AssetsManager to load meshes
  60063. */
  60064. export class MeshAssetTask extends AbstractAssetTask {
  60065. /**
  60066. * Defines the name of the task
  60067. */
  60068. name: string;
  60069. /**
  60070. * Defines the list of mesh's names you want to load
  60071. */
  60072. meshesNames: any;
  60073. /**
  60074. * Defines the root url to use as a base to load your meshes and associated resources
  60075. */
  60076. rootUrl: string;
  60077. /**
  60078. * Defines the filename of the scene to load from
  60079. */
  60080. sceneFilename: string;
  60081. /**
  60082. * Gets the list of loaded meshes
  60083. */
  60084. loadedMeshes: Array<AbstractMesh>;
  60085. /**
  60086. * Gets the list of loaded particle systems
  60087. */
  60088. loadedParticleSystems: Array<IParticleSystem>;
  60089. /**
  60090. * Gets the list of loaded skeletons
  60091. */
  60092. loadedSkeletons: Array<Skeleton>;
  60093. /**
  60094. * Gets the list of loaded animation groups
  60095. */
  60096. loadedAnimationGroups: Array<AnimationGroup>;
  60097. /**
  60098. * Callback called when the task is successful
  60099. */
  60100. onSuccess: (task: MeshAssetTask) => void;
  60101. /**
  60102. * Callback called when the task is successful
  60103. */
  60104. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60105. /**
  60106. * Creates a new MeshAssetTask
  60107. * @param name defines the name of the task
  60108. * @param meshesNames defines the list of mesh's names you want to load
  60109. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60110. * @param sceneFilename defines the filename of the scene to load from
  60111. */
  60112. constructor(
  60113. /**
  60114. * Defines the name of the task
  60115. */
  60116. name: string,
  60117. /**
  60118. * Defines the list of mesh's names you want to load
  60119. */
  60120. meshesNames: any,
  60121. /**
  60122. * Defines the root url to use as a base to load your meshes and associated resources
  60123. */
  60124. rootUrl: string,
  60125. /**
  60126. * Defines the filename of the scene to load from
  60127. */
  60128. sceneFilename: string);
  60129. /**
  60130. * Execute the current task
  60131. * @param scene defines the scene where you want your assets to be loaded
  60132. * @param onSuccess is a callback called when the task is successfully executed
  60133. * @param onError is a callback called if an error occurs
  60134. */
  60135. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60136. }
  60137. /**
  60138. * Define a task used by AssetsManager to load text content
  60139. */
  60140. export class TextFileAssetTask extends AbstractAssetTask {
  60141. /**
  60142. * Defines the name of the task
  60143. */
  60144. name: string;
  60145. /**
  60146. * Defines the location of the file to load
  60147. */
  60148. url: string;
  60149. /**
  60150. * Gets the loaded text string
  60151. */
  60152. text: string;
  60153. /**
  60154. * Callback called when the task is successful
  60155. */
  60156. onSuccess: (task: TextFileAssetTask) => void;
  60157. /**
  60158. * Callback called when the task is successful
  60159. */
  60160. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60161. /**
  60162. * Creates a new TextFileAssetTask object
  60163. * @param name defines the name of the task
  60164. * @param url defines the location of the file to load
  60165. */
  60166. constructor(
  60167. /**
  60168. * Defines the name of the task
  60169. */
  60170. name: string,
  60171. /**
  60172. * Defines the location of the file to load
  60173. */
  60174. url: string);
  60175. /**
  60176. * Execute the current task
  60177. * @param scene defines the scene where you want your assets to be loaded
  60178. * @param onSuccess is a callback called when the task is successfully executed
  60179. * @param onError is a callback called if an error occurs
  60180. */
  60181. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60182. }
  60183. /**
  60184. * Define a task used by AssetsManager to load binary data
  60185. */
  60186. export class BinaryFileAssetTask extends AbstractAssetTask {
  60187. /**
  60188. * Defines the name of the task
  60189. */
  60190. name: string;
  60191. /**
  60192. * Defines the location of the file to load
  60193. */
  60194. url: string;
  60195. /**
  60196. * Gets the lodaded data (as an array buffer)
  60197. */
  60198. data: ArrayBuffer;
  60199. /**
  60200. * Callback called when the task is successful
  60201. */
  60202. onSuccess: (task: BinaryFileAssetTask) => void;
  60203. /**
  60204. * Callback called when the task is successful
  60205. */
  60206. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  60207. /**
  60208. * Creates a new BinaryFileAssetTask object
  60209. * @param name defines the name of the new task
  60210. * @param url defines the location of the file to load
  60211. */
  60212. constructor(
  60213. /**
  60214. * Defines the name of the task
  60215. */
  60216. name: string,
  60217. /**
  60218. * Defines the location of the file to load
  60219. */
  60220. url: string);
  60221. /**
  60222. * Execute the current task
  60223. * @param scene defines the scene where you want your assets to be loaded
  60224. * @param onSuccess is a callback called when the task is successfully executed
  60225. * @param onError is a callback called if an error occurs
  60226. */
  60227. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60228. }
  60229. /**
  60230. * Define a task used by AssetsManager to load images
  60231. */
  60232. export class ImageAssetTask extends AbstractAssetTask {
  60233. /**
  60234. * Defines the name of the task
  60235. */
  60236. name: string;
  60237. /**
  60238. * Defines the location of the image to load
  60239. */
  60240. url: string;
  60241. /**
  60242. * Gets the loaded images
  60243. */
  60244. image: HTMLImageElement;
  60245. /**
  60246. * Callback called when the task is successful
  60247. */
  60248. onSuccess: (task: ImageAssetTask) => void;
  60249. /**
  60250. * Callback called when the task is successful
  60251. */
  60252. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  60253. /**
  60254. * Creates a new ImageAssetTask
  60255. * @param name defines the name of the task
  60256. * @param url defines the location of the image to load
  60257. */
  60258. constructor(
  60259. /**
  60260. * Defines the name of the task
  60261. */
  60262. name: string,
  60263. /**
  60264. * Defines the location of the image to load
  60265. */
  60266. url: string);
  60267. /**
  60268. * Execute the current task
  60269. * @param scene defines the scene where you want your assets to be loaded
  60270. * @param onSuccess is a callback called when the task is successfully executed
  60271. * @param onError is a callback called if an error occurs
  60272. */
  60273. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60274. }
  60275. /**
  60276. * Defines the interface used by texture loading tasks
  60277. */
  60278. export interface ITextureAssetTask<TEX extends BaseTexture> {
  60279. /**
  60280. * Gets the loaded texture
  60281. */
  60282. texture: TEX;
  60283. }
  60284. /**
  60285. * Define a task used by AssetsManager to load 2D textures
  60286. */
  60287. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  60288. /**
  60289. * Defines the name of the task
  60290. */
  60291. name: string;
  60292. /**
  60293. * Defines the location of the file to load
  60294. */
  60295. url: string;
  60296. /**
  60297. * Defines if mipmap should not be generated (default is false)
  60298. */
  60299. noMipmap?: boolean | undefined;
  60300. /**
  60301. * Defines if texture must be inverted on Y axis (default is false)
  60302. */
  60303. invertY?: boolean | undefined;
  60304. /**
  60305. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60306. */
  60307. samplingMode: number;
  60308. /**
  60309. * Gets the loaded texture
  60310. */
  60311. texture: Texture;
  60312. /**
  60313. * Callback called when the task is successful
  60314. */
  60315. onSuccess: (task: TextureAssetTask) => void;
  60316. /**
  60317. * Callback called when the task is successful
  60318. */
  60319. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  60320. /**
  60321. * Creates a new TextureAssetTask object
  60322. * @param name defines the name of the task
  60323. * @param url defines the location of the file to load
  60324. * @param noMipmap defines if mipmap should not be generated (default is false)
  60325. * @param invertY defines if texture must be inverted on Y axis (default is false)
  60326. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60327. */
  60328. constructor(
  60329. /**
  60330. * Defines the name of the task
  60331. */
  60332. name: string,
  60333. /**
  60334. * Defines the location of the file to load
  60335. */
  60336. url: string,
  60337. /**
  60338. * Defines if mipmap should not be generated (default is false)
  60339. */
  60340. noMipmap?: boolean | undefined,
  60341. /**
  60342. * Defines if texture must be inverted on Y axis (default is false)
  60343. */
  60344. invertY?: boolean | undefined,
  60345. /**
  60346. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60347. */
  60348. samplingMode?: number);
  60349. /**
  60350. * Execute the current task
  60351. * @param scene defines the scene where you want your assets to be loaded
  60352. * @param onSuccess is a callback called when the task is successfully executed
  60353. * @param onError is a callback called if an error occurs
  60354. */
  60355. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60356. }
  60357. /**
  60358. * Define a task used by AssetsManager to load cube textures
  60359. */
  60360. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  60361. /**
  60362. * Defines the name of the task
  60363. */
  60364. name: string;
  60365. /**
  60366. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60367. */
  60368. url: string;
  60369. /**
  60370. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60371. */
  60372. extensions?: string[] | undefined;
  60373. /**
  60374. * Defines if mipmaps should not be generated (default is false)
  60375. */
  60376. noMipmap?: boolean | undefined;
  60377. /**
  60378. * Defines the explicit list of files (undefined by default)
  60379. */
  60380. files?: string[] | undefined;
  60381. /**
  60382. * Gets the loaded texture
  60383. */
  60384. texture: CubeTexture;
  60385. /**
  60386. * Callback called when the task is successful
  60387. */
  60388. onSuccess: (task: CubeTextureAssetTask) => void;
  60389. /**
  60390. * Callback called when the task is successful
  60391. */
  60392. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  60393. /**
  60394. * Creates a new CubeTextureAssetTask
  60395. * @param name defines the name of the task
  60396. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60397. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60398. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60399. * @param files defines the explicit list of files (undefined by default)
  60400. */
  60401. constructor(
  60402. /**
  60403. * Defines the name of the task
  60404. */
  60405. name: string,
  60406. /**
  60407. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60408. */
  60409. url: string,
  60410. /**
  60411. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60412. */
  60413. extensions?: string[] | undefined,
  60414. /**
  60415. * Defines if mipmaps should not be generated (default is false)
  60416. */
  60417. noMipmap?: boolean | undefined,
  60418. /**
  60419. * Defines the explicit list of files (undefined by default)
  60420. */
  60421. files?: string[] | undefined);
  60422. /**
  60423. * Execute the current task
  60424. * @param scene defines the scene where you want your assets to be loaded
  60425. * @param onSuccess is a callback called when the task is successfully executed
  60426. * @param onError is a callback called if an error occurs
  60427. */
  60428. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60429. }
  60430. /**
  60431. * Define a task used by AssetsManager to load HDR cube textures
  60432. */
  60433. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  60434. /**
  60435. * Defines the name of the task
  60436. */
  60437. name: string;
  60438. /**
  60439. * Defines the location of the file to load
  60440. */
  60441. url: string;
  60442. /**
  60443. * Defines the desired size (the more it increases the longer the generation will be)
  60444. */
  60445. size: number;
  60446. /**
  60447. * Defines if mipmaps should not be generated (default is false)
  60448. */
  60449. noMipmap: boolean;
  60450. /**
  60451. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60452. */
  60453. generateHarmonics: boolean;
  60454. /**
  60455. * 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)
  60456. */
  60457. gammaSpace: boolean;
  60458. /**
  60459. * Internal Use Only
  60460. */
  60461. reserved: boolean;
  60462. /**
  60463. * Gets the loaded texture
  60464. */
  60465. texture: HDRCubeTexture;
  60466. /**
  60467. * Callback called when the task is successful
  60468. */
  60469. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  60470. /**
  60471. * Callback called when the task is successful
  60472. */
  60473. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  60474. /**
  60475. * Creates a new HDRCubeTextureAssetTask object
  60476. * @param name defines the name of the task
  60477. * @param url defines the location of the file to load
  60478. * @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.
  60479. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60480. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60481. * @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)
  60482. * @param reserved Internal use only
  60483. */
  60484. constructor(
  60485. /**
  60486. * Defines the name of the task
  60487. */
  60488. name: string,
  60489. /**
  60490. * Defines the location of the file to load
  60491. */
  60492. url: string,
  60493. /**
  60494. * Defines the desired size (the more it increases the longer the generation will be)
  60495. */
  60496. size: number,
  60497. /**
  60498. * Defines if mipmaps should not be generated (default is false)
  60499. */
  60500. noMipmap?: boolean,
  60501. /**
  60502. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60503. */
  60504. generateHarmonics?: boolean,
  60505. /**
  60506. * 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)
  60507. */
  60508. gammaSpace?: boolean,
  60509. /**
  60510. * Internal Use Only
  60511. */
  60512. reserved?: boolean);
  60513. /**
  60514. * Execute the current task
  60515. * @param scene defines the scene where you want your assets to be loaded
  60516. * @param onSuccess is a callback called when the task is successfully executed
  60517. * @param onError is a callback called if an error occurs
  60518. */
  60519. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60520. }
  60521. /**
  60522. * Define a task used by AssetsManager to load Equirectangular cube textures
  60523. */
  60524. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  60525. /**
  60526. * Defines the name of the task
  60527. */
  60528. name: string;
  60529. /**
  60530. * Defines the location of the file to load
  60531. */
  60532. url: string;
  60533. /**
  60534. * Defines the desired size (the more it increases the longer the generation will be)
  60535. */
  60536. size: number;
  60537. /**
  60538. * Defines if mipmaps should not be generated (default is false)
  60539. */
  60540. noMipmap: boolean;
  60541. /**
  60542. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60543. * but the standard material would require them in Gamma space) (default is true)
  60544. */
  60545. gammaSpace: boolean;
  60546. /**
  60547. * Gets the loaded texture
  60548. */
  60549. texture: EquiRectangularCubeTexture;
  60550. /**
  60551. * Callback called when the task is successful
  60552. */
  60553. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  60554. /**
  60555. * Callback called when the task is successful
  60556. */
  60557. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  60558. /**
  60559. * Creates a new EquiRectangularCubeTextureAssetTask object
  60560. * @param name defines the name of the task
  60561. * @param url defines the location of the file to load
  60562. * @param size defines the desired size (the more it increases the longer the generation will be)
  60563. * If the size is omitted this implies you are using a preprocessed cubemap.
  60564. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60565. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  60566. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  60567. * (default is true)
  60568. */
  60569. constructor(
  60570. /**
  60571. * Defines the name of the task
  60572. */
  60573. name: string,
  60574. /**
  60575. * Defines the location of the file to load
  60576. */
  60577. url: string,
  60578. /**
  60579. * Defines the desired size (the more it increases the longer the generation will be)
  60580. */
  60581. size: number,
  60582. /**
  60583. * Defines if mipmaps should not be generated (default is false)
  60584. */
  60585. noMipmap?: boolean,
  60586. /**
  60587. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60588. * but the standard material would require them in Gamma space) (default is true)
  60589. */
  60590. gammaSpace?: boolean);
  60591. /**
  60592. * Execute the current task
  60593. * @param scene defines the scene where you want your assets to be loaded
  60594. * @param onSuccess is a callback called when the task is successfully executed
  60595. * @param onError is a callback called if an error occurs
  60596. */
  60597. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60598. }
  60599. /**
  60600. * This class can be used to easily import assets into a scene
  60601. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  60602. */
  60603. export class AssetsManager {
  60604. private _scene;
  60605. private _isLoading;
  60606. protected _tasks: AbstractAssetTask[];
  60607. protected _waitingTasksCount: number;
  60608. protected _totalTasksCount: number;
  60609. /**
  60610. * Callback called when all tasks are processed
  60611. */
  60612. onFinish: (tasks: AbstractAssetTask[]) => void;
  60613. /**
  60614. * Callback called when a task is successful
  60615. */
  60616. onTaskSuccess: (task: AbstractAssetTask) => void;
  60617. /**
  60618. * Callback called when a task had an error
  60619. */
  60620. onTaskError: (task: AbstractAssetTask) => void;
  60621. /**
  60622. * Callback called when a task is done (whatever the result is)
  60623. */
  60624. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  60625. /**
  60626. * Observable called when all tasks are processed
  60627. */
  60628. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  60629. /**
  60630. * Observable called when a task had an error
  60631. */
  60632. onTaskErrorObservable: Observable<AbstractAssetTask>;
  60633. /**
  60634. * Observable called when all tasks were executed
  60635. */
  60636. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  60637. /**
  60638. * Observable called when a task is done (whatever the result is)
  60639. */
  60640. onProgressObservable: Observable<IAssetsProgressEvent>;
  60641. /**
  60642. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  60643. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  60644. */
  60645. useDefaultLoadingScreen: boolean;
  60646. /**
  60647. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  60648. * when all assets have been downloaded.
  60649. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  60650. */
  60651. autoHideLoadingUI: boolean;
  60652. /**
  60653. * Creates a new AssetsManager
  60654. * @param scene defines the scene to work on
  60655. */
  60656. constructor(scene: Scene);
  60657. /**
  60658. * Add a MeshAssetTask to the list of active tasks
  60659. * @param taskName defines the name of the new task
  60660. * @param meshesNames defines the name of meshes to load
  60661. * @param rootUrl defines the root url to use to locate files
  60662. * @param sceneFilename defines the filename of the scene file
  60663. * @returns a new MeshAssetTask object
  60664. */
  60665. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  60666. /**
  60667. * Add a TextFileAssetTask to the list of active tasks
  60668. * @param taskName defines the name of the new task
  60669. * @param url defines the url of the file to load
  60670. * @returns a new TextFileAssetTask object
  60671. */
  60672. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  60673. /**
  60674. * Add a BinaryFileAssetTask to the list of active tasks
  60675. * @param taskName defines the name of the new task
  60676. * @param url defines the url of the file to load
  60677. * @returns a new BinaryFileAssetTask object
  60678. */
  60679. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  60680. /**
  60681. * Add a ImageAssetTask to the list of active tasks
  60682. * @param taskName defines the name of the new task
  60683. * @param url defines the url of the file to load
  60684. * @returns a new ImageAssetTask object
  60685. */
  60686. addImageTask(taskName: string, url: string): ImageAssetTask;
  60687. /**
  60688. * Add a TextureAssetTask to the list of active tasks
  60689. * @param taskName defines the name of the new task
  60690. * @param url defines the url of the file to load
  60691. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60692. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  60693. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60694. * @returns a new TextureAssetTask object
  60695. */
  60696. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  60697. /**
  60698. * Add a CubeTextureAssetTask to the list of active tasks
  60699. * @param taskName defines the name of the new task
  60700. * @param url defines the url of the file to load
  60701. * @param extensions defines the extension to use to load the cube map (can be null)
  60702. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60703. * @param files defines the list of files to load (can be null)
  60704. * @returns a new CubeTextureAssetTask object
  60705. */
  60706. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  60707. /**
  60708. *
  60709. * Add a HDRCubeTextureAssetTask to the list of active tasks
  60710. * @param taskName defines the name of the new task
  60711. * @param url defines the url of the file to load
  60712. * @param size defines the size you want for the cubemap (can be null)
  60713. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60714. * @param generateHarmonics defines if you want to automatically generate (true by default)
  60715. * @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)
  60716. * @param reserved Internal use only
  60717. * @returns a new HDRCubeTextureAssetTask object
  60718. */
  60719. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  60720. /**
  60721. *
  60722. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  60723. * @param taskName defines the name of the new task
  60724. * @param url defines the url of the file to load
  60725. * @param size defines the size you want for the cubemap (can be null)
  60726. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60727. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60728. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60729. * @returns a new EquiRectangularCubeTextureAssetTask object
  60730. */
  60731. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  60732. /**
  60733. * Remove a task from the assets manager.
  60734. * @param task the task to remove
  60735. */
  60736. removeTask(task: AbstractAssetTask): void;
  60737. private _decreaseWaitingTasksCount;
  60738. private _runTask;
  60739. /**
  60740. * Reset the AssetsManager and remove all tasks
  60741. * @return the current instance of the AssetsManager
  60742. */
  60743. reset(): AssetsManager;
  60744. /**
  60745. * Start the loading process
  60746. * @return the current instance of the AssetsManager
  60747. */
  60748. load(): AssetsManager;
  60749. /**
  60750. * Start the loading process as an async operation
  60751. * @return a promise returning the list of failed tasks
  60752. */
  60753. loadAsync(): Promise<void>;
  60754. }
  60755. }
  60756. declare module BABYLON {
  60757. /**
  60758. * Wrapper class for promise with external resolve and reject.
  60759. */
  60760. export class Deferred<T> {
  60761. /**
  60762. * The promise associated with this deferred object.
  60763. */
  60764. readonly promise: Promise<T>;
  60765. private _resolve;
  60766. private _reject;
  60767. /**
  60768. * The resolve method of the promise associated with this deferred object.
  60769. */
  60770. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  60771. /**
  60772. * The reject method of the promise associated with this deferred object.
  60773. */
  60774. readonly reject: (reason?: any) => void;
  60775. /**
  60776. * Constructor for this deferred object.
  60777. */
  60778. constructor();
  60779. }
  60780. }
  60781. declare module BABYLON {
  60782. /**
  60783. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  60784. */
  60785. export class MeshExploder {
  60786. private _centerMesh;
  60787. private _meshes;
  60788. private _meshesOrigins;
  60789. private _toCenterVectors;
  60790. private _scaledDirection;
  60791. private _newPosition;
  60792. private _centerPosition;
  60793. /**
  60794. * Explodes meshes from a center mesh.
  60795. * @param meshes The meshes to explode.
  60796. * @param centerMesh The mesh to be center of explosion.
  60797. */
  60798. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  60799. private _setCenterMesh;
  60800. /**
  60801. * Get class name
  60802. * @returns "MeshExploder"
  60803. */
  60804. getClassName(): string;
  60805. /**
  60806. * "Exploded meshes"
  60807. * @returns Array of meshes with the centerMesh at index 0.
  60808. */
  60809. getMeshes(): Array<Mesh>;
  60810. /**
  60811. * Explodes meshes giving a specific direction
  60812. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  60813. */
  60814. explode(direction?: number): void;
  60815. }
  60816. }
  60817. declare module BABYLON {
  60818. /**
  60819. * Class used to help managing file picking and drag'n'drop
  60820. */
  60821. export class FilesInput {
  60822. /**
  60823. * List of files ready to be loaded
  60824. */
  60825. static readonly FilesToLoad: {
  60826. [key: string]: File;
  60827. };
  60828. /**
  60829. * Callback called when a file is processed
  60830. */
  60831. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  60832. private _engine;
  60833. private _currentScene;
  60834. private _sceneLoadedCallback;
  60835. private _progressCallback;
  60836. private _additionalRenderLoopLogicCallback;
  60837. private _textureLoadingCallback;
  60838. private _startingProcessingFilesCallback;
  60839. private _onReloadCallback;
  60840. private _errorCallback;
  60841. private _elementToMonitor;
  60842. private _sceneFileToLoad;
  60843. private _filesToLoad;
  60844. /**
  60845. * Creates a new FilesInput
  60846. * @param engine defines the rendering engine
  60847. * @param scene defines the hosting scene
  60848. * @param sceneLoadedCallback callback called when scene is loaded
  60849. * @param progressCallback callback called to track progress
  60850. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  60851. * @param textureLoadingCallback callback called when a texture is loading
  60852. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  60853. * @param onReloadCallback callback called when a reload is requested
  60854. * @param errorCallback callback call if an error occurs
  60855. */
  60856. 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);
  60857. private _dragEnterHandler;
  60858. private _dragOverHandler;
  60859. private _dropHandler;
  60860. /**
  60861. * Calls this function to listen to drag'n'drop events on a specific DOM element
  60862. * @param elementToMonitor defines the DOM element to track
  60863. */
  60864. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  60865. /**
  60866. * Release all associated resources
  60867. */
  60868. dispose(): void;
  60869. private renderFunction;
  60870. private drag;
  60871. private drop;
  60872. private _traverseFolder;
  60873. private _processFiles;
  60874. /**
  60875. * Load files from a drop event
  60876. * @param event defines the drop event to use as source
  60877. */
  60878. loadFiles(event: any): void;
  60879. private _processReload;
  60880. /**
  60881. * Reload the current scene from the loaded files
  60882. */
  60883. reload(): void;
  60884. }
  60885. }
  60886. declare module BABYLON {
  60887. /**
  60888. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  60889. */
  60890. export class PerformanceMonitor implements IPerformanceMonitor {
  60891. private _enabled;
  60892. private _rollingFrameTime;
  60893. private _lastFrameTimeMs;
  60894. /**
  60895. * constructor
  60896. * @param frameSampleSize The number of samples required to saturate the sliding window
  60897. */
  60898. constructor(frameSampleSize?: number);
  60899. /**
  60900. * Samples current frame
  60901. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  60902. */
  60903. sampleFrame(timeMs?: number): void;
  60904. /**
  60905. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  60906. */
  60907. readonly averageFrameTime: number;
  60908. /**
  60909. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  60910. */
  60911. readonly averageFrameTimeVariance: number;
  60912. /**
  60913. * Returns the frame time of the most recent frame
  60914. */
  60915. readonly instantaneousFrameTime: number;
  60916. /**
  60917. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  60918. */
  60919. readonly averageFPS: number;
  60920. /**
  60921. * Returns the average framerate in frames per second using the most recent frame time
  60922. */
  60923. readonly instantaneousFPS: number;
  60924. /**
  60925. * Returns true if enough samples have been taken to completely fill the sliding window
  60926. */
  60927. readonly isSaturated: boolean;
  60928. /**
  60929. * Enables contributions to the sliding window sample set
  60930. */
  60931. enable(): void;
  60932. /**
  60933. * Disables contributions to the sliding window sample set
  60934. * Samples will not be interpolated over the disabled period
  60935. */
  60936. disable(): void;
  60937. /**
  60938. * Returns true if sampling is enabled
  60939. */
  60940. readonly isEnabled: boolean;
  60941. /**
  60942. * Resets performance monitor
  60943. */
  60944. reset(): void;
  60945. }
  60946. /**
  60947. * RollingAverage
  60948. *
  60949. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  60950. */
  60951. export class RollingAverage {
  60952. /**
  60953. * Current average
  60954. */
  60955. average: number;
  60956. /**
  60957. * Current variance
  60958. */
  60959. variance: number;
  60960. protected _samples: Array<number>;
  60961. protected _sampleCount: number;
  60962. protected _pos: number;
  60963. protected _m2: number;
  60964. /**
  60965. * constructor
  60966. * @param length The number of samples required to saturate the sliding window
  60967. */
  60968. constructor(length: number);
  60969. /**
  60970. * Adds a sample to the sample set
  60971. * @param v The sample value
  60972. */
  60973. add(v: number): void;
  60974. /**
  60975. * Returns previously added values or null if outside of history or outside the sliding window domain
  60976. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  60977. * @return Value previously recorded with add() or null if outside of range
  60978. */
  60979. history(i: number): number;
  60980. /**
  60981. * Returns true if enough samples have been taken to completely fill the sliding window
  60982. * @return true if sample-set saturated
  60983. */
  60984. isSaturated(): boolean;
  60985. /**
  60986. * Resets the rolling average (equivalent to 0 samples taken so far)
  60987. */
  60988. reset(): void;
  60989. /**
  60990. * Wraps a value around the sample range boundaries
  60991. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  60992. * @return Wrapped position in sample range
  60993. */
  60994. protected _wrapPosition(i: number): number;
  60995. }
  60996. }
  60997. declare module BABYLON {
  60998. /**
  60999. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61000. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61001. */
  61002. export class SceneOptimization {
  61003. /**
  61004. * Defines the priority of this optimization (0 by default which means first in the list)
  61005. */
  61006. priority: number;
  61007. /**
  61008. * Gets a string describing the action executed by the current optimization
  61009. * @returns description string
  61010. */
  61011. getDescription(): string;
  61012. /**
  61013. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61014. * @param scene defines the current scene where to apply this optimization
  61015. * @param optimizer defines the current optimizer
  61016. * @returns true if everything that can be done was applied
  61017. */
  61018. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61019. /**
  61020. * Creates the SceneOptimization object
  61021. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61022. * @param desc defines the description associated with the optimization
  61023. */
  61024. constructor(
  61025. /**
  61026. * Defines the priority of this optimization (0 by default which means first in the list)
  61027. */
  61028. priority?: number);
  61029. }
  61030. /**
  61031. * Defines an optimization used to reduce the size of render target textures
  61032. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61033. */
  61034. export class TextureOptimization extends SceneOptimization {
  61035. /**
  61036. * Defines the priority of this optimization (0 by default which means first in the list)
  61037. */
  61038. priority: number;
  61039. /**
  61040. * 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
  61041. */
  61042. maximumSize: number;
  61043. /**
  61044. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61045. */
  61046. step: number;
  61047. /**
  61048. * Gets a string describing the action executed by the current optimization
  61049. * @returns description string
  61050. */
  61051. getDescription(): string;
  61052. /**
  61053. * Creates the TextureOptimization object
  61054. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61055. * @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
  61056. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61057. */
  61058. constructor(
  61059. /**
  61060. * Defines the priority of this optimization (0 by default which means first in the list)
  61061. */
  61062. priority?: number,
  61063. /**
  61064. * 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
  61065. */
  61066. maximumSize?: number,
  61067. /**
  61068. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61069. */
  61070. step?: number);
  61071. /**
  61072. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61073. * @param scene defines the current scene where to apply this optimization
  61074. * @param optimizer defines the current optimizer
  61075. * @returns true if everything that can be done was applied
  61076. */
  61077. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61078. }
  61079. /**
  61080. * Defines an optimization used to increase or decrease the rendering resolution
  61081. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61082. */
  61083. export class HardwareScalingOptimization extends SceneOptimization {
  61084. /**
  61085. * Defines the priority of this optimization (0 by default which means first in the list)
  61086. */
  61087. priority: number;
  61088. /**
  61089. * Defines the maximum scale to use (2 by default)
  61090. */
  61091. maximumScale: number;
  61092. /**
  61093. * Defines the step to use between two passes (0.5 by default)
  61094. */
  61095. step: number;
  61096. private _currentScale;
  61097. private _directionOffset;
  61098. /**
  61099. * Gets a string describing the action executed by the current optimization
  61100. * @return description string
  61101. */
  61102. getDescription(): string;
  61103. /**
  61104. * Creates the HardwareScalingOptimization object
  61105. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61106. * @param maximumScale defines the maximum scale to use (2 by default)
  61107. * @param step defines the step to use between two passes (0.5 by default)
  61108. */
  61109. constructor(
  61110. /**
  61111. * Defines the priority of this optimization (0 by default which means first in the list)
  61112. */
  61113. priority?: number,
  61114. /**
  61115. * Defines the maximum scale to use (2 by default)
  61116. */
  61117. maximumScale?: number,
  61118. /**
  61119. * Defines the step to use between two passes (0.5 by default)
  61120. */
  61121. step?: number);
  61122. /**
  61123. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61124. * @param scene defines the current scene where to apply this optimization
  61125. * @param optimizer defines the current optimizer
  61126. * @returns true if everything that can be done was applied
  61127. */
  61128. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61129. }
  61130. /**
  61131. * Defines an optimization used to remove shadows
  61132. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61133. */
  61134. export class ShadowsOptimization extends SceneOptimization {
  61135. /**
  61136. * Gets a string describing the action executed by the current optimization
  61137. * @return description string
  61138. */
  61139. getDescription(): string;
  61140. /**
  61141. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61142. * @param scene defines the current scene where to apply this optimization
  61143. * @param optimizer defines the current optimizer
  61144. * @returns true if everything that can be done was applied
  61145. */
  61146. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61147. }
  61148. /**
  61149. * Defines an optimization used to turn post-processes off
  61150. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61151. */
  61152. export class PostProcessesOptimization extends SceneOptimization {
  61153. /**
  61154. * Gets a string describing the action executed by the current optimization
  61155. * @return description string
  61156. */
  61157. getDescription(): string;
  61158. /**
  61159. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61160. * @param scene defines the current scene where to apply this optimization
  61161. * @param optimizer defines the current optimizer
  61162. * @returns true if everything that can be done was applied
  61163. */
  61164. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61165. }
  61166. /**
  61167. * Defines an optimization used to turn lens flares off
  61168. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61169. */
  61170. export class LensFlaresOptimization extends SceneOptimization {
  61171. /**
  61172. * Gets a string describing the action executed by the current optimization
  61173. * @return description string
  61174. */
  61175. getDescription(): string;
  61176. /**
  61177. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61178. * @param scene defines the current scene where to apply this optimization
  61179. * @param optimizer defines the current optimizer
  61180. * @returns true if everything that can be done was applied
  61181. */
  61182. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61183. }
  61184. /**
  61185. * Defines an optimization based on user defined callback.
  61186. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61187. */
  61188. export class CustomOptimization extends SceneOptimization {
  61189. /**
  61190. * Callback called to apply the custom optimization.
  61191. */
  61192. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61193. /**
  61194. * Callback called to get custom description
  61195. */
  61196. onGetDescription: () => string;
  61197. /**
  61198. * Gets a string describing the action executed by the current optimization
  61199. * @returns description string
  61200. */
  61201. getDescription(): string;
  61202. /**
  61203. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61204. * @param scene defines the current scene where to apply this optimization
  61205. * @param optimizer defines the current optimizer
  61206. * @returns true if everything that can be done was applied
  61207. */
  61208. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61209. }
  61210. /**
  61211. * Defines an optimization used to turn particles off
  61212. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61213. */
  61214. export class ParticlesOptimization extends SceneOptimization {
  61215. /**
  61216. * Gets a string describing the action executed by the current optimization
  61217. * @return description string
  61218. */
  61219. getDescription(): string;
  61220. /**
  61221. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61222. * @param scene defines the current scene where to apply this optimization
  61223. * @param optimizer defines the current optimizer
  61224. * @returns true if everything that can be done was applied
  61225. */
  61226. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61227. }
  61228. /**
  61229. * Defines an optimization used to turn render targets off
  61230. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61231. */
  61232. export class RenderTargetsOptimization extends SceneOptimization {
  61233. /**
  61234. * Gets a string describing the action executed by the current optimization
  61235. * @return description string
  61236. */
  61237. getDescription(): string;
  61238. /**
  61239. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61240. * @param scene defines the current scene where to apply this optimization
  61241. * @param optimizer defines the current optimizer
  61242. * @returns true if everything that can be done was applied
  61243. */
  61244. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61245. }
  61246. /**
  61247. * Defines an optimization used to merge meshes with compatible materials
  61248. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61249. */
  61250. export class MergeMeshesOptimization extends SceneOptimization {
  61251. private static _UpdateSelectionTree;
  61252. /**
  61253. * Gets or sets a boolean which defines if optimization octree has to be updated
  61254. */
  61255. /**
  61256. * Gets or sets a boolean which defines if optimization octree has to be updated
  61257. */
  61258. static UpdateSelectionTree: boolean;
  61259. /**
  61260. * Gets a string describing the action executed by the current optimization
  61261. * @return description string
  61262. */
  61263. getDescription(): string;
  61264. private _canBeMerged;
  61265. /**
  61266. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61267. * @param scene defines the current scene where to apply this optimization
  61268. * @param optimizer defines the current optimizer
  61269. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61270. * @returns true if everything that can be done was applied
  61271. */
  61272. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61273. }
  61274. /**
  61275. * Defines a list of options used by SceneOptimizer
  61276. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61277. */
  61278. export class SceneOptimizerOptions {
  61279. /**
  61280. * Defines the target frame rate to reach (60 by default)
  61281. */
  61282. targetFrameRate: number;
  61283. /**
  61284. * Defines the interval between two checkes (2000ms by default)
  61285. */
  61286. trackerDuration: number;
  61287. /**
  61288. * Gets the list of optimizations to apply
  61289. */
  61290. optimizations: SceneOptimization[];
  61291. /**
  61292. * Creates a new list of options used by SceneOptimizer
  61293. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61294. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61295. */
  61296. constructor(
  61297. /**
  61298. * Defines the target frame rate to reach (60 by default)
  61299. */
  61300. targetFrameRate?: number,
  61301. /**
  61302. * Defines the interval between two checkes (2000ms by default)
  61303. */
  61304. trackerDuration?: number);
  61305. /**
  61306. * Add a new optimization
  61307. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61308. * @returns the current SceneOptimizerOptions
  61309. */
  61310. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61311. /**
  61312. * Add a new custom optimization
  61313. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  61314. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  61315. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61316. * @returns the current SceneOptimizerOptions
  61317. */
  61318. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  61319. /**
  61320. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  61321. * @param targetFrameRate defines the target frame rate (60 by default)
  61322. * @returns a SceneOptimizerOptions object
  61323. */
  61324. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61325. /**
  61326. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  61327. * @param targetFrameRate defines the target frame rate (60 by default)
  61328. * @returns a SceneOptimizerOptions object
  61329. */
  61330. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61331. /**
  61332. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  61333. * @param targetFrameRate defines the target frame rate (60 by default)
  61334. * @returns a SceneOptimizerOptions object
  61335. */
  61336. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61337. }
  61338. /**
  61339. * Class used to run optimizations in order to reach a target frame rate
  61340. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61341. */
  61342. export class SceneOptimizer implements IDisposable {
  61343. private _isRunning;
  61344. private _options;
  61345. private _scene;
  61346. private _currentPriorityLevel;
  61347. private _targetFrameRate;
  61348. private _trackerDuration;
  61349. private _currentFrameRate;
  61350. private _sceneDisposeObserver;
  61351. private _improvementMode;
  61352. /**
  61353. * Defines an observable called when the optimizer reaches the target frame rate
  61354. */
  61355. onSuccessObservable: Observable<SceneOptimizer>;
  61356. /**
  61357. * Defines an observable called when the optimizer enables an optimization
  61358. */
  61359. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  61360. /**
  61361. * Defines an observable called when the optimizer is not able to reach the target frame rate
  61362. */
  61363. onFailureObservable: Observable<SceneOptimizer>;
  61364. /**
  61365. * Gets a boolean indicating if the optimizer is in improvement mode
  61366. */
  61367. readonly isInImprovementMode: boolean;
  61368. /**
  61369. * Gets the current priority level (0 at start)
  61370. */
  61371. readonly currentPriorityLevel: number;
  61372. /**
  61373. * Gets the current frame rate checked by the SceneOptimizer
  61374. */
  61375. readonly currentFrameRate: number;
  61376. /**
  61377. * Gets or sets the current target frame rate (60 by default)
  61378. */
  61379. /**
  61380. * Gets or sets the current target frame rate (60 by default)
  61381. */
  61382. targetFrameRate: number;
  61383. /**
  61384. * Gets or sets the current interval between two checks (every 2000ms by default)
  61385. */
  61386. /**
  61387. * Gets or sets the current interval between two checks (every 2000ms by default)
  61388. */
  61389. trackerDuration: number;
  61390. /**
  61391. * Gets the list of active optimizations
  61392. */
  61393. readonly optimizations: SceneOptimization[];
  61394. /**
  61395. * Creates a new SceneOptimizer
  61396. * @param scene defines the scene to work on
  61397. * @param options defines the options to use with the SceneOptimizer
  61398. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  61399. * @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)
  61400. */
  61401. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  61402. /**
  61403. * Stops the current optimizer
  61404. */
  61405. stop(): void;
  61406. /**
  61407. * Reset the optimizer to initial step (current priority level = 0)
  61408. */
  61409. reset(): void;
  61410. /**
  61411. * Start the optimizer. By default it will try to reach a specific framerate
  61412. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  61413. */
  61414. start(): void;
  61415. private _checkCurrentState;
  61416. /**
  61417. * Release all resources
  61418. */
  61419. dispose(): void;
  61420. /**
  61421. * Helper function to create a SceneOptimizer with one single line of code
  61422. * @param scene defines the scene to work on
  61423. * @param options defines the options to use with the SceneOptimizer
  61424. * @param onSuccess defines a callback to call on success
  61425. * @param onFailure defines a callback to call on failure
  61426. * @returns the new SceneOptimizer object
  61427. */
  61428. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  61429. }
  61430. }
  61431. declare module BABYLON {
  61432. /**
  61433. * Class used to serialize a scene into a string
  61434. */
  61435. export class SceneSerializer {
  61436. /**
  61437. * Clear cache used by a previous serialization
  61438. */
  61439. static ClearCache(): void;
  61440. /**
  61441. * Serialize a scene into a JSON compatible object
  61442. * @param scene defines the scene to serialize
  61443. * @returns a JSON compatible object
  61444. */
  61445. static Serialize(scene: Scene): any;
  61446. /**
  61447. * Serialize a mesh into a JSON compatible object
  61448. * @param toSerialize defines the mesh to serialize
  61449. * @param withParents defines if parents must be serialized as well
  61450. * @param withChildren defines if children must be serialized as well
  61451. * @returns a JSON compatible object
  61452. */
  61453. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  61454. }
  61455. }
  61456. declare module BABYLON {
  61457. /**
  61458. * Class used to host texture specific utilities
  61459. */
  61460. export class TextureTools {
  61461. /**
  61462. * Uses the GPU to create a copy texture rescaled at a given size
  61463. * @param texture Texture to copy from
  61464. * @param width defines the desired width
  61465. * @param height defines the desired height
  61466. * @param useBilinearMode defines if bilinear mode has to be used
  61467. * @return the generated texture
  61468. */
  61469. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  61470. }
  61471. }
  61472. declare module BABYLON {
  61473. /**
  61474. * This represents the different options available for the video capture.
  61475. */
  61476. export interface VideoRecorderOptions {
  61477. /** Defines the mime type of the video. */
  61478. mimeType: string;
  61479. /** Defines the FPS the video should be recorded at. */
  61480. fps: number;
  61481. /** Defines the chunk size for the recording data. */
  61482. recordChunckSize: number;
  61483. /** The audio tracks to attach to the recording. */
  61484. audioTracks?: MediaStreamTrack[];
  61485. }
  61486. /**
  61487. * This can help with recording videos from BabylonJS.
  61488. * This is based on the available WebRTC functionalities of the browser.
  61489. *
  61490. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  61491. */
  61492. export class VideoRecorder {
  61493. private static readonly _defaultOptions;
  61494. /**
  61495. * Returns whether or not the VideoRecorder is available in your browser.
  61496. * @param engine Defines the Babylon Engine.
  61497. * @returns true if supported otherwise false.
  61498. */
  61499. static IsSupported(engine: Engine): boolean;
  61500. private readonly _options;
  61501. private _canvas;
  61502. private _mediaRecorder;
  61503. private _recordedChunks;
  61504. private _fileName;
  61505. private _resolve;
  61506. private _reject;
  61507. /**
  61508. * True when a recording is already in progress.
  61509. */
  61510. readonly isRecording: boolean;
  61511. /**
  61512. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  61513. * @param engine Defines the BabylonJS Engine you wish to record.
  61514. * @param options Defines options that can be used to customize the capture.
  61515. */
  61516. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  61517. /**
  61518. * Stops the current recording before the default capture timeout passed in the startRecording function.
  61519. */
  61520. stopRecording(): void;
  61521. /**
  61522. * Starts recording the canvas for a max duration specified in parameters.
  61523. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  61524. * If null no automatic download will start and you can rely on the promise to get the data back.
  61525. * @param maxDuration Defines the maximum recording time in seconds.
  61526. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  61527. * @return A promise callback at the end of the recording with the video data in Blob.
  61528. */
  61529. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  61530. /**
  61531. * Releases internal resources used during the recording.
  61532. */
  61533. dispose(): void;
  61534. private _handleDataAvailable;
  61535. private _handleError;
  61536. private _handleStop;
  61537. }
  61538. }
  61539. declare module BABYLON {
  61540. /**
  61541. * Class containing a set of static utilities functions for screenshots
  61542. */
  61543. export class ScreenshotTools {
  61544. /**
  61545. * Captures a screenshot of the current rendering
  61546. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61547. * @param engine defines the rendering engine
  61548. * @param camera defines the source camera
  61549. * @param size This parameter can be set to a single number or to an object with the
  61550. * following (optional) properties: precision, width, height. If a single number is passed,
  61551. * it will be used for both width and height. If an object is passed, the screenshot size
  61552. * will be derived from the parameters. The precision property is a multiplier allowing
  61553. * rendering at a higher or lower resolution
  61554. * @param successCallback defines the callback receives a single parameter which contains the
  61555. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61556. * src parameter of an <img> to display it
  61557. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61558. * Check your browser for supported MIME types
  61559. */
  61560. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  61561. /**
  61562. * Captures a screenshot of the current rendering
  61563. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61564. * @param engine defines the rendering engine
  61565. * @param camera defines the source camera
  61566. * @param size This parameter can be set to a single number or to an object with the
  61567. * following (optional) properties: precision, width, height. If a single number is passed,
  61568. * it will be used for both width and height. If an object is passed, the screenshot size
  61569. * will be derived from the parameters. The precision property is a multiplier allowing
  61570. * rendering at a higher or lower resolution
  61571. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61572. * Check your browser for supported MIME types
  61573. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61574. * to the src parameter of an <img> to display it
  61575. */
  61576. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  61577. /**
  61578. * Generates an image screenshot from the specified camera.
  61579. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61580. * @param engine The engine to use for rendering
  61581. * @param camera The camera to use for rendering
  61582. * @param size This parameter can be set to a single number or to an object with the
  61583. * following (optional) properties: precision, width, height. If a single number is passed,
  61584. * it will be used for both width and height. If an object is passed, the screenshot size
  61585. * will be derived from the parameters. The precision property is a multiplier allowing
  61586. * rendering at a higher or lower resolution
  61587. * @param successCallback The callback receives a single parameter which contains the
  61588. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61589. * src parameter of an <img> to display it
  61590. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61591. * Check your browser for supported MIME types
  61592. * @param samples Texture samples (default: 1)
  61593. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61594. * @param fileName A name for for the downloaded file.
  61595. */
  61596. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  61597. /**
  61598. * Generates an image screenshot from the specified camera.
  61599. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61600. * @param engine The engine to use for rendering
  61601. * @param camera The camera to use for rendering
  61602. * @param size This parameter can be set to a single number or to an object with the
  61603. * following (optional) properties: precision, width, height. If a single number is passed,
  61604. * it will be used for both width and height. If an object is passed, the screenshot size
  61605. * will be derived from the parameters. The precision property is a multiplier allowing
  61606. * rendering at a higher or lower resolution
  61607. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61608. * Check your browser for supported MIME types
  61609. * @param samples Texture samples (default: 1)
  61610. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61611. * @param fileName A name for for the downloaded file.
  61612. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61613. * to the src parameter of an <img> to display it
  61614. */
  61615. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  61616. /**
  61617. * Gets height and width for screenshot size
  61618. * @private
  61619. */
  61620. private static _getScreenshotSize;
  61621. }
  61622. }
  61623. declare module BABYLON {
  61624. /**
  61625. * A cursor which tracks a point on a path
  61626. */
  61627. export class PathCursor {
  61628. private path;
  61629. /**
  61630. * Stores path cursor callbacks for when an onchange event is triggered
  61631. */
  61632. private _onchange;
  61633. /**
  61634. * The value of the path cursor
  61635. */
  61636. value: number;
  61637. /**
  61638. * The animation array of the path cursor
  61639. */
  61640. animations: Animation[];
  61641. /**
  61642. * Initializes the path cursor
  61643. * @param path The path to track
  61644. */
  61645. constructor(path: Path2);
  61646. /**
  61647. * Gets the cursor point on the path
  61648. * @returns A point on the path cursor at the cursor location
  61649. */
  61650. getPoint(): Vector3;
  61651. /**
  61652. * Moves the cursor ahead by the step amount
  61653. * @param step The amount to move the cursor forward
  61654. * @returns This path cursor
  61655. */
  61656. moveAhead(step?: number): PathCursor;
  61657. /**
  61658. * Moves the cursor behind by the step amount
  61659. * @param step The amount to move the cursor back
  61660. * @returns This path cursor
  61661. */
  61662. moveBack(step?: number): PathCursor;
  61663. /**
  61664. * Moves the cursor by the step amount
  61665. * If the step amount is greater than one, an exception is thrown
  61666. * @param step The amount to move the cursor
  61667. * @returns This path cursor
  61668. */
  61669. move(step: number): PathCursor;
  61670. /**
  61671. * Ensures that the value is limited between zero and one
  61672. * @returns This path cursor
  61673. */
  61674. private ensureLimits;
  61675. /**
  61676. * Runs onchange callbacks on change (used by the animation engine)
  61677. * @returns This path cursor
  61678. */
  61679. private raiseOnChange;
  61680. /**
  61681. * Executes a function on change
  61682. * @param f A path cursor onchange callback
  61683. * @returns This path cursor
  61684. */
  61685. onchange(f: (cursor: PathCursor) => void): PathCursor;
  61686. }
  61687. }
  61688. declare module BABYLON {
  61689. /** @hidden */
  61690. export var blurPixelShader: {
  61691. name: string;
  61692. shader: string;
  61693. };
  61694. }
  61695. declare module BABYLON {
  61696. /** @hidden */
  61697. export var pointCloudVertexDeclaration: {
  61698. name: string;
  61699. shader: string;
  61700. };
  61701. }
  61702. // Mixins
  61703. interface Window {
  61704. mozIndexedDB: IDBFactory;
  61705. webkitIndexedDB: IDBFactory;
  61706. msIndexedDB: IDBFactory;
  61707. webkitURL: typeof URL;
  61708. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  61709. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  61710. WebGLRenderingContext: WebGLRenderingContext;
  61711. MSGesture: MSGesture;
  61712. CANNON: any;
  61713. AudioContext: AudioContext;
  61714. webkitAudioContext: AudioContext;
  61715. PointerEvent: any;
  61716. Math: Math;
  61717. Uint8Array: Uint8ArrayConstructor;
  61718. Float32Array: Float32ArrayConstructor;
  61719. mozURL: typeof URL;
  61720. msURL: typeof URL;
  61721. VRFrameData: any; // WebVR, from specs 1.1
  61722. DracoDecoderModule: any;
  61723. setImmediate(handler: (...args: any[]) => void): number;
  61724. }
  61725. interface HTMLCanvasElement {
  61726. requestPointerLock(): void;
  61727. msRequestPointerLock?(): void;
  61728. mozRequestPointerLock?(): void;
  61729. webkitRequestPointerLock?(): void;
  61730. /** Track wether a record is in progress */
  61731. isRecording: boolean;
  61732. /** Capture Stream method defined by some browsers */
  61733. captureStream(fps?: number): MediaStream;
  61734. }
  61735. interface CanvasRenderingContext2D {
  61736. msImageSmoothingEnabled: boolean;
  61737. }
  61738. interface MouseEvent {
  61739. mozMovementX: number;
  61740. mozMovementY: number;
  61741. webkitMovementX: number;
  61742. webkitMovementY: number;
  61743. msMovementX: number;
  61744. msMovementY: number;
  61745. }
  61746. interface Navigator {
  61747. mozGetVRDevices: (any: any) => any;
  61748. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61749. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61750. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61751. webkitGetGamepads(): Gamepad[];
  61752. msGetGamepads(): Gamepad[];
  61753. webkitGamepads(): Gamepad[];
  61754. }
  61755. interface HTMLVideoElement {
  61756. mozSrcObject: any;
  61757. }
  61758. interface Math {
  61759. fround(x: number): number;
  61760. imul(a: number, b: number): number;
  61761. }
  61762. interface WebGLRenderingContext {
  61763. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  61764. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  61765. vertexAttribDivisor(index: number, divisor: number): void;
  61766. createVertexArray(): any;
  61767. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  61768. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  61769. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  61770. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  61771. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  61772. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  61773. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  61774. // Queries
  61775. createQuery(): WebGLQuery;
  61776. deleteQuery(query: WebGLQuery): void;
  61777. beginQuery(target: number, query: WebGLQuery): void;
  61778. endQuery(target: number): void;
  61779. getQueryParameter(query: WebGLQuery, pname: number): any;
  61780. getQuery(target: number, pname: number): any;
  61781. MAX_SAMPLES: number;
  61782. RGBA8: number;
  61783. READ_FRAMEBUFFER: number;
  61784. DRAW_FRAMEBUFFER: number;
  61785. UNIFORM_BUFFER: number;
  61786. HALF_FLOAT_OES: number;
  61787. RGBA16F: number;
  61788. RGBA32F: number;
  61789. R32F: number;
  61790. RG32F: number;
  61791. RGB32F: number;
  61792. R16F: number;
  61793. RG16F: number;
  61794. RGB16F: number;
  61795. RED: number;
  61796. RG: number;
  61797. R8: number;
  61798. RG8: number;
  61799. UNSIGNED_INT_24_8: number;
  61800. DEPTH24_STENCIL8: number;
  61801. MIN: number;
  61802. MAX: number;
  61803. /* Multiple Render Targets */
  61804. drawBuffers(buffers: number[]): void;
  61805. readBuffer(src: number): void;
  61806. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  61807. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  61808. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  61809. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  61810. // Occlusion Query
  61811. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  61812. ANY_SAMPLES_PASSED: number;
  61813. QUERY_RESULT_AVAILABLE: number;
  61814. QUERY_RESULT: number;
  61815. }
  61816. interface WebGLProgram { private __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  61817. }
  61818. interface EXT_disjoint_timer_query {
  61819. QUERY_COUNTER_BITS_EXT: number;
  61820. TIME_ELAPSED_EXT: number;
  61821. TIMESTAMP_EXT: number;
  61822. GPU_DISJOINT_EXT: number;
  61823. QUERY_RESULT_EXT: number;
  61824. QUERY_RESULT_AVAILABLE_EXT: number;
  61825. queryCounterEXT(query: WebGLQuery, target: number): void;
  61826. createQueryEXT(): WebGLQuery;
  61827. beginQueryEXT(target: number, query: WebGLQuery): void;
  61828. endQueryEXT(target: number): void;
  61829. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  61830. deleteQueryEXT(query: WebGLQuery): void;
  61831. }
  61832. interface WebGLUniformLocation { private _currentState: any;
  61833. }
  61834. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  61835. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  61836. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  61837. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  61838. interface WebGLRenderingContext {
  61839. readonly RASTERIZER_DISCARD: number;
  61840. readonly DEPTH_COMPONENT24: number;
  61841. readonly TEXTURE_3D: number;
  61842. readonly TEXTURE_2D_ARRAY: number;
  61843. readonly TEXTURE_COMPARE_FUNC: number;
  61844. readonly TEXTURE_COMPARE_MODE: number;
  61845. readonly COMPARE_REF_TO_TEXTURE: number;
  61846. readonly TEXTURE_WRAP_R: number;
  61847. readonly HALF_FLOAT: number;
  61848. readonly RGB8: number;
  61849. readonly RED_INTEGER: number;
  61850. readonly RG_INTEGER: number;
  61851. readonly RGB_INTEGER: number;
  61852. readonly RGBA_INTEGER: number;
  61853. readonly R8_SNORM: number;
  61854. readonly RG8_SNORM: number;
  61855. readonly RGB8_SNORM: number;
  61856. readonly RGBA8_SNORM: number;
  61857. readonly R8I: number;
  61858. readonly RG8I: number;
  61859. readonly RGB8I: number;
  61860. readonly RGBA8I: number;
  61861. readonly R8UI: number;
  61862. readonly RG8UI: number;
  61863. readonly RGB8UI: number;
  61864. readonly RGBA8UI: number;
  61865. readonly R16I: number;
  61866. readonly RG16I: number;
  61867. readonly RGB16I: number;
  61868. readonly RGBA16I: number;
  61869. readonly R16UI: number;
  61870. readonly RG16UI: number;
  61871. readonly RGB16UI: number;
  61872. readonly RGBA16UI: number;
  61873. readonly R32I: number;
  61874. readonly RG32I: number;
  61875. readonly RGB32I: number;
  61876. readonly RGBA32I: number;
  61877. readonly R32UI: number;
  61878. readonly RG32UI: number;
  61879. readonly RGB32UI: number;
  61880. readonly RGBA32UI: number;
  61881. readonly RGB10_A2UI: number;
  61882. readonly R11F_G11F_B10F: number;
  61883. readonly RGB9_E5: number;
  61884. readonly RGB10_A2: number;
  61885. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  61886. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  61887. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  61888. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  61889. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  61890. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  61891. 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;
  61892. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  61893. readonly TRANSFORM_FEEDBACK: number;
  61894. readonly INTERLEAVED_ATTRIBS: number;
  61895. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  61896. createTransformFeedback(): WebGLTransformFeedback;
  61897. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  61898. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  61899. beginTransformFeedback(primitiveMode: number): void;
  61900. endTransformFeedback(): void;
  61901. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  61902. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61903. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61904. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61905. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  61906. }
  61907. interface ImageBitmap {
  61908. readonly width: number;
  61909. readonly height: number;
  61910. close(): void;
  61911. }
  61912. interface WebGLQuery extends WebGLObject {
  61913. }
  61914. declare var WebGLQuery: {
  61915. prototype: WebGLQuery;
  61916. new(): WebGLQuery;
  61917. };
  61918. interface WebGLSampler extends WebGLObject {
  61919. }
  61920. declare var WebGLSampler: {
  61921. prototype: WebGLSampler;
  61922. new(): WebGLSampler;
  61923. };
  61924. interface WebGLSync extends WebGLObject {
  61925. }
  61926. declare var WebGLSync: {
  61927. prototype: WebGLSync;
  61928. new(): WebGLSync;
  61929. };
  61930. interface WebGLTransformFeedback extends WebGLObject {
  61931. }
  61932. declare var WebGLTransformFeedback: {
  61933. prototype: WebGLTransformFeedback;
  61934. new(): WebGLTransformFeedback;
  61935. };
  61936. interface WebGLVertexArrayObject extends WebGLObject {
  61937. }
  61938. declare var WebGLVertexArrayObject: {
  61939. prototype: WebGLVertexArrayObject;
  61940. new(): WebGLVertexArrayObject;
  61941. };
  61942. // Type definitions for WebVR API
  61943. // Project: https://w3c.github.io/webvr/
  61944. // Definitions by: six a <https://github.com/lostfictions>
  61945. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  61946. interface VRDisplay extends EventTarget {
  61947. /**
  61948. * Dictionary of capabilities describing the VRDisplay.
  61949. */
  61950. readonly capabilities: VRDisplayCapabilities;
  61951. /**
  61952. * z-depth defining the far plane of the eye view frustum
  61953. * enables mapping of values in the render target depth
  61954. * attachment to scene coordinates. Initially set to 10000.0.
  61955. */
  61956. depthFar: number;
  61957. /**
  61958. * z-depth defining the near plane of the eye view frustum
  61959. * enables mapping of values in the render target depth
  61960. * attachment to scene coordinates. Initially set to 0.01.
  61961. */
  61962. depthNear: number;
  61963. /**
  61964. * An identifier for this distinct VRDisplay. Used as an
  61965. * association point in the Gamepad API.
  61966. */
  61967. readonly displayId: number;
  61968. /**
  61969. * A display name, a user-readable name identifying it.
  61970. */
  61971. readonly displayName: string;
  61972. readonly isConnected: boolean;
  61973. readonly isPresenting: boolean;
  61974. /**
  61975. * If this VRDisplay supports room-scale experiences, the optional
  61976. * stage attribute contains details on the room-scale parameters.
  61977. */
  61978. readonly stageParameters: VRStageParameters | null;
  61979. /**
  61980. * Passing the value returned by `requestAnimationFrame` to
  61981. * `cancelAnimationFrame` will unregister the callback.
  61982. * @param handle Define the hanle of the request to cancel
  61983. */
  61984. cancelAnimationFrame(handle: number): void;
  61985. /**
  61986. * Stops presenting to the VRDisplay.
  61987. * @returns a promise to know when it stopped
  61988. */
  61989. exitPresent(): Promise<void>;
  61990. /**
  61991. * Return the current VREyeParameters for the given eye.
  61992. * @param whichEye Define the eye we want the parameter for
  61993. * @returns the eye parameters
  61994. */
  61995. getEyeParameters(whichEye: string): VREyeParameters;
  61996. /**
  61997. * Populates the passed VRFrameData with the information required to render
  61998. * the current frame.
  61999. * @param frameData Define the data structure to populate
  62000. * @returns true if ok otherwise false
  62001. */
  62002. getFrameData(frameData: VRFrameData): boolean;
  62003. /**
  62004. * Get the layers currently being presented.
  62005. * @returns the list of VR layers
  62006. */
  62007. getLayers(): VRLayer[];
  62008. /**
  62009. * Return a VRPose containing the future predicted pose of the VRDisplay
  62010. * when the current frame will be presented. The value returned will not
  62011. * change until JavaScript has returned control to the browser.
  62012. *
  62013. * The VRPose will contain the position, orientation, velocity,
  62014. * and acceleration of each of these properties.
  62015. * @returns the pose object
  62016. */
  62017. getPose(): VRPose;
  62018. /**
  62019. * Return the current instantaneous pose of the VRDisplay, with no
  62020. * prediction applied.
  62021. * @returns the current instantaneous pose
  62022. */
  62023. getImmediatePose(): VRPose;
  62024. /**
  62025. * The callback passed to `requestAnimationFrame` will be called
  62026. * any time a new frame should be rendered. When the VRDisplay is
  62027. * presenting the callback will be called at the native refresh
  62028. * rate of the HMD. When not presenting this function acts
  62029. * identically to how window.requestAnimationFrame acts. Content should
  62030. * make no assumptions of frame rate or vsync behavior as the HMD runs
  62031. * asynchronously from other displays and at differing refresh rates.
  62032. * @param callback Define the eaction to run next frame
  62033. * @returns the request handle it
  62034. */
  62035. requestAnimationFrame(callback: FrameRequestCallback): number;
  62036. /**
  62037. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  62038. * Repeat calls while already presenting will update the VRLayers being displayed.
  62039. * @param layers Define the list of layer to present
  62040. * @returns a promise to know when the request has been fulfilled
  62041. */
  62042. requestPresent(layers: VRLayer[]): Promise<void>;
  62043. /**
  62044. * Reset the pose for this display, treating its current position and
  62045. * orientation as the "origin/zero" values. VRPose.position,
  62046. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62047. * updated when calling resetPose(). This should be called in only
  62048. * sitting-space experiences.
  62049. */
  62050. resetPose(): void;
  62051. /**
  62052. * The VRLayer provided to the VRDisplay will be captured and presented
  62053. * in the HMD. Calling this function has the same effect on the source
  62054. * canvas as any other operation that uses its source image, and canvases
  62055. * created without preserveDrawingBuffer set to true will be cleared.
  62056. * @param pose Define the pose to submit
  62057. */
  62058. submitFrame(pose?: VRPose): void;
  62059. }
  62060. declare var VRDisplay: {
  62061. prototype: VRDisplay;
  62062. new(): VRDisplay;
  62063. };
  62064. interface VRLayer {
  62065. leftBounds?: number[] | Float32Array | null;
  62066. rightBounds?: number[] | Float32Array | null;
  62067. source?: HTMLCanvasElement | null;
  62068. }
  62069. interface VRDisplayCapabilities {
  62070. readonly canPresent: boolean;
  62071. readonly hasExternalDisplay: boolean;
  62072. readonly hasOrientation: boolean;
  62073. readonly hasPosition: boolean;
  62074. readonly maxLayers: number;
  62075. }
  62076. interface VREyeParameters {
  62077. /** @deprecated */
  62078. readonly fieldOfView: VRFieldOfView;
  62079. readonly offset: Float32Array;
  62080. readonly renderHeight: number;
  62081. readonly renderWidth: number;
  62082. }
  62083. interface VRFieldOfView {
  62084. readonly downDegrees: number;
  62085. readonly leftDegrees: number;
  62086. readonly rightDegrees: number;
  62087. readonly upDegrees: number;
  62088. }
  62089. interface VRFrameData {
  62090. readonly leftProjectionMatrix: Float32Array;
  62091. readonly leftViewMatrix: Float32Array;
  62092. readonly pose: VRPose;
  62093. readonly rightProjectionMatrix: Float32Array;
  62094. readonly rightViewMatrix: Float32Array;
  62095. readonly timestamp: number;
  62096. }
  62097. interface VRPose {
  62098. readonly angularAcceleration: Float32Array | null;
  62099. readonly angularVelocity: Float32Array | null;
  62100. readonly linearAcceleration: Float32Array | null;
  62101. readonly linearVelocity: Float32Array | null;
  62102. readonly orientation: Float32Array | null;
  62103. readonly position: Float32Array | null;
  62104. readonly timestamp: number;
  62105. }
  62106. interface VRStageParameters {
  62107. sittingToStandingTransform?: Float32Array;
  62108. sizeX?: number;
  62109. sizeY?: number;
  62110. }
  62111. interface Navigator {
  62112. getVRDisplays(): Promise<VRDisplay[]>;
  62113. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62114. }
  62115. interface Window {
  62116. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62117. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62118. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62119. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62120. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62121. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62122. }
  62123. interface Gamepad {
  62124. readonly displayId: number;
  62125. }
  62126. type XRSessionMode =
  62127. | "inline"
  62128. | "immersive-vr"
  62129. | "immersive-ar";
  62130. type XRReferenceSpaceType =
  62131. | "viewer"
  62132. | "local"
  62133. | "local-floor"
  62134. | "bounded-floor"
  62135. | "unbounded";
  62136. type XREnvironmentBlendMode =
  62137. | "opaque"
  62138. | "additive"
  62139. | "alpha-blend";
  62140. type XRVisibilityState =
  62141. | "visible"
  62142. | "visible-blurred"
  62143. | "hidden";
  62144. type XRHandedness =
  62145. | "none"
  62146. | "left"
  62147. | "right";
  62148. type XRTargetRayMode =
  62149. | "gaze"
  62150. | "tracked-pointer"
  62151. | "screen";
  62152. type XREye =
  62153. | "none"
  62154. | "left"
  62155. | "right";
  62156. interface XRSpace extends EventTarget {
  62157. }
  62158. interface XRRenderState {
  62159. depthNear?: number;
  62160. depthFar?: number;
  62161. inlineVerticalFieldOfView?: number;
  62162. baseLayer?: XRWebGLLayer;
  62163. }
  62164. interface XRInputSource {
  62165. handedness: XRHandedness;
  62166. targetRayMode: XRTargetRayMode;
  62167. targetRaySpace: XRSpace;
  62168. gripSpace: XRSpace | undefined;
  62169. gamepad: Gamepad | undefined;
  62170. profiles: Array<string>;
  62171. }
  62172. interface XRSession {
  62173. addEventListener: Function;
  62174. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  62175. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  62176. requestAnimationFrame: Function;
  62177. end(): Promise<void>;
  62178. renderState: XRRenderState;
  62179. inputSources: Array<XRInputSource>;
  62180. }
  62181. interface XRReferenceSpace extends XRSpace {
  62182. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  62183. onreset: any;
  62184. }
  62185. interface XRFrame {
  62186. session: XRSession;
  62187. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  62188. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  62189. }
  62190. interface XRViewerPose extends XRPose {
  62191. views: Array<XRView>;
  62192. }
  62193. interface XRPose {
  62194. transform: XRRigidTransform;
  62195. emulatedPosition: boolean;
  62196. }
  62197. declare var XRWebGLLayer: {
  62198. prototype: XRWebGLLayer;
  62199. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  62200. };
  62201. interface XRWebGLLayer {
  62202. framebuffer: WebGLFramebuffer;
  62203. framebufferWidth: number;
  62204. framebufferHeight: number;
  62205. getViewport: Function;
  62206. }
  62207. interface XRRigidTransform {
  62208. position: DOMPointReadOnly;
  62209. orientation: DOMPointReadOnly;
  62210. matrix: Float32Array;
  62211. inverse: XRRigidTransform;
  62212. }
  62213. interface XRView {
  62214. eye: XREye;
  62215. projectionMatrix: Float32Array;
  62216. transform: XRRigidTransform;
  62217. }
  62218. interface XRInputSourceChangeEvent {
  62219. session: XRSession;
  62220. removed: Array<XRInputSource>;
  62221. added: Array<XRInputSource>;
  62222. }
  62223. /**
  62224. * @ignore
  62225. */
  62226. declare module BABYLON.GLTF2.Exporter {
  62227. }
  62228. /**
  62229. * @ignore
  62230. */
  62231. declare module BABYLON.GLTF1 {
  62232. }
  62233. declare module BABYLON.GUI {
  62234. /**
  62235. * Class used to specific a value and its associated unit
  62236. */
  62237. export class ValueAndUnit {
  62238. /** defines the unit to store */
  62239. unit: number;
  62240. /** defines a boolean indicating if the value can be negative */
  62241. negativeValueAllowed: boolean;
  62242. private _value;
  62243. private _originalUnit;
  62244. /**
  62245. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  62246. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62247. */
  62248. ignoreAdaptiveScaling: boolean;
  62249. /**
  62250. * Creates a new ValueAndUnit
  62251. * @param value defines the value to store
  62252. * @param unit defines the unit to store
  62253. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  62254. */
  62255. constructor(value: number,
  62256. /** defines the unit to store */
  62257. unit?: number,
  62258. /** defines a boolean indicating if the value can be negative */
  62259. negativeValueAllowed?: boolean);
  62260. /** Gets a boolean indicating if the value is a percentage */
  62261. readonly isPercentage: boolean;
  62262. /** Gets a boolean indicating if the value is store as pixel */
  62263. readonly isPixel: boolean;
  62264. /** Gets direct internal value */
  62265. readonly internalValue: number;
  62266. /**
  62267. * Gets value as pixel
  62268. * @param host defines the root host
  62269. * @param refValue defines the reference value for percentages
  62270. * @returns the value as pixel
  62271. */
  62272. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  62273. /**
  62274. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  62275. * @param value defines the value to store
  62276. * @param unit defines the unit to store
  62277. * @returns the current ValueAndUnit
  62278. */
  62279. updateInPlace(value: number, unit?: number): ValueAndUnit;
  62280. /**
  62281. * Gets the value accordingly to its unit
  62282. * @param host defines the root host
  62283. * @returns the value
  62284. */
  62285. getValue(host: AdvancedDynamicTexture): number;
  62286. /**
  62287. * Gets a string representation of the value
  62288. * @param host defines the root host
  62289. * @param decimals defines an optional number of decimals to display
  62290. * @returns a string
  62291. */
  62292. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  62293. /**
  62294. * Store a value parsed from a string
  62295. * @param source defines the source string
  62296. * @returns true if the value was successfully parsed
  62297. */
  62298. fromString(source: string | number): boolean;
  62299. private static _Regex;
  62300. private static _UNITMODE_PERCENTAGE;
  62301. private static _UNITMODE_PIXEL;
  62302. /** UNITMODE_PERCENTAGE */
  62303. static readonly UNITMODE_PERCENTAGE: number;
  62304. /** UNITMODE_PIXEL */
  62305. static readonly UNITMODE_PIXEL: number;
  62306. }
  62307. }
  62308. declare module BABYLON.GUI {
  62309. /**
  62310. * Define a style used by control to automatically setup properties based on a template.
  62311. * Only support font related properties so far
  62312. */
  62313. export class Style implements BABYLON.IDisposable {
  62314. private _fontFamily;
  62315. private _fontStyle;
  62316. private _fontWeight;
  62317. /** @hidden */ private _host: AdvancedDynamicTexture;
  62318. /** @hidden */ private _fontSize: ValueAndUnit;
  62319. /**
  62320. * BABYLON.Observable raised when the style values are changed
  62321. */
  62322. onChangedObservable: BABYLON.Observable<Style>;
  62323. /**
  62324. * Creates a new style object
  62325. * @param host defines the AdvancedDynamicTexture which hosts this style
  62326. */
  62327. constructor(host: AdvancedDynamicTexture);
  62328. /**
  62329. * Gets or sets the font size
  62330. */
  62331. fontSize: string | number;
  62332. /**
  62333. * Gets or sets the font family
  62334. */
  62335. fontFamily: string;
  62336. /**
  62337. * Gets or sets the font style
  62338. */
  62339. fontStyle: string;
  62340. /** Gets or sets font weight */
  62341. fontWeight: string;
  62342. /** Dispose all associated resources */
  62343. dispose(): void;
  62344. }
  62345. }
  62346. declare module BABYLON.GUI {
  62347. /**
  62348. * Class used to transport BABYLON.Vector2 information for pointer events
  62349. */
  62350. export class Vector2WithInfo extends BABYLON.Vector2 {
  62351. /** defines the current mouse button index */
  62352. buttonIndex: number;
  62353. /**
  62354. * Creates a new Vector2WithInfo
  62355. * @param source defines the vector2 data to transport
  62356. * @param buttonIndex defines the current mouse button index
  62357. */
  62358. constructor(source: BABYLON.Vector2,
  62359. /** defines the current mouse button index */
  62360. buttonIndex?: number);
  62361. }
  62362. /** Class used to provide 2D matrix features */
  62363. export class Matrix2D {
  62364. /** Gets the internal array of 6 floats used to store matrix data */
  62365. m: Float32Array;
  62366. /**
  62367. * Creates a new matrix
  62368. * @param m00 defines value for (0, 0)
  62369. * @param m01 defines value for (0, 1)
  62370. * @param m10 defines value for (1, 0)
  62371. * @param m11 defines value for (1, 1)
  62372. * @param m20 defines value for (2, 0)
  62373. * @param m21 defines value for (2, 1)
  62374. */
  62375. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  62376. /**
  62377. * Fills the matrix from direct values
  62378. * @param m00 defines value for (0, 0)
  62379. * @param m01 defines value for (0, 1)
  62380. * @param m10 defines value for (1, 0)
  62381. * @param m11 defines value for (1, 1)
  62382. * @param m20 defines value for (2, 0)
  62383. * @param m21 defines value for (2, 1)
  62384. * @returns the current modified matrix
  62385. */
  62386. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  62387. /**
  62388. * Gets matrix determinant
  62389. * @returns the determinant
  62390. */
  62391. determinant(): number;
  62392. /**
  62393. * Inverses the matrix and stores it in a target matrix
  62394. * @param result defines the target matrix
  62395. * @returns the current matrix
  62396. */
  62397. invertToRef(result: Matrix2D): Matrix2D;
  62398. /**
  62399. * Multiplies the current matrix with another one
  62400. * @param other defines the second operand
  62401. * @param result defines the target matrix
  62402. * @returns the current matrix
  62403. */
  62404. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  62405. /**
  62406. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  62407. * @param x defines the x coordinate to transform
  62408. * @param y defines the x coordinate to transform
  62409. * @param result defines the target vector2
  62410. * @returns the current matrix
  62411. */
  62412. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  62413. /**
  62414. * Creates an identity matrix
  62415. * @returns a new matrix
  62416. */
  62417. static Identity(): Matrix2D;
  62418. /**
  62419. * Creates a translation matrix and stores it in a target matrix
  62420. * @param x defines the x coordinate of the translation
  62421. * @param y defines the y coordinate of the translation
  62422. * @param result defines the target matrix
  62423. */
  62424. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  62425. /**
  62426. * Creates a scaling matrix and stores it in a target matrix
  62427. * @param x defines the x coordinate of the scaling
  62428. * @param y defines the y coordinate of the scaling
  62429. * @param result defines the target matrix
  62430. */
  62431. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  62432. /**
  62433. * Creates a rotation matrix and stores it in a target matrix
  62434. * @param angle defines the rotation angle
  62435. * @param result defines the target matrix
  62436. */
  62437. static RotationToRef(angle: number, result: Matrix2D): void;
  62438. private static _TempPreTranslationMatrix;
  62439. private static _TempPostTranslationMatrix;
  62440. private static _TempRotationMatrix;
  62441. private static _TempScalingMatrix;
  62442. private static _TempCompose0;
  62443. private static _TempCompose1;
  62444. private static _TempCompose2;
  62445. /**
  62446. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  62447. * @param tx defines the x coordinate of the translation
  62448. * @param ty defines the y coordinate of the translation
  62449. * @param angle defines the rotation angle
  62450. * @param scaleX defines the x coordinate of the scaling
  62451. * @param scaleY defines the y coordinate of the scaling
  62452. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  62453. * @param result defines the target matrix
  62454. */
  62455. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  62456. }
  62457. }
  62458. declare module BABYLON.GUI {
  62459. /**
  62460. * Class used to store 2D control sizes
  62461. */
  62462. export class Measure {
  62463. /** defines left coordinate */
  62464. left: number;
  62465. /** defines top coordinate */
  62466. top: number;
  62467. /** defines width dimension */
  62468. width: number;
  62469. /** defines height dimension */
  62470. height: number;
  62471. /**
  62472. * Creates a new measure
  62473. * @param left defines left coordinate
  62474. * @param top defines top coordinate
  62475. * @param width defines width dimension
  62476. * @param height defines height dimension
  62477. */
  62478. constructor(
  62479. /** defines left coordinate */
  62480. left: number,
  62481. /** defines top coordinate */
  62482. top: number,
  62483. /** defines width dimension */
  62484. width: number,
  62485. /** defines height dimension */
  62486. height: number);
  62487. /**
  62488. * Copy from another measure
  62489. * @param other defines the other measure to copy from
  62490. */
  62491. copyFrom(other: Measure): void;
  62492. /**
  62493. * Copy from a group of 4 floats
  62494. * @param left defines left coordinate
  62495. * @param top defines top coordinate
  62496. * @param width defines width dimension
  62497. * @param height defines height dimension
  62498. */
  62499. copyFromFloats(left: number, top: number, width: number, height: number): void;
  62500. /**
  62501. * Computes the axis aligned bounding box measure for two given measures
  62502. * @param a Input measure
  62503. * @param b Input measure
  62504. * @param result the resulting bounding measure
  62505. */
  62506. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  62507. /**
  62508. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  62509. * @param transform the matrix to transform the measure before computing the AABB
  62510. * @param result the resulting AABB
  62511. */
  62512. transformToRef(transform: Matrix2D, result: Measure): void;
  62513. /**
  62514. * Check equality between this measure and another one
  62515. * @param other defines the other measures
  62516. * @returns true if both measures are equals
  62517. */
  62518. isEqualsTo(other: Measure): boolean;
  62519. /**
  62520. * Creates an empty measure
  62521. * @returns a new measure
  62522. */
  62523. static Empty(): Measure;
  62524. }
  62525. }
  62526. declare module BABYLON.GUI {
  62527. /**
  62528. * Interface used to define a control that can receive focus
  62529. */
  62530. export interface IFocusableControl {
  62531. /**
  62532. * Function called when the control receives the focus
  62533. */
  62534. onFocus(): void;
  62535. /**
  62536. * Function called when the control loses the focus
  62537. */
  62538. onBlur(): void;
  62539. /**
  62540. * Function called to let the control handle keyboard events
  62541. * @param evt defines the current keyboard event
  62542. */
  62543. processKeyboard(evt: KeyboardEvent): void;
  62544. /**
  62545. * Function called to get the list of controls that should not steal the focus from this control
  62546. * @returns an array of controls
  62547. */
  62548. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  62549. }
  62550. /**
  62551. * Class used to create texture to support 2D GUI elements
  62552. * @see http://doc.babylonjs.com/how_to/gui
  62553. */
  62554. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  62555. private _isDirty;
  62556. private _renderObserver;
  62557. private _resizeObserver;
  62558. private _preKeyboardObserver;
  62559. private _pointerMoveObserver;
  62560. private _pointerObserver;
  62561. private _canvasPointerOutObserver;
  62562. private _background;
  62563. /** @hidden */ private _rootContainer: Container;
  62564. /** @hidden */ private _lastPickedControl: Control;
  62565. /** @hidden */ private _lastControlOver: {
  62566. [pointerId: number]: Control;
  62567. };
  62568. /** @hidden */ private _lastControlDown: {
  62569. [pointerId: number]: Control;
  62570. };
  62571. /** @hidden */ private _capturingControl: {
  62572. [pointerId: number]: Control;
  62573. };
  62574. /** @hidden */ private _shouldBlockPointer: boolean;
  62575. /** @hidden */ private _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  62576. /** @hidden */ private _linkedControls: Control[];
  62577. private _isFullscreen;
  62578. private _fullscreenViewport;
  62579. private _idealWidth;
  62580. private _idealHeight;
  62581. private _useSmallestIdeal;
  62582. private _renderAtIdealSize;
  62583. private _focusedControl;
  62584. private _blockNextFocusCheck;
  62585. private _renderScale;
  62586. private _rootCanvas;
  62587. private _cursorChanged;
  62588. /**
  62589. * Define type to string to ensure compatibility across browsers
  62590. * Safari doesn't support DataTransfer constructor
  62591. */
  62592. private _clipboardData;
  62593. /**
  62594. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  62595. */
  62596. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  62597. /**
  62598. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  62599. */
  62600. onControlPickedObservable: BABYLON.Observable<Control>;
  62601. /**
  62602. * BABYLON.Observable event triggered before layout is evaluated
  62603. */
  62604. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62605. /**
  62606. * BABYLON.Observable event triggered after the layout was evaluated
  62607. */
  62608. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62609. /**
  62610. * BABYLON.Observable event triggered before the texture is rendered
  62611. */
  62612. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62613. /**
  62614. * BABYLON.Observable event triggered after the texture was rendered
  62615. */
  62616. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62617. /**
  62618. * Gets or sets a boolean defining if alpha is stored as premultiplied
  62619. */
  62620. premulAlpha: boolean;
  62621. /**
  62622. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  62623. * Useful when you want more antialiasing
  62624. */
  62625. renderScale: number;
  62626. /** Gets or sets the background color */
  62627. background: string;
  62628. /**
  62629. * Gets or sets the ideal width used to design controls.
  62630. * The GUI will then rescale everything accordingly
  62631. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62632. */
  62633. idealWidth: number;
  62634. /**
  62635. * Gets or sets the ideal height used to design controls.
  62636. * The GUI will then rescale everything accordingly
  62637. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62638. */
  62639. idealHeight: number;
  62640. /**
  62641. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  62642. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62643. */
  62644. useSmallestIdeal: boolean;
  62645. /**
  62646. * Gets or sets a boolean indicating if adaptive scaling must be used
  62647. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62648. */
  62649. renderAtIdealSize: boolean;
  62650. /**
  62651. * Gets the underlying layer used to render the texture when in fullscreen mode
  62652. */
  62653. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  62654. /**
  62655. * Gets the root container control
  62656. */
  62657. readonly rootContainer: Container;
  62658. /**
  62659. * Returns an array containing the root container.
  62660. * This is mostly used to let the Inspector introspects the ADT
  62661. * @returns an array containing the rootContainer
  62662. */
  62663. getChildren(): Array<Container>;
  62664. /**
  62665. * Will return all controls that are inside this texture
  62666. * @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
  62667. * @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
  62668. * @return all child controls
  62669. */
  62670. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  62671. /**
  62672. * Gets or sets the current focused control
  62673. */
  62674. focusedControl: BABYLON.Nullable<IFocusableControl>;
  62675. /**
  62676. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  62677. */
  62678. isForeground: boolean;
  62679. /**
  62680. * Gets or set information about clipboardData
  62681. */
  62682. clipboardData: string;
  62683. /**
  62684. * Creates a new AdvancedDynamicTexture
  62685. * @param name defines the name of the texture
  62686. * @param width defines the width of the texture
  62687. * @param height defines the height of the texture
  62688. * @param scene defines the hosting scene
  62689. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  62690. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  62691. */
  62692. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  62693. /**
  62694. * Get the current class name of the texture useful for serialization or dynamic coding.
  62695. * @returns "AdvancedDynamicTexture"
  62696. */
  62697. getClassName(): string;
  62698. /**
  62699. * Function used to execute a function on all controls
  62700. * @param func defines the function to execute
  62701. * @param container defines the container where controls belong. If null the root container will be used
  62702. */
  62703. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  62704. private _useInvalidateRectOptimization;
  62705. /**
  62706. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  62707. */
  62708. useInvalidateRectOptimization: boolean;
  62709. private _invalidatedRectangle;
  62710. /**
  62711. * Invalidates a rectangle area on the gui texture
  62712. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  62713. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  62714. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  62715. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  62716. */
  62717. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  62718. /**
  62719. * Marks the texture as dirty forcing a complete update
  62720. */
  62721. markAsDirty(): void;
  62722. /**
  62723. * Helper function used to create a new style
  62724. * @returns a new style
  62725. * @see http://doc.babylonjs.com/how_to/gui#styles
  62726. */
  62727. createStyle(): Style;
  62728. /**
  62729. * Adds a new control to the root container
  62730. * @param control defines the control to add
  62731. * @returns the current texture
  62732. */
  62733. addControl(control: Control): AdvancedDynamicTexture;
  62734. /**
  62735. * Removes a control from the root container
  62736. * @param control defines the control to remove
  62737. * @returns the current texture
  62738. */
  62739. removeControl(control: Control): AdvancedDynamicTexture;
  62740. /**
  62741. * Release all resources
  62742. */
  62743. dispose(): void;
  62744. private _onResize;
  62745. /** @hidden */ private _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  62746. /**
  62747. * Get screen coordinates for a vector3
  62748. * @param position defines the position to project
  62749. * @param worldMatrix defines the world matrix to use
  62750. * @returns the projected position
  62751. */
  62752. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  62753. private _checkUpdate;
  62754. private _clearMeasure;
  62755. private _render;
  62756. /** @hidden */ private _changeCursor(cursor: string): void;
  62757. /** @hidden */ private _registerLastControlDown(control: Control, pointerId: number): void;
  62758. private _doPicking;
  62759. /** @hidden */ private _cleanControlAfterRemovalFromList(list: {
  62760. [pointerId: number]: Control;
  62761. }, control: Control): void;
  62762. /** @hidden */ private _cleanControlAfterRemoval(control: Control): void;
  62763. /** Attach to all scene events required to support pointer events */
  62764. attach(): void;
  62765. /** @hidden */
  62766. private onClipboardCopy;
  62767. /** @hidden */
  62768. private onClipboardCut;
  62769. /** @hidden */
  62770. private onClipboardPaste;
  62771. /**
  62772. * Register the clipboard Events onto the canvas
  62773. */
  62774. registerClipboardEvents(): void;
  62775. /**
  62776. * Unregister the clipboard Events from the canvas
  62777. */
  62778. unRegisterClipboardEvents(): void;
  62779. /**
  62780. * Connect the texture to a hosting mesh to enable interactions
  62781. * @param mesh defines the mesh to attach to
  62782. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  62783. */
  62784. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  62785. /**
  62786. * Move the focus to a specific control
  62787. * @param control defines the control which will receive the focus
  62788. */
  62789. moveFocusToControl(control: IFocusableControl): void;
  62790. private _manageFocus;
  62791. private _attachToOnPointerOut;
  62792. /**
  62793. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  62794. * @param mesh defines the mesh which will receive the texture
  62795. * @param width defines the texture width (1024 by default)
  62796. * @param height defines the texture height (1024 by default)
  62797. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  62798. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  62799. * @returns a new AdvancedDynamicTexture
  62800. */
  62801. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  62802. /**
  62803. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  62804. * In this mode the texture will rely on a layer for its rendering.
  62805. * This allows it to be treated like any other layer.
  62806. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  62807. * LayerMask is set through advancedTexture.layer.layerMask
  62808. * @param name defines name for the texture
  62809. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  62810. * @param scene defines the hsoting scene
  62811. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  62812. * @returns a new AdvancedDynamicTexture
  62813. */
  62814. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  62815. }
  62816. }
  62817. declare module BABYLON.GUI {
  62818. /**
  62819. * Root class used for all 2D controls
  62820. * @see http://doc.babylonjs.com/how_to/gui#controls
  62821. */
  62822. export class Control {
  62823. /** defines the name of the control */
  62824. name?: string | undefined;
  62825. /**
  62826. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  62827. */
  62828. static AllowAlphaInheritance: boolean;
  62829. private _alpha;
  62830. private _alphaSet;
  62831. private _zIndex;
  62832. /** @hidden */ private _host: AdvancedDynamicTexture;
  62833. /** Gets or sets the control parent */
  62834. parent: BABYLON.Nullable<Container>;
  62835. /** @hidden */ private _currentMeasure: Measure;
  62836. private _fontFamily;
  62837. private _fontStyle;
  62838. private _fontWeight;
  62839. private _fontSize;
  62840. private _font;
  62841. /** @hidden */ private _width: ValueAndUnit;
  62842. /** @hidden */ private _height: ValueAndUnit;
  62843. /** @hidden */
  62844. protected _fontOffset: {
  62845. ascent: number;
  62846. height: number;
  62847. descent: number;
  62848. };
  62849. private _color;
  62850. private _style;
  62851. private _styleObserver;
  62852. /** @hidden */
  62853. protected _horizontalAlignment: number;
  62854. /** @hidden */
  62855. protected _verticalAlignment: number;
  62856. /** @hidden */
  62857. protected _isDirty: boolean;
  62858. /** @hidden */
  62859. protected _wasDirty: boolean;
  62860. /** @hidden */ private _tempParentMeasure: Measure;
  62861. /** @hidden */ private _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  62862. /** @hidden */
  62863. protected _cachedParentMeasure: Measure;
  62864. private _paddingLeft;
  62865. private _paddingRight;
  62866. private _paddingTop;
  62867. private _paddingBottom;
  62868. /** @hidden */ private _left: ValueAndUnit;
  62869. /** @hidden */ private _top: ValueAndUnit;
  62870. private _scaleX;
  62871. private _scaleY;
  62872. private _rotation;
  62873. private _transformCenterX;
  62874. private _transformCenterY;
  62875. /** @hidden */ private _transformMatrix: Matrix2D;
  62876. /** @hidden */
  62877. protected _invertTransformMatrix: Matrix2D;
  62878. /** @hidden */
  62879. protected _transformedPosition: BABYLON.Vector2;
  62880. private _isMatrixDirty;
  62881. private _cachedOffsetX;
  62882. private _cachedOffsetY;
  62883. private _isVisible;
  62884. private _isHighlighted;
  62885. /** @hidden */ private _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62886. private _fontSet;
  62887. private _dummyVector2;
  62888. private _downCount;
  62889. private _enterCount;
  62890. private _doNotRender;
  62891. private _downPointerIds;
  62892. protected _isEnabled: boolean;
  62893. protected _disabledColor: string;
  62894. /** @hidden */
  62895. protected _rebuildLayout: boolean;
  62896. /** @hidden */ private _isClipped: boolean;
  62897. /** @hidden */ private _tag: any;
  62898. /**
  62899. * 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
  62900. */
  62901. uniqueId: number;
  62902. /**
  62903. * Gets or sets an object used to store user defined information for the node
  62904. */
  62905. metadata: any;
  62906. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  62907. isHitTestVisible: boolean;
  62908. /** Gets or sets a boolean indicating if the control can block pointer events */
  62909. isPointerBlocker: boolean;
  62910. /** Gets or sets a boolean indicating if the control can be focusable */
  62911. isFocusInvisible: boolean;
  62912. /**
  62913. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  62914. * 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
  62915. */
  62916. clipChildren: boolean;
  62917. /**
  62918. * Gets or sets a boolean indicating that control content must be clipped
  62919. * 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
  62920. */
  62921. clipContent: boolean;
  62922. /**
  62923. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  62924. */
  62925. useBitmapCache: boolean;
  62926. private _cacheData;
  62927. private _shadowOffsetX;
  62928. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  62929. shadowOffsetX: number;
  62930. private _shadowOffsetY;
  62931. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  62932. shadowOffsetY: number;
  62933. private _shadowBlur;
  62934. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  62935. shadowBlur: number;
  62936. private _shadowColor;
  62937. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  62938. shadowColor: string;
  62939. /** Gets or sets the cursor to use when the control is hovered */
  62940. hoverCursor: string;
  62941. /** @hidden */
  62942. protected _linkOffsetX: ValueAndUnit;
  62943. /** @hidden */
  62944. protected _linkOffsetY: ValueAndUnit;
  62945. /** Gets the control type name */
  62946. readonly typeName: string;
  62947. /**
  62948. * Get the current class name of the control.
  62949. * @returns current class name
  62950. */
  62951. getClassName(): string;
  62952. /**
  62953. * An event triggered when the pointer move over the control.
  62954. */
  62955. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  62956. /**
  62957. * An event triggered when the pointer move out of the control.
  62958. */
  62959. onPointerOutObservable: BABYLON.Observable<Control>;
  62960. /**
  62961. * An event triggered when the pointer taps the control
  62962. */
  62963. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  62964. /**
  62965. * An event triggered when pointer up
  62966. */
  62967. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  62968. /**
  62969. * An event triggered when a control is clicked on
  62970. */
  62971. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  62972. /**
  62973. * An event triggered when pointer enters the control
  62974. */
  62975. onPointerEnterObservable: BABYLON.Observable<Control>;
  62976. /**
  62977. * An event triggered when the control is marked as dirty
  62978. */
  62979. onDirtyObservable: BABYLON.Observable<Control>;
  62980. /**
  62981. * An event triggered before drawing the control
  62982. */
  62983. onBeforeDrawObservable: BABYLON.Observable<Control>;
  62984. /**
  62985. * An event triggered after the control was drawn
  62986. */
  62987. onAfterDrawObservable: BABYLON.Observable<Control>;
  62988. /**
  62989. * Get the hosting AdvancedDynamicTexture
  62990. */
  62991. readonly host: AdvancedDynamicTexture;
  62992. /** Gets or set information about font offsets (used to render and align text) */
  62993. fontOffset: {
  62994. ascent: number;
  62995. height: number;
  62996. descent: number;
  62997. };
  62998. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  62999. alpha: number;
  63000. /**
  63001. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  63002. */
  63003. isHighlighted: boolean;
  63004. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  63005. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63006. */
  63007. scaleX: number;
  63008. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  63009. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63010. */
  63011. scaleY: number;
  63012. /** Gets or sets the rotation angle (0 by default)
  63013. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63014. */
  63015. rotation: number;
  63016. /** Gets or sets the transformation center on Y axis (0 by default)
  63017. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63018. */
  63019. transformCenterY: number;
  63020. /** Gets or sets the transformation center on X axis (0 by default)
  63021. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63022. */
  63023. transformCenterX: number;
  63024. /**
  63025. * Gets or sets the horizontal alignment
  63026. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63027. */
  63028. horizontalAlignment: number;
  63029. /**
  63030. * Gets or sets the vertical alignment
  63031. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63032. */
  63033. verticalAlignment: number;
  63034. /**
  63035. * Gets or sets control width
  63036. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63037. */
  63038. width: string | number;
  63039. /**
  63040. * Gets or sets the control width in pixel
  63041. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63042. */
  63043. widthInPixels: number;
  63044. /**
  63045. * Gets or sets control height
  63046. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63047. */
  63048. height: string | number;
  63049. /**
  63050. * Gets or sets control height in pixel
  63051. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63052. */
  63053. heightInPixels: number;
  63054. /** Gets or set font family */
  63055. fontFamily: string;
  63056. /** Gets or sets font style */
  63057. fontStyle: string;
  63058. /** Gets or sets font weight */
  63059. fontWeight: string;
  63060. /**
  63061. * Gets or sets style
  63062. * @see http://doc.babylonjs.com/how_to/gui#styles
  63063. */
  63064. style: BABYLON.Nullable<Style>;
  63065. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  63066. /** Gets or sets font size in pixels */
  63067. fontSizeInPixels: number;
  63068. /** Gets or sets font size */
  63069. fontSize: string | number;
  63070. /** Gets or sets foreground color */
  63071. color: string;
  63072. /** Gets or sets z index which is used to reorder controls on the z axis */
  63073. zIndex: number;
  63074. /** Gets or sets a boolean indicating if the control can be rendered */
  63075. notRenderable: boolean;
  63076. /** Gets or sets a boolean indicating if the control is visible */
  63077. isVisible: boolean;
  63078. /** Gets a boolean indicating that the control needs to update its rendering */
  63079. readonly isDirty: boolean;
  63080. /**
  63081. * Gets the current linked mesh (or null if none)
  63082. */
  63083. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63084. /**
  63085. * Gets or sets a value indicating the padding to use on the left of the control
  63086. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63087. */
  63088. paddingLeft: string | number;
  63089. /**
  63090. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  63091. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63092. */
  63093. paddingLeftInPixels: number;
  63094. /**
  63095. * Gets or sets a value indicating the padding to use on the right of the control
  63096. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63097. */
  63098. paddingRight: string | number;
  63099. /**
  63100. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  63101. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63102. */
  63103. paddingRightInPixels: number;
  63104. /**
  63105. * Gets or sets a value indicating the padding to use on the top of the control
  63106. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63107. */
  63108. paddingTop: string | number;
  63109. /**
  63110. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  63111. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63112. */
  63113. paddingTopInPixels: number;
  63114. /**
  63115. * Gets or sets a value indicating the padding to use on the bottom of the control
  63116. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63117. */
  63118. paddingBottom: string | number;
  63119. /**
  63120. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  63121. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63122. */
  63123. paddingBottomInPixels: number;
  63124. /**
  63125. * Gets or sets a value indicating the left coordinate of the control
  63126. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63127. */
  63128. left: string | number;
  63129. /**
  63130. * Gets or sets a value indicating the left coordinate in pixels of the control
  63131. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63132. */
  63133. leftInPixels: number;
  63134. /**
  63135. * Gets or sets a value indicating the top coordinate of the control
  63136. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63137. */
  63138. top: string | number;
  63139. /**
  63140. * Gets or sets a value indicating the top coordinate in pixels of the control
  63141. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63142. */
  63143. topInPixels: number;
  63144. /**
  63145. * Gets or sets a value indicating the offset on X axis to the linked mesh
  63146. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63147. */
  63148. linkOffsetX: string | number;
  63149. /**
  63150. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  63151. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63152. */
  63153. linkOffsetXInPixels: number;
  63154. /**
  63155. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  63156. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63157. */
  63158. linkOffsetY: string | number;
  63159. /**
  63160. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  63161. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63162. */
  63163. linkOffsetYInPixels: number;
  63164. /** Gets the center coordinate on X axis */
  63165. readonly centerX: number;
  63166. /** Gets the center coordinate on Y axis */
  63167. readonly centerY: number;
  63168. /** Gets or sets if control is Enabled*/
  63169. isEnabled: boolean;
  63170. /** Gets or sets background color of control if it's disabled*/
  63171. disabledColor: string;
  63172. /**
  63173. * Creates a new control
  63174. * @param name defines the name of the control
  63175. */
  63176. constructor(
  63177. /** defines the name of the control */
  63178. name?: string | undefined);
  63179. /** @hidden */
  63180. protected _getTypeName(): string;
  63181. /**
  63182. * Gets the first ascendant in the hierarchy of the given type
  63183. * @param className defines the required type
  63184. * @returns the ascendant or null if not found
  63185. */
  63186. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  63187. /** @hidden */ private _resetFontCache(): void;
  63188. /**
  63189. * Determines if a container is an ascendant of the current control
  63190. * @param container defines the container to look for
  63191. * @returns true if the container is one of the ascendant of the control
  63192. */
  63193. isAscendant(container: Control): boolean;
  63194. /**
  63195. * Gets coordinates in local control space
  63196. * @param globalCoordinates defines the coordinates to transform
  63197. * @returns the new coordinates in local space
  63198. */
  63199. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63200. /**
  63201. * Gets coordinates in local control space
  63202. * @param globalCoordinates defines the coordinates to transform
  63203. * @param result defines the target vector2 where to store the result
  63204. * @returns the current control
  63205. */
  63206. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  63207. /**
  63208. * Gets coordinates in parent local control space
  63209. * @param globalCoordinates defines the coordinates to transform
  63210. * @returns the new coordinates in parent local space
  63211. */
  63212. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63213. /**
  63214. * Move the current control to a vector3 position projected onto the screen.
  63215. * @param position defines the target position
  63216. * @param scene defines the hosting scene
  63217. */
  63218. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  63219. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  63220. /**
  63221. * Will return all controls that have this control as ascendant
  63222. * @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
  63223. * @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
  63224. * @return all child controls
  63225. */
  63226. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63227. /**
  63228. * Link current control with a target mesh
  63229. * @param mesh defines the mesh to link with
  63230. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63231. */
  63232. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  63233. /** @hidden */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  63234. /** @hidden */ private _offsetLeft(offset: number): void;
  63235. /** @hidden */ private _offsetTop(offset: number): void;
  63236. /** @hidden */ private _markMatrixAsDirty(): void;
  63237. /** @hidden */ private _flagDescendantsAsMatrixDirty(): void;
  63238. /** @hidden */ private _intersectsRect(rect: Measure): boolean;
  63239. /** @hidden */
  63240. protected invalidateRect(): void;
  63241. /** @hidden */ private _markAsDirty(force?: boolean): void;
  63242. /** @hidden */ private _markAllAsDirty(): void;
  63243. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  63244. /** @hidden */
  63245. protected _transform(context?: CanvasRenderingContext2D): void;
  63246. /** @hidden */ private _renderHighlight(context: CanvasRenderingContext2D): void;
  63247. /** @hidden */ private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63248. /** @hidden */
  63249. protected _applyStates(context: CanvasRenderingContext2D): void;
  63250. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  63251. /** @hidden */
  63252. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63253. protected _evaluateClippingState(parentMeasure: Measure): void;
  63254. /** @hidden */ private _measure(): void;
  63255. /** @hidden */
  63256. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63257. /** @hidden */
  63258. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63259. /** @hidden */
  63260. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63261. /** @hidden */
  63262. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63263. private static _ClipMeasure;
  63264. private _tmpMeasureA;
  63265. private _clip;
  63266. /** @hidden */ private _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  63267. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  63268. /**
  63269. * Tests if a given coordinates belong to the current control
  63270. * @param x defines x coordinate to test
  63271. * @param y defines y coordinate to test
  63272. * @returns true if the coordinates are inside the control
  63273. */
  63274. contains(x: number, y: number): boolean;
  63275. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63276. /** @hidden */ private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63277. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  63278. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  63279. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63280. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63281. /** @hidden */ private _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  63282. /** @hidden */ private _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  63283. private _prepareFont;
  63284. /** Releases associated resources */
  63285. dispose(): void;
  63286. private static _HORIZONTAL_ALIGNMENT_LEFT;
  63287. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  63288. private static _HORIZONTAL_ALIGNMENT_CENTER;
  63289. private static _VERTICAL_ALIGNMENT_TOP;
  63290. private static _VERTICAL_ALIGNMENT_BOTTOM;
  63291. private static _VERTICAL_ALIGNMENT_CENTER;
  63292. /** HORIZONTAL_ALIGNMENT_LEFT */
  63293. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  63294. /** HORIZONTAL_ALIGNMENT_RIGHT */
  63295. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  63296. /** HORIZONTAL_ALIGNMENT_CENTER */
  63297. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  63298. /** VERTICAL_ALIGNMENT_TOP */
  63299. static readonly VERTICAL_ALIGNMENT_TOP: number;
  63300. /** VERTICAL_ALIGNMENT_BOTTOM */
  63301. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  63302. /** VERTICAL_ALIGNMENT_CENTER */
  63303. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  63304. private static _FontHeightSizes;
  63305. /** @hidden */ private static _GetFontOffset(font: string): {
  63306. ascent: number;
  63307. height: number;
  63308. descent: number;
  63309. };
  63310. /**
  63311. * Creates a stack panel that can be used to render headers
  63312. * @param control defines the control to associate with the header
  63313. * @param text defines the text of the header
  63314. * @param size defines the size of the header
  63315. * @param options defines options used to configure the header
  63316. * @returns a new StackPanel
  63317. * @ignore
  63318. * @hidden
  63319. */
  63320. static AddHeader: (control: Control, text: string, size: string | number, options: {
  63321. isHorizontal: boolean;
  63322. controlFirst: boolean;
  63323. }) => any;
  63324. /** @hidden */
  63325. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  63326. }
  63327. }
  63328. declare module BABYLON.GUI {
  63329. /**
  63330. * Root class for 2D containers
  63331. * @see http://doc.babylonjs.com/how_to/gui#containers
  63332. */
  63333. export class Container extends Control {
  63334. name?: string | undefined;
  63335. /** @hidden */
  63336. protected _children: Control[];
  63337. /** @hidden */
  63338. protected _measureForChildren: Measure;
  63339. /** @hidden */
  63340. protected _background: string;
  63341. /** @hidden */
  63342. protected _adaptWidthToChildren: boolean;
  63343. /** @hidden */
  63344. protected _adaptHeightToChildren: boolean;
  63345. /**
  63346. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  63347. */
  63348. logLayoutCycleErrors: boolean;
  63349. /**
  63350. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  63351. */
  63352. maxLayoutCycle: number;
  63353. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  63354. adaptHeightToChildren: boolean;
  63355. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  63356. adaptWidthToChildren: boolean;
  63357. /** Gets or sets background color */
  63358. background: string;
  63359. /** Gets the list of children */
  63360. readonly children: Control[];
  63361. /**
  63362. * Creates a new Container
  63363. * @param name defines the name of the container
  63364. */
  63365. constructor(name?: string | undefined);
  63366. protected _getTypeName(): string; private _flagDescendantsAsMatrixDirty(): void;
  63367. /**
  63368. * Gets a child using its name
  63369. * @param name defines the child name to look for
  63370. * @returns the child control if found
  63371. */
  63372. getChildByName(name: string): BABYLON.Nullable<Control>;
  63373. /**
  63374. * Gets a child using its type and its name
  63375. * @param name defines the child name to look for
  63376. * @param type defines the child type to look for
  63377. * @returns the child control if found
  63378. */
  63379. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  63380. /**
  63381. * Search for a specific control in children
  63382. * @param control defines the control to look for
  63383. * @returns true if the control is in child list
  63384. */
  63385. containsControl(control: Control): boolean;
  63386. /**
  63387. * Adds a new control to the current container
  63388. * @param control defines the control to add
  63389. * @returns the current container
  63390. */
  63391. addControl(control: BABYLON.Nullable<Control>): Container;
  63392. /**
  63393. * Removes all controls from the current container
  63394. * @returns the current container
  63395. */
  63396. clearControls(): Container;
  63397. /**
  63398. * Removes a control from the current container
  63399. * @param control defines the control to remove
  63400. * @returns the current container
  63401. */
  63402. removeControl(control: Control): Container;
  63403. /** @hidden */ private _reOrderControl(control: Control): void;
  63404. /** @hidden */ private _offsetLeft(offset: number): void;
  63405. /** @hidden */ private _offsetTop(offset: number): void;
  63406. /** @hidden */ private _markAllAsDirty(): void;
  63407. /** @hidden */
  63408. protected _localDraw(context: CanvasRenderingContext2D): void;
  63409. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  63410. /** @hidden */
  63411. protected _beforeLayout(): void;
  63412. /** @hidden */
  63413. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63414. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  63415. protected _postMeasure(): void;
  63416. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  63417. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  63418. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63419. /** @hidden */
  63420. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63421. /** Releases associated resources */
  63422. dispose(): void;
  63423. }
  63424. }
  63425. declare module BABYLON.GUI {
  63426. /** Class used to create rectangle container */
  63427. export class Rectangle extends Container {
  63428. name?: string | undefined;
  63429. private _thickness;
  63430. private _cornerRadius;
  63431. /** Gets or sets border thickness */
  63432. thickness: number;
  63433. /** Gets or sets the corner radius angle */
  63434. cornerRadius: number;
  63435. /**
  63436. * Creates a new Rectangle
  63437. * @param name defines the control name
  63438. */
  63439. constructor(name?: string | undefined);
  63440. protected _getTypeName(): string;
  63441. protected _localDraw(context: CanvasRenderingContext2D): void;
  63442. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63443. private _drawRoundedRect;
  63444. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63445. }
  63446. }
  63447. declare module BABYLON.GUI {
  63448. /**
  63449. * Enum that determines the text-wrapping mode to use.
  63450. */
  63451. export enum TextWrapping {
  63452. /**
  63453. * Clip the text when it's larger than Control.width; this is the default mode.
  63454. */
  63455. Clip = 0,
  63456. /**
  63457. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  63458. */
  63459. WordWrap = 1,
  63460. /**
  63461. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  63462. */
  63463. Ellipsis = 2
  63464. }
  63465. /**
  63466. * Class used to create text block control
  63467. */
  63468. export class TextBlock extends Control {
  63469. /**
  63470. * Defines the name of the control
  63471. */
  63472. name?: string | undefined;
  63473. private _text;
  63474. private _textWrapping;
  63475. private _textHorizontalAlignment;
  63476. private _textVerticalAlignment;
  63477. private _lines;
  63478. private _resizeToFit;
  63479. private _lineSpacing;
  63480. private _outlineWidth;
  63481. private _outlineColor;
  63482. /**
  63483. * An event triggered after the text is changed
  63484. */
  63485. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  63486. /**
  63487. * An event triggered after the text was broken up into lines
  63488. */
  63489. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  63490. /**
  63491. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  63492. */
  63493. readonly lines: any[];
  63494. /**
  63495. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  63496. */
  63497. /**
  63498. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  63499. */
  63500. resizeToFit: boolean;
  63501. /**
  63502. * Gets or sets a boolean indicating if text must be wrapped
  63503. */
  63504. /**
  63505. * Gets or sets a boolean indicating if text must be wrapped
  63506. */
  63507. textWrapping: TextWrapping | boolean;
  63508. /**
  63509. * Gets or sets text to display
  63510. */
  63511. /**
  63512. * Gets or sets text to display
  63513. */
  63514. text: string;
  63515. /**
  63516. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  63517. */
  63518. /**
  63519. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  63520. */
  63521. textHorizontalAlignment: number;
  63522. /**
  63523. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  63524. */
  63525. /**
  63526. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  63527. */
  63528. textVerticalAlignment: number;
  63529. /**
  63530. * Gets or sets line spacing value
  63531. */
  63532. /**
  63533. * Gets or sets line spacing value
  63534. */
  63535. lineSpacing: string | number;
  63536. /**
  63537. * Gets or sets outlineWidth of the text to display
  63538. */
  63539. /**
  63540. * Gets or sets outlineWidth of the text to display
  63541. */
  63542. outlineWidth: number;
  63543. /**
  63544. * Gets or sets outlineColor of the text to display
  63545. */
  63546. /**
  63547. * Gets or sets outlineColor of the text to display
  63548. */
  63549. outlineColor: string;
  63550. /**
  63551. * Creates a new TextBlock object
  63552. * @param name defines the name of the control
  63553. * @param text defines the text to display (emptry string by default)
  63554. */
  63555. constructor(
  63556. /**
  63557. * Defines the name of the control
  63558. */
  63559. name?: string | undefined, text?: string);
  63560. protected _getTypeName(): string;
  63561. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63562. private _drawText;
  63563. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  63564. protected _applyStates(context: CanvasRenderingContext2D): void;
  63565. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  63566. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  63567. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  63568. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  63569. protected _renderLines(context: CanvasRenderingContext2D): void;
  63570. /**
  63571. * Given a width constraint applied on the text block, find the expected height
  63572. * @returns expected height
  63573. */
  63574. computeExpectedHeight(): number;
  63575. dispose(): void;
  63576. }
  63577. }
  63578. declare module BABYLON.GUI {
  63579. /**
  63580. * Class used to create 2D images
  63581. */
  63582. export class Image extends Control {
  63583. name?: string | undefined;
  63584. private static _WorkingCanvas;
  63585. private _domImage;
  63586. private _imageWidth;
  63587. private _imageHeight;
  63588. private _loaded;
  63589. private _stretch;
  63590. private _source;
  63591. private _autoScale;
  63592. private _sourceLeft;
  63593. private _sourceTop;
  63594. private _sourceWidth;
  63595. private _sourceHeight;
  63596. private _cellWidth;
  63597. private _cellHeight;
  63598. private _cellId;
  63599. private _populateNinePatchSlicesFromImage;
  63600. private _sliceLeft;
  63601. private _sliceRight;
  63602. private _sliceTop;
  63603. private _sliceBottom;
  63604. private _detectPointerOnOpaqueOnly;
  63605. /**
  63606. * BABYLON.Observable notified when the content is loaded
  63607. */
  63608. onImageLoadedObservable: BABYLON.Observable<Image>;
  63609. /**
  63610. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  63611. */
  63612. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  63613. /**
  63614. * Gets a boolean indicating that the content is loaded
  63615. */
  63616. readonly isLoaded: boolean;
  63617. /**
  63618. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  63619. */
  63620. populateNinePatchSlicesFromImage: boolean;
  63621. /**
  63622. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  63623. * Beware using this as this will comsume more memory as the image has to be stored twice
  63624. */
  63625. detectPointerOnOpaqueOnly: boolean;
  63626. /**
  63627. * Gets or sets the left value for slicing (9-patch)
  63628. */
  63629. sliceLeft: number;
  63630. /**
  63631. * Gets or sets the right value for slicing (9-patch)
  63632. */
  63633. sliceRight: number;
  63634. /**
  63635. * Gets or sets the top value for slicing (9-patch)
  63636. */
  63637. sliceTop: number;
  63638. /**
  63639. * Gets or sets the bottom value for slicing (9-patch)
  63640. */
  63641. sliceBottom: number;
  63642. /**
  63643. * Gets or sets the left coordinate in the source image
  63644. */
  63645. sourceLeft: number;
  63646. /**
  63647. * Gets or sets the top coordinate in the source image
  63648. */
  63649. sourceTop: number;
  63650. /**
  63651. * Gets or sets the width to capture in the source image
  63652. */
  63653. sourceWidth: number;
  63654. /**
  63655. * Gets or sets the height to capture in the source image
  63656. */
  63657. sourceHeight: number;
  63658. /**
  63659. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  63660. * @see http://doc.babylonjs.com/how_to/gui#image
  63661. */
  63662. autoScale: boolean;
  63663. /** Gets or sets the streching mode used by the image */
  63664. stretch: number;
  63665. /**
  63666. * Gets or sets the internal DOM image used to render the control
  63667. */
  63668. domImage: HTMLImageElement;
  63669. private _onImageLoaded;
  63670. private _extractNinePatchSliceDataFromImage;
  63671. /**
  63672. * Gets or sets image source url
  63673. */
  63674. source: BABYLON.Nullable<string>;
  63675. /**
  63676. * Checks for svg document with icon id present
  63677. */
  63678. private _svgCheck;
  63679. /**
  63680. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  63681. * given external svg file and icon id
  63682. */
  63683. private _getSVGAttribs;
  63684. /**
  63685. * Gets or sets the cell width to use when animation sheet is enabled
  63686. * @see http://doc.babylonjs.com/how_to/gui#image
  63687. */
  63688. cellWidth: number;
  63689. /**
  63690. * Gets or sets the cell height to use when animation sheet is enabled
  63691. * @see http://doc.babylonjs.com/how_to/gui#image
  63692. */
  63693. cellHeight: number;
  63694. /**
  63695. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  63696. * @see http://doc.babylonjs.com/how_to/gui#image
  63697. */
  63698. cellId: number;
  63699. /**
  63700. * Creates a new Image
  63701. * @param name defines the control name
  63702. * @param url defines the image url
  63703. */
  63704. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  63705. /**
  63706. * Tests if a given coordinates belong to the current control
  63707. * @param x defines x coordinate to test
  63708. * @param y defines y coordinate to test
  63709. * @returns true if the coordinates are inside the control
  63710. */
  63711. contains(x: number, y: number): boolean;
  63712. protected _getTypeName(): string;
  63713. /** Force the control to synchronize with its content */
  63714. synchronizeSizeWithContent(): void;
  63715. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63716. private _prepareWorkingCanvasForOpaqueDetection;
  63717. private _drawImage; private _draw(context: CanvasRenderingContext2D): void;
  63718. private _renderCornerPatch;
  63719. private _renderNinePatch;
  63720. dispose(): void;
  63721. /** STRETCH_NONE */
  63722. static readonly STRETCH_NONE: number;
  63723. /** STRETCH_FILL */
  63724. static readonly STRETCH_FILL: number;
  63725. /** STRETCH_UNIFORM */
  63726. static readonly STRETCH_UNIFORM: number;
  63727. /** STRETCH_EXTEND */
  63728. static readonly STRETCH_EXTEND: number;
  63729. /** NINE_PATCH */
  63730. static readonly STRETCH_NINE_PATCH: number;
  63731. }
  63732. }
  63733. declare module BABYLON.GUI {
  63734. /**
  63735. * Class used to create 2D buttons
  63736. */
  63737. export class Button extends Rectangle {
  63738. name?: string | undefined;
  63739. /**
  63740. * Function called to generate a pointer enter animation
  63741. */
  63742. pointerEnterAnimation: () => void;
  63743. /**
  63744. * Function called to generate a pointer out animation
  63745. */
  63746. pointerOutAnimation: () => void;
  63747. /**
  63748. * Function called to generate a pointer down animation
  63749. */
  63750. pointerDownAnimation: () => void;
  63751. /**
  63752. * Function called to generate a pointer up animation
  63753. */
  63754. pointerUpAnimation: () => void;
  63755. /**
  63756. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  63757. */
  63758. delegatePickingToChildren: boolean;
  63759. private _image;
  63760. /**
  63761. * Returns the image part of the button (if any)
  63762. */
  63763. readonly image: BABYLON.Nullable<Image>;
  63764. private _textBlock;
  63765. /**
  63766. * Returns the image part of the button (if any)
  63767. */
  63768. readonly textBlock: BABYLON.Nullable<TextBlock>;
  63769. /**
  63770. * Creates a new Button
  63771. * @param name defines the name of the button
  63772. */
  63773. constructor(name?: string | undefined);
  63774. protected _getTypeName(): string;
  63775. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63776. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  63777. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  63778. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63779. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63780. /**
  63781. * Creates a new button made with an image and a text
  63782. * @param name defines the name of the button
  63783. * @param text defines the text of the button
  63784. * @param imageUrl defines the url of the image
  63785. * @returns a new Button
  63786. */
  63787. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  63788. /**
  63789. * Creates a new button made with an image
  63790. * @param name defines the name of the button
  63791. * @param imageUrl defines the url of the image
  63792. * @returns a new Button
  63793. */
  63794. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  63795. /**
  63796. * Creates a new button made with a text
  63797. * @param name defines the name of the button
  63798. * @param text defines the text of the button
  63799. * @returns a new Button
  63800. */
  63801. static CreateSimpleButton(name: string, text: string): Button;
  63802. /**
  63803. * Creates a new button made with an image and a centered text
  63804. * @param name defines the name of the button
  63805. * @param text defines the text of the button
  63806. * @param imageUrl defines the url of the image
  63807. * @returns a new Button
  63808. */
  63809. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  63810. }
  63811. }
  63812. declare module BABYLON.GUI {
  63813. /**
  63814. * Class used to create a 2D stack panel container
  63815. */
  63816. export class StackPanel extends Container {
  63817. name?: string | undefined;
  63818. private _isVertical;
  63819. private _manualWidth;
  63820. private _manualHeight;
  63821. private _doNotTrackManualChanges;
  63822. /**
  63823. * Gets or sets a boolean indicating that layou warnings should be ignored
  63824. */
  63825. ignoreLayoutWarnings: boolean;
  63826. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  63827. isVertical: boolean;
  63828. /**
  63829. * Gets or sets panel width.
  63830. * This value should not be set when in horizontal mode as it will be computed automatically
  63831. */
  63832. width: string | number;
  63833. /**
  63834. * Gets or sets panel height.
  63835. * This value should not be set when in vertical mode as it will be computed automatically
  63836. */
  63837. height: string | number;
  63838. /**
  63839. * Creates a new StackPanel
  63840. * @param name defines control name
  63841. */
  63842. constructor(name?: string | undefined);
  63843. protected _getTypeName(): string;
  63844. /** @hidden */
  63845. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63846. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63847. protected _postMeasure(): void;
  63848. }
  63849. }
  63850. declare module BABYLON.GUI {
  63851. /**
  63852. * Class used to represent a 2D checkbox
  63853. */
  63854. export class Checkbox extends Control {
  63855. name?: string | undefined;
  63856. private _isChecked;
  63857. private _background;
  63858. private _checkSizeRatio;
  63859. private _thickness;
  63860. /** Gets or sets border thickness */
  63861. thickness: number;
  63862. /**
  63863. * BABYLON.Observable raised when isChecked property changes
  63864. */
  63865. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  63866. /** Gets or sets a value indicating the ratio between overall size and check size */
  63867. checkSizeRatio: number;
  63868. /** Gets or sets background color */
  63869. background: string;
  63870. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  63871. isChecked: boolean;
  63872. /**
  63873. * Creates a new CheckBox
  63874. * @param name defines the control name
  63875. */
  63876. constructor(name?: string | undefined);
  63877. protected _getTypeName(): string;
  63878. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  63879. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63880. /**
  63881. * Utility function to easily create a checkbox with a header
  63882. * @param title defines the label to use for the header
  63883. * @param onValueChanged defines the callback to call when value changes
  63884. * @returns a StackPanel containing the checkbox and a textBlock
  63885. */
  63886. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  63887. }
  63888. }
  63889. declare module BABYLON.GUI {
  63890. /**
  63891. * Class used to store key control properties
  63892. */
  63893. export class KeyPropertySet {
  63894. /** Width */
  63895. width?: string;
  63896. /** Height */
  63897. height?: string;
  63898. /** Left padding */
  63899. paddingLeft?: string;
  63900. /** Right padding */
  63901. paddingRight?: string;
  63902. /** Top padding */
  63903. paddingTop?: string;
  63904. /** Bottom padding */
  63905. paddingBottom?: string;
  63906. /** Foreground color */
  63907. color?: string;
  63908. /** Background color */
  63909. background?: string;
  63910. }
  63911. /**
  63912. * Class used to create virtual keyboard
  63913. */
  63914. export class VirtualKeyboard extends StackPanel {
  63915. /** BABYLON.Observable raised when a key is pressed */
  63916. onKeyPressObservable: BABYLON.Observable<string>;
  63917. /** Gets or sets default key button width */
  63918. defaultButtonWidth: string;
  63919. /** Gets or sets default key button height */
  63920. defaultButtonHeight: string;
  63921. /** Gets or sets default key button left padding */
  63922. defaultButtonPaddingLeft: string;
  63923. /** Gets or sets default key button right padding */
  63924. defaultButtonPaddingRight: string;
  63925. /** Gets or sets default key button top padding */
  63926. defaultButtonPaddingTop: string;
  63927. /** Gets or sets default key button bottom padding */
  63928. defaultButtonPaddingBottom: string;
  63929. /** Gets or sets default key button foreground color */
  63930. defaultButtonColor: string;
  63931. /** Gets or sets default key button background color */
  63932. defaultButtonBackground: string;
  63933. /** Gets or sets shift button foreground color */
  63934. shiftButtonColor: string;
  63935. /** Gets or sets shift button thickness*/
  63936. selectedShiftThickness: number;
  63937. /** Gets shift key state */
  63938. shiftState: number;
  63939. protected _getTypeName(): string;
  63940. private _createKey;
  63941. /**
  63942. * Adds a new row of keys
  63943. * @param keys defines the list of keys to add
  63944. * @param propertySets defines the associated property sets
  63945. */
  63946. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  63947. /**
  63948. * Set the shift key to a specific state
  63949. * @param shiftState defines the new shift state
  63950. */
  63951. applyShiftState(shiftState: number): void;
  63952. private _currentlyConnectedInputText;
  63953. private _connectedInputTexts;
  63954. private _onKeyPressObserver;
  63955. /** Gets the input text control currently attached to the keyboard */
  63956. readonly connectedInputText: BABYLON.Nullable<InputText>;
  63957. /**
  63958. * Connects the keyboard with an input text control
  63959. *
  63960. * @param input defines the target control
  63961. */
  63962. connect(input: InputText): void;
  63963. /**
  63964. * Disconnects the keyboard from connected InputText controls
  63965. *
  63966. * @param input optionally defines a target control, otherwise all are disconnected
  63967. */
  63968. disconnect(input?: InputText): void;
  63969. private _removeConnectedInputObservables;
  63970. /**
  63971. * Release all resources
  63972. */
  63973. dispose(): void;
  63974. /**
  63975. * Creates a new keyboard using a default layout
  63976. *
  63977. * @param name defines control name
  63978. * @returns a new VirtualKeyboard
  63979. */
  63980. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  63981. }
  63982. }
  63983. declare module BABYLON.GUI {
  63984. /**
  63985. * Class used to create input text control
  63986. */
  63987. export class InputText extends Control implements IFocusableControl {
  63988. name?: string | undefined;
  63989. private _text;
  63990. private _placeholderText;
  63991. private _background;
  63992. private _focusedBackground;
  63993. private _focusedColor;
  63994. private _placeholderColor;
  63995. private _thickness;
  63996. private _margin;
  63997. private _autoStretchWidth;
  63998. private _maxWidth;
  63999. private _isFocused;
  64000. private _blinkTimeout;
  64001. private _blinkIsEven;
  64002. private _cursorOffset;
  64003. private _scrollLeft;
  64004. private _textWidth;
  64005. private _clickedCoordinate;
  64006. private _deadKey;
  64007. private _addKey;
  64008. private _currentKey;
  64009. private _isTextHighlightOn;
  64010. private _textHighlightColor;
  64011. private _highligherOpacity;
  64012. private _highlightedText;
  64013. private _startHighlightIndex;
  64014. private _endHighlightIndex;
  64015. private _cursorIndex;
  64016. private _onFocusSelectAll;
  64017. private _isPointerDown;
  64018. private _onClipboardObserver;
  64019. private _onPointerDblTapObserver;
  64020. /** @hidden */ private _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  64021. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  64022. promptMessage: string;
  64023. /** Force disable prompt on mobile device */
  64024. disableMobilePrompt: boolean;
  64025. /** BABYLON.Observable raised when the text changes */
  64026. onTextChangedObservable: BABYLON.Observable<InputText>;
  64027. /** BABYLON.Observable raised just before an entered character is to be added */
  64028. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  64029. /** BABYLON.Observable raised when the control gets the focus */
  64030. onFocusObservable: BABYLON.Observable<InputText>;
  64031. /** BABYLON.Observable raised when the control loses the focus */
  64032. onBlurObservable: BABYLON.Observable<InputText>;
  64033. /**Observable raised when the text is highlighted */
  64034. onTextHighlightObservable: BABYLON.Observable<InputText>;
  64035. /**Observable raised when copy event is triggered */
  64036. onTextCopyObservable: BABYLON.Observable<InputText>;
  64037. /** BABYLON.Observable raised when cut event is triggered */
  64038. onTextCutObservable: BABYLON.Observable<InputText>;
  64039. /** BABYLON.Observable raised when paste event is triggered */
  64040. onTextPasteObservable: BABYLON.Observable<InputText>;
  64041. /** BABYLON.Observable raised when a key event was processed */
  64042. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  64043. /** Gets or sets the maximum width allowed by the control */
  64044. maxWidth: string | number;
  64045. /** Gets the maximum width allowed by the control in pixels */
  64046. readonly maxWidthInPixels: number;
  64047. /** Gets or sets the text highlighter transparency; default: 0.4 */
  64048. highligherOpacity: number;
  64049. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  64050. onFocusSelectAll: boolean;
  64051. /** Gets or sets the text hightlight color */
  64052. textHighlightColor: string;
  64053. /** Gets or sets control margin */
  64054. margin: string;
  64055. /** Gets control margin in pixels */
  64056. readonly marginInPixels: number;
  64057. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  64058. autoStretchWidth: boolean;
  64059. /** Gets or sets border thickness */
  64060. thickness: number;
  64061. /** Gets or sets the background color when focused */
  64062. focusedBackground: string;
  64063. /** Gets or sets the background color when focused */
  64064. focusedColor: string;
  64065. /** Gets or sets the background color */
  64066. background: string;
  64067. /** Gets or sets the placeholder color */
  64068. placeholderColor: string;
  64069. /** Gets or sets the text displayed when the control is empty */
  64070. placeholderText: string;
  64071. /** Gets or sets the dead key flag */
  64072. deadKey: boolean;
  64073. /** Gets or sets the highlight text */
  64074. highlightedText: string;
  64075. /** Gets or sets if the current key should be added */
  64076. addKey: boolean;
  64077. /** Gets or sets the value of the current key being entered */
  64078. currentKey: string;
  64079. /** Gets or sets the text displayed in the control */
  64080. text: string;
  64081. /** Gets or sets control width */
  64082. width: string | number;
  64083. /**
  64084. * Creates a new InputText
  64085. * @param name defines the control name
  64086. * @param text defines the text of the control
  64087. */
  64088. constructor(name?: string | undefined, text?: string);
  64089. /** @hidden */
  64090. onBlur(): void;
  64091. /** @hidden */
  64092. onFocus(): void;
  64093. protected _getTypeName(): string;
  64094. /**
  64095. * Function called to get the list of controls that should not steal the focus from this control
  64096. * @returns an array of controls
  64097. */
  64098. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  64099. /** @hidden */
  64100. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  64101. /** @hidden */
  64102. private _updateValueFromCursorIndex;
  64103. /** @hidden */
  64104. private _processDblClick;
  64105. /** @hidden */
  64106. private _selectAllText;
  64107. /**
  64108. * Handles the keyboard event
  64109. * @param evt Defines the KeyboardEvent
  64110. */
  64111. processKeyboard(evt: KeyboardEvent): void;
  64112. /** @hidden */
  64113. private _onCopyText;
  64114. /** @hidden */
  64115. private _onCutText;
  64116. /** @hidden */
  64117. 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;
  64118. protected _beforeRenderText(text: string): string;
  64119. dispose(): void;
  64120. }
  64121. }
  64122. declare module BABYLON.GUI {
  64123. /**
  64124. * Class used to create a 2D grid container
  64125. */
  64126. export class Grid extends Container {
  64127. name?: string | undefined;
  64128. private _rowDefinitions;
  64129. private _columnDefinitions;
  64130. private _cells;
  64131. private _childControls;
  64132. /**
  64133. * Gets the number of columns
  64134. */
  64135. readonly columnCount: number;
  64136. /**
  64137. * Gets the number of rows
  64138. */
  64139. readonly rowCount: number;
  64140. /** Gets the list of children */
  64141. readonly children: Control[];
  64142. /** Gets the list of cells (e.g. the containers) */
  64143. readonly cells: {
  64144. [key: string]: Container;
  64145. };
  64146. /**
  64147. * Gets the definition of a specific row
  64148. * @param index defines the index of the row
  64149. * @returns the row definition
  64150. */
  64151. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64152. /**
  64153. * Gets the definition of a specific column
  64154. * @param index defines the index of the column
  64155. * @returns the column definition
  64156. */
  64157. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64158. /**
  64159. * Adds a new row to the grid
  64160. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64161. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  64162. * @returns the current grid
  64163. */
  64164. addRowDefinition(height: number, isPixel?: boolean): Grid;
  64165. /**
  64166. * Adds a new column to the grid
  64167. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64168. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64169. * @returns the current grid
  64170. */
  64171. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  64172. /**
  64173. * Update a row definition
  64174. * @param index defines the index of the row to update
  64175. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64176. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  64177. * @returns the current grid
  64178. */
  64179. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  64180. /**
  64181. * Update a column definition
  64182. * @param index defines the index of the column to update
  64183. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64184. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64185. * @returns the current grid
  64186. */
  64187. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  64188. /**
  64189. * Gets the list of children stored in a specific cell
  64190. * @param row defines the row to check
  64191. * @param column defines the column to check
  64192. * @returns the list of controls
  64193. */
  64194. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  64195. /**
  64196. * Gets a string representing the child cell info (row x column)
  64197. * @param child defines the control to get info from
  64198. * @returns a string containing the child cell info (row x column)
  64199. */
  64200. getChildCellInfo(child: Control): string;
  64201. private _removeCell;
  64202. private _offsetCell;
  64203. /**
  64204. * Remove a column definition at specified index
  64205. * @param index defines the index of the column to remove
  64206. * @returns the current grid
  64207. */
  64208. removeColumnDefinition(index: number): Grid;
  64209. /**
  64210. * Remove a row definition at specified index
  64211. * @param index defines the index of the row to remove
  64212. * @returns the current grid
  64213. */
  64214. removeRowDefinition(index: number): Grid;
  64215. /**
  64216. * Adds a new control to the current grid
  64217. * @param control defines the control to add
  64218. * @param row defines the row where to add the control (0 by default)
  64219. * @param column defines the column where to add the control (0 by default)
  64220. * @returns the current grid
  64221. */
  64222. addControl(control: Control, row?: number, column?: number): Grid;
  64223. /**
  64224. * Removes a control from the current container
  64225. * @param control defines the control to remove
  64226. * @returns the current container
  64227. */
  64228. removeControl(control: Control): Container;
  64229. /**
  64230. * Creates a new Grid
  64231. * @param name defines control name
  64232. */
  64233. constructor(name?: string | undefined);
  64234. protected _getTypeName(): string;
  64235. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  64236. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _flagDescendantsAsMatrixDirty(): void; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64237. /** Releases associated resources */
  64238. dispose(): void;
  64239. }
  64240. }
  64241. declare module BABYLON.GUI {
  64242. /** Class used to create color pickers */
  64243. export class ColorPicker extends Control {
  64244. name?: string | undefined;
  64245. private static _Epsilon;
  64246. private _colorWheelCanvas;
  64247. private _value;
  64248. private _tmpColor;
  64249. private _pointerStartedOnSquare;
  64250. private _pointerStartedOnWheel;
  64251. private _squareLeft;
  64252. private _squareTop;
  64253. private _squareSize;
  64254. private _h;
  64255. private _s;
  64256. private _v;
  64257. private _lastPointerDownID;
  64258. /**
  64259. * BABYLON.Observable raised when the value changes
  64260. */
  64261. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  64262. /** Gets or sets the color of the color picker */
  64263. value: BABYLON.Color3;
  64264. /**
  64265. * Gets or sets control width
  64266. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64267. */
  64268. width: string | number;
  64269. /**
  64270. * Gets or sets control height
  64271. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64272. */
  64273. /** Gets or sets control height */
  64274. height: string | number;
  64275. /** Gets or sets control size */
  64276. size: string | number;
  64277. /**
  64278. * Creates a new ColorPicker
  64279. * @param name defines the control name
  64280. */
  64281. constructor(name?: string | undefined);
  64282. protected _getTypeName(): string;
  64283. /** @hidden */
  64284. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64285. private _updateSquareProps;
  64286. private _drawGradientSquare;
  64287. private _drawCircle;
  64288. private _createColorWheelCanvas;
  64289. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  64290. private _pointerIsDown;
  64291. private _updateValueFromPointer;
  64292. private _isPointOnSquare;
  64293. 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;
  64294. /**
  64295. * This function expands the color picker by creating a color picker dialog with manual
  64296. * color value input and the ability to save colors into an array to be used later in
  64297. * subsequent launches of the dialogue.
  64298. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  64299. * @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.
  64300. * @returns picked color as a hex string and the saved colors array as hex strings.
  64301. */
  64302. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  64303. pickerWidth?: string;
  64304. pickerHeight?: string;
  64305. headerHeight?: string;
  64306. lastColor?: string;
  64307. swatchLimit?: number;
  64308. numSwatchesPerLine?: number;
  64309. savedColors?: Array<string>;
  64310. }): Promise<{
  64311. savedColors?: string[];
  64312. pickedColor: string;
  64313. }>;
  64314. }
  64315. }
  64316. declare module BABYLON.GUI {
  64317. /** Class used to create 2D ellipse containers */
  64318. export class Ellipse extends Container {
  64319. name?: string | undefined;
  64320. private _thickness;
  64321. /** Gets or sets border thickness */
  64322. thickness: number;
  64323. /**
  64324. * Creates a new Ellipse
  64325. * @param name defines the control name
  64326. */
  64327. constructor(name?: string | undefined);
  64328. protected _getTypeName(): string;
  64329. protected _localDraw(context: CanvasRenderingContext2D): void;
  64330. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64331. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64332. }
  64333. }
  64334. declare module BABYLON.GUI {
  64335. /**
  64336. * Class used to create a password control
  64337. */
  64338. export class InputPassword extends InputText {
  64339. protected _beforeRenderText(text: string): string;
  64340. }
  64341. }
  64342. declare module BABYLON.GUI {
  64343. /** Class used to render 2D lines */
  64344. export class Line extends Control {
  64345. name?: string | undefined;
  64346. private _lineWidth;
  64347. private _x1;
  64348. private _y1;
  64349. private _x2;
  64350. private _y2;
  64351. private _dash;
  64352. private _connectedControl;
  64353. private _connectedControlDirtyObserver;
  64354. /** Gets or sets the dash pattern */
  64355. dash: Array<number>;
  64356. /** Gets or sets the control connected with the line end */
  64357. connectedControl: Control;
  64358. /** Gets or sets start coordinates on X axis */
  64359. x1: string | number;
  64360. /** Gets or sets start coordinates on Y axis */
  64361. y1: string | number;
  64362. /** Gets or sets end coordinates on X axis */
  64363. x2: string | number;
  64364. /** Gets or sets end coordinates on Y axis */
  64365. y2: string | number;
  64366. /** Gets or sets line width */
  64367. lineWidth: number;
  64368. /** Gets or sets horizontal alignment */
  64369. horizontalAlignment: number;
  64370. /** Gets or sets vertical alignment */
  64371. verticalAlignment: number;
  64372. private readonly _effectiveX2;
  64373. private readonly _effectiveY2;
  64374. /**
  64375. * Creates a new Line
  64376. * @param name defines the control name
  64377. */
  64378. constructor(name?: string | undefined);
  64379. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _measure(): void;
  64380. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64381. /**
  64382. * Move one end of the line given 3D cartesian coordinates.
  64383. * @param position Targeted world position
  64384. * @param scene BABYLON.Scene
  64385. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  64386. */
  64387. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  64388. /**
  64389. * Move one end of the line to a position in screen absolute space.
  64390. * @param projectedPosition Position in screen absolute space (X, Y)
  64391. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  64392. */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  64393. }
  64394. }
  64395. declare module BABYLON.GUI {
  64396. /**
  64397. * Class used to store a point for a MultiLine object.
  64398. * The point can be pure 2D coordinates, a mesh or a control
  64399. */
  64400. export class MultiLinePoint {
  64401. private _multiLine;
  64402. private _x;
  64403. private _y;
  64404. private _control;
  64405. private _mesh;
  64406. private _controlObserver;
  64407. private _meshObserver;
  64408. /** @hidden */ private _point: BABYLON.Vector2;
  64409. /**
  64410. * Creates a new MultiLinePoint
  64411. * @param multiLine defines the source MultiLine object
  64412. */
  64413. constructor(multiLine: MultiLine);
  64414. /** Gets or sets x coordinate */
  64415. x: string | number;
  64416. /** Gets or sets y coordinate */
  64417. y: string | number;
  64418. /** Gets or sets the control associated with this point */
  64419. control: BABYLON.Nullable<Control>;
  64420. /** Gets or sets the mesh associated with this point */
  64421. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64422. /** Resets links */
  64423. resetLinks(): void;
  64424. /**
  64425. * Gets a translation vector
  64426. * @returns the translation vector
  64427. */
  64428. translate(): BABYLON.Vector2;
  64429. private _translatePoint;
  64430. /** Release associated resources */
  64431. dispose(): void;
  64432. }
  64433. }
  64434. declare module BABYLON.GUI {
  64435. /**
  64436. * Class used to create multi line control
  64437. */
  64438. export class MultiLine extends Control {
  64439. name?: string | undefined;
  64440. private _lineWidth;
  64441. private _dash;
  64442. private _points;
  64443. private _minX;
  64444. private _minY;
  64445. private _maxX;
  64446. private _maxY;
  64447. /**
  64448. * Creates a new MultiLine
  64449. * @param name defines the control name
  64450. */
  64451. constructor(name?: string | undefined);
  64452. /** Gets or sets dash pattern */
  64453. dash: Array<number>;
  64454. /**
  64455. * Gets point stored at specified index
  64456. * @param index defines the index to look for
  64457. * @returns the requested point if found
  64458. */
  64459. getAt(index: number): MultiLinePoint;
  64460. /** Function called when a point is updated */
  64461. onPointUpdate: () => void;
  64462. /**
  64463. * Adds new points to the point collection
  64464. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  64465. * @returns the list of created MultiLinePoint
  64466. */
  64467. add(...items: (AbstractMesh | Control | {
  64468. x: string | number;
  64469. y: string | number;
  64470. })[]): MultiLinePoint[];
  64471. /**
  64472. * Adds a new point to the point collection
  64473. * @param item defines the item (mesh, control or 2d coordiantes) to add
  64474. * @returns the created MultiLinePoint
  64475. */
  64476. push(item?: (AbstractMesh | Control | {
  64477. x: string | number;
  64478. y: string | number;
  64479. })): MultiLinePoint;
  64480. /**
  64481. * Remove a specific value or point from the active point collection
  64482. * @param value defines the value or point to remove
  64483. */
  64484. remove(value: number | MultiLinePoint): void;
  64485. /**
  64486. * Resets this object to initial state (no point)
  64487. */
  64488. reset(): void;
  64489. /**
  64490. * Resets all links
  64491. */
  64492. resetLinks(): void;
  64493. /** Gets or sets line width */
  64494. lineWidth: number;
  64495. horizontalAlignment: number;
  64496. verticalAlignment: number;
  64497. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  64498. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _measure(): void;
  64499. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64500. dispose(): void;
  64501. }
  64502. }
  64503. declare module BABYLON.GUI {
  64504. /**
  64505. * Class used to create radio button controls
  64506. */
  64507. export class RadioButton extends Control {
  64508. name?: string | undefined;
  64509. private _isChecked;
  64510. private _background;
  64511. private _checkSizeRatio;
  64512. private _thickness;
  64513. /** Gets or sets border thickness */
  64514. thickness: number;
  64515. /** Gets or sets group name */
  64516. group: string;
  64517. /** BABYLON.Observable raised when isChecked is changed */
  64518. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  64519. /** Gets or sets a value indicating the ratio between overall size and check size */
  64520. checkSizeRatio: number;
  64521. /** Gets or sets background color */
  64522. background: string;
  64523. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  64524. isChecked: boolean;
  64525. /**
  64526. * Creates a new RadioButton
  64527. * @param name defines the control name
  64528. */
  64529. constructor(name?: string | undefined);
  64530. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64531. /**
  64532. * Utility function to easily create a radio button with a header
  64533. * @param title defines the label to use for the header
  64534. * @param group defines the group to use for the radio button
  64535. * @param isChecked defines the initial state of the radio button
  64536. * @param onValueChanged defines the callback to call when value changes
  64537. * @returns a StackPanel containing the radio button and a textBlock
  64538. */
  64539. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  64540. }
  64541. }
  64542. declare module BABYLON.GUI {
  64543. /**
  64544. * Class used to create slider controls
  64545. */
  64546. export class BaseSlider extends Control {
  64547. name?: string | undefined;
  64548. protected _thumbWidth: ValueAndUnit;
  64549. private _minimum;
  64550. private _maximum;
  64551. private _value;
  64552. private _isVertical;
  64553. protected _barOffset: ValueAndUnit;
  64554. private _isThumbClamped;
  64555. protected _displayThumb: boolean;
  64556. private _step;
  64557. private _lastPointerDownID;
  64558. protected _effectiveBarOffset: number;
  64559. protected _renderLeft: number;
  64560. protected _renderTop: number;
  64561. protected _renderWidth: number;
  64562. protected _renderHeight: number;
  64563. protected _backgroundBoxLength: number;
  64564. protected _backgroundBoxThickness: number;
  64565. protected _effectiveThumbThickness: number;
  64566. /** BABYLON.Observable raised when the sldier value changes */
  64567. onValueChangedObservable: BABYLON.Observable<number>;
  64568. /** Gets or sets a boolean indicating if the thumb must be rendered */
  64569. displayThumb: boolean;
  64570. /** Gets or sets a step to apply to values (0 by default) */
  64571. step: number;
  64572. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  64573. barOffset: string | number;
  64574. /** Gets main bar offset in pixels*/
  64575. readonly barOffsetInPixels: number;
  64576. /** Gets or sets thumb width */
  64577. thumbWidth: string | number;
  64578. /** Gets thumb width in pixels */
  64579. readonly thumbWidthInPixels: number;
  64580. /** Gets or sets minimum value */
  64581. minimum: number;
  64582. /** Gets or sets maximum value */
  64583. maximum: number;
  64584. /** Gets or sets current value */
  64585. value: number;
  64586. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  64587. isVertical: boolean;
  64588. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  64589. isThumbClamped: boolean;
  64590. /**
  64591. * Creates a new BaseSlider
  64592. * @param name defines the control name
  64593. */
  64594. constructor(name?: string | undefined);
  64595. protected _getTypeName(): string;
  64596. protected _getThumbPosition(): number;
  64597. protected _getThumbThickness(type: string): number;
  64598. protected _prepareRenderingData(type: string): void;
  64599. private _pointerIsDown;
  64600. /** @hidden */
  64601. 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;
  64602. }
  64603. }
  64604. declare module BABYLON.GUI {
  64605. /**
  64606. * Class used to create slider controls
  64607. */
  64608. export class Slider extends BaseSlider {
  64609. name?: string | undefined;
  64610. private _background;
  64611. private _borderColor;
  64612. private _isThumbCircle;
  64613. protected _displayValueBar: boolean;
  64614. /** Gets or sets a boolean indicating if the value bar must be rendered */
  64615. displayValueBar: boolean;
  64616. /** Gets or sets border color */
  64617. borderColor: string;
  64618. /** Gets or sets background color */
  64619. background: string;
  64620. /** Gets or sets a boolean indicating if the thumb should be round or square */
  64621. isThumbCircle: boolean;
  64622. /**
  64623. * Creates a new Slider
  64624. * @param name defines the control name
  64625. */
  64626. constructor(name?: string | undefined);
  64627. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  64628. }
  64629. }
  64630. declare module BABYLON.GUI {
  64631. /** Class used to create a RadioGroup
  64632. * which contains groups of radio buttons
  64633. */
  64634. export class SelectorGroup {
  64635. /** name of SelectorGroup */
  64636. name: string;
  64637. private _groupPanel;
  64638. private _selectors;
  64639. private _groupHeader;
  64640. /**
  64641. * Creates a new SelectorGroup
  64642. * @param name of group, used as a group heading
  64643. */
  64644. constructor(
  64645. /** name of SelectorGroup */
  64646. name: string);
  64647. /** Gets the groupPanel of the SelectorGroup */
  64648. readonly groupPanel: StackPanel;
  64649. /** Gets the selectors array */
  64650. readonly selectors: StackPanel[];
  64651. /** Gets and sets the group header */
  64652. header: string;
  64653. /** @hidden */
  64654. private _addGroupHeader;
  64655. /** @hidden*/ private _getSelector(selectorNb: number): StackPanel | undefined;
  64656. /** Removes the selector at the given position
  64657. * @param selectorNb the position of the selector within the group
  64658. */
  64659. removeSelector(selectorNb: number): void;
  64660. }
  64661. /** Class used to create a CheckboxGroup
  64662. * which contains groups of checkbox buttons
  64663. */
  64664. export class CheckboxGroup extends SelectorGroup {
  64665. /** Adds a checkbox as a control
  64666. * @param text is the label for the selector
  64667. * @param func is the function called when the Selector is checked
  64668. * @param checked is true when Selector is checked
  64669. */
  64670. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  64671. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  64672. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  64673. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  64674. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64675. }
  64676. /** Class used to create a RadioGroup
  64677. * which contains groups of radio buttons
  64678. */
  64679. export class RadioGroup extends SelectorGroup {
  64680. private _selectNb;
  64681. /** Adds a radio button as a control
  64682. * @param label is the label for the selector
  64683. * @param func is the function called when the Selector is checked
  64684. * @param checked is true when Selector is checked
  64685. */
  64686. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  64687. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  64688. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  64689. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  64690. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64691. }
  64692. /** Class used to create a SliderGroup
  64693. * which contains groups of slider buttons
  64694. */
  64695. export class SliderGroup extends SelectorGroup {
  64696. /**
  64697. * Adds a slider to the SelectorGroup
  64698. * @param label is the label for the SliderBar
  64699. * @param func is the function called when the Slider moves
  64700. * @param unit is a string describing the units used, eg degrees or metres
  64701. * @param min is the minimum value for the Slider
  64702. * @param max is the maximum value for the Slider
  64703. * @param value is the start value for the Slider between min and max
  64704. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  64705. */
  64706. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  64707. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  64708. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  64709. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  64710. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64711. }
  64712. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  64713. * @see http://doc.babylonjs.com/how_to/selector
  64714. */
  64715. export class SelectionPanel extends Rectangle {
  64716. /** name of SelectionPanel */
  64717. name: string;
  64718. /** an array of SelectionGroups */
  64719. groups: SelectorGroup[];
  64720. private _panel;
  64721. private _buttonColor;
  64722. private _buttonBackground;
  64723. private _headerColor;
  64724. private _barColor;
  64725. private _barHeight;
  64726. private _spacerHeight;
  64727. private _labelColor;
  64728. private _groups;
  64729. private _bars;
  64730. /**
  64731. * Creates a new SelectionPanel
  64732. * @param name of SelectionPanel
  64733. * @param groups is an array of SelectionGroups
  64734. */
  64735. constructor(
  64736. /** name of SelectionPanel */
  64737. name: string,
  64738. /** an array of SelectionGroups */
  64739. groups?: SelectorGroup[]);
  64740. protected _getTypeName(): string;
  64741. /** Gets or sets the headerColor */
  64742. headerColor: string;
  64743. private _setHeaderColor;
  64744. /** Gets or sets the button color */
  64745. buttonColor: string;
  64746. private _setbuttonColor;
  64747. /** Gets or sets the label color */
  64748. labelColor: string;
  64749. private _setLabelColor;
  64750. /** Gets or sets the button background */
  64751. buttonBackground: string;
  64752. private _setButtonBackground;
  64753. /** Gets or sets the color of separator bar */
  64754. barColor: string;
  64755. private _setBarColor;
  64756. /** Gets or sets the height of separator bar */
  64757. barHeight: string;
  64758. private _setBarHeight;
  64759. /** Gets or sets the height of spacers*/
  64760. spacerHeight: string;
  64761. private _setSpacerHeight;
  64762. /** Adds a bar between groups */
  64763. private _addSpacer;
  64764. /** Add a group to the selection panel
  64765. * @param group is the selector group to add
  64766. */
  64767. addGroup(group: SelectorGroup): void;
  64768. /** Remove the group from the given position
  64769. * @param groupNb is the position of the group in the list
  64770. */
  64771. removeGroup(groupNb: number): void;
  64772. /** Change a group header label
  64773. * @param label is the new group header label
  64774. * @param groupNb is the number of the group to relabel
  64775. * */
  64776. setHeaderName(label: string, groupNb: number): void;
  64777. /** Change selector label to the one given
  64778. * @param label is the new selector label
  64779. * @param groupNb is the number of the groupcontaining the selector
  64780. * @param selectorNb is the number of the selector within a group to relabel
  64781. * */
  64782. relabel(label: string, groupNb: number, selectorNb: number): void;
  64783. /** For a given group position remove the selector at the given position
  64784. * @param groupNb is the number of the group to remove the selector from
  64785. * @param selectorNb is the number of the selector within the group
  64786. */
  64787. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  64788. /** For a given group position of correct type add a checkbox button
  64789. * @param groupNb is the number of the group to remove the selector from
  64790. * @param label is the label for the selector
  64791. * @param func is the function called when the Selector is checked
  64792. * @param checked is true when Selector is checked
  64793. */
  64794. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  64795. /** For a given group position of correct type add a radio button
  64796. * @param groupNb is the number of the group to remove the selector from
  64797. * @param label is the label for the selector
  64798. * @param func is the function called when the Selector is checked
  64799. * @param checked is true when Selector is checked
  64800. */
  64801. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  64802. /**
  64803. * For a given slider group add a slider
  64804. * @param groupNb is the number of the group to add the slider to
  64805. * @param label is the label for the Slider
  64806. * @param func is the function called when the Slider moves
  64807. * @param unit is a string describing the units used, eg degrees or metres
  64808. * @param min is the minimum value for the Slider
  64809. * @param max is the maximum value for the Slider
  64810. * @param value is the start value for the Slider between min and max
  64811. * @param onVal is the function used to format the value displayed, eg radians to degrees
  64812. */
  64813. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  64814. }
  64815. }
  64816. declare module BABYLON.GUI {
  64817. /**
  64818. * Class used to hold a the container for ScrollViewer
  64819. * @hidden
  64820. */
  64821. export class _ScrollViewerWindow extends Container {
  64822. parentClientWidth: number;
  64823. parentClientHeight: number;
  64824. /**
  64825. * Creates a new ScrollViewerWindow
  64826. * @param name of ScrollViewerWindow
  64827. */
  64828. constructor(name?: string);
  64829. protected _getTypeName(): string;
  64830. /** @hidden */
  64831. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64832. protected _postMeasure(): void;
  64833. }
  64834. }
  64835. declare module BABYLON.GUI {
  64836. /**
  64837. * Class used to create slider controls
  64838. */
  64839. export class ScrollBar extends BaseSlider {
  64840. name?: string | undefined;
  64841. private _background;
  64842. private _borderColor;
  64843. private _thumbMeasure;
  64844. /** Gets or sets border color */
  64845. borderColor: string;
  64846. /** Gets or sets background color */
  64847. background: string;
  64848. /**
  64849. * Creates a new Slider
  64850. * @param name defines the control name
  64851. */
  64852. constructor(name?: string | undefined);
  64853. protected _getTypeName(): string;
  64854. protected _getThumbThickness(): number; private _draw(context: CanvasRenderingContext2D): void;
  64855. private _first;
  64856. private _originX;
  64857. private _originY;
  64858. /** @hidden */
  64859. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64860. }
  64861. }
  64862. declare module BABYLON.GUI {
  64863. /**
  64864. * Class used to hold a viewer window and sliders in a grid
  64865. */
  64866. export class ScrollViewer extends Rectangle {
  64867. private _grid;
  64868. private _horizontalBarSpace;
  64869. private _verticalBarSpace;
  64870. private _dragSpace;
  64871. private _horizontalBar;
  64872. private _verticalBar;
  64873. private _barColor;
  64874. private _barBackground;
  64875. private _barSize;
  64876. private _endLeft;
  64877. private _endTop;
  64878. private _window;
  64879. private _pointerIsOver;
  64880. private _wheelPrecision;
  64881. private _onPointerObserver;
  64882. private _clientWidth;
  64883. private _clientHeight;
  64884. /**
  64885. * Gets the horizontal scrollbar
  64886. */
  64887. readonly horizontalBar: ScrollBar;
  64888. /**
  64889. * Gets the vertical scrollbar
  64890. */
  64891. readonly verticalBar: ScrollBar;
  64892. /**
  64893. * Adds a new control to the current container
  64894. * @param control defines the control to add
  64895. * @returns the current container
  64896. */
  64897. addControl(control: BABYLON.Nullable<Control>): Container;
  64898. /**
  64899. * Removes a control from the current container
  64900. * @param control defines the control to remove
  64901. * @returns the current container
  64902. */
  64903. removeControl(control: Control): Container;
  64904. /** Gets the list of children */
  64905. readonly children: Control[]; private _flagDescendantsAsMatrixDirty(): void;
  64906. /**
  64907. * Creates a new ScrollViewer
  64908. * @param name of ScrollViewer
  64909. */
  64910. constructor(name?: string);
  64911. /** Reset the scroll viewer window to initial size */
  64912. resetWindow(): void;
  64913. protected _getTypeName(): string;
  64914. private _buildClientSizes;
  64915. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64916. protected _postMeasure(): void;
  64917. /**
  64918. * Gets or sets the mouse wheel precision
  64919. * from 0 to 1 with a default value of 0.05
  64920. * */
  64921. wheelPrecision: number;
  64922. /** Gets or sets the bar color */
  64923. barColor: string;
  64924. /** Gets or sets the size of the bar */
  64925. barSize: number;
  64926. /** Gets or sets the bar background */
  64927. barBackground: string;
  64928. /** @hidden */
  64929. private _updateScroller; private _link(host: AdvancedDynamicTexture): void;
  64930. /** @hidden */
  64931. private _attachWheel; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64932. /** Releases associated resources */
  64933. dispose(): void;
  64934. }
  64935. }
  64936. declare module BABYLON.GUI {
  64937. /** Class used to render a grid */
  64938. export class DisplayGrid extends Control {
  64939. name?: string | undefined;
  64940. private _cellWidth;
  64941. private _cellHeight;
  64942. private _minorLineTickness;
  64943. private _minorLineColor;
  64944. private _majorLineTickness;
  64945. private _majorLineColor;
  64946. private _majorLineFrequency;
  64947. private _background;
  64948. private _displayMajorLines;
  64949. private _displayMinorLines;
  64950. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  64951. displayMinorLines: boolean;
  64952. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  64953. displayMajorLines: boolean;
  64954. /** Gets or sets background color (Black by default) */
  64955. background: string;
  64956. /** Gets or sets the width of each cell (20 by default) */
  64957. cellWidth: number;
  64958. /** Gets or sets the height of each cell (20 by default) */
  64959. cellHeight: number;
  64960. /** Gets or sets the tickness of minor lines (1 by default) */
  64961. minorLineTickness: number;
  64962. /** Gets or sets the color of minor lines (DarkGray by default) */
  64963. minorLineColor: string;
  64964. /** Gets or sets the tickness of major lines (2 by default) */
  64965. majorLineTickness: number;
  64966. /** Gets or sets the color of major lines (White by default) */
  64967. majorLineColor: string;
  64968. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  64969. majorLineFrequency: number;
  64970. /**
  64971. * Creates a new GridDisplayRectangle
  64972. * @param name defines the control name
  64973. */
  64974. constructor(name?: string | undefined); private _draw(context: CanvasRenderingContext2D): void;
  64975. protected _getTypeName(): string;
  64976. }
  64977. }
  64978. declare module BABYLON.GUI {
  64979. /**
  64980. * Class used to create slider controls based on images
  64981. */
  64982. export class ImageBasedSlider extends BaseSlider {
  64983. name?: string | undefined;
  64984. private _backgroundImage;
  64985. private _thumbImage;
  64986. private _valueBarImage;
  64987. private _tempMeasure;
  64988. displayThumb: boolean;
  64989. /**
  64990. * Gets or sets the image used to render the background
  64991. */
  64992. backgroundImage: Image;
  64993. /**
  64994. * Gets or sets the image used to render the value bar
  64995. */
  64996. valueBarImage: Image;
  64997. /**
  64998. * Gets or sets the image used to render the thumb
  64999. */
  65000. thumbImage: Image;
  65001. /**
  65002. * Creates a new ImageBasedSlider
  65003. * @param name defines the control name
  65004. */
  65005. constructor(name?: string | undefined);
  65006. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  65007. }
  65008. }
  65009. declare module BABYLON.GUI {
  65010. /**
  65011. * Forcing an export so that this code will execute
  65012. * @hidden
  65013. */
  65014. const name = "Statics";
  65015. }
  65016. declare module BABYLON.GUI {
  65017. /**
  65018. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  65019. */
  65020. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  65021. /**
  65022. * Define the instrumented AdvancedDynamicTexture.
  65023. */
  65024. texture: AdvancedDynamicTexture;
  65025. private _captureRenderTime;
  65026. private _renderTime;
  65027. private _captureLayoutTime;
  65028. private _layoutTime;
  65029. private _onBeginRenderObserver;
  65030. private _onEndRenderObserver;
  65031. private _onBeginLayoutObserver;
  65032. private _onEndLayoutObserver;
  65033. /**
  65034. * Gets the perf counter used to capture render time
  65035. */
  65036. readonly renderTimeCounter: BABYLON.PerfCounter;
  65037. /**
  65038. * Gets the perf counter used to capture layout time
  65039. */
  65040. readonly layoutTimeCounter: BABYLON.PerfCounter;
  65041. /**
  65042. * Enable or disable the render time capture
  65043. */
  65044. captureRenderTime: boolean;
  65045. /**
  65046. * Enable or disable the layout time capture
  65047. */
  65048. captureLayoutTime: boolean;
  65049. /**
  65050. * Instantiates a new advanced dynamic texture instrumentation.
  65051. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  65052. * @param texture Defines the AdvancedDynamicTexture to instrument
  65053. */
  65054. constructor(
  65055. /**
  65056. * Define the instrumented AdvancedDynamicTexture.
  65057. */
  65058. texture: AdvancedDynamicTexture);
  65059. /**
  65060. * Dispose and release associated resources.
  65061. */
  65062. dispose(): void;
  65063. }
  65064. }
  65065. declare module BABYLON.GUI {
  65066. /**
  65067. * Class used to load GUI via XML.
  65068. */
  65069. export class XmlLoader {
  65070. private _nodes;
  65071. private _nodeTypes;
  65072. private _isLoaded;
  65073. private _objectAttributes;
  65074. private _parentClass;
  65075. /**
  65076. * Create a new xml loader
  65077. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  65078. */
  65079. constructor(parentClass?: null);
  65080. private _getChainElement;
  65081. private _getClassAttribute;
  65082. private _createGuiElement;
  65083. private _parseGrid;
  65084. private _parseElement;
  65085. private _prepareSourceElement;
  65086. private _parseElementsFromSource;
  65087. private _parseXml;
  65088. /**
  65089. * Gets if the loading has finished.
  65090. * @returns whether the loading has finished or not
  65091. */
  65092. isLoaded(): boolean;
  65093. /**
  65094. * Gets a loaded node / control by id.
  65095. * @param id the Controls id set in the xml
  65096. * @returns element of type Control
  65097. */
  65098. getNodeById(id: string): any;
  65099. /**
  65100. * Gets all loaded nodes / controls
  65101. * @returns Array of controls
  65102. */
  65103. getNodes(): any;
  65104. /**
  65105. * Initiates the xml layout loading
  65106. * @param xmlFile defines the xml layout to load
  65107. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  65108. * @param callback defines the callback called on layout load.
  65109. */
  65110. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  65111. }
  65112. }
  65113. declare module BABYLON.GUI {
  65114. /**
  65115. * Class used to create containers for controls
  65116. */
  65117. export class Container3D extends Control3D {
  65118. private _blockLayout;
  65119. /**
  65120. * Gets the list of child controls
  65121. */
  65122. protected _children: Control3D[];
  65123. /**
  65124. * Gets the list of child controls
  65125. */
  65126. readonly children: Array<Control3D>;
  65127. /**
  65128. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  65129. * This is helpful to optimize layout operation when adding multiple children in a row
  65130. */
  65131. blockLayout: boolean;
  65132. /**
  65133. * Creates a new container
  65134. * @param name defines the container name
  65135. */
  65136. constructor(name?: string);
  65137. /**
  65138. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  65139. * @returns the current container
  65140. */
  65141. updateLayout(): Container3D;
  65142. /**
  65143. * Gets a boolean indicating if the given control is in the children of this control
  65144. * @param control defines the control to check
  65145. * @returns true if the control is in the child list
  65146. */
  65147. containsControl(control: Control3D): boolean;
  65148. /**
  65149. * Adds a control to the children of this control
  65150. * @param control defines the control to add
  65151. * @returns the current container
  65152. */
  65153. addControl(control: Control3D): Container3D;
  65154. /**
  65155. * This function will be called everytime a new control is added
  65156. */
  65157. protected _arrangeChildren(): void;
  65158. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65159. /**
  65160. * Removes a control from the children of this control
  65161. * @param control defines the control to remove
  65162. * @returns the current container
  65163. */
  65164. removeControl(control: Control3D): Container3D;
  65165. protected _getTypeName(): string;
  65166. /**
  65167. * Releases all associated resources
  65168. */
  65169. dispose(): void;
  65170. /** Control rotation will remain unchanged */
  65171. static readonly UNSET_ORIENTATION: number;
  65172. /** Control will rotate to make it look at sphere central axis */
  65173. static readonly FACEORIGIN_ORIENTATION: number;
  65174. /** Control will rotate to make it look back at sphere central axis */
  65175. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  65176. /** Control will rotate to look at z axis (0, 0, 1) */
  65177. static readonly FACEFORWARD_ORIENTATION: number;
  65178. /** Control will rotate to look at negative z axis (0, 0, -1) */
  65179. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  65180. }
  65181. }
  65182. declare module BABYLON.GUI {
  65183. /**
  65184. * Class used to manage 3D user interface
  65185. * @see http://doc.babylonjs.com/how_to/gui3d
  65186. */
  65187. export class GUI3DManager implements BABYLON.IDisposable {
  65188. private _scene;
  65189. private _sceneDisposeObserver;
  65190. private _utilityLayer;
  65191. private _rootContainer;
  65192. private _pointerObserver;
  65193. private _pointerOutObserver;
  65194. /** @hidden */ private _lastPickedControl: Control3D;
  65195. /** @hidden */ private _lastControlOver: {
  65196. [pointerId: number]: Control3D;
  65197. };
  65198. /** @hidden */ private _lastControlDown: {
  65199. [pointerId: number]: Control3D;
  65200. };
  65201. /**
  65202. * BABYLON.Observable raised when the point picked by the pointer events changed
  65203. */
  65204. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  65205. /** @hidden */ private _sharedMaterials: {
  65206. [key: string]: BABYLON.Material;
  65207. };
  65208. /** Gets the hosting scene */
  65209. readonly scene: BABYLON.Scene;
  65210. /** Gets associated utility layer */
  65211. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  65212. /**
  65213. * Creates a new GUI3DManager
  65214. * @param scene
  65215. */
  65216. constructor(scene?: BABYLON.Scene);
  65217. private _handlePointerOut;
  65218. private _doPicking;
  65219. /**
  65220. * Gets the root container
  65221. */
  65222. readonly rootContainer: Container3D;
  65223. /**
  65224. * Gets a boolean indicating if the given control is in the root child list
  65225. * @param control defines the control to check
  65226. * @returns true if the control is in the root child list
  65227. */
  65228. containsControl(control: Control3D): boolean;
  65229. /**
  65230. * Adds a control to the root child list
  65231. * @param control defines the control to add
  65232. * @returns the current manager
  65233. */
  65234. addControl(control: Control3D): GUI3DManager;
  65235. /**
  65236. * Removes a control from the root child list
  65237. * @param control defines the control to remove
  65238. * @returns the current container
  65239. */
  65240. removeControl(control: Control3D): GUI3DManager;
  65241. /**
  65242. * Releases all associated resources
  65243. */
  65244. dispose(): void;
  65245. }
  65246. }
  65247. declare module BABYLON.GUI {
  65248. /**
  65249. * Class used to transport BABYLON.Vector3 information for pointer events
  65250. */
  65251. export class Vector3WithInfo extends BABYLON.Vector3 {
  65252. /** defines the current mouse button index */
  65253. buttonIndex: number;
  65254. /**
  65255. * Creates a new Vector3WithInfo
  65256. * @param source defines the vector3 data to transport
  65257. * @param buttonIndex defines the current mouse button index
  65258. */
  65259. constructor(source: BABYLON.Vector3,
  65260. /** defines the current mouse button index */
  65261. buttonIndex?: number);
  65262. }
  65263. }
  65264. declare module BABYLON.GUI {
  65265. /**
  65266. * Class used as base class for controls
  65267. */
  65268. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  65269. /** Defines the control name */
  65270. name?: string | undefined;
  65271. /** @hidden */ private _host: GUI3DManager;
  65272. private _node;
  65273. private _downCount;
  65274. private _enterCount;
  65275. private _downPointerIds;
  65276. private _isVisible;
  65277. /** Gets or sets the control position in world space */
  65278. position: BABYLON.Vector3;
  65279. /** Gets or sets the control scaling in world space */
  65280. scaling: BABYLON.Vector3;
  65281. /** Callback used to start pointer enter animation */
  65282. pointerEnterAnimation: () => void;
  65283. /** Callback used to start pointer out animation */
  65284. pointerOutAnimation: () => void;
  65285. /** Callback used to start pointer down animation */
  65286. pointerDownAnimation: () => void;
  65287. /** Callback used to start pointer up animation */
  65288. pointerUpAnimation: () => void;
  65289. /**
  65290. * An event triggered when the pointer move over the control
  65291. */
  65292. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  65293. /**
  65294. * An event triggered when the pointer move out of the control
  65295. */
  65296. onPointerOutObservable: BABYLON.Observable<Control3D>;
  65297. /**
  65298. * An event triggered when the pointer taps the control
  65299. */
  65300. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  65301. /**
  65302. * An event triggered when pointer is up
  65303. */
  65304. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  65305. /**
  65306. * An event triggered when a control is clicked on (with a mouse)
  65307. */
  65308. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  65309. /**
  65310. * An event triggered when pointer enters the control
  65311. */
  65312. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  65313. /**
  65314. * Gets or sets the parent container
  65315. */
  65316. parent: BABYLON.Nullable<Container3D>;
  65317. private _behaviors;
  65318. /**
  65319. * Gets the list of attached behaviors
  65320. * @see http://doc.babylonjs.com/features/behaviour
  65321. */
  65322. readonly behaviors: BABYLON.Behavior<Control3D>[];
  65323. /**
  65324. * Attach a behavior to the control
  65325. * @see http://doc.babylonjs.com/features/behaviour
  65326. * @param behavior defines the behavior to attach
  65327. * @returns the current control
  65328. */
  65329. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65330. /**
  65331. * Remove an attached behavior
  65332. * @see http://doc.babylonjs.com/features/behaviour
  65333. * @param behavior defines the behavior to attach
  65334. * @returns the current control
  65335. */
  65336. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65337. /**
  65338. * Gets an attached behavior by name
  65339. * @param name defines the name of the behavior to look for
  65340. * @see http://doc.babylonjs.com/features/behaviour
  65341. * @returns null if behavior was not found else the requested behavior
  65342. */
  65343. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  65344. /** Gets or sets a boolean indicating if the control is visible */
  65345. isVisible: boolean;
  65346. /**
  65347. * Creates a new control
  65348. * @param name defines the control name
  65349. */
  65350. constructor(
  65351. /** Defines the control name */
  65352. name?: string | undefined);
  65353. /**
  65354. * Gets a string representing the class name
  65355. */
  65356. readonly typeName: string;
  65357. /**
  65358. * Get the current class name of the control.
  65359. * @returns current class name
  65360. */
  65361. getClassName(): string;
  65362. protected _getTypeName(): string;
  65363. /**
  65364. * Gets the transform node used by this control
  65365. */
  65366. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  65367. /**
  65368. * Gets the mesh used to render this control
  65369. */
  65370. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65371. /**
  65372. * Link the control as child of the given node
  65373. * @param node defines the node to link to. Use null to unlink the control
  65374. * @returns the current control
  65375. */
  65376. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  65377. /** @hidden **/ private _prepareNode(scene: BABYLON.Scene): void;
  65378. /**
  65379. * Node creation.
  65380. * Can be overriden by children
  65381. * @param scene defines the scene where the node must be attached
  65382. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  65383. */
  65384. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65385. /**
  65386. * Affect a material to the given mesh
  65387. * @param mesh defines the mesh which will represent the control
  65388. */
  65389. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65390. /** @hidden */ private _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  65391. /** @hidden */ private _onPointerEnter(target: Control3D): boolean;
  65392. /** @hidden */ private _onPointerOut(target: Control3D): void;
  65393. /** @hidden */ private _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  65394. /** @hidden */ private _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65395. /** @hidden */
  65396. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  65397. /** @hidden */ private _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  65398. /** @hidden */ private _disposeNode(): void;
  65399. /**
  65400. * Releases all associated resources
  65401. */
  65402. dispose(): void;
  65403. }
  65404. }
  65405. declare module BABYLON.GUI {
  65406. /**
  65407. * Class used as a root to all buttons
  65408. */
  65409. export class AbstractButton3D extends Control3D {
  65410. /**
  65411. * Creates a new button
  65412. * @param name defines the control name
  65413. */
  65414. constructor(name?: string);
  65415. protected _getTypeName(): string;
  65416. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65417. }
  65418. }
  65419. declare module BABYLON.GUI {
  65420. /**
  65421. * Class used to create a button in 3D
  65422. */
  65423. export class Button3D extends AbstractButton3D {
  65424. /** @hidden */
  65425. protected _currentMaterial: BABYLON.Material;
  65426. private _facadeTexture;
  65427. private _content;
  65428. private _contentResolution;
  65429. private _contentScaleRatio;
  65430. /**
  65431. * Gets or sets the texture resolution used to render content (512 by default)
  65432. */
  65433. contentResolution: BABYLON.int;
  65434. /**
  65435. * Gets or sets the texture scale ratio used to render content (2 by default)
  65436. */
  65437. contentScaleRatio: number;
  65438. protected _disposeFacadeTexture(): void;
  65439. protected _resetContent(): void;
  65440. /**
  65441. * Creates a new button
  65442. * @param name defines the control name
  65443. */
  65444. constructor(name?: string);
  65445. /**
  65446. * Gets or sets the GUI 2D content used to display the button's facade
  65447. */
  65448. content: Control;
  65449. /**
  65450. * Apply the facade texture (created from the content property).
  65451. * This function can be overloaded by child classes
  65452. * @param facadeTexture defines the AdvancedDynamicTexture to use
  65453. */
  65454. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  65455. protected _getTypeName(): string;
  65456. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65457. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65458. /**
  65459. * Releases all associated resources
  65460. */
  65461. dispose(): void;
  65462. }
  65463. }
  65464. declare module BABYLON.GUI {
  65465. /**
  65466. * Abstract class used to create a container panel deployed on the surface of a volume
  65467. */
  65468. export abstract class VolumeBasedPanel extends Container3D {
  65469. private _columns;
  65470. private _rows;
  65471. private _rowThenColum;
  65472. private _orientation;
  65473. protected _cellWidth: number;
  65474. protected _cellHeight: number;
  65475. /**
  65476. * Gets or sets the distance between elements
  65477. */
  65478. margin: number;
  65479. /**
  65480. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  65481. * | Value | Type | Description |
  65482. * | ----- | ----------------------------------- | ----------- |
  65483. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  65484. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  65485. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  65486. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  65487. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  65488. */
  65489. orientation: number;
  65490. /**
  65491. * Gets or sets the number of columns requested (10 by default).
  65492. * The panel will automatically compute the number of rows based on number of child controls.
  65493. */
  65494. columns: BABYLON.int;
  65495. /**
  65496. * Gets or sets a the number of rows requested.
  65497. * The panel will automatically compute the number of columns based on number of child controls.
  65498. */
  65499. rows: BABYLON.int;
  65500. /**
  65501. * Creates new VolumeBasedPanel
  65502. */
  65503. constructor();
  65504. protected _arrangeChildren(): void;
  65505. /** Child classes must implement this function to provide correct control positioning */
  65506. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65507. /** Child classes can implement this function to provide additional processing */
  65508. protected _finalProcessing(): void;
  65509. }
  65510. }
  65511. declare module BABYLON.GUI {
  65512. /**
  65513. * Class used to create a container panel deployed on the surface of a cylinder
  65514. */
  65515. export class CylinderPanel extends VolumeBasedPanel {
  65516. private _radius;
  65517. /**
  65518. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  65519. */
  65520. radius: BABYLON.float;
  65521. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65522. private _cylindricalMapping;
  65523. }
  65524. }
  65525. declare module BABYLON.GUI {
  65526. /** @hidden */
  65527. export var fluentVertexShader: {
  65528. name: string;
  65529. shader: string;
  65530. };
  65531. }
  65532. declare module BABYLON.GUI {
  65533. /** @hidden */
  65534. export var fluentPixelShader: {
  65535. name: string;
  65536. shader: string;
  65537. };
  65538. }
  65539. declare module BABYLON.GUI {
  65540. /** @hidden */
  65541. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  65542. INNERGLOW: boolean;
  65543. BORDER: boolean;
  65544. HOVERLIGHT: boolean;
  65545. TEXTURE: boolean;
  65546. constructor();
  65547. }
  65548. /**
  65549. * Class used to render controls with fluent desgin
  65550. */
  65551. export class FluentMaterial extends BABYLON.PushMaterial {
  65552. /**
  65553. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  65554. */
  65555. innerGlowColorIntensity: number;
  65556. /**
  65557. * Gets or sets the inner glow color (white by default)
  65558. */
  65559. innerGlowColor: BABYLON.Color3;
  65560. /**
  65561. * Gets or sets alpha value (default is 1.0)
  65562. */
  65563. alpha: number;
  65564. /**
  65565. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  65566. */
  65567. albedoColor: BABYLON.Color3;
  65568. /**
  65569. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  65570. */
  65571. renderBorders: boolean;
  65572. /**
  65573. * Gets or sets border width (default is 0.5)
  65574. */
  65575. borderWidth: number;
  65576. /**
  65577. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  65578. */
  65579. edgeSmoothingValue: number;
  65580. /**
  65581. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  65582. */
  65583. borderMinValue: number;
  65584. /**
  65585. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  65586. */
  65587. renderHoverLight: boolean;
  65588. /**
  65589. * Gets or sets the radius used to render the hover light (default is 1.0)
  65590. */
  65591. hoverRadius: number;
  65592. /**
  65593. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  65594. */
  65595. hoverColor: BABYLON.Color4;
  65596. /**
  65597. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  65598. */
  65599. hoverPosition: BABYLON.Vector3;
  65600. private _albedoTexture;
  65601. /** Gets or sets the texture to use for albedo color */
  65602. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  65603. /**
  65604. * Creates a new Fluent material
  65605. * @param name defines the name of the material
  65606. * @param scene defines the hosting scene
  65607. */
  65608. constructor(name: string, scene: BABYLON.Scene);
  65609. needAlphaBlending(): boolean;
  65610. needAlphaTesting(): boolean;
  65611. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  65612. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65613. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  65614. getActiveTextures(): BABYLON.BaseTexture[];
  65615. hasTexture(texture: BABYLON.BaseTexture): boolean;
  65616. dispose(forceDisposeEffect?: boolean): void;
  65617. clone(name: string): FluentMaterial;
  65618. serialize(): any;
  65619. getClassName(): string;
  65620. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  65621. }
  65622. }
  65623. declare module BABYLON.GUI {
  65624. /**
  65625. * Class used to create a holographic button in 3D
  65626. */
  65627. export class HolographicButton extends Button3D {
  65628. private _backPlate;
  65629. private _textPlate;
  65630. private _frontPlate;
  65631. private _text;
  65632. private _imageUrl;
  65633. private _shareMaterials;
  65634. private _frontMaterial;
  65635. private _backMaterial;
  65636. private _plateMaterial;
  65637. private _pickedPointObserver;
  65638. private _tooltipFade;
  65639. private _tooltipTextBlock;
  65640. private _tooltipTexture;
  65641. private _tooltipMesh;
  65642. private _tooltipHoverObserver;
  65643. private _tooltipOutObserver;
  65644. private _disposeTooltip;
  65645. /**
  65646. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  65647. */
  65648. tooltipText: BABYLON.Nullable<string>;
  65649. /**
  65650. * Gets or sets text for the button
  65651. */
  65652. text: string;
  65653. /**
  65654. * Gets or sets the image url for the button
  65655. */
  65656. imageUrl: string;
  65657. /**
  65658. * Gets the back material used by this button
  65659. */
  65660. readonly backMaterial: FluentMaterial;
  65661. /**
  65662. * Gets the front material used by this button
  65663. */
  65664. readonly frontMaterial: FluentMaterial;
  65665. /**
  65666. * Gets the plate material used by this button
  65667. */
  65668. readonly plateMaterial: BABYLON.StandardMaterial;
  65669. /**
  65670. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  65671. */
  65672. readonly shareMaterials: boolean;
  65673. /**
  65674. * Creates a new button
  65675. * @param name defines the control name
  65676. */
  65677. constructor(name?: string, shareMaterials?: boolean);
  65678. protected _getTypeName(): string;
  65679. private _rebuildContent;
  65680. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65681. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  65682. private _createBackMaterial;
  65683. private _createFrontMaterial;
  65684. private _createPlateMaterial;
  65685. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  65686. /**
  65687. * Releases all associated resources
  65688. */
  65689. dispose(): void;
  65690. }
  65691. }
  65692. declare module BABYLON.GUI {
  65693. /**
  65694. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  65695. */
  65696. export class MeshButton3D extends Button3D {
  65697. /** @hidden */
  65698. protected _currentMesh: BABYLON.Mesh;
  65699. /**
  65700. * Creates a new 3D button based on a mesh
  65701. * @param mesh mesh to become a 3D button
  65702. * @param name defines the control name
  65703. */
  65704. constructor(mesh: BABYLON.Mesh, name?: string);
  65705. protected _getTypeName(): string;
  65706. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65707. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65708. }
  65709. }
  65710. declare module BABYLON.GUI {
  65711. /**
  65712. * Class used to create a container panel deployed on the surface of a plane
  65713. */
  65714. export class PlanePanel extends VolumeBasedPanel {
  65715. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65716. }
  65717. }
  65718. declare module BABYLON.GUI {
  65719. /**
  65720. * Class used to create a container panel where items get randomized planar mapping
  65721. */
  65722. export class ScatterPanel extends VolumeBasedPanel {
  65723. private _iteration;
  65724. /**
  65725. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  65726. */
  65727. iteration: BABYLON.float;
  65728. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65729. private _scatterMapping;
  65730. protected _finalProcessing(): void;
  65731. }
  65732. }
  65733. declare module BABYLON.GUI {
  65734. /**
  65735. * Class used to create a container panel deployed on the surface of a sphere
  65736. */
  65737. export class SpherePanel extends VolumeBasedPanel {
  65738. private _radius;
  65739. /**
  65740. * Gets or sets the radius of the sphere where to project controls (5 by default)
  65741. */
  65742. radius: BABYLON.float;
  65743. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65744. private _sphericalMapping;
  65745. }
  65746. }
  65747. declare module BABYLON.GUI {
  65748. /**
  65749. * Class used to create a stack panel in 3D on XY plane
  65750. */
  65751. export class StackPanel3D extends Container3D {
  65752. private _isVertical;
  65753. /**
  65754. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  65755. */
  65756. isVertical: boolean;
  65757. /**
  65758. * Gets or sets the distance between elements
  65759. */
  65760. margin: number;
  65761. /**
  65762. * Creates new StackPanel
  65763. * @param isVertical
  65764. */
  65765. constructor(isVertical?: boolean);
  65766. protected _arrangeChildren(): void;
  65767. }
  65768. }
  65769. declare module BABYLON {
  65770. /**
  65771. * Mode that determines the coordinate system to use.
  65772. */
  65773. export enum GLTFLoaderCoordinateSystemMode {
  65774. /**
  65775. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  65776. */
  65777. AUTO = 0,
  65778. /**
  65779. * Sets the useRightHandedSystem flag on the scene.
  65780. */
  65781. FORCE_RIGHT_HANDED = 1
  65782. }
  65783. /**
  65784. * Mode that determines what animations will start.
  65785. */
  65786. export enum GLTFLoaderAnimationStartMode {
  65787. /**
  65788. * No animation will start.
  65789. */
  65790. NONE = 0,
  65791. /**
  65792. * The first animation will start.
  65793. */
  65794. FIRST = 1,
  65795. /**
  65796. * All animations will start.
  65797. */
  65798. ALL = 2
  65799. }
  65800. /**
  65801. * Interface that contains the data for the glTF asset.
  65802. */
  65803. export interface IGLTFLoaderData {
  65804. /**
  65805. * Object that represents the glTF JSON.
  65806. */
  65807. json: Object;
  65808. /**
  65809. * The BIN chunk of a binary glTF.
  65810. */
  65811. bin: Nullable<ArrayBufferView>;
  65812. }
  65813. /**
  65814. * Interface for extending the loader.
  65815. */
  65816. export interface IGLTFLoaderExtension {
  65817. /**
  65818. * The name of this extension.
  65819. */
  65820. readonly name: string;
  65821. /**
  65822. * Defines whether this extension is enabled.
  65823. */
  65824. enabled: boolean;
  65825. }
  65826. /**
  65827. * Loader state.
  65828. */
  65829. export enum GLTFLoaderState {
  65830. /**
  65831. * The asset is loading.
  65832. */
  65833. LOADING = 0,
  65834. /**
  65835. * The asset is ready for rendering.
  65836. */
  65837. READY = 1,
  65838. /**
  65839. * The asset is completely loaded.
  65840. */
  65841. COMPLETE = 2
  65842. }
  65843. /** @hidden */
  65844. export interface IGLTFLoader extends IDisposable {
  65845. readonly state: Nullable<GLTFLoaderState>;
  65846. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  65847. meshes: AbstractMesh[];
  65848. particleSystems: IParticleSystem[];
  65849. skeletons: Skeleton[];
  65850. animationGroups: AnimationGroup[];
  65851. }>;
  65852. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  65853. }
  65854. /**
  65855. * File loader for loading glTF files into a scene.
  65856. */
  65857. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  65858. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  65859. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  65860. /**
  65861. * Raised when the asset has been parsed
  65862. */
  65863. onParsedObservable: Observable<IGLTFLoaderData>;
  65864. private _onParsedObserver;
  65865. /**
  65866. * Raised when the asset has been parsed
  65867. */
  65868. onParsed: (loaderData: IGLTFLoaderData) => void;
  65869. /**
  65870. * 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.
  65871. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  65872. * Defaults to true.
  65873. * @hidden
  65874. */
  65875. static IncrementalLoading: boolean;
  65876. /**
  65877. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  65878. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  65879. * @hidden
  65880. */
  65881. static HomogeneousCoordinates: boolean;
  65882. /**
  65883. * The coordinate system mode. Defaults to AUTO.
  65884. */
  65885. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  65886. /**
  65887. * The animation start mode. Defaults to FIRST.
  65888. */
  65889. animationStartMode: GLTFLoaderAnimationStartMode;
  65890. /**
  65891. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  65892. */
  65893. compileMaterials: boolean;
  65894. /**
  65895. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  65896. */
  65897. useClipPlane: boolean;
  65898. /**
  65899. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  65900. */
  65901. compileShadowGenerators: boolean;
  65902. /**
  65903. * Defines if the Alpha blended materials are only applied as coverage.
  65904. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  65905. * If true, no extra effects are applied to transparent pixels.
  65906. */
  65907. transparencyAsCoverage: boolean;
  65908. /**
  65909. * Function called before loading a url referenced by the asset.
  65910. */
  65911. preprocessUrlAsync: (url: string) => Promise<string>;
  65912. /**
  65913. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  65914. */
  65915. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  65916. private _onMeshLoadedObserver;
  65917. /**
  65918. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  65919. */
  65920. onMeshLoaded: (mesh: AbstractMesh) => void;
  65921. /**
  65922. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  65923. */
  65924. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  65925. private _onTextureLoadedObserver;
  65926. /**
  65927. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  65928. */
  65929. onTextureLoaded: (texture: BaseTexture) => void;
  65930. /**
  65931. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  65932. */
  65933. readonly onMaterialLoadedObservable: Observable<Material>;
  65934. private _onMaterialLoadedObserver;
  65935. /**
  65936. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  65937. */
  65938. onMaterialLoaded: (material: Material) => void;
  65939. /**
  65940. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  65941. */
  65942. readonly onCameraLoadedObservable: Observable<Camera>;
  65943. private _onCameraLoadedObserver;
  65944. /**
  65945. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  65946. */
  65947. onCameraLoaded: (camera: Camera) => void;
  65948. /**
  65949. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  65950. * For assets with LODs, raised when all of the LODs are complete.
  65951. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  65952. */
  65953. readonly onCompleteObservable: Observable<void>;
  65954. private _onCompleteObserver;
  65955. /**
  65956. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  65957. * For assets with LODs, raised when all of the LODs are complete.
  65958. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  65959. */
  65960. onComplete: () => void;
  65961. /**
  65962. * Observable raised when an error occurs.
  65963. */
  65964. readonly onErrorObservable: Observable<any>;
  65965. private _onErrorObserver;
  65966. /**
  65967. * Callback raised when an error occurs.
  65968. */
  65969. onError: (reason: any) => void;
  65970. /**
  65971. * Observable raised after the loader is disposed.
  65972. */
  65973. readonly onDisposeObservable: Observable<void>;
  65974. private _onDisposeObserver;
  65975. /**
  65976. * Callback raised after the loader is disposed.
  65977. */
  65978. onDispose: () => void;
  65979. /**
  65980. * Observable raised after a loader extension is created.
  65981. * Set additional options for a loader extension in this event.
  65982. */
  65983. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  65984. private _onExtensionLoadedObserver;
  65985. /**
  65986. * Callback raised after a loader extension is created.
  65987. */
  65988. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  65989. /**
  65990. * Defines if the loader logging is enabled.
  65991. */
  65992. loggingEnabled: boolean;
  65993. /**
  65994. * Defines if the loader should capture performance counters.
  65995. */
  65996. capturePerformanceCounters: boolean;
  65997. /**
  65998. * Defines if the loader should validate the asset.
  65999. */
  66000. validate: boolean;
  66001. /**
  66002. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  66003. */
  66004. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  66005. private _onValidatedObserver;
  66006. /**
  66007. * Callback raised after a loader extension is created.
  66008. */
  66009. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  66010. private _loader;
  66011. /**
  66012. * Name of the loader ("gltf")
  66013. */
  66014. name: string;
  66015. /**
  66016. * Supported file extensions of the loader (.gltf, .glb)
  66017. */
  66018. extensions: ISceneLoaderPluginExtensions;
  66019. /**
  66020. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  66021. */
  66022. dispose(): void;
  66023. /** @hidden */ private _clear(): void;
  66024. /**
  66025. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  66026. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66027. * @param scene the scene the meshes should be added to
  66028. * @param data the glTF data to load
  66029. * @param rootUrl root url to load from
  66030. * @param onProgress event that fires when loading progress has occured
  66031. * @param fileName Defines the name of the file to load
  66032. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66033. */
  66034. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66035. meshes: AbstractMesh[];
  66036. particleSystems: IParticleSystem[];
  66037. skeletons: Skeleton[];
  66038. animationGroups: AnimationGroup[];
  66039. }>;
  66040. /**
  66041. * Imports all objects from the loaded glTF data and adds them to the scene
  66042. * @param scene the scene the objects should be added to
  66043. * @param data the glTF data to load
  66044. * @param rootUrl root url to load from
  66045. * @param onProgress event that fires when loading progress has occured
  66046. * @param fileName Defines the name of the file to load
  66047. * @returns a promise which completes when objects have been loaded to the scene
  66048. */
  66049. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66050. /**
  66051. * Load into an asset container.
  66052. * @param scene The scene to load into
  66053. * @param data The data to import
  66054. * @param rootUrl The root url for scene and resources
  66055. * @param onProgress The callback when the load progresses
  66056. * @param fileName Defines the name of the file to load
  66057. * @returns The loaded asset container
  66058. */
  66059. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  66060. /**
  66061. * If the data string can be loaded directly.
  66062. * @param data string contianing the file data
  66063. * @returns if the data can be loaded directly
  66064. */
  66065. canDirectLoad(data: string): boolean;
  66066. /**
  66067. * Rewrites a url by combining a root url and response url.
  66068. */
  66069. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  66070. /**
  66071. * Instantiates a glTF file loader plugin.
  66072. * @returns the created plugin
  66073. */
  66074. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  66075. /**
  66076. * The loader state or null if the loader is not active.
  66077. */
  66078. readonly loaderState: Nullable<GLTFLoaderState>;
  66079. /**
  66080. * Returns a promise that resolves when the asset is completely loaded.
  66081. * @returns a promise that resolves when the asset is completely loaded.
  66082. */
  66083. whenCompleteAsync(): Promise<void>;
  66084. private _parseAsync;
  66085. private _validateAsync;
  66086. private _getLoader;
  66087. private _unpackBinary;
  66088. private _unpackBinaryV1;
  66089. private _unpackBinaryV2;
  66090. private static _parseVersion;
  66091. private static _compareVersion;
  66092. private static _decodeBufferToText;
  66093. private static readonly _logSpaces;
  66094. private _logIndentLevel;
  66095. private _loggingEnabled;
  66096. /** @hidden */ private _log: (message: string) => void;
  66097. /** @hidden */ private _logOpen(message: string): void;
  66098. /** @hidden */ private _logClose(): void;
  66099. private _logEnabled;
  66100. private _logDisabled;
  66101. private _capturePerformanceCounters;
  66102. /** @hidden */ private _startPerformanceCounter: (counterName: string) => void;
  66103. /** @hidden */ private _endPerformanceCounter: (counterName: string) => void;
  66104. private _startPerformanceCounterEnabled;
  66105. private _startPerformanceCounterDisabled;
  66106. private _endPerformanceCounterEnabled;
  66107. private _endPerformanceCounterDisabled;
  66108. }
  66109. }
  66110. declare module BABYLON.GLTF1 {
  66111. /**
  66112. * Enums
  66113. * @hidden
  66114. */
  66115. export enum EComponentType {
  66116. BYTE = 5120,
  66117. UNSIGNED_BYTE = 5121,
  66118. SHORT = 5122,
  66119. UNSIGNED_SHORT = 5123,
  66120. FLOAT = 5126
  66121. }
  66122. /** @hidden */
  66123. export enum EShaderType {
  66124. FRAGMENT = 35632,
  66125. VERTEX = 35633
  66126. }
  66127. /** @hidden */
  66128. export enum EParameterType {
  66129. BYTE = 5120,
  66130. UNSIGNED_BYTE = 5121,
  66131. SHORT = 5122,
  66132. UNSIGNED_SHORT = 5123,
  66133. INT = 5124,
  66134. UNSIGNED_INT = 5125,
  66135. FLOAT = 5126,
  66136. FLOAT_VEC2 = 35664,
  66137. FLOAT_VEC3 = 35665,
  66138. FLOAT_VEC4 = 35666,
  66139. INT_VEC2 = 35667,
  66140. INT_VEC3 = 35668,
  66141. INT_VEC4 = 35669,
  66142. BOOL = 35670,
  66143. BOOL_VEC2 = 35671,
  66144. BOOL_VEC3 = 35672,
  66145. BOOL_VEC4 = 35673,
  66146. FLOAT_MAT2 = 35674,
  66147. FLOAT_MAT3 = 35675,
  66148. FLOAT_MAT4 = 35676,
  66149. SAMPLER_2D = 35678
  66150. }
  66151. /** @hidden */
  66152. export enum ETextureWrapMode {
  66153. CLAMP_TO_EDGE = 33071,
  66154. MIRRORED_REPEAT = 33648,
  66155. REPEAT = 10497
  66156. }
  66157. /** @hidden */
  66158. export enum ETextureFilterType {
  66159. NEAREST = 9728,
  66160. LINEAR = 9728,
  66161. NEAREST_MIPMAP_NEAREST = 9984,
  66162. LINEAR_MIPMAP_NEAREST = 9985,
  66163. NEAREST_MIPMAP_LINEAR = 9986,
  66164. LINEAR_MIPMAP_LINEAR = 9987
  66165. }
  66166. /** @hidden */
  66167. export enum ETextureFormat {
  66168. ALPHA = 6406,
  66169. RGB = 6407,
  66170. RGBA = 6408,
  66171. LUMINANCE = 6409,
  66172. LUMINANCE_ALPHA = 6410
  66173. }
  66174. /** @hidden */
  66175. export enum ECullingType {
  66176. FRONT = 1028,
  66177. BACK = 1029,
  66178. FRONT_AND_BACK = 1032
  66179. }
  66180. /** @hidden */
  66181. export enum EBlendingFunction {
  66182. ZERO = 0,
  66183. ONE = 1,
  66184. SRC_COLOR = 768,
  66185. ONE_MINUS_SRC_COLOR = 769,
  66186. DST_COLOR = 774,
  66187. ONE_MINUS_DST_COLOR = 775,
  66188. SRC_ALPHA = 770,
  66189. ONE_MINUS_SRC_ALPHA = 771,
  66190. DST_ALPHA = 772,
  66191. ONE_MINUS_DST_ALPHA = 773,
  66192. CONSTANT_COLOR = 32769,
  66193. ONE_MINUS_CONSTANT_COLOR = 32770,
  66194. CONSTANT_ALPHA = 32771,
  66195. ONE_MINUS_CONSTANT_ALPHA = 32772,
  66196. SRC_ALPHA_SATURATE = 776
  66197. }
  66198. /** @hidden */
  66199. export interface IGLTFProperty {
  66200. extensions?: {
  66201. [key: string]: any;
  66202. };
  66203. extras?: Object;
  66204. }
  66205. /** @hidden */
  66206. export interface IGLTFChildRootProperty extends IGLTFProperty {
  66207. name?: string;
  66208. }
  66209. /** @hidden */
  66210. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  66211. bufferView: string;
  66212. byteOffset: number;
  66213. byteStride: number;
  66214. count: number;
  66215. type: string;
  66216. componentType: EComponentType;
  66217. max?: number[];
  66218. min?: number[];
  66219. name?: string;
  66220. }
  66221. /** @hidden */
  66222. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  66223. buffer: string;
  66224. byteOffset: number;
  66225. byteLength: number;
  66226. byteStride: number;
  66227. target?: number;
  66228. }
  66229. /** @hidden */
  66230. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  66231. uri: string;
  66232. byteLength?: number;
  66233. type?: string;
  66234. }
  66235. /** @hidden */
  66236. export interface IGLTFShader extends IGLTFChildRootProperty {
  66237. uri: string;
  66238. type: EShaderType;
  66239. }
  66240. /** @hidden */
  66241. export interface IGLTFProgram extends IGLTFChildRootProperty {
  66242. attributes: string[];
  66243. fragmentShader: string;
  66244. vertexShader: string;
  66245. }
  66246. /** @hidden */
  66247. export interface IGLTFTechniqueParameter {
  66248. type: number;
  66249. count?: number;
  66250. semantic?: string;
  66251. node?: string;
  66252. value?: number | boolean | string | Array<any>;
  66253. source?: string;
  66254. babylonValue?: any;
  66255. }
  66256. /** @hidden */
  66257. export interface IGLTFTechniqueCommonProfile {
  66258. lightingModel: string;
  66259. texcoordBindings: Object;
  66260. parameters?: Array<any>;
  66261. }
  66262. /** @hidden */
  66263. export interface IGLTFTechniqueStatesFunctions {
  66264. blendColor?: number[];
  66265. blendEquationSeparate?: number[];
  66266. blendFuncSeparate?: number[];
  66267. colorMask: boolean[];
  66268. cullFace: number[];
  66269. }
  66270. /** @hidden */
  66271. export interface IGLTFTechniqueStates {
  66272. enable: number[];
  66273. functions: IGLTFTechniqueStatesFunctions;
  66274. }
  66275. /** @hidden */
  66276. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  66277. parameters: {
  66278. [key: string]: IGLTFTechniqueParameter;
  66279. };
  66280. program: string;
  66281. attributes: {
  66282. [key: string]: string;
  66283. };
  66284. uniforms: {
  66285. [key: string]: string;
  66286. };
  66287. states: IGLTFTechniqueStates;
  66288. }
  66289. /** @hidden */
  66290. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  66291. technique?: string;
  66292. values: string[];
  66293. }
  66294. /** @hidden */
  66295. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  66296. attributes: {
  66297. [key: string]: string;
  66298. };
  66299. indices: string;
  66300. material: string;
  66301. mode?: number;
  66302. }
  66303. /** @hidden */
  66304. export interface IGLTFMesh extends IGLTFChildRootProperty {
  66305. primitives: IGLTFMeshPrimitive[];
  66306. }
  66307. /** @hidden */
  66308. export interface IGLTFImage extends IGLTFChildRootProperty {
  66309. uri: string;
  66310. }
  66311. /** @hidden */
  66312. export interface IGLTFSampler extends IGLTFChildRootProperty {
  66313. magFilter?: number;
  66314. minFilter?: number;
  66315. wrapS?: number;
  66316. wrapT?: number;
  66317. }
  66318. /** @hidden */
  66319. export interface IGLTFTexture extends IGLTFChildRootProperty {
  66320. sampler: string;
  66321. source: string;
  66322. format?: ETextureFormat;
  66323. internalFormat?: ETextureFormat;
  66324. target?: number;
  66325. type?: number;
  66326. babylonTexture?: Texture;
  66327. }
  66328. /** @hidden */
  66329. export interface IGLTFAmbienLight {
  66330. color?: number[];
  66331. }
  66332. /** @hidden */
  66333. export interface IGLTFDirectionalLight {
  66334. color?: number[];
  66335. }
  66336. /** @hidden */
  66337. export interface IGLTFPointLight {
  66338. color?: number[];
  66339. constantAttenuation?: number;
  66340. linearAttenuation?: number;
  66341. quadraticAttenuation?: number;
  66342. }
  66343. /** @hidden */
  66344. export interface IGLTFSpotLight {
  66345. color?: number[];
  66346. constantAttenuation?: number;
  66347. fallOfAngle?: number;
  66348. fallOffExponent?: number;
  66349. linearAttenuation?: number;
  66350. quadraticAttenuation?: number;
  66351. }
  66352. /** @hidden */
  66353. export interface IGLTFLight extends IGLTFChildRootProperty {
  66354. type: string;
  66355. }
  66356. /** @hidden */
  66357. export interface IGLTFCameraOrthographic {
  66358. xmag: number;
  66359. ymag: number;
  66360. zfar: number;
  66361. znear: number;
  66362. }
  66363. /** @hidden */
  66364. export interface IGLTFCameraPerspective {
  66365. aspectRatio: number;
  66366. yfov: number;
  66367. zfar: number;
  66368. znear: number;
  66369. }
  66370. /** @hidden */
  66371. export interface IGLTFCamera extends IGLTFChildRootProperty {
  66372. type: string;
  66373. }
  66374. /** @hidden */
  66375. export interface IGLTFAnimationChannelTarget {
  66376. id: string;
  66377. path: string;
  66378. }
  66379. /** @hidden */
  66380. export interface IGLTFAnimationChannel {
  66381. sampler: string;
  66382. target: IGLTFAnimationChannelTarget;
  66383. }
  66384. /** @hidden */
  66385. export interface IGLTFAnimationSampler {
  66386. input: string;
  66387. output: string;
  66388. interpolation?: string;
  66389. }
  66390. /** @hidden */
  66391. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  66392. channels?: IGLTFAnimationChannel[];
  66393. parameters?: {
  66394. [key: string]: string;
  66395. };
  66396. samplers?: {
  66397. [key: string]: IGLTFAnimationSampler;
  66398. };
  66399. }
  66400. /** @hidden */
  66401. export interface IGLTFNodeInstanceSkin {
  66402. skeletons: string[];
  66403. skin: string;
  66404. meshes: string[];
  66405. }
  66406. /** @hidden */
  66407. export interface IGLTFSkins extends IGLTFChildRootProperty {
  66408. bindShapeMatrix: number[];
  66409. inverseBindMatrices: string;
  66410. jointNames: string[];
  66411. babylonSkeleton?: Skeleton;
  66412. }
  66413. /** @hidden */
  66414. export interface IGLTFNode extends IGLTFChildRootProperty {
  66415. camera?: string;
  66416. children: string[];
  66417. skin?: string;
  66418. jointName?: string;
  66419. light?: string;
  66420. matrix: number[];
  66421. mesh?: string;
  66422. meshes?: string[];
  66423. rotation?: number[];
  66424. scale?: number[];
  66425. translation?: number[];
  66426. babylonNode?: Node;
  66427. }
  66428. /** @hidden */
  66429. export interface IGLTFScene extends IGLTFChildRootProperty {
  66430. nodes: string[];
  66431. }
  66432. /** @hidden */
  66433. export interface IGLTFRuntime {
  66434. extensions: {
  66435. [key: string]: any;
  66436. };
  66437. accessors: {
  66438. [key: string]: IGLTFAccessor;
  66439. };
  66440. buffers: {
  66441. [key: string]: IGLTFBuffer;
  66442. };
  66443. bufferViews: {
  66444. [key: string]: IGLTFBufferView;
  66445. };
  66446. meshes: {
  66447. [key: string]: IGLTFMesh;
  66448. };
  66449. lights: {
  66450. [key: string]: IGLTFLight;
  66451. };
  66452. cameras: {
  66453. [key: string]: IGLTFCamera;
  66454. };
  66455. nodes: {
  66456. [key: string]: IGLTFNode;
  66457. };
  66458. images: {
  66459. [key: string]: IGLTFImage;
  66460. };
  66461. textures: {
  66462. [key: string]: IGLTFTexture;
  66463. };
  66464. shaders: {
  66465. [key: string]: IGLTFShader;
  66466. };
  66467. programs: {
  66468. [key: string]: IGLTFProgram;
  66469. };
  66470. samplers: {
  66471. [key: string]: IGLTFSampler;
  66472. };
  66473. techniques: {
  66474. [key: string]: IGLTFTechnique;
  66475. };
  66476. materials: {
  66477. [key: string]: IGLTFMaterial;
  66478. };
  66479. animations: {
  66480. [key: string]: IGLTFAnimation;
  66481. };
  66482. skins: {
  66483. [key: string]: IGLTFSkins;
  66484. };
  66485. currentScene?: Object;
  66486. scenes: {
  66487. [key: string]: IGLTFScene;
  66488. };
  66489. extensionsUsed: string[];
  66490. extensionsRequired?: string[];
  66491. buffersCount: number;
  66492. shaderscount: number;
  66493. scene: Scene;
  66494. rootUrl: string;
  66495. loadedBufferCount: number;
  66496. loadedBufferViews: {
  66497. [name: string]: ArrayBufferView;
  66498. };
  66499. loadedShaderCount: number;
  66500. importOnlyMeshes: boolean;
  66501. importMeshesNames?: string[];
  66502. dummyNodes: Node[];
  66503. }
  66504. /** @hidden */
  66505. export interface INodeToRoot {
  66506. bone: Bone;
  66507. node: IGLTFNode;
  66508. id: string;
  66509. }
  66510. /** @hidden */
  66511. export interface IJointNode {
  66512. node: IGLTFNode;
  66513. id: string;
  66514. }
  66515. }
  66516. declare module BABYLON.GLTF1 {
  66517. /**
  66518. * Utils functions for GLTF
  66519. * @hidden
  66520. */
  66521. export class GLTFUtils {
  66522. /**
  66523. * Sets the given "parameter" matrix
  66524. * @param scene: the Scene object
  66525. * @param source: the source node where to pick the matrix
  66526. * @param parameter: the GLTF technique parameter
  66527. * @param uniformName: the name of the shader's uniform
  66528. * @param shaderMaterial: the shader material
  66529. */
  66530. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  66531. /**
  66532. * Sets the given "parameter" matrix
  66533. * @param shaderMaterial: the shader material
  66534. * @param uniform: the name of the shader's uniform
  66535. * @param value: the value of the uniform
  66536. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  66537. */
  66538. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  66539. /**
  66540. * Returns the wrap mode of the texture
  66541. * @param mode: the mode value
  66542. */
  66543. static GetWrapMode(mode: number): number;
  66544. /**
  66545. * Returns the byte stride giving an accessor
  66546. * @param accessor: the GLTF accessor objet
  66547. */
  66548. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  66549. /**
  66550. * Returns the texture filter mode giving a mode value
  66551. * @param mode: the filter mode value
  66552. */
  66553. static GetTextureFilterMode(mode: number): ETextureFilterType;
  66554. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  66555. /**
  66556. * Returns a buffer from its accessor
  66557. * @param gltfRuntime: the GLTF runtime
  66558. * @param accessor: the GLTF accessor
  66559. */
  66560. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  66561. /**
  66562. * Decodes a buffer view into a string
  66563. * @param view: the buffer view
  66564. */
  66565. static DecodeBufferToText(view: ArrayBufferView): string;
  66566. /**
  66567. * Returns the default material of gltf. Related to
  66568. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  66569. * @param scene: the Babylon.js scene
  66570. */
  66571. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  66572. private static _DefaultMaterial;
  66573. }
  66574. }
  66575. declare module BABYLON.GLTF1 {
  66576. /**
  66577. * Implementation of the base glTF spec
  66578. * @hidden
  66579. */
  66580. export class GLTFLoaderBase {
  66581. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  66582. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  66583. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  66584. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  66585. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  66586. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  66587. }
  66588. /**
  66589. * glTF V1 Loader
  66590. * @hidden
  66591. */
  66592. export class GLTFLoader implements IGLTFLoader {
  66593. static Extensions: {
  66594. [name: string]: GLTFLoaderExtension;
  66595. };
  66596. static RegisterExtension(extension: GLTFLoaderExtension): void;
  66597. state: Nullable<GLTFLoaderState>;
  66598. dispose(): void;
  66599. private _importMeshAsync;
  66600. /**
  66601. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  66602. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66603. * @param scene the scene the meshes should be added to
  66604. * @param data gltf data containing information of the meshes in a loaded file
  66605. * @param rootUrl root url to load from
  66606. * @param onProgress event that fires when loading progress has occured
  66607. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66608. */
  66609. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  66610. meshes: AbstractMesh[];
  66611. particleSystems: IParticleSystem[];
  66612. skeletons: Skeleton[];
  66613. animationGroups: AnimationGroup[];
  66614. }>;
  66615. private _loadAsync;
  66616. /**
  66617. * Imports all objects from a loaded gltf file and adds them to the scene
  66618. * @param scene the scene the objects should be added to
  66619. * @param data gltf data containing information of the meshes in a loaded file
  66620. * @param rootUrl root url to load from
  66621. * @param onProgress event that fires when loading progress has occured
  66622. * @returns a promise which completes when objects have been loaded to the scene
  66623. */
  66624. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  66625. private _loadShadersAsync;
  66626. private _loadBuffersAsync;
  66627. private _createNodes;
  66628. }
  66629. /** @hidden */
  66630. export abstract class GLTFLoaderExtension {
  66631. private _name;
  66632. constructor(name: string);
  66633. readonly name: string;
  66634. /**
  66635. * Defines an override for loading the runtime
  66636. * Return true to stop further extensions from loading the runtime
  66637. */
  66638. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  66639. /**
  66640. * Defines an onverride for creating gltf runtime
  66641. * Return true to stop further extensions from creating the runtime
  66642. */
  66643. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  66644. /**
  66645. * Defines an override for loading buffers
  66646. * Return true to stop further extensions from loading this buffer
  66647. */
  66648. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  66649. /**
  66650. * Defines an override for loading texture buffers
  66651. * Return true to stop further extensions from loading this texture data
  66652. */
  66653. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66654. /**
  66655. * Defines an override for creating textures
  66656. * Return true to stop further extensions from loading this texture
  66657. */
  66658. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  66659. /**
  66660. * Defines an override for loading shader strings
  66661. * Return true to stop further extensions from loading this shader data
  66662. */
  66663. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  66664. /**
  66665. * Defines an override for loading materials
  66666. * Return true to stop further extensions from loading this material
  66667. */
  66668. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  66669. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  66670. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  66671. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  66672. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  66673. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  66674. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  66675. private static LoadTextureBufferAsync;
  66676. private static CreateTextureAsync;
  66677. private static ApplyExtensions;
  66678. }
  66679. }
  66680. declare module BABYLON.GLTF1 {
  66681. /** @hidden */
  66682. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  66683. private _bin;
  66684. constructor();
  66685. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  66686. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66687. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66688. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  66689. }
  66690. }
  66691. declare module BABYLON.GLTF1 {
  66692. /** @hidden */
  66693. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  66694. constructor();
  66695. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  66696. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  66697. private _loadTexture;
  66698. }
  66699. }
  66700. declare module BABYLON.GLTF2.Loader {
  66701. /**
  66702. * Loader interface with an index field.
  66703. */
  66704. export interface IArrayItem {
  66705. /**
  66706. * The index of this item in the array.
  66707. */
  66708. index: number;
  66709. }
  66710. /**
  66711. * Loader interface with additional members.
  66712. */
  66713. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  66714. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  66715. /** @hidden */ private _babylonVertexBuffer?: Promise<VertexBuffer>;
  66716. }
  66717. /**
  66718. * Loader interface with additional members.
  66719. */
  66720. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  66721. }
  66722. /** @hidden */
  66723. export interface _IAnimationSamplerData {
  66724. input: Float32Array;
  66725. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  66726. output: Float32Array;
  66727. }
  66728. /**
  66729. * Loader interface with additional members.
  66730. */
  66731. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  66732. /** @hidden */ private _data?: Promise<_IAnimationSamplerData>;
  66733. }
  66734. /**
  66735. * Loader interface with additional members.
  66736. */
  66737. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  66738. channels: IAnimationChannel[];
  66739. samplers: IAnimationSampler[];
  66740. /** @hidden */ private _babylonAnimationGroup?: AnimationGroup;
  66741. }
  66742. /**
  66743. * Loader interface with additional members.
  66744. */
  66745. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  66746. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  66747. }
  66748. /**
  66749. * Loader interface with additional members.
  66750. */
  66751. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  66752. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  66753. /** @hidden */ private _babylonBuffer?: Promise<Buffer>;
  66754. }
  66755. /**
  66756. * Loader interface with additional members.
  66757. */
  66758. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  66759. }
  66760. /**
  66761. * Loader interface with additional members.
  66762. */
  66763. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  66764. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  66765. }
  66766. /**
  66767. * Loader interface with additional members.
  66768. */
  66769. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  66770. }
  66771. /**
  66772. * Loader interface with additional members.
  66773. */
  66774. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  66775. }
  66776. /**
  66777. * Loader interface with additional members.
  66778. */
  66779. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  66780. baseColorTexture?: ITextureInfo;
  66781. metallicRoughnessTexture?: ITextureInfo;
  66782. }
  66783. /**
  66784. * Loader interface with additional members.
  66785. */
  66786. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  66787. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  66788. normalTexture?: IMaterialNormalTextureInfo;
  66789. occlusionTexture?: IMaterialOcclusionTextureInfo;
  66790. emissiveTexture?: ITextureInfo;
  66791. /** @hidden */ private _data?: {
  66792. [babylonDrawMode: number]: {
  66793. babylonMaterial: Material;
  66794. babylonMeshes: AbstractMesh[];
  66795. promise: Promise<void>;
  66796. };
  66797. };
  66798. }
  66799. /**
  66800. * Loader interface with additional members.
  66801. */
  66802. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  66803. primitives: IMeshPrimitive[];
  66804. }
  66805. /**
  66806. * Loader interface with additional members.
  66807. */
  66808. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  66809. /** @hidden */ private _instanceData?: {
  66810. babylonSourceMesh: Mesh;
  66811. promise: Promise<any>;
  66812. };
  66813. }
  66814. /**
  66815. * Loader interface with additional members.
  66816. */
  66817. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  66818. /**
  66819. * The parent glTF node.
  66820. */
  66821. parent?: INode;
  66822. /** @hidden */ private _babylonTransformNode?: TransformNode;
  66823. /** @hidden */ private _primitiveBabylonMeshes?: AbstractMesh[];
  66824. /** @hidden */ private _babylonBones?: Bone[];
  66825. /** @hidden */ private _numMorphTargets?: number;
  66826. }
  66827. /** @hidden */
  66828. export interface _ISamplerData {
  66829. noMipMaps: boolean;
  66830. samplingMode: number;
  66831. wrapU: number;
  66832. wrapV: number;
  66833. }
  66834. /**
  66835. * Loader interface with additional members.
  66836. */
  66837. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  66838. /** @hidden */ private _data?: _ISamplerData;
  66839. }
  66840. /**
  66841. * Loader interface with additional members.
  66842. */
  66843. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  66844. }
  66845. /**
  66846. * Loader interface with additional members.
  66847. */
  66848. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  66849. /** @hidden */ private _data?: {
  66850. babylonSkeleton: Skeleton;
  66851. promise: Promise<void>;
  66852. };
  66853. }
  66854. /**
  66855. * Loader interface with additional members.
  66856. */
  66857. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  66858. }
  66859. /**
  66860. * Loader interface with additional members.
  66861. */
  66862. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  66863. }
  66864. /**
  66865. * Loader interface with additional members.
  66866. */
  66867. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  66868. accessors?: IAccessor[];
  66869. animations?: IAnimation[];
  66870. buffers?: IBuffer[];
  66871. bufferViews?: IBufferView[];
  66872. cameras?: ICamera[];
  66873. images?: IImage[];
  66874. materials?: IMaterial[];
  66875. meshes?: IMesh[];
  66876. nodes?: INode[];
  66877. samplers?: ISampler[];
  66878. scenes?: IScene[];
  66879. skins?: ISkin[];
  66880. textures?: ITexture[];
  66881. }
  66882. }
  66883. declare module BABYLON.GLTF2 {
  66884. /**
  66885. * Interface for a glTF loader extension.
  66886. */
  66887. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  66888. /**
  66889. * Called after the loader state changes to LOADING.
  66890. */
  66891. onLoading?(): void;
  66892. /**
  66893. * Called after the loader state changes to READY.
  66894. */
  66895. onReady?(): void;
  66896. /**
  66897. * Define this method to modify the default behavior when loading scenes.
  66898. * @param context The context when loading the asset
  66899. * @param scene The glTF scene property
  66900. * @returns A promise that resolves when the load is complete or null if not handled
  66901. */
  66902. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  66903. /**
  66904. * Define this method to modify the default behavior when loading nodes.
  66905. * @param context The context when loading the asset
  66906. * @param node The glTF node property
  66907. * @param assign A function called synchronously after parsing the glTF properties
  66908. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  66909. */
  66910. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66911. /**
  66912. * Define this method to modify the default behavior when loading cameras.
  66913. * @param context The context when loading the asset
  66914. * @param camera The glTF camera property
  66915. * @param assign A function called synchronously after parsing the glTF properties
  66916. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  66917. */
  66918. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  66919. /**
  66920. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  66921. * @param context The context when loading the asset
  66922. * @param primitive The glTF mesh primitive property
  66923. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  66924. */ private _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  66925. /**
  66926. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  66927. * @param context The context when loading the asset
  66928. * @param name The mesh name when loading the asset
  66929. * @param node The glTF node when loading the asset
  66930. * @param mesh The glTF mesh when loading the asset
  66931. * @param primitive The glTF mesh primitive property
  66932. * @param assign A function called synchronously after parsing the glTF properties
  66933. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  66934. */ private _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  66935. /**
  66936. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  66937. * @param context The context when loading the asset
  66938. * @param material The glTF material property
  66939. * @param assign A function called synchronously after parsing the glTF properties
  66940. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  66941. */ private _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  66942. /**
  66943. * Define this method to modify the default behavior when creating materials.
  66944. * @param context The context when loading the asset
  66945. * @param material The glTF material property
  66946. * @param babylonDrawMode The draw mode for the Babylon material
  66947. * @returns The Babylon material or null if not handled
  66948. */
  66949. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  66950. /**
  66951. * Define this method to modify the default behavior when loading material properties.
  66952. * @param context The context when loading the asset
  66953. * @param material The glTF material property
  66954. * @param babylonMaterial The Babylon material
  66955. * @returns A promise that resolves when the load is complete or null if not handled
  66956. */
  66957. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66958. /**
  66959. * Define this method to modify the default behavior when loading texture infos.
  66960. * @param context The context when loading the asset
  66961. * @param textureInfo The glTF texture info property
  66962. * @param assign A function called synchronously after parsing the glTF properties
  66963. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  66964. */
  66965. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  66966. /**
  66967. * Define this method to modify the default behavior when loading animations.
  66968. * @param context The context when loading the asset
  66969. * @param animation The glTF animation property
  66970. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  66971. */
  66972. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  66973. /**
  66974. * @hidden Define this method to modify the default behavior when loading skins.
  66975. * @param context The context when loading the asset
  66976. * @param node The glTF node property
  66977. * @param skin The glTF skin property
  66978. * @returns A promise that resolves when the load is complete or null if not handled
  66979. */ private _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  66980. /**
  66981. * @hidden Define this method to modify the default behavior when loading uris.
  66982. * @param context The context when loading the asset
  66983. * @param property The glTF property associated with the uri
  66984. * @param uri The uri to load
  66985. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  66986. */ private _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  66987. }
  66988. }
  66989. declare module BABYLON.GLTF2 {
  66990. /**
  66991. * Helper class for working with arrays when loading the glTF asset
  66992. */
  66993. export class ArrayItem {
  66994. /**
  66995. * Gets an item from the given array.
  66996. * @param context The context when loading the asset
  66997. * @param array The array to get the item from
  66998. * @param index The index to the array
  66999. * @returns The array item
  67000. */
  67001. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  67002. /**
  67003. * Assign an `index` field to each item of the given array.
  67004. * @param array The array of items
  67005. */
  67006. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  67007. }
  67008. /**
  67009. * The glTF 2.0 loader
  67010. */
  67011. export class GLTFLoader implements IGLTFLoader {
  67012. /** @hidden */ private _completePromises: Promise<any>[];
  67013. private _disposed;
  67014. private _parent;
  67015. private _state;
  67016. private _extensions;
  67017. private _rootUrl;
  67018. private _fileName;
  67019. private _uniqueRootUrl;
  67020. private _gltf;
  67021. private _babylonScene;
  67022. private _rootBabylonMesh;
  67023. private _defaultBabylonMaterialData;
  67024. private _progressCallback?;
  67025. private _requests;
  67026. private static readonly _DefaultSampler;
  67027. private static _ExtensionNames;
  67028. private static _ExtensionFactories;
  67029. /**
  67030. * Registers a loader extension.
  67031. * @param name The name of the loader extension.
  67032. * @param factory The factory function that creates the loader extension.
  67033. */
  67034. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  67035. /**
  67036. * Unregisters a loader extension.
  67037. * @param name The name of the loader extenion.
  67038. * @returns A boolean indicating whether the extension has been unregistered
  67039. */
  67040. static UnregisterExtension(name: string): boolean;
  67041. /**
  67042. * Gets the loader state.
  67043. */
  67044. readonly state: Nullable<GLTFLoaderState>;
  67045. /**
  67046. * The glTF object parsed from the JSON.
  67047. */
  67048. readonly gltf: IGLTF;
  67049. /**
  67050. * The Babylon scene when loading the asset.
  67051. */
  67052. readonly babylonScene: Scene;
  67053. /**
  67054. * The root Babylon mesh when loading the asset.
  67055. */
  67056. readonly rootBabylonMesh: Mesh;
  67057. /** @hidden */
  67058. constructor(parent: GLTFFileLoader);
  67059. /** @hidden */
  67060. dispose(): void;
  67061. /** @hidden */
  67062. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67063. meshes: AbstractMesh[];
  67064. particleSystems: IParticleSystem[];
  67065. skeletons: Skeleton[];
  67066. animationGroups: AnimationGroup[];
  67067. }>;
  67068. /** @hidden */
  67069. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67070. private _loadAsync;
  67071. private _loadData;
  67072. private _setupData;
  67073. private _loadExtensions;
  67074. private _checkExtensions;
  67075. private _setState;
  67076. private _createRootNode;
  67077. /**
  67078. * Loads a glTF scene.
  67079. * @param context The context when loading the asset
  67080. * @param scene The glTF scene property
  67081. * @returns A promise that resolves when the load is complete
  67082. */
  67083. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  67084. private _forEachPrimitive;
  67085. private _getMeshes;
  67086. private _getSkeletons;
  67087. private _getAnimationGroups;
  67088. private _startAnimations;
  67089. /**
  67090. * Loads a glTF node.
  67091. * @param context The context when loading the asset
  67092. * @param node The glTF node property
  67093. * @param assign A function called synchronously after parsing the glTF properties
  67094. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  67095. */
  67096. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  67097. private _loadMeshAsync;
  67098. /**
  67099. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  67100. * @param context The context when loading the asset
  67101. * @param name The mesh name when loading the asset
  67102. * @param node The glTF node when loading the asset
  67103. * @param mesh The glTF mesh when loading the asset
  67104. * @param primitive The glTF mesh primitive property
  67105. * @param assign A function called synchronously after parsing the glTF properties
  67106. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  67107. */ private _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  67108. private _loadVertexDataAsync;
  67109. private _createMorphTargets;
  67110. private _loadMorphTargetsAsync;
  67111. private _loadMorphTargetVertexDataAsync;
  67112. private static _LoadTransform;
  67113. private _loadSkinAsync;
  67114. private _loadBones;
  67115. private _loadBone;
  67116. private _loadSkinInverseBindMatricesDataAsync;
  67117. private _updateBoneMatrices;
  67118. private _getNodeMatrix;
  67119. /**
  67120. * Loads a glTF camera.
  67121. * @param context The context when loading the asset
  67122. * @param camera The glTF camera property
  67123. * @param assign A function called synchronously after parsing the glTF properties
  67124. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  67125. */
  67126. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  67127. private _loadAnimationsAsync;
  67128. /**
  67129. * Loads a glTF animation.
  67130. * @param context The context when loading the asset
  67131. * @param animation The glTF animation property
  67132. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  67133. */
  67134. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  67135. /**
  67136. * @hidden Loads a glTF animation channel.
  67137. * @param context The context when loading the asset
  67138. * @param animationContext The context of the animation when loading the asset
  67139. * @param animation The glTF animation property
  67140. * @param channel The glTF animation channel property
  67141. * @param babylonAnimationGroup The babylon animation group property
  67142. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  67143. * @returns A void promise when the channel load is complete
  67144. */ private _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  67145. private _loadAnimationSamplerAsync;
  67146. private _loadBufferAsync;
  67147. /**
  67148. * Loads a glTF buffer view.
  67149. * @param context The context when loading the asset
  67150. * @param bufferView The glTF buffer view property
  67151. * @returns A promise that resolves with the loaded data when the load is complete
  67152. */
  67153. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  67154. private _loadAccessorAsync;
  67155. private _loadFloatAccessorAsync;
  67156. private _loadIndicesAccessorAsync;
  67157. private _loadVertexBufferViewAsync;
  67158. private _loadVertexAccessorAsync;
  67159. private _loadMaterialMetallicRoughnessPropertiesAsync;
  67160. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  67161. private _createDefaultMaterial;
  67162. /**
  67163. * Creates a Babylon material from a glTF material.
  67164. * @param context The context when loading the asset
  67165. * @param material The glTF material property
  67166. * @param babylonDrawMode The draw mode for the Babylon material
  67167. * @returns The Babylon material
  67168. */
  67169. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  67170. /**
  67171. * Loads properties from a glTF material into a Babylon material.
  67172. * @param context The context when loading the asset
  67173. * @param material The glTF material property
  67174. * @param babylonMaterial The Babylon material
  67175. * @returns A promise that resolves when the load is complete
  67176. */
  67177. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67178. /**
  67179. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  67180. * @param context The context when loading the asset
  67181. * @param material The glTF material property
  67182. * @param babylonMaterial The Babylon material
  67183. * @returns A promise that resolves when the load is complete
  67184. */
  67185. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67186. /**
  67187. * Loads the alpha properties from a glTF material into a Babylon material.
  67188. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  67189. * @param context The context when loading the asset
  67190. * @param material The glTF material property
  67191. * @param babylonMaterial The Babylon material
  67192. */
  67193. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  67194. /**
  67195. * Loads a glTF texture info.
  67196. * @param context The context when loading the asset
  67197. * @param textureInfo The glTF texture info property
  67198. * @param assign A function called synchronously after parsing the glTF properties
  67199. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  67200. */
  67201. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  67202. private _loadTextureAsync;
  67203. private _loadSampler;
  67204. /**
  67205. * Loads a glTF image.
  67206. * @param context The context when loading the asset
  67207. * @param image The glTF image property
  67208. * @returns A promise that resolves with the loaded data when the load is complete
  67209. */
  67210. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  67211. /**
  67212. * Loads a glTF uri.
  67213. * @param context The context when loading the asset
  67214. * @param property The glTF property associated with the uri
  67215. * @param uri The base64 or relative uri
  67216. * @returns A promise that resolves with the loaded data when the load is complete
  67217. */
  67218. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  67219. private _onProgress;
  67220. /**
  67221. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  67222. * @param babylonObject the Babylon object with metadata
  67223. * @param pointer the JSON pointer
  67224. */
  67225. static AddPointerMetadata(babylonObject: {
  67226. metadata: any;
  67227. }, pointer: string): void;
  67228. private static _GetTextureWrapMode;
  67229. private static _GetTextureSamplingMode;
  67230. private static _GetTypedArrayConstructor;
  67231. private static _GetTypedArray;
  67232. private static _GetNumComponents;
  67233. private static _ValidateUri;
  67234. private static _GetDrawMode;
  67235. private _compileMaterialsAsync;
  67236. private _compileShadowGeneratorsAsync;
  67237. private _forEachExtensions;
  67238. private _applyExtensions;
  67239. private _extensionsOnLoading;
  67240. private _extensionsOnReady;
  67241. private _extensionsLoadSceneAsync;
  67242. private _extensionsLoadNodeAsync;
  67243. private _extensionsLoadCameraAsync;
  67244. private _extensionsLoadVertexDataAsync;
  67245. private _extensionsLoadMeshPrimitiveAsync;
  67246. private _extensionsLoadMaterialAsync;
  67247. private _extensionsCreateMaterial;
  67248. private _extensionsLoadMaterialPropertiesAsync;
  67249. private _extensionsLoadTextureInfoAsync;
  67250. private _extensionsLoadAnimationAsync;
  67251. private _extensionsLoadSkinAsync;
  67252. private _extensionsLoadUriAsync;
  67253. /**
  67254. * Helper method called by a loader extension to load an glTF extension.
  67255. * @param context The context when loading the asset
  67256. * @param property The glTF property to load the extension from
  67257. * @param extensionName The name of the extension to load
  67258. * @param actionAsync The action to run
  67259. * @returns The promise returned by actionAsync or null if the extension does not exist
  67260. */
  67261. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  67262. /**
  67263. * Helper method called by a loader extension to load a glTF extra.
  67264. * @param context The context when loading the asset
  67265. * @param property The glTF property to load the extra from
  67266. * @param extensionName The name of the extension to load
  67267. * @param actionAsync The action to run
  67268. * @returns The promise returned by actionAsync or null if the extra does not exist
  67269. */
  67270. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  67271. /**
  67272. * Increments the indentation level and logs a message.
  67273. * @param message The message to log
  67274. */
  67275. logOpen(message: string): void;
  67276. /**
  67277. * Decrements the indentation level.
  67278. */
  67279. logClose(): void;
  67280. /**
  67281. * Logs a message
  67282. * @param message The message to log
  67283. */
  67284. log(message: string): void;
  67285. /**
  67286. * Starts a performance counter.
  67287. * @param counterName The name of the performance counter
  67288. */
  67289. startPerformanceCounter(counterName: string): void;
  67290. /**
  67291. * Ends a performance counter.
  67292. * @param counterName The name of the performance counter
  67293. */
  67294. endPerformanceCounter(counterName: string): void;
  67295. }
  67296. }
  67297. declare module BABYLON.GLTF2.Loader.Extensions {
  67298. /**
  67299. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  67300. */
  67301. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  67302. /** The name of this extension. */
  67303. readonly name: string;
  67304. /** Defines whether this extension is enabled. */
  67305. enabled: boolean;
  67306. private _loader;
  67307. private _lights?;
  67308. /** @hidden */
  67309. constructor(loader: GLTFLoader);
  67310. /** @hidden */
  67311. dispose(): void;
  67312. /** @hidden */
  67313. onLoading(): void;
  67314. /** @hidden */
  67315. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67316. private _loadLightAsync;
  67317. }
  67318. }
  67319. declare module BABYLON.GLTF2.Loader.Extensions {
  67320. /**
  67321. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  67322. */
  67323. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  67324. /** The name of this extension. */
  67325. readonly name: string;
  67326. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  67327. dracoCompression?: DracoCompression;
  67328. /** Defines whether this extension is enabled. */
  67329. enabled: boolean;
  67330. private _loader;
  67331. /** @hidden */
  67332. constructor(loader: GLTFLoader);
  67333. /** @hidden */
  67334. dispose(): void;
  67335. /** @hidden */ private _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  67336. }
  67337. }
  67338. declare module BABYLON.GLTF2.Loader.Extensions {
  67339. /**
  67340. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  67341. */
  67342. export class KHR_lights implements IGLTFLoaderExtension {
  67343. /** The name of this extension. */
  67344. readonly name: string;
  67345. /** Defines whether this extension is enabled. */
  67346. enabled: boolean;
  67347. private _loader;
  67348. private _lights?;
  67349. /** @hidden */
  67350. constructor(loader: GLTFLoader);
  67351. /** @hidden */
  67352. dispose(): void;
  67353. /** @hidden */
  67354. onLoading(): void;
  67355. /** @hidden */
  67356. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67357. }
  67358. }
  67359. declare module BABYLON.GLTF2.Loader.Extensions {
  67360. /**
  67361. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  67362. */
  67363. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  67364. /** The name of this extension. */
  67365. readonly name: string;
  67366. /** Defines whether this extension is enabled. */
  67367. enabled: boolean;
  67368. private _loader;
  67369. /** @hidden */
  67370. constructor(loader: GLTFLoader);
  67371. /** @hidden */
  67372. dispose(): void;
  67373. /** @hidden */
  67374. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67375. private _loadSpecularGlossinessPropertiesAsync;
  67376. }
  67377. }
  67378. declare module BABYLON.GLTF2.Loader.Extensions {
  67379. /**
  67380. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  67381. */
  67382. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  67383. /** The name of this extension. */
  67384. readonly name: string;
  67385. /** Defines whether this extension is enabled. */
  67386. enabled: boolean;
  67387. private _loader;
  67388. /** @hidden */
  67389. constructor(loader: GLTFLoader);
  67390. /** @hidden */
  67391. dispose(): void;
  67392. /** @hidden */
  67393. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67394. private _loadUnlitPropertiesAsync;
  67395. }
  67396. }
  67397. declare module BABYLON.GLTF2.Loader.Extensions {
  67398. /**
  67399. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  67400. */
  67401. export class KHR_texture_transform implements IGLTFLoaderExtension {
  67402. /** The name of this extension. */
  67403. readonly name: string;
  67404. /** Defines whether this extension is enabled. */
  67405. enabled: boolean;
  67406. private _loader;
  67407. /** @hidden */
  67408. constructor(loader: GLTFLoader);
  67409. /** @hidden */
  67410. dispose(): void;
  67411. /** @hidden */
  67412. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  67413. }
  67414. }
  67415. declare module BABYLON.GLTF2.Loader.Extensions {
  67416. /**
  67417. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  67418. */
  67419. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  67420. /** The name of this extension. */
  67421. readonly name: string;
  67422. /** Defines whether this extension is enabled. */
  67423. enabled: boolean;
  67424. private _loader;
  67425. private _clips;
  67426. private _emitters;
  67427. /** @hidden */
  67428. constructor(loader: GLTFLoader);
  67429. /** @hidden */
  67430. dispose(): void;
  67431. /** @hidden */
  67432. onLoading(): void;
  67433. /** @hidden */
  67434. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67435. /** @hidden */
  67436. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67437. /** @hidden */
  67438. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  67439. private _loadClipAsync;
  67440. private _loadEmitterAsync;
  67441. private _getEventAction;
  67442. private _loadAnimationEventAsync;
  67443. }
  67444. }
  67445. declare module BABYLON.GLTF2.Loader.Extensions {
  67446. /**
  67447. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  67448. */
  67449. export class MSFT_lod implements IGLTFLoaderExtension {
  67450. /** The name of this extension. */
  67451. readonly name: string;
  67452. /** Defines whether this extension is enabled. */
  67453. enabled: boolean;
  67454. /**
  67455. * Maximum number of LODs to load, starting from the lowest LOD.
  67456. */
  67457. maxLODsToLoad: number;
  67458. /**
  67459. * Observable raised when all node LODs of one level are loaded.
  67460. * The event data is the index of the loaded LOD starting from zero.
  67461. * Dispose the loader to cancel the loading of the next level of LODs.
  67462. */
  67463. onNodeLODsLoadedObservable: Observable<number>;
  67464. /**
  67465. * Observable raised when all material LODs of one level are loaded.
  67466. * The event data is the index of the loaded LOD starting from zero.
  67467. * Dispose the loader to cancel the loading of the next level of LODs.
  67468. */
  67469. onMaterialLODsLoadedObservable: Observable<number>;
  67470. private _loader;
  67471. private _nodeIndexLOD;
  67472. private _nodeSignalLODs;
  67473. private _nodePromiseLODs;
  67474. private _materialIndexLOD;
  67475. private _materialSignalLODs;
  67476. private _materialPromiseLODs;
  67477. /** @hidden */
  67478. constructor(loader: GLTFLoader);
  67479. /** @hidden */
  67480. dispose(): void;
  67481. /** @hidden */
  67482. onReady(): void;
  67483. /** @hidden */
  67484. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67485. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  67486. /** @hidden */ private _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  67487. /**
  67488. * Gets an array of LOD properties from lowest to highest.
  67489. */
  67490. private _getLODs;
  67491. private _disposeUnusedMaterials;
  67492. }
  67493. }
  67494. declare module BABYLON.GLTF2.Loader.Extensions {
  67495. /** @hidden */
  67496. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  67497. readonly name: string;
  67498. enabled: boolean;
  67499. private _loader;
  67500. constructor(loader: GLTFLoader);
  67501. dispose(): void;
  67502. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67503. }
  67504. }
  67505. declare module BABYLON.GLTF2.Loader.Extensions {
  67506. /** @hidden */
  67507. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  67508. readonly name: string;
  67509. enabled: boolean;
  67510. private _loader;
  67511. constructor(loader: GLTFLoader);
  67512. dispose(): void;
  67513. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67514. }
  67515. }
  67516. declare module BABYLON.GLTF2.Loader.Extensions {
  67517. /**
  67518. * Store glTF extras (if present) in BJS objects' metadata
  67519. */
  67520. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  67521. /** The name of this extension. */
  67522. readonly name: string;
  67523. /** Defines whether this extension is enabled. */
  67524. enabled: boolean;
  67525. private _loader;
  67526. private _assignExtras;
  67527. /** @hidden */
  67528. constructor(loader: GLTFLoader);
  67529. /** @hidden */
  67530. dispose(): void;
  67531. /** @hidden */
  67532. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67533. /** @hidden */
  67534. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  67535. /** @hidden */
  67536. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  67537. }
  67538. }
  67539. declare module BABYLON {
  67540. /**
  67541. * Class reading and parsing the MTL file bundled with the obj file.
  67542. */
  67543. export class MTLFileLoader {
  67544. /**
  67545. * All material loaded from the mtl will be set here
  67546. */
  67547. materials: StandardMaterial[];
  67548. /**
  67549. * This function will read the mtl file and create each material described inside
  67550. * This function could be improve by adding :
  67551. * -some component missing (Ni, Tf...)
  67552. * -including the specific options available
  67553. *
  67554. * @param scene defines the scene the material will be created in
  67555. * @param data defines the mtl data to parse
  67556. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  67557. */
  67558. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  67559. /**
  67560. * Gets the texture for the material.
  67561. *
  67562. * If the material is imported from input file,
  67563. * We sanitize the url to ensure it takes the textre from aside the material.
  67564. *
  67565. * @param rootUrl The root url to load from
  67566. * @param value The value stored in the mtl
  67567. * @return The Texture
  67568. */
  67569. private static _getTexture;
  67570. }
  67571. /**
  67572. * Options for loading OBJ/MTL files
  67573. */
  67574. type MeshLoadOptions = {
  67575. /**
  67576. * Defines if UVs are optimized by default during load.
  67577. */
  67578. OptimizeWithUV: boolean;
  67579. /**
  67580. * Defines custom scaling of UV coordinates of loaded meshes.
  67581. */
  67582. UVScaling: Vector2;
  67583. /**
  67584. * Invert model on y-axis (does a model scaling inversion)
  67585. */
  67586. InvertY: boolean;
  67587. /**
  67588. * Invert Y-Axis of referenced textures on load
  67589. */
  67590. InvertTextureY: boolean;
  67591. /**
  67592. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  67593. */
  67594. ImportVertexColors: boolean;
  67595. /**
  67596. * Compute the normals for the model, even if normals are present in the file.
  67597. */
  67598. ComputeNormals: boolean;
  67599. /**
  67600. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  67601. */
  67602. SkipMaterials: boolean;
  67603. /**
  67604. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  67605. */
  67606. MaterialLoadingFailsSilently: boolean;
  67607. };
  67608. /**
  67609. * OBJ file type loader.
  67610. * This is a babylon scene loader plugin.
  67611. */
  67612. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  67613. /**
  67614. * Defines if UVs are optimized by default during load.
  67615. */
  67616. static OPTIMIZE_WITH_UV: boolean;
  67617. /**
  67618. * Invert model on y-axis (does a model scaling inversion)
  67619. */
  67620. static INVERT_Y: boolean;
  67621. /**
  67622. * Invert Y-Axis of referenced textures on load
  67623. */
  67624. static INVERT_TEXTURE_Y: boolean;
  67625. /**
  67626. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  67627. */
  67628. static IMPORT_VERTEX_COLORS: boolean;
  67629. /**
  67630. * Compute the normals for the model, even if normals are present in the file.
  67631. */
  67632. static COMPUTE_NORMALS: boolean;
  67633. /**
  67634. * Defines custom scaling of UV coordinates of loaded meshes.
  67635. */
  67636. static UV_SCALING: Vector2;
  67637. /**
  67638. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  67639. */
  67640. static SKIP_MATERIALS: boolean;
  67641. /**
  67642. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  67643. *
  67644. * Defaults to true for backwards compatibility.
  67645. */
  67646. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  67647. /**
  67648. * Defines the name of the plugin.
  67649. */
  67650. name: string;
  67651. /**
  67652. * Defines the extension the plugin is able to load.
  67653. */
  67654. extensions: string;
  67655. /** @hidden */
  67656. obj: RegExp;
  67657. /** @hidden */
  67658. group: RegExp;
  67659. /** @hidden */
  67660. mtllib: RegExp;
  67661. /** @hidden */
  67662. usemtl: RegExp;
  67663. /** @hidden */
  67664. smooth: RegExp;
  67665. /** @hidden */
  67666. vertexPattern: RegExp;
  67667. /** @hidden */
  67668. normalPattern: RegExp;
  67669. /** @hidden */
  67670. uvPattern: RegExp;
  67671. /** @hidden */
  67672. facePattern1: RegExp;
  67673. /** @hidden */
  67674. facePattern2: RegExp;
  67675. /** @hidden */
  67676. facePattern3: RegExp;
  67677. /** @hidden */
  67678. facePattern4: RegExp;
  67679. /** @hidden */
  67680. facePattern5: RegExp;
  67681. private _meshLoadOptions;
  67682. /**
  67683. * Creates loader for .OBJ files
  67684. *
  67685. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  67686. */
  67687. constructor(meshLoadOptions?: MeshLoadOptions);
  67688. private static readonly currentMeshLoadOptions;
  67689. /**
  67690. * Calls synchronously the MTL file attached to this obj.
  67691. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  67692. * Without this function materials are not displayed in the first frame (but displayed after).
  67693. * In consequence it is impossible to get material information in your HTML file
  67694. *
  67695. * @param url The URL of the MTL file
  67696. * @param rootUrl
  67697. * @param onSuccess Callback function to be called when the MTL file is loaded
  67698. * @private
  67699. */
  67700. private _loadMTL;
  67701. /**
  67702. * Instantiates a OBJ file loader plugin.
  67703. * @returns the created plugin
  67704. */
  67705. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  67706. /**
  67707. * If the data string can be loaded directly.
  67708. *
  67709. * @param data string containing the file data
  67710. * @returns if the data can be loaded directly
  67711. */
  67712. canDirectLoad(data: string): boolean;
  67713. /**
  67714. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  67715. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67716. * @param scene the scene the meshes should be added to
  67717. * @param data the OBJ data to load
  67718. * @param rootUrl root url to load from
  67719. * @param onProgress event that fires when loading progress has occured
  67720. * @param fileName Defines the name of the file to load
  67721. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67722. */
  67723. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67724. meshes: AbstractMesh[];
  67725. particleSystems: IParticleSystem[];
  67726. skeletons: Skeleton[];
  67727. animationGroups: AnimationGroup[];
  67728. }>;
  67729. /**
  67730. * Imports all objects from the loaded OBJ data and adds them to the scene
  67731. * @param scene the scene the objects should be added to
  67732. * @param data the OBJ data to load
  67733. * @param rootUrl root url to load from
  67734. * @param onProgress event that fires when loading progress has occured
  67735. * @param fileName Defines the name of the file to load
  67736. * @returns a promise which completes when objects have been loaded to the scene
  67737. */
  67738. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67739. /**
  67740. * Load into an asset container.
  67741. * @param scene The scene to load into
  67742. * @param data The data to import
  67743. * @param rootUrl The root url for scene and resources
  67744. * @param onProgress The callback when the load progresses
  67745. * @param fileName Defines the name of the file to load
  67746. * @returns The loaded asset container
  67747. */
  67748. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  67749. /**
  67750. * Read the OBJ file and create an Array of meshes.
  67751. * Each mesh contains all information given by the OBJ and the MTL file.
  67752. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  67753. *
  67754. * @param meshesNames
  67755. * @param scene Scene The scene where are displayed the data
  67756. * @param data String The content of the obj file
  67757. * @param rootUrl String The path to the folder
  67758. * @returns Array<AbstractMesh>
  67759. * @private
  67760. */
  67761. private _parseSolid;
  67762. }
  67763. }
  67764. declare module BABYLON {
  67765. /**
  67766. * STL file type loader.
  67767. * This is a babylon scene loader plugin.
  67768. */
  67769. export class STLFileLoader implements ISceneLoaderPlugin {
  67770. /** @hidden */
  67771. solidPattern: RegExp;
  67772. /** @hidden */
  67773. facetsPattern: RegExp;
  67774. /** @hidden */
  67775. normalPattern: RegExp;
  67776. /** @hidden */
  67777. vertexPattern: RegExp;
  67778. /**
  67779. * Defines the name of the plugin.
  67780. */
  67781. name: string;
  67782. /**
  67783. * Defines the extensions the stl loader is able to load.
  67784. * force data to come in as an ArrayBuffer
  67785. * we'll convert to string if it looks like it's an ASCII .stl
  67786. */
  67787. extensions: ISceneLoaderPluginExtensions;
  67788. /**
  67789. * Import meshes into a scene.
  67790. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  67791. * @param scene The scene to import into
  67792. * @param data The data to import
  67793. * @param rootUrl The root url for scene and resources
  67794. * @param meshes The meshes array to import into
  67795. * @param particleSystems The particle systems array to import into
  67796. * @param skeletons The skeletons array to import into
  67797. * @param onError The callback when import fails
  67798. * @returns True if successful or false otherwise
  67799. */
  67800. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  67801. /**
  67802. * Load into a scene.
  67803. * @param scene The scene to load into
  67804. * @param data The data to import
  67805. * @param rootUrl The root url for scene and resources
  67806. * @param onError The callback when import fails
  67807. * @returns true if successful or false otherwise
  67808. */
  67809. load(scene: Scene, data: any, rootUrl: string): boolean;
  67810. /**
  67811. * Load into an asset container.
  67812. * @param scene The scene to load into
  67813. * @param data The data to import
  67814. * @param rootUrl The root url for scene and resources
  67815. * @param onError The callback when import fails
  67816. * @returns The loaded asset container
  67817. */
  67818. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  67819. private _isBinary;
  67820. private _parseBinary;
  67821. private _parseASCII;
  67822. }
  67823. }
  67824. declare module BABYLON {
  67825. /**
  67826. * Class for generating OBJ data from a Babylon scene.
  67827. */
  67828. export class OBJExport {
  67829. /**
  67830. * Exports the geometry of a Mesh array in .OBJ file format (text)
  67831. * @param mesh defines the list of meshes to serialize
  67832. * @param materials defines if materials should be exported
  67833. * @param matlibname defines the name of the associated mtl file
  67834. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  67835. * @returns the OBJ content
  67836. */
  67837. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  67838. /**
  67839. * Exports the material(s) of a mesh in .MTL file format (text)
  67840. * @param mesh defines the mesh to extract the material from
  67841. * @returns the mtl content
  67842. */
  67843. static MTL(mesh: Mesh): string;
  67844. }
  67845. }
  67846. declare module BABYLON {
  67847. /** @hidden */
  67848. export var __IGLTFExporterExtension: number;
  67849. /**
  67850. * Interface for extending the exporter
  67851. * @hidden
  67852. */
  67853. export interface IGLTFExporterExtension {
  67854. /**
  67855. * The name of this extension
  67856. */
  67857. readonly name: string;
  67858. /**
  67859. * Defines whether this extension is enabled
  67860. */
  67861. enabled: boolean;
  67862. /**
  67863. * Defines whether this extension is required
  67864. */
  67865. required: boolean;
  67866. }
  67867. }
  67868. declare module BABYLON.GLTF2.Exporter {
  67869. /** @hidden */
  67870. export var __IGLTFExporterExtensionV2: number;
  67871. /**
  67872. * Interface for a glTF exporter extension
  67873. * @hidden
  67874. */
  67875. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  67876. /**
  67877. * Define this method to modify the default behavior before exporting a texture
  67878. * @param context The context when loading the asset
  67879. * @param babylonTexture The glTF texture info property
  67880. * @param mimeType The mime-type of the generated image
  67881. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  67882. */
  67883. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  67884. /**
  67885. * Define this method to modify the default behavior when exporting texture info
  67886. * @param context The context when loading the asset
  67887. * @param meshPrimitive glTF mesh primitive
  67888. * @param babylonSubMesh Babylon submesh
  67889. * @param binaryWriter glTF serializer binary writer instance
  67890. * @returns nullable IMeshPrimitive promise
  67891. */
  67892. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  67893. /**
  67894. * Define this method to modify the default behavior when exporting a node
  67895. * @param context The context when exporting the node
  67896. * @param node glTF node
  67897. * @param babylonNode BabylonJS node
  67898. * @returns nullable INode promise
  67899. */
  67900. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  67901. /**
  67902. * Called after the exporter state changes to EXPORTING
  67903. */
  67904. onExporting?(): void;
  67905. }
  67906. }
  67907. declare module BABYLON.GLTF2.Exporter {
  67908. /**
  67909. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  67910. * @hidden
  67911. */
  67912. export class _GLTFMaterialExporter {
  67913. /**
  67914. * Represents the dielectric specular values for R, G and B
  67915. */
  67916. private static readonly _DielectricSpecular;
  67917. /**
  67918. * Allows the maximum specular power to be defined for material calculations
  67919. */
  67920. private static readonly _MaxSpecularPower;
  67921. /**
  67922. * Mapping to store textures
  67923. */
  67924. private _textureMap;
  67925. /**
  67926. * Numeric tolerance value
  67927. */
  67928. private static readonly _Epsilon;
  67929. /**
  67930. * Reference to the glTF Exporter
  67931. */
  67932. private _exporter;
  67933. constructor(exporter: _Exporter);
  67934. /**
  67935. * Specifies if two colors are approximately equal in value
  67936. * @param color1 first color to compare to
  67937. * @param color2 second color to compare to
  67938. * @param epsilon threshold value
  67939. */
  67940. private static FuzzyEquals;
  67941. /**
  67942. * Gets the materials from a Babylon scene and converts them to glTF materials
  67943. * @param scene babylonjs scene
  67944. * @param mimeType texture mime type
  67945. * @param images array of images
  67946. * @param textures array of textures
  67947. * @param materials array of materials
  67948. * @param imageData mapping of texture names to base64 textures
  67949. * @param hasTextureCoords specifies if texture coordinates are present on the material
  67950. */ private _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67951. /**
  67952. * Makes a copy of the glTF material without the texture parameters
  67953. * @param originalMaterial original glTF material
  67954. * @returns glTF material without texture parameters
  67955. */ private _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  67956. /**
  67957. * Specifies if the material has any texture parameters present
  67958. * @param material glTF Material
  67959. * @returns boolean specifying if texture parameters are present
  67960. */ private _hasTexturesPresent(material: IMaterial): boolean;
  67961. /**
  67962. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  67963. * @param babylonStandardMaterial
  67964. * @returns glTF Metallic Roughness Material representation
  67965. */ private _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  67966. /**
  67967. * Computes the metallic factor
  67968. * @param diffuse diffused value
  67969. * @param specular specular value
  67970. * @param oneMinusSpecularStrength one minus the specular strength
  67971. * @returns metallic value
  67972. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  67973. /**
  67974. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  67975. * @param glTFMaterial glTF material
  67976. * @param babylonMaterial Babylon material
  67977. */
  67978. private static _SetAlphaMode;
  67979. /**
  67980. * Converts a Babylon Standard Material to a glTF Material
  67981. * @param babylonStandardMaterial BJS Standard Material
  67982. * @param mimeType mime type to use for the textures
  67983. * @param images array of glTF image interfaces
  67984. * @param textures array of glTF texture interfaces
  67985. * @param materials array of glTF material interfaces
  67986. * @param imageData map of image file name to data
  67987. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67988. */ private _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67989. /**
  67990. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  67991. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  67992. * @param mimeType mime type to use for the textures
  67993. * @param images array of glTF image interfaces
  67994. * @param textures array of glTF texture interfaces
  67995. * @param materials array of glTF material interfaces
  67996. * @param imageData map of image file name to data
  67997. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67998. */ private _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67999. /**
  68000. * Converts an image typed array buffer to a base64 image
  68001. * @param buffer typed array buffer
  68002. * @param width width of the image
  68003. * @param height height of the image
  68004. * @param mimeType mimetype of the image
  68005. * @returns base64 image string
  68006. */
  68007. private _createBase64FromCanvasAsync;
  68008. /**
  68009. * Generates a white texture based on the specified width and height
  68010. * @param width width of the texture in pixels
  68011. * @param height height of the texture in pixels
  68012. * @param scene babylonjs scene
  68013. * @returns white texture
  68014. */
  68015. private _createWhiteTexture;
  68016. /**
  68017. * 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
  68018. * @param texture1 first texture to resize
  68019. * @param texture2 second texture to resize
  68020. * @param scene babylonjs scene
  68021. * @returns resized textures or null
  68022. */
  68023. private _resizeTexturesToSameDimensions;
  68024. /**
  68025. * Converts an array of pixels to a Float32Array
  68026. * Throws an error if the pixel format is not supported
  68027. * @param pixels - array buffer containing pixel values
  68028. * @returns Float32 of pixels
  68029. */
  68030. private _convertPixelArrayToFloat32;
  68031. /**
  68032. * Convert Specular Glossiness Textures to Metallic Roughness
  68033. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  68034. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  68035. * @param diffuseTexture texture used to store diffuse information
  68036. * @param specularGlossinessTexture texture used to store specular and glossiness information
  68037. * @param factors specular glossiness material factors
  68038. * @param mimeType the mime type to use for the texture
  68039. * @returns pbr metallic roughness interface or null
  68040. */
  68041. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  68042. /**
  68043. * Converts specular glossiness material properties to metallic roughness
  68044. * @param specularGlossiness interface with specular glossiness material properties
  68045. * @returns interface with metallic roughness material properties
  68046. */
  68047. private _convertSpecularGlossinessToMetallicRoughness;
  68048. /**
  68049. * Calculates the surface reflectance, independent of lighting conditions
  68050. * @param color Color source to calculate brightness from
  68051. * @returns number representing the perceived brightness, or zero if color is undefined
  68052. */
  68053. private _getPerceivedBrightness;
  68054. /**
  68055. * Returns the maximum color component value
  68056. * @param color
  68057. * @returns maximum color component value, or zero if color is null or undefined
  68058. */
  68059. private _getMaxComponent;
  68060. /**
  68061. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  68062. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68063. * @param mimeType mime type to use for the textures
  68064. * @param images array of glTF image interfaces
  68065. * @param textures array of glTF texture interfaces
  68066. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68067. * @param imageData map of image file name to data
  68068. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68069. * @returns glTF PBR Metallic Roughness factors
  68070. */
  68071. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  68072. private _getGLTFTextureSampler;
  68073. private _getGLTFTextureWrapMode;
  68074. private _getGLTFTextureWrapModesSampler;
  68075. /**
  68076. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  68077. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68078. * @param mimeType mime type to use for the textures
  68079. * @param images array of glTF image interfaces
  68080. * @param textures array of glTF texture interfaces
  68081. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68082. * @param imageData map of image file name to data
  68083. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68084. * @returns glTF PBR Metallic Roughness factors
  68085. */
  68086. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  68087. /**
  68088. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68089. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68090. * @param mimeType mime type to use for the textures
  68091. * @param images array of glTF image interfaces
  68092. * @param textures array of glTF texture interfaces
  68093. * @param materials array of glTF material interfaces
  68094. * @param imageData map of image file name to data
  68095. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68096. */ private _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68097. private setMetallicRoughnessPbrMaterial;
  68098. private getPixelsFromTexture;
  68099. /**
  68100. * Extracts a texture from a Babylon texture into file data and glTF data
  68101. * @param babylonTexture Babylon texture to extract
  68102. * @param mimeType Mime Type of the babylonTexture
  68103. * @return glTF texture info, or null if the texture format is not supported
  68104. */ private _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; private _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  68105. /**
  68106. * Builds a texture from base64 string
  68107. * @param base64Texture base64 texture string
  68108. * @param baseTextureName Name to use for the texture
  68109. * @param mimeType image mime type for the texture
  68110. * @param images array of images
  68111. * @param textures array of textures
  68112. * @param imageData map of image data
  68113. * @returns glTF texture info, or null if the texture format is not supported
  68114. */
  68115. private _getTextureInfoFromBase64;
  68116. }
  68117. }
  68118. declare module BABYLON {
  68119. /**
  68120. * Class for holding and downloading glTF file data
  68121. */
  68122. export class GLTFData {
  68123. /**
  68124. * Object which contains the file name as the key and its data as the value
  68125. */
  68126. glTFFiles: {
  68127. [fileName: string]: string | Blob;
  68128. };
  68129. /**
  68130. * Initializes the glTF file object
  68131. */
  68132. constructor();
  68133. /**
  68134. * Downloads the glTF data as files based on their names and data
  68135. */
  68136. downloadFiles(): void;
  68137. }
  68138. }
  68139. declare module BABYLON {
  68140. /**
  68141. * Holds a collection of exporter options and parameters
  68142. */
  68143. export interface IExportOptions {
  68144. /**
  68145. * Function which indicates whether a babylon node should be exported or not
  68146. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  68147. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  68148. */
  68149. shouldExportNode?(node: Node): boolean;
  68150. /**
  68151. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  68152. * @param metadata source metadata to read from
  68153. * @returns the data to store to glTF node extras
  68154. */
  68155. metadataSelector?(metadata: any): any;
  68156. /**
  68157. * The sample rate to bake animation curves
  68158. */
  68159. animationSampleRate?: number;
  68160. /**
  68161. * Begin serialization without waiting for the scene to be ready
  68162. */
  68163. exportWithoutWaitingForScene?: boolean;
  68164. }
  68165. /**
  68166. * Class for generating glTF data from a Babylon scene.
  68167. */
  68168. export class GLTF2Export {
  68169. /**
  68170. * Exports the geometry of the scene to .gltf file format asynchronously
  68171. * @param scene Babylon scene with scene hierarchy information
  68172. * @param filePrefix File prefix to use when generating the glTF file
  68173. * @param options Exporter options
  68174. * @returns Returns an object with a .gltf file and associates texture names
  68175. * as keys and their data and paths as values
  68176. */
  68177. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68178. private static _PreExportAsync;
  68179. private static _PostExportAsync;
  68180. /**
  68181. * Exports the geometry of the scene to .glb file format asychronously
  68182. * @param scene Babylon scene with scene hierarchy information
  68183. * @param filePrefix File prefix to use when generating glb file
  68184. * @param options Exporter options
  68185. * @returns Returns an object with a .glb filename as key and data as value
  68186. */
  68187. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68188. }
  68189. }
  68190. declare module BABYLON.GLTF2.Exporter {
  68191. /**
  68192. * @hidden
  68193. */
  68194. export class _GLTFUtilities {
  68195. /**
  68196. * Creates a buffer view based on the supplied arguments
  68197. * @param bufferIndex index value of the specified buffer
  68198. * @param byteOffset byte offset value
  68199. * @param byteLength byte length of the bufferView
  68200. * @param byteStride byte distance between conequential elements
  68201. * @param name name of the buffer view
  68202. * @returns bufferView for glTF
  68203. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  68204. /**
  68205. * Creates an accessor based on the supplied arguments
  68206. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  68207. * @param name The name of the accessor
  68208. * @param type The type of the accessor
  68209. * @param componentType The datatype of components in the attribute
  68210. * @param count The number of attributes referenced by this accessor
  68211. * @param byteOffset The offset relative to the start of the bufferView in bytes
  68212. * @param min Minimum value of each component in this attribute
  68213. * @param max Maximum value of each component in this attribute
  68214. * @returns accessor for glTF
  68215. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  68216. /**
  68217. * Calculates the minimum and maximum values of an array of position floats
  68218. * @param positions Positions array of a mesh
  68219. * @param vertexStart Starting vertex offset to calculate min and max values
  68220. * @param vertexCount Number of vertices to check for min and max values
  68221. * @returns min number array and max number array
  68222. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  68223. min: number[];
  68224. max: number[];
  68225. };
  68226. /**
  68227. * Converts a new right-handed Vector3
  68228. * @param vector vector3 array
  68229. * @returns right-handed Vector3
  68230. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  68231. /**
  68232. * Converts a Vector3 to right-handed
  68233. * @param vector Vector3 to convert to right-handed
  68234. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  68235. /**
  68236. * Converts a three element number array to right-handed
  68237. * @param vector number array to convert to right-handed
  68238. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  68239. /**
  68240. * Converts a new right-handed Vector3
  68241. * @param vector vector3 array
  68242. * @returns right-handed Vector3
  68243. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  68244. /**
  68245. * Converts a Vector3 to right-handed
  68246. * @param vector Vector3 to convert to right-handed
  68247. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  68248. /**
  68249. * Converts a three element number array to right-handed
  68250. * @param vector number array to convert to right-handed
  68251. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  68252. /**
  68253. * Converts a Vector4 to right-handed
  68254. * @param vector Vector4 to convert to right-handed
  68255. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  68256. /**
  68257. * Converts a Vector4 to right-handed
  68258. * @param vector Vector4 to convert to right-handed
  68259. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  68260. /**
  68261. * Converts a Quaternion to right-handed
  68262. * @param quaternion Source quaternion to convert to right-handed
  68263. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  68264. /**
  68265. * Converts a Quaternion to right-handed
  68266. * @param quaternion Source quaternion to convert to right-handed
  68267. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  68268. }
  68269. }
  68270. declare module BABYLON.GLTF2.Exporter {
  68271. /**
  68272. * Converts Babylon Scene into glTF 2.0.
  68273. * @hidden
  68274. */
  68275. export class _Exporter {
  68276. /**
  68277. * Stores the glTF to export
  68278. */ private _glTF: IGLTF;
  68279. /**
  68280. * Stores all generated buffer views, which represents views into the main glTF buffer data
  68281. */ private _bufferViews: IBufferView[];
  68282. /**
  68283. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  68284. */ private _accessors: IAccessor[];
  68285. /**
  68286. * Stores all the generated nodes, which contains transform and/or mesh information per node
  68287. */
  68288. private _nodes;
  68289. /**
  68290. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  68291. */
  68292. private _scenes;
  68293. /**
  68294. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  68295. */
  68296. private _meshes;
  68297. /**
  68298. * Stores all the generated material information, which represents the appearance of each primitive
  68299. */ private _materials: IMaterial[]; private _materialMap: {
  68300. [materialID: number]: number;
  68301. };
  68302. /**
  68303. * Stores all the generated texture information, which is referenced by glTF materials
  68304. */ private _textures: ITexture[];
  68305. /**
  68306. * Stores all the generated image information, which is referenced by glTF textures
  68307. */ private _images: IImage[];
  68308. /**
  68309. * Stores all the texture samplers
  68310. */ private _samplers: ISampler[];
  68311. /**
  68312. * Stores all the generated animation samplers, which is referenced by glTF animations
  68313. */
  68314. /**
  68315. * Stores the animations for glTF models
  68316. */
  68317. private _animations;
  68318. /**
  68319. * Stores the total amount of bytes stored in the glTF buffer
  68320. */
  68321. private _totalByteLength;
  68322. /**
  68323. * Stores a reference to the Babylon scene containing the source geometry and material information
  68324. */ private _babylonScene: Scene;
  68325. /**
  68326. * Stores a map of the image data, where the key is the file name and the value
  68327. * is the image data
  68328. */ private _imageData: {
  68329. [fileName: string]: {
  68330. data: Uint8Array;
  68331. mimeType: ImageMimeType;
  68332. };
  68333. };
  68334. /**
  68335. * Stores a map of the unique id of a node to its index in the node array
  68336. */
  68337. private _nodeMap;
  68338. /**
  68339. * Specifies if the Babylon scene should be converted to right-handed on export
  68340. */ private _convertToRightHandedSystem: boolean;
  68341. /**
  68342. * Baked animation sample rate
  68343. */
  68344. private _animationSampleRate;
  68345. private _options;
  68346. private _localEngine; private _glTFMaterialExporter: _GLTFMaterialExporter;
  68347. private _extensions;
  68348. private static _ExtensionNames;
  68349. private static _ExtensionFactories;
  68350. 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>>;
  68351. private _forEachExtensions;
  68352. private _extensionsOnExporting;
  68353. /**
  68354. * Load glTF serializer extensions
  68355. */
  68356. private _loadExtensions;
  68357. /**
  68358. * Creates a glTF Exporter instance, which can accept optional exporter options
  68359. * @param babylonScene Babylon scene object
  68360. * @param options Options to modify the behavior of the exporter
  68361. */
  68362. constructor(babylonScene: Scene, options?: IExportOptions);
  68363. /**
  68364. * Registers a glTF exporter extension
  68365. * @param name Name of the extension to export
  68366. * @param factory The factory function that creates the exporter extension
  68367. */
  68368. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  68369. /**
  68370. * Un-registers an exporter extension
  68371. * @param name The name fo the exporter extension
  68372. * @returns A boolean indicating whether the extension has been un-registered
  68373. */
  68374. static UnregisterExtension(name: string): boolean;
  68375. /**
  68376. * Lazy load a local engine with premultiplied alpha set to false
  68377. */ private _getLocalEngine(): Engine;
  68378. private reorderIndicesBasedOnPrimitiveMode;
  68379. /**
  68380. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  68381. * clock-wise during export to glTF
  68382. * @param submesh BabylonJS submesh
  68383. * @param primitiveMode Primitive mode of the mesh
  68384. * @param sideOrientation the winding order of the submesh
  68385. * @param vertexBufferKind The type of vertex attribute
  68386. * @param meshAttributeArray The vertex attribute data
  68387. * @param byteOffset The offset to the binary data
  68388. * @param binaryWriter The binary data for the glTF file
  68389. */
  68390. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  68391. /**
  68392. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  68393. * clock-wise during export to glTF
  68394. * @param submesh BabylonJS submesh
  68395. * @param primitiveMode Primitive mode of the mesh
  68396. * @param sideOrientation the winding order of the submesh
  68397. * @param vertexBufferKind The type of vertex attribute
  68398. * @param meshAttributeArray The vertex attribute data
  68399. * @param byteOffset The offset to the binary data
  68400. * @param binaryWriter The binary data for the glTF file
  68401. */
  68402. private reorderTriangleFillMode;
  68403. /**
  68404. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  68405. * clock-wise during export to glTF
  68406. * @param submesh BabylonJS submesh
  68407. * @param primitiveMode Primitive mode of the mesh
  68408. * @param sideOrientation the winding order of the submesh
  68409. * @param vertexBufferKind The type of vertex attribute
  68410. * @param meshAttributeArray The vertex attribute data
  68411. * @param byteOffset The offset to the binary data
  68412. * @param binaryWriter The binary data for the glTF file
  68413. */
  68414. private reorderTriangleStripDrawMode;
  68415. /**
  68416. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  68417. * clock-wise during export to glTF
  68418. * @param submesh BabylonJS submesh
  68419. * @param primitiveMode Primitive mode of the mesh
  68420. * @param sideOrientation the winding order of the submesh
  68421. * @param vertexBufferKind The type of vertex attribute
  68422. * @param meshAttributeArray The vertex attribute data
  68423. * @param byteOffset The offset to the binary data
  68424. * @param binaryWriter The binary data for the glTF file
  68425. */
  68426. private reorderTriangleFanMode;
  68427. /**
  68428. * Writes the vertex attribute data to binary
  68429. * @param vertices The vertices to write to the binary writer
  68430. * @param byteOffset The offset into the binary writer to overwrite binary data
  68431. * @param vertexAttributeKind The vertex attribute type
  68432. * @param meshAttributeArray The vertex attribute data
  68433. * @param binaryWriter The writer containing the binary data
  68434. */
  68435. private writeVertexAttributeData;
  68436. /**
  68437. * Writes mesh attribute data to a data buffer
  68438. * Returns the bytelength of the data
  68439. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  68440. * @param meshAttributeArray Array containing the attribute data
  68441. * @param binaryWriter The buffer to write the binary data to
  68442. * @param indices Used to specify the order of the vertex data
  68443. */
  68444. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  68445. /**
  68446. * Generates glTF json data
  68447. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  68448. * @param glTFPrefix Text to use when prefixing a glTF file
  68449. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  68450. * @returns json data as string
  68451. */
  68452. private generateJSON;
  68453. /**
  68454. * Generates data for .gltf and .bin files based on the glTF prefix string
  68455. * @param glTFPrefix Text to use when prefixing a glTF file
  68456. * @returns GLTFData with glTF file data
  68457. */ private _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  68458. /**
  68459. * Creates a binary buffer for glTF
  68460. * @returns array buffer for binary data
  68461. */
  68462. private _generateBinaryAsync;
  68463. /**
  68464. * Pads the number to a multiple of 4
  68465. * @param num number to pad
  68466. * @returns padded number
  68467. */
  68468. private _getPadding;
  68469. /**
  68470. * Generates a glb file from the json and binary data
  68471. * Returns an object with the glb file name as the key and data as the value
  68472. * @param glTFPrefix
  68473. * @returns object with glb filename as key and data as value
  68474. */ private _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  68475. /**
  68476. * Sets the TRS for each node
  68477. * @param node glTF Node for storing the transformation data
  68478. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  68479. */
  68480. private setNodeTransformation;
  68481. private getVertexBufferFromMesh;
  68482. /**
  68483. * Creates a bufferview based on the vertices type for the Babylon mesh
  68484. * @param kind Indicates the type of vertices data
  68485. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  68486. * @param binaryWriter The buffer to write the bufferview data to
  68487. */
  68488. private createBufferViewKind;
  68489. /**
  68490. * The primitive mode of the Babylon mesh
  68491. * @param babylonMesh The BabylonJS mesh
  68492. */
  68493. private getMeshPrimitiveMode;
  68494. /**
  68495. * Sets the primitive mode of the glTF mesh primitive
  68496. * @param meshPrimitive glTF mesh primitive
  68497. * @param primitiveMode The primitive mode
  68498. */
  68499. private setPrimitiveMode;
  68500. /**
  68501. * Sets the vertex attribute accessor based of the glTF mesh primitive
  68502. * @param meshPrimitive glTF mesh primitive
  68503. * @param attributeKind vertex attribute
  68504. * @returns boolean specifying if uv coordinates are present
  68505. */
  68506. private setAttributeKind;
  68507. /**
  68508. * Sets data for the primitive attributes of each submesh
  68509. * @param mesh glTF Mesh object to store the primitive attribute information
  68510. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  68511. * @param binaryWriter Buffer to write the attribute data to
  68512. */
  68513. private setPrimitiveAttributesAsync;
  68514. /**
  68515. * Creates a glTF scene based on the array of meshes
  68516. * Returns the the total byte offset
  68517. * @param babylonScene Babylon scene to get the mesh data from
  68518. * @param binaryWriter Buffer to write binary data to
  68519. */
  68520. private createSceneAsync;
  68521. /**
  68522. * Creates a mapping of Node unique id to node index and handles animations
  68523. * @param babylonScene Babylon Scene
  68524. * @param nodes Babylon transform nodes
  68525. * @param binaryWriter Buffer to write binary data to
  68526. * @returns Node mapping of unique id to index
  68527. */
  68528. private createNodeMapAndAnimationsAsync;
  68529. /**
  68530. * Creates a glTF node from a Babylon mesh
  68531. * @param babylonMesh Source Babylon mesh
  68532. * @param binaryWriter Buffer for storing geometry data
  68533. * @returns glTF node
  68534. */
  68535. private createNodeAsync;
  68536. }
  68537. /**
  68538. * @hidden
  68539. *
  68540. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  68541. */
  68542. export class _BinaryWriter {
  68543. /**
  68544. * Array buffer which stores all binary data
  68545. */
  68546. private _arrayBuffer;
  68547. /**
  68548. * View of the array buffer
  68549. */
  68550. private _dataView;
  68551. /**
  68552. * byte offset of data in array buffer
  68553. */
  68554. private _byteOffset;
  68555. /**
  68556. * Initialize binary writer with an initial byte length
  68557. * @param byteLength Initial byte length of the array buffer
  68558. */
  68559. constructor(byteLength: number);
  68560. /**
  68561. * Resize the array buffer to the specified byte length
  68562. * @param byteLength
  68563. */
  68564. private resizeBuffer;
  68565. /**
  68566. * Get an array buffer with the length of the byte offset
  68567. * @returns ArrayBuffer resized to the byte offset
  68568. */
  68569. getArrayBuffer(): ArrayBuffer;
  68570. /**
  68571. * Get the byte offset of the array buffer
  68572. * @returns byte offset
  68573. */
  68574. getByteOffset(): number;
  68575. /**
  68576. * Stores an UInt8 in the array buffer
  68577. * @param entry
  68578. * @param byteOffset If defined, specifies where to set the value as an offset.
  68579. */
  68580. setUInt8(entry: number, byteOffset?: number): void;
  68581. /**
  68582. * Gets an UInt32 in the array buffer
  68583. * @param entry
  68584. * @param byteOffset If defined, specifies where to set the value as an offset.
  68585. */
  68586. getUInt32(byteOffset: number): number;
  68587. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  68588. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  68589. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  68590. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  68591. /**
  68592. * Stores a Float32 in the array buffer
  68593. * @param entry
  68594. */
  68595. setFloat32(entry: number, byteOffset?: number): void;
  68596. /**
  68597. * Stores an UInt32 in the array buffer
  68598. * @param entry
  68599. * @param byteOffset If defined, specifies where to set the value as an offset.
  68600. */
  68601. setUInt32(entry: number, byteOffset?: number): void;
  68602. }
  68603. }
  68604. declare module BABYLON.GLTF2.Exporter {
  68605. /**
  68606. * @hidden
  68607. * Interface to store animation data.
  68608. */
  68609. export interface _IAnimationData {
  68610. /**
  68611. * Keyframe data.
  68612. */
  68613. inputs: number[];
  68614. /**
  68615. * Value data.
  68616. */
  68617. outputs: number[][];
  68618. /**
  68619. * Animation interpolation data.
  68620. */
  68621. samplerInterpolation: AnimationSamplerInterpolation;
  68622. /**
  68623. * Minimum keyframe value.
  68624. */
  68625. inputsMin: number;
  68626. /**
  68627. * Maximum keyframe value.
  68628. */
  68629. inputsMax: number;
  68630. }
  68631. /**
  68632. * @hidden
  68633. */
  68634. export interface _IAnimationInfo {
  68635. /**
  68636. * The target channel for the animation
  68637. */
  68638. animationChannelTargetPath: AnimationChannelTargetPath;
  68639. /**
  68640. * The glTF accessor type for the data.
  68641. */
  68642. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  68643. /**
  68644. * Specifies if quaternions should be used.
  68645. */
  68646. useQuaternion: boolean;
  68647. }
  68648. /**
  68649. * @hidden
  68650. * Utility class for generating glTF animation data from BabylonJS.
  68651. */
  68652. export class _GLTFAnimation {
  68653. /**
  68654. * @ignore
  68655. *
  68656. * Creates glTF channel animation from BabylonJS animation.
  68657. * @param babylonTransformNode - BabylonJS mesh.
  68658. * @param animation - animation.
  68659. * @param animationChannelTargetPath - The target animation channel.
  68660. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  68661. * @param useQuaternion - Specifies if quaternions are used.
  68662. * @returns nullable IAnimationData
  68663. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  68664. private static _DeduceAnimationInfo;
  68665. /**
  68666. * @ignore
  68667. * Create node animations from the transform node animations
  68668. * @param babylonNode
  68669. * @param runtimeGLTFAnimation
  68670. * @param idleGLTFAnimations
  68671. * @param nodeMap
  68672. * @param nodes
  68673. * @param binaryWriter
  68674. * @param bufferViews
  68675. * @param accessors
  68676. * @param convertToRightHandedSystem
  68677. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  68678. [key: number]: number;
  68679. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  68680. /**
  68681. * @ignore
  68682. * Create node animations from the animation groups
  68683. * @param babylonScene
  68684. * @param glTFAnimations
  68685. * @param nodeMap
  68686. * @param nodes
  68687. * @param binaryWriter
  68688. * @param bufferViews
  68689. * @param accessors
  68690. * @param convertToRightHandedSystem
  68691. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  68692. [key: number]: number;
  68693. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  68694. private static AddAnimation;
  68695. /**
  68696. * Create a baked animation
  68697. * @param babylonTransformNode BabylonJS mesh
  68698. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  68699. * @param animationChannelTargetPath animation target channel
  68700. * @param minFrame minimum animation frame
  68701. * @param maxFrame maximum animation frame
  68702. * @param fps frames per second of the animation
  68703. * @param inputs input key frames of the animation
  68704. * @param outputs output key frame data of the animation
  68705. * @param convertToRightHandedSystem converts the values to right-handed
  68706. * @param useQuaternion specifies if quaternions should be used
  68707. */
  68708. private static _CreateBakedAnimation;
  68709. private static _ConvertFactorToVector3OrQuaternion;
  68710. private static _SetInterpolatedValue;
  68711. /**
  68712. * Creates linear animation from the animation key frames
  68713. * @param babylonTransformNode BabylonJS mesh
  68714. * @param animation BabylonJS animation
  68715. * @param animationChannelTargetPath The target animation channel
  68716. * @param frameDelta The difference between the last and first frame of the animation
  68717. * @param inputs Array to store the key frame times
  68718. * @param outputs Array to store the key frame data
  68719. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  68720. * @param useQuaternion Specifies if quaternions are used in the animation
  68721. */
  68722. private static _CreateLinearOrStepAnimation;
  68723. /**
  68724. * Creates cubic spline animation from the animation key frames
  68725. * @param babylonTransformNode BabylonJS mesh
  68726. * @param animation BabylonJS animation
  68727. * @param animationChannelTargetPath The target animation channel
  68728. * @param frameDelta The difference between the last and first frame of the animation
  68729. * @param inputs Array to store the key frame times
  68730. * @param outputs Array to store the key frame data
  68731. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  68732. * @param useQuaternion Specifies if quaternions are used in the animation
  68733. */
  68734. private static _CreateCubicSplineAnimation;
  68735. private static _GetBasePositionRotationOrScale;
  68736. /**
  68737. * Adds a key frame value
  68738. * @param keyFrame
  68739. * @param animation
  68740. * @param outputs
  68741. * @param animationChannelTargetPath
  68742. * @param basePositionRotationOrScale
  68743. * @param convertToRightHandedSystem
  68744. * @param useQuaternion
  68745. */
  68746. private static _AddKeyframeValue;
  68747. /**
  68748. * Determine the interpolation based on the key frames
  68749. * @param keyFrames
  68750. * @param animationChannelTargetPath
  68751. * @param useQuaternion
  68752. */
  68753. private static _DeduceInterpolation;
  68754. /**
  68755. * Adds an input tangent or output tangent to the output data
  68756. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  68757. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  68758. * @param outputs The animation data by keyframe
  68759. * @param animationChannelTargetPath The target animation channel
  68760. * @param interpolation The interpolation type
  68761. * @param keyFrame The key frame with the animation data
  68762. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  68763. * @param useQuaternion Specifies if quaternions are used
  68764. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  68765. */
  68766. private static AddSplineTangent;
  68767. /**
  68768. * Get the minimum and maximum key frames' frame values
  68769. * @param keyFrames animation key frames
  68770. * @returns the minimum and maximum key frame value
  68771. */
  68772. private static calculateMinMaxKeyFrames;
  68773. }
  68774. }
  68775. declare module BABYLON.GLTF2.Exporter {
  68776. /** @hidden */
  68777. export var textureTransformPixelShader: {
  68778. name: string;
  68779. shader: string;
  68780. };
  68781. }
  68782. declare module BABYLON.GLTF2.Exporter.Extensions {
  68783. /**
  68784. * @hidden
  68785. */
  68786. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  68787. /** Name of this extension */
  68788. readonly name: string;
  68789. /** Defines whether this extension is enabled */
  68790. enabled: boolean;
  68791. /** Defines whether this extension is required */
  68792. required: boolean;
  68793. /** Reference to the glTF exporter */
  68794. private _exporter;
  68795. constructor(exporter: _Exporter);
  68796. dispose(): void;
  68797. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  68798. /**
  68799. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  68800. * @param babylonTexture
  68801. * @param offset
  68802. * @param rotation
  68803. * @param scale
  68804. * @param scene
  68805. */
  68806. private _textureTransformTextureAsync;
  68807. }
  68808. }
  68809. declare module BABYLON.GLTF2.Exporter.Extensions {
  68810. /**
  68811. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  68812. */
  68813. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  68814. /** The name of this extension. */
  68815. readonly name: string;
  68816. /** Defines whether this extension is enabled. */
  68817. enabled: boolean;
  68818. /** Defines whether this extension is required */
  68819. required: boolean;
  68820. /** Reference to the glTF exporter */
  68821. private _exporter;
  68822. private _lights;
  68823. /** @hidden */
  68824. constructor(exporter: _Exporter);
  68825. /** @hidden */
  68826. dispose(): void;
  68827. /** @hidden */
  68828. onExporting(): void;
  68829. /**
  68830. * Define this method to modify the default behavior when exporting a node
  68831. * @param context The context when exporting the node
  68832. * @param node glTF node
  68833. * @param babylonNode BabylonJS node
  68834. * @returns nullable INode promise
  68835. */
  68836. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68837. }
  68838. }
  68839. declare module BABYLON {
  68840. /**
  68841. * Class for generating STL data from a Babylon scene.
  68842. */
  68843. export class STLExport {
  68844. /**
  68845. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  68846. * @param meshes list defines the mesh to serialize
  68847. * @param download triggers the automatic download of the file.
  68848. * @param fileName changes the downloads fileName.
  68849. * @param binary changes the STL to a binary type.
  68850. * @param isLittleEndian toggle for binary type exporter.
  68851. * @returns the STL as UTF8 string
  68852. */
  68853. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  68854. }
  68855. }
  68856. declare module "babylonjs-gltf2interface" {
  68857. export = BABYLON.GLTF2;
  68858. }
  68859. /**
  68860. * Module for glTF 2.0 Interface
  68861. */
  68862. declare module BABYLON.GLTF2 {
  68863. /**
  68864. * The datatype of the components in the attribute
  68865. */
  68866. const enum AccessorComponentType {
  68867. /**
  68868. * Byte
  68869. */
  68870. BYTE = 5120,
  68871. /**
  68872. * Unsigned Byte
  68873. */
  68874. UNSIGNED_BYTE = 5121,
  68875. /**
  68876. * Short
  68877. */
  68878. SHORT = 5122,
  68879. /**
  68880. * Unsigned Short
  68881. */
  68882. UNSIGNED_SHORT = 5123,
  68883. /**
  68884. * Unsigned Int
  68885. */
  68886. UNSIGNED_INT = 5125,
  68887. /**
  68888. * Float
  68889. */
  68890. FLOAT = 5126,
  68891. }
  68892. /**
  68893. * Specifies if the attirbute is a scalar, vector, or matrix
  68894. */
  68895. const enum AccessorType {
  68896. /**
  68897. * Scalar
  68898. */
  68899. SCALAR = "SCALAR",
  68900. /**
  68901. * Vector2
  68902. */
  68903. VEC2 = "VEC2",
  68904. /**
  68905. * Vector3
  68906. */
  68907. VEC3 = "VEC3",
  68908. /**
  68909. * Vector4
  68910. */
  68911. VEC4 = "VEC4",
  68912. /**
  68913. * Matrix2x2
  68914. */
  68915. MAT2 = "MAT2",
  68916. /**
  68917. * Matrix3x3
  68918. */
  68919. MAT3 = "MAT3",
  68920. /**
  68921. * Matrix4x4
  68922. */
  68923. MAT4 = "MAT4",
  68924. }
  68925. /**
  68926. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  68927. */
  68928. const enum AnimationChannelTargetPath {
  68929. /**
  68930. * Translation
  68931. */
  68932. TRANSLATION = "translation",
  68933. /**
  68934. * Rotation
  68935. */
  68936. ROTATION = "rotation",
  68937. /**
  68938. * Scale
  68939. */
  68940. SCALE = "scale",
  68941. /**
  68942. * Weights
  68943. */
  68944. WEIGHTS = "weights",
  68945. }
  68946. /**
  68947. * Interpolation algorithm
  68948. */
  68949. const enum AnimationSamplerInterpolation {
  68950. /**
  68951. * The animated values are linearly interpolated between keyframes
  68952. */
  68953. LINEAR = "LINEAR",
  68954. /**
  68955. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  68956. */
  68957. STEP = "STEP",
  68958. /**
  68959. * The animation's interpolation is computed using a cubic spline with specified tangents
  68960. */
  68961. CUBICSPLINE = "CUBICSPLINE",
  68962. }
  68963. /**
  68964. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  68965. */
  68966. const enum CameraType {
  68967. /**
  68968. * A perspective camera containing properties to create a perspective projection matrix
  68969. */
  68970. PERSPECTIVE = "perspective",
  68971. /**
  68972. * An orthographic camera containing properties to create an orthographic projection matrix
  68973. */
  68974. ORTHOGRAPHIC = "orthographic",
  68975. }
  68976. /**
  68977. * The mime-type of the image
  68978. */
  68979. const enum ImageMimeType {
  68980. /**
  68981. * JPEG Mime-type
  68982. */
  68983. JPEG = "image/jpeg",
  68984. /**
  68985. * PNG Mime-type
  68986. */
  68987. PNG = "image/png",
  68988. }
  68989. /**
  68990. * The alpha rendering mode of the material
  68991. */
  68992. const enum MaterialAlphaMode {
  68993. /**
  68994. * The alpha value is ignored and the rendered output is fully opaque
  68995. */
  68996. OPAQUE = "OPAQUE",
  68997. /**
  68998. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  68999. */
  69000. MASK = "MASK",
  69001. /**
  69002. * 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)
  69003. */
  69004. BLEND = "BLEND",
  69005. }
  69006. /**
  69007. * The type of the primitives to render
  69008. */
  69009. const enum MeshPrimitiveMode {
  69010. /**
  69011. * Points
  69012. */
  69013. POINTS = 0,
  69014. /**
  69015. * Lines
  69016. */
  69017. LINES = 1,
  69018. /**
  69019. * Line Loop
  69020. */
  69021. LINE_LOOP = 2,
  69022. /**
  69023. * Line Strip
  69024. */
  69025. LINE_STRIP = 3,
  69026. /**
  69027. * Triangles
  69028. */
  69029. TRIANGLES = 4,
  69030. /**
  69031. * Triangle Strip
  69032. */
  69033. TRIANGLE_STRIP = 5,
  69034. /**
  69035. * Triangle Fan
  69036. */
  69037. TRIANGLE_FAN = 6,
  69038. }
  69039. /**
  69040. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  69041. */
  69042. const enum TextureMagFilter {
  69043. /**
  69044. * Nearest
  69045. */
  69046. NEAREST = 9728,
  69047. /**
  69048. * Linear
  69049. */
  69050. LINEAR = 9729,
  69051. }
  69052. /**
  69053. * Minification filter. All valid values correspond to WebGL enums
  69054. */
  69055. const enum TextureMinFilter {
  69056. /**
  69057. * Nearest
  69058. */
  69059. NEAREST = 9728,
  69060. /**
  69061. * Linear
  69062. */
  69063. LINEAR = 9729,
  69064. /**
  69065. * Nearest Mip-Map Nearest
  69066. */
  69067. NEAREST_MIPMAP_NEAREST = 9984,
  69068. /**
  69069. * Linear Mipmap Nearest
  69070. */
  69071. LINEAR_MIPMAP_NEAREST = 9985,
  69072. /**
  69073. * Nearest Mipmap Linear
  69074. */
  69075. NEAREST_MIPMAP_LINEAR = 9986,
  69076. /**
  69077. * Linear Mipmap Linear
  69078. */
  69079. LINEAR_MIPMAP_LINEAR = 9987,
  69080. }
  69081. /**
  69082. * S (U) wrapping mode. All valid values correspond to WebGL enums
  69083. */
  69084. const enum TextureWrapMode {
  69085. /**
  69086. * Clamp to Edge
  69087. */
  69088. CLAMP_TO_EDGE = 33071,
  69089. /**
  69090. * Mirrored Repeat
  69091. */
  69092. MIRRORED_REPEAT = 33648,
  69093. /**
  69094. * Repeat
  69095. */
  69096. REPEAT = 10497,
  69097. }
  69098. /**
  69099. * glTF Property
  69100. */
  69101. interface IProperty {
  69102. /**
  69103. * Dictionary object with extension-specific objects
  69104. */
  69105. extensions?: {
  69106. [key: string]: any;
  69107. };
  69108. /**
  69109. * Application-Specific data
  69110. */
  69111. extras?: any;
  69112. }
  69113. /**
  69114. * glTF Child of Root Property
  69115. */
  69116. interface IChildRootProperty extends IProperty {
  69117. /**
  69118. * The user-defined name of this object
  69119. */
  69120. name?: string;
  69121. }
  69122. /**
  69123. * Indices of those attributes that deviate from their initialization value
  69124. */
  69125. interface IAccessorSparseIndices extends IProperty {
  69126. /**
  69127. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69128. */
  69129. bufferView: number;
  69130. /**
  69131. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69132. */
  69133. byteOffset?: number;
  69134. /**
  69135. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  69136. */
  69137. componentType: AccessorComponentType;
  69138. }
  69139. /**
  69140. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  69141. */
  69142. interface IAccessorSparseValues extends IProperty {
  69143. /**
  69144. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69145. */
  69146. bufferView: number;
  69147. /**
  69148. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69149. */
  69150. byteOffset?: number;
  69151. }
  69152. /**
  69153. * Sparse storage of attributes that deviate from their initialization value
  69154. */
  69155. interface IAccessorSparse extends IProperty {
  69156. /**
  69157. * The number of attributes encoded in this sparse accessor
  69158. */
  69159. count: number;
  69160. /**
  69161. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  69162. */
  69163. indices: IAccessorSparseIndices;
  69164. /**
  69165. * 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
  69166. */
  69167. values: IAccessorSparseValues;
  69168. }
  69169. /**
  69170. * 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
  69171. */
  69172. interface IAccessor extends IChildRootProperty {
  69173. /**
  69174. * The index of the bufferview
  69175. */
  69176. bufferView?: number;
  69177. /**
  69178. * The offset relative to the start of the bufferView in bytes
  69179. */
  69180. byteOffset?: number;
  69181. /**
  69182. * The datatype of components in the attribute
  69183. */
  69184. componentType: AccessorComponentType;
  69185. /**
  69186. * Specifies whether integer data values should be normalized
  69187. */
  69188. normalized?: boolean;
  69189. /**
  69190. * The number of attributes referenced by this accessor
  69191. */
  69192. count: number;
  69193. /**
  69194. * Specifies if the attribute is a scalar, vector, or matrix
  69195. */
  69196. type: AccessorType;
  69197. /**
  69198. * Maximum value of each component in this attribute
  69199. */
  69200. max?: number[];
  69201. /**
  69202. * Minimum value of each component in this attribute
  69203. */
  69204. min?: number[];
  69205. /**
  69206. * Sparse storage of attributes that deviate from their initialization value
  69207. */
  69208. sparse?: IAccessorSparse;
  69209. }
  69210. /**
  69211. * Targets an animation's sampler at a node's property
  69212. */
  69213. interface IAnimationChannel extends IProperty {
  69214. /**
  69215. * The index of a sampler in this animation used to compute the value for the target
  69216. */
  69217. sampler: number;
  69218. /**
  69219. * The index of the node and TRS property to target
  69220. */
  69221. target: IAnimationChannelTarget;
  69222. }
  69223. /**
  69224. * The index of the node and TRS property that an animation channel targets
  69225. */
  69226. interface IAnimationChannelTarget extends IProperty {
  69227. /**
  69228. * The index of the node to target
  69229. */
  69230. node: number;
  69231. /**
  69232. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  69233. */
  69234. path: AnimationChannelTargetPath;
  69235. }
  69236. /**
  69237. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  69238. */
  69239. interface IAnimationSampler extends IProperty {
  69240. /**
  69241. * The index of an accessor containing keyframe input values, e.g., time
  69242. */
  69243. input: number;
  69244. /**
  69245. * Interpolation algorithm
  69246. */
  69247. interpolation?: AnimationSamplerInterpolation;
  69248. /**
  69249. * The index of an accessor, containing keyframe output values
  69250. */
  69251. output: number;
  69252. }
  69253. /**
  69254. * A keyframe animation
  69255. */
  69256. interface IAnimation extends IChildRootProperty {
  69257. /**
  69258. * An array of channels, each of which targets an animation's sampler at a node's property
  69259. */
  69260. channels: IAnimationChannel[];
  69261. /**
  69262. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  69263. */
  69264. samplers: IAnimationSampler[];
  69265. }
  69266. /**
  69267. * Metadata about the glTF asset
  69268. */
  69269. interface IAsset extends IChildRootProperty {
  69270. /**
  69271. * A copyright message suitable for display to credit the content creator
  69272. */
  69273. copyright?: string;
  69274. /**
  69275. * Tool that generated this glTF model. Useful for debugging
  69276. */
  69277. generator?: string;
  69278. /**
  69279. * The glTF version that this asset targets
  69280. */
  69281. version: string;
  69282. /**
  69283. * The minimum glTF version that this asset targets
  69284. */
  69285. minVersion?: string;
  69286. }
  69287. /**
  69288. * A buffer points to binary geometry, animation, or skins
  69289. */
  69290. interface IBuffer extends IChildRootProperty {
  69291. /**
  69292. * 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
  69293. */
  69294. uri?: string;
  69295. /**
  69296. * The length of the buffer in bytes
  69297. */
  69298. byteLength: number;
  69299. }
  69300. /**
  69301. * A view into a buffer generally representing a subset of the buffer
  69302. */
  69303. interface IBufferView extends IChildRootProperty {
  69304. /**
  69305. * The index of the buffer
  69306. */
  69307. buffer: number;
  69308. /**
  69309. * The offset into the buffer in bytes
  69310. */
  69311. byteOffset?: number;
  69312. /**
  69313. * The lenth of the bufferView in bytes
  69314. */
  69315. byteLength: number;
  69316. /**
  69317. * The stride, in bytes
  69318. */
  69319. byteStride?: number;
  69320. }
  69321. /**
  69322. * An orthographic camera containing properties to create an orthographic projection matrix
  69323. */
  69324. interface ICameraOrthographic extends IProperty {
  69325. /**
  69326. * The floating-point horizontal magnification of the view. Must not be zero
  69327. */
  69328. xmag: number;
  69329. /**
  69330. * The floating-point vertical magnification of the view. Must not be zero
  69331. */
  69332. ymag: number;
  69333. /**
  69334. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  69335. */
  69336. zfar: number;
  69337. /**
  69338. * The floating-point distance to the near clipping plane
  69339. */
  69340. znear: number;
  69341. }
  69342. /**
  69343. * A perspective camera containing properties to create a perspective projection matrix
  69344. */
  69345. interface ICameraPerspective extends IProperty {
  69346. /**
  69347. * The floating-point aspect ratio of the field of view
  69348. */
  69349. aspectRatio?: number;
  69350. /**
  69351. * The floating-point vertical field of view in radians
  69352. */
  69353. yfov: number;
  69354. /**
  69355. * The floating-point distance to the far clipping plane
  69356. */
  69357. zfar?: number;
  69358. /**
  69359. * The floating-point distance to the near clipping plane
  69360. */
  69361. znear: number;
  69362. }
  69363. /**
  69364. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  69365. */
  69366. interface ICamera extends IChildRootProperty {
  69367. /**
  69368. * An orthographic camera containing properties to create an orthographic projection matrix
  69369. */
  69370. orthographic?: ICameraOrthographic;
  69371. /**
  69372. * A perspective camera containing properties to create a perspective projection matrix
  69373. */
  69374. perspective?: ICameraPerspective;
  69375. /**
  69376. * Specifies if the camera uses a perspective or orthographic projection
  69377. */
  69378. type: CameraType;
  69379. }
  69380. /**
  69381. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  69382. */
  69383. interface IImage extends IChildRootProperty {
  69384. /**
  69385. * 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
  69386. */
  69387. uri?: string;
  69388. /**
  69389. * The image's MIME type
  69390. */
  69391. mimeType?: ImageMimeType;
  69392. /**
  69393. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  69394. */
  69395. bufferView?: number;
  69396. }
  69397. /**
  69398. * Material Normal Texture Info
  69399. */
  69400. interface IMaterialNormalTextureInfo extends ITextureInfo {
  69401. /**
  69402. * The scalar multiplier applied to each normal vector of the normal texture
  69403. */
  69404. scale?: number;
  69405. }
  69406. /**
  69407. * Material Occlusion Texture Info
  69408. */
  69409. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  69410. /**
  69411. * A scalar multiplier controlling the amount of occlusion applied
  69412. */
  69413. strength?: number;
  69414. }
  69415. /**
  69416. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  69417. */
  69418. interface IMaterialPbrMetallicRoughness {
  69419. /**
  69420. * The material's base color factor
  69421. */
  69422. baseColorFactor?: number[];
  69423. /**
  69424. * The base color texture
  69425. */
  69426. baseColorTexture?: ITextureInfo;
  69427. /**
  69428. * The metalness of the material
  69429. */
  69430. metallicFactor?: number;
  69431. /**
  69432. * The roughness of the material
  69433. */
  69434. roughnessFactor?: number;
  69435. /**
  69436. * The metallic-roughness texture
  69437. */
  69438. metallicRoughnessTexture?: ITextureInfo;
  69439. }
  69440. /**
  69441. * The material appearance of a primitive
  69442. */
  69443. interface IMaterial extends IChildRootProperty {
  69444. /**
  69445. * 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
  69446. */
  69447. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  69448. /**
  69449. * The normal map texture
  69450. */
  69451. normalTexture?: IMaterialNormalTextureInfo;
  69452. /**
  69453. * The occlusion map texture
  69454. */
  69455. occlusionTexture?: IMaterialOcclusionTextureInfo;
  69456. /**
  69457. * The emissive map texture
  69458. */
  69459. emissiveTexture?: ITextureInfo;
  69460. /**
  69461. * 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
  69462. */
  69463. emissiveFactor?: number[];
  69464. /**
  69465. * The alpha rendering mode of the material
  69466. */
  69467. alphaMode?: MaterialAlphaMode;
  69468. /**
  69469. * The alpha cutoff value of the material
  69470. */
  69471. alphaCutoff?: number;
  69472. /**
  69473. * Specifies whether the material is double sided
  69474. */
  69475. doubleSided?: boolean;
  69476. }
  69477. /**
  69478. * Geometry to be rendered with the given material
  69479. */
  69480. interface IMeshPrimitive extends IProperty {
  69481. /**
  69482. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  69483. */
  69484. attributes: {
  69485. [name: string]: number;
  69486. };
  69487. /**
  69488. * The index of the accessor that contains the indices
  69489. */
  69490. indices?: number;
  69491. /**
  69492. * The index of the material to apply to this primitive when rendering
  69493. */
  69494. material?: number;
  69495. /**
  69496. * The type of primitives to render. All valid values correspond to WebGL enums
  69497. */
  69498. mode?: MeshPrimitiveMode;
  69499. /**
  69500. * 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
  69501. */
  69502. targets?: {
  69503. [name: string]: number;
  69504. }[];
  69505. }
  69506. /**
  69507. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  69508. */
  69509. interface IMesh extends IChildRootProperty {
  69510. /**
  69511. * An array of primitives, each defining geometry to be rendered with a material
  69512. */
  69513. primitives: IMeshPrimitive[];
  69514. /**
  69515. * Array of weights to be applied to the Morph Targets
  69516. */
  69517. weights?: number[];
  69518. }
  69519. /**
  69520. * A node in the node hierarchy
  69521. */
  69522. interface INode extends IChildRootProperty {
  69523. /**
  69524. * The index of the camera referenced by this node
  69525. */
  69526. camera?: number;
  69527. /**
  69528. * The indices of this node's children
  69529. */
  69530. children?: number[];
  69531. /**
  69532. * The index of the skin referenced by this node
  69533. */
  69534. skin?: number;
  69535. /**
  69536. * A floating-point 4x4 transformation matrix stored in column-major order
  69537. */
  69538. matrix?: number[];
  69539. /**
  69540. * The index of the mesh in this node
  69541. */
  69542. mesh?: number;
  69543. /**
  69544. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  69545. */
  69546. rotation?: number[];
  69547. /**
  69548. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  69549. */
  69550. scale?: number[];
  69551. /**
  69552. * The node's translation along the x, y, and z axes
  69553. */
  69554. translation?: number[];
  69555. /**
  69556. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  69557. */
  69558. weights?: number[];
  69559. }
  69560. /**
  69561. * Texture sampler properties for filtering and wrapping modes
  69562. */
  69563. interface ISampler extends IChildRootProperty {
  69564. /**
  69565. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  69566. */
  69567. magFilter?: TextureMagFilter;
  69568. /**
  69569. * Minification filter. All valid values correspond to WebGL enums
  69570. */
  69571. minFilter?: TextureMinFilter;
  69572. /**
  69573. * S (U) wrapping mode. All valid values correspond to WebGL enums
  69574. */
  69575. wrapS?: TextureWrapMode;
  69576. /**
  69577. * T (V) wrapping mode. All valid values correspond to WebGL enums
  69578. */
  69579. wrapT?: TextureWrapMode;
  69580. }
  69581. /**
  69582. * The root nodes of a scene
  69583. */
  69584. interface IScene extends IChildRootProperty {
  69585. /**
  69586. * The indices of each root node
  69587. */
  69588. nodes: number[];
  69589. }
  69590. /**
  69591. * Joints and matrices defining a skin
  69592. */
  69593. interface ISkin extends IChildRootProperty {
  69594. /**
  69595. * 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
  69596. */
  69597. inverseBindMatrices?: number;
  69598. /**
  69599. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  69600. */
  69601. skeleton?: number;
  69602. /**
  69603. * 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)
  69604. */
  69605. joints: number[];
  69606. }
  69607. /**
  69608. * A texture and its sampler
  69609. */
  69610. interface ITexture extends IChildRootProperty {
  69611. /**
  69612. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  69613. */
  69614. sampler?: number;
  69615. /**
  69616. * The index of the image used by this texture
  69617. */
  69618. source: number;
  69619. }
  69620. /**
  69621. * Reference to a texture
  69622. */
  69623. interface ITextureInfo extends IProperty {
  69624. /**
  69625. * The index of the texture
  69626. */
  69627. index: number;
  69628. /**
  69629. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  69630. */
  69631. texCoord?: number;
  69632. }
  69633. /**
  69634. * The root object for a glTF asset
  69635. */
  69636. interface IGLTF extends IProperty {
  69637. /**
  69638. * An array of accessors. An accessor is a typed view into a bufferView
  69639. */
  69640. accessors?: IAccessor[];
  69641. /**
  69642. * An array of keyframe animations
  69643. */
  69644. animations?: IAnimation[];
  69645. /**
  69646. * Metadata about the glTF asset
  69647. */
  69648. asset: IAsset;
  69649. /**
  69650. * An array of buffers. A buffer points to binary geometry, animation, or skins
  69651. */
  69652. buffers?: IBuffer[];
  69653. /**
  69654. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  69655. */
  69656. bufferViews?: IBufferView[];
  69657. /**
  69658. * An array of cameras
  69659. */
  69660. cameras?: ICamera[];
  69661. /**
  69662. * Names of glTF extensions used somewhere in this asset
  69663. */
  69664. extensionsUsed?: string[];
  69665. /**
  69666. * Names of glTF extensions required to properly load this asset
  69667. */
  69668. extensionsRequired?: string[];
  69669. /**
  69670. * An array of images. An image defines data used to create a texture
  69671. */
  69672. images?: IImage[];
  69673. /**
  69674. * An array of materials. A material defines the appearance of a primitive
  69675. */
  69676. materials?: IMaterial[];
  69677. /**
  69678. * An array of meshes. A mesh is a set of primitives to be rendered
  69679. */
  69680. meshes?: IMesh[];
  69681. /**
  69682. * An array of nodes
  69683. */
  69684. nodes?: INode[];
  69685. /**
  69686. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  69687. */
  69688. samplers?: ISampler[];
  69689. /**
  69690. * The index of the default scene
  69691. */
  69692. scene?: number;
  69693. /**
  69694. * An array of scenes
  69695. */
  69696. scenes?: IScene[];
  69697. /**
  69698. * An array of skins. A skin is defined by joints and matrices
  69699. */
  69700. skins?: ISkin[];
  69701. /**
  69702. * An array of textures
  69703. */
  69704. textures?: ITexture[];
  69705. }
  69706. /**
  69707. * The glTF validation results
  69708. * @ignore
  69709. */
  69710. interface IGLTFValidationResults {
  69711. info: {
  69712. generator: string;
  69713. hasAnimations: boolean;
  69714. hasDefaultScene: boolean;
  69715. hasMaterials: boolean;
  69716. hasMorphTargets: boolean;
  69717. hasSkins: boolean;
  69718. hasTextures: boolean;
  69719. maxAttributesUsed: number;
  69720. primitivesCount: number
  69721. };
  69722. issues: {
  69723. messages: Array<string>;
  69724. numErrors: number;
  69725. numHints: number;
  69726. numInfos: number;
  69727. numWarnings: number;
  69728. truncated: boolean
  69729. };
  69730. mimeType: string;
  69731. uri: string;
  69732. validatedAt: string;
  69733. validatorVersion: string;
  69734. }
  69735. /**
  69736. * The glTF validation options
  69737. */
  69738. interface IGLTFValidationOptions {
  69739. /** Uri to use */
  69740. uri?: string;
  69741. /** Function used to load external resources */
  69742. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  69743. /** Boolean indicating that we need to validate accessor data */
  69744. validateAccessorData?: boolean;
  69745. /** max number of issues allowed */
  69746. maxIssues?: number;
  69747. /** Ignored issues */
  69748. ignoredIssues?: Array<string>;
  69749. /** Value to override severy settings */
  69750. severityOverrides?: Object;
  69751. }
  69752. /**
  69753. * The glTF validator object
  69754. * @ignore
  69755. */
  69756. interface IGLTFValidator {
  69757. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  69758. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  69759. }
  69760. }
  69761. declare module BABYLON {
  69762. /** @hidden */
  69763. export var cellPixelShader: {
  69764. name: string;
  69765. shader: string;
  69766. };
  69767. }
  69768. declare module BABYLON {
  69769. /** @hidden */
  69770. export var cellVertexShader: {
  69771. name: string;
  69772. shader: string;
  69773. };
  69774. }
  69775. declare module BABYLON {
  69776. export class CellMaterial extends BABYLON.PushMaterial {
  69777. private _diffuseTexture;
  69778. diffuseTexture: BABYLON.BaseTexture;
  69779. diffuseColor: BABYLON.Color3; private _computeHighLevel: boolean;
  69780. computeHighLevel: boolean;
  69781. private _disableLighting;
  69782. disableLighting: boolean;
  69783. private _maxSimultaneousLights;
  69784. maxSimultaneousLights: number;
  69785. private _renderId;
  69786. constructor(name: string, scene: BABYLON.Scene);
  69787. needAlphaBlending(): boolean;
  69788. needAlphaTesting(): boolean;
  69789. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69790. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69791. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69792. getAnimatables(): BABYLON.IAnimatable[];
  69793. getActiveTextures(): BABYLON.BaseTexture[];
  69794. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69795. dispose(forceDisposeEffect?: boolean): void;
  69796. getClassName(): string;
  69797. clone(name: string): CellMaterial;
  69798. serialize(): any;
  69799. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  69800. }
  69801. }
  69802. declare module BABYLON {
  69803. export class CustomShaderStructure {
  69804. FragmentStore: string;
  69805. VertexStore: string;
  69806. constructor();
  69807. }
  69808. export class ShaderSpecialParts {
  69809. constructor();
  69810. Fragment_Begin: string;
  69811. Fragment_Definitions: string;
  69812. Fragment_MainBegin: string;
  69813. Fragment_Custom_Diffuse: string;
  69814. Fragment_Before_Lights: string;
  69815. Fragment_Before_Fog: string;
  69816. Fragment_Custom_Alpha: string;
  69817. Fragment_Before_FragColor: string;
  69818. Vertex_Begin: string;
  69819. Vertex_Definitions: string;
  69820. Vertex_MainBegin: string;
  69821. Vertex_Before_PositionUpdated: string;
  69822. Vertex_Before_NormalUpdated: string;
  69823. Vertex_MainEnd: string;
  69824. }
  69825. export class CustomMaterial extends BABYLON.StandardMaterial {
  69826. static ShaderIndexer: number;
  69827. CustomParts: ShaderSpecialParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  69828. FragmentShader: string;
  69829. VertexShader: string;
  69830. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  69831. ReviewUniform(name: string, arr: string[]): string[];
  69832. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  69833. constructor(name: string, scene: BABYLON.Scene);
  69834. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  69835. Fragment_Begin(shaderPart: string): CustomMaterial;
  69836. Fragment_Definitions(shaderPart: string): CustomMaterial;
  69837. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  69838. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  69839. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  69840. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  69841. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  69842. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  69843. Vertex_Begin(shaderPart: string): CustomMaterial;
  69844. Vertex_Definitions(shaderPart: string): CustomMaterial;
  69845. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  69846. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  69847. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  69848. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  69849. }
  69850. }
  69851. declare module BABYLON {
  69852. export class ShaderAlebdoParts {
  69853. constructor();
  69854. Fragment_Begin: string;
  69855. Fragment_Definitions: string;
  69856. Fragment_MainBegin: string;
  69857. Fragment_Custom_Albedo: string;
  69858. Fragment_Before_Lights: string;
  69859. Fragment_Custom_MetallicRoughness: string;
  69860. Fragment_Custom_MicroSurface: string;
  69861. Fragment_Before_Fog: string;
  69862. Fragment_Custom_Alpha: string;
  69863. Fragment_Before_FragColor: string;
  69864. Vertex_Begin: string;
  69865. Vertex_Definitions: string;
  69866. Vertex_MainBegin: string;
  69867. Vertex_Before_PositionUpdated: string;
  69868. Vertex_Before_NormalUpdated: string;
  69869. Vertex_MainEnd: string;
  69870. }
  69871. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  69872. static ShaderIndexer: number;
  69873. CustomParts: ShaderAlebdoParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  69874. FragmentShader: string;
  69875. VertexShader: string;
  69876. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  69877. ReviewUniform(name: string, arr: string[]): string[];
  69878. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  69879. constructor(name: string, scene: BABYLON.Scene);
  69880. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  69881. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  69882. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  69883. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  69884. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  69885. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  69886. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  69887. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  69888. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  69889. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  69890. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  69891. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  69892. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  69893. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  69894. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  69895. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  69896. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  69897. }
  69898. }
  69899. declare module BABYLON {
  69900. /** @hidden */
  69901. export var firePixelShader: {
  69902. name: string;
  69903. shader: string;
  69904. };
  69905. }
  69906. declare module BABYLON {
  69907. /** @hidden */
  69908. export var fireVertexShader: {
  69909. name: string;
  69910. shader: string;
  69911. };
  69912. }
  69913. declare module BABYLON {
  69914. export class FireMaterial extends BABYLON.PushMaterial {
  69915. private _diffuseTexture;
  69916. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69917. private _distortionTexture;
  69918. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69919. private _opacityTexture;
  69920. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69921. diffuseColor: BABYLON.Color3;
  69922. speed: number;
  69923. private _scaledDiffuse;
  69924. private _renderId;
  69925. private _lastTime;
  69926. constructor(name: string, scene: BABYLON.Scene);
  69927. needAlphaBlending(): boolean;
  69928. needAlphaTesting(): boolean;
  69929. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69930. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69931. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69932. getAnimatables(): BABYLON.IAnimatable[];
  69933. getActiveTextures(): BABYLON.BaseTexture[];
  69934. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69935. getClassName(): string;
  69936. dispose(forceDisposeEffect?: boolean): void;
  69937. clone(name: string): FireMaterial;
  69938. serialize(): any;
  69939. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  69940. }
  69941. }
  69942. declare module BABYLON {
  69943. /** @hidden */
  69944. export var furPixelShader: {
  69945. name: string;
  69946. shader: string;
  69947. };
  69948. }
  69949. declare module BABYLON {
  69950. /** @hidden */
  69951. export var furVertexShader: {
  69952. name: string;
  69953. shader: string;
  69954. };
  69955. }
  69956. declare module BABYLON {
  69957. export class FurMaterial extends BABYLON.PushMaterial {
  69958. private _diffuseTexture;
  69959. diffuseTexture: BABYLON.BaseTexture;
  69960. private _heightTexture;
  69961. heightTexture: BABYLON.BaseTexture;
  69962. diffuseColor: BABYLON.Color3;
  69963. furLength: number;
  69964. furAngle: number;
  69965. furColor: BABYLON.Color3;
  69966. furOffset: number;
  69967. furSpacing: number;
  69968. furGravity: BABYLON.Vector3;
  69969. furSpeed: number;
  69970. furDensity: number;
  69971. furOcclusion: number;
  69972. furTexture: BABYLON.DynamicTexture;
  69973. private _disableLighting;
  69974. disableLighting: boolean;
  69975. private _maxSimultaneousLights;
  69976. maxSimultaneousLights: number;
  69977. highLevelFur: boolean; private _meshes: BABYLON.AbstractMesh[];
  69978. private _renderId;
  69979. private _furTime;
  69980. constructor(name: string, scene: BABYLON.Scene);
  69981. furTime: number;
  69982. needAlphaBlending(): boolean;
  69983. needAlphaTesting(): boolean;
  69984. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69985. updateFur(): void;
  69986. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69987. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69988. getAnimatables(): BABYLON.IAnimatable[];
  69989. getActiveTextures(): BABYLON.BaseTexture[];
  69990. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69991. dispose(forceDisposeEffect?: boolean): void;
  69992. clone(name: string): FurMaterial;
  69993. serialize(): any;
  69994. getClassName(): string;
  69995. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  69996. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  69997. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  69998. }
  69999. }
  70000. declare module BABYLON {
  70001. /** @hidden */
  70002. export var gradientPixelShader: {
  70003. name: string;
  70004. shader: string;
  70005. };
  70006. }
  70007. declare module BABYLON {
  70008. /** @hidden */
  70009. export var gradientVertexShader: {
  70010. name: string;
  70011. shader: string;
  70012. };
  70013. }
  70014. declare module BABYLON {
  70015. export class GradientMaterial extends BABYLON.PushMaterial {
  70016. private _maxSimultaneousLights;
  70017. maxSimultaneousLights: number;
  70018. topColor: BABYLON.Color3;
  70019. topColorAlpha: number;
  70020. bottomColor: BABYLON.Color3;
  70021. bottomColorAlpha: number;
  70022. offset: number;
  70023. scale: number;
  70024. smoothness: number;
  70025. private _disableLighting;
  70026. disableLighting: boolean;
  70027. private _renderId;
  70028. constructor(name: string, scene: BABYLON.Scene);
  70029. needAlphaBlending(): boolean;
  70030. needAlphaTesting(): boolean;
  70031. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70032. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70033. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70034. getAnimatables(): BABYLON.IAnimatable[];
  70035. dispose(forceDisposeEffect?: boolean): void;
  70036. clone(name: string): GradientMaterial;
  70037. serialize(): any;
  70038. getClassName(): string;
  70039. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  70040. }
  70041. }
  70042. declare module BABYLON {
  70043. /** @hidden */
  70044. export var gridPixelShader: {
  70045. name: string;
  70046. shader: string;
  70047. };
  70048. }
  70049. declare module BABYLON {
  70050. /** @hidden */
  70051. export var gridVertexShader: {
  70052. name: string;
  70053. shader: string;
  70054. };
  70055. }
  70056. declare module BABYLON {
  70057. /**
  70058. * The grid materials allows you to wrap any shape with a grid.
  70059. * Colors are customizable.
  70060. */
  70061. export class GridMaterial extends BABYLON.PushMaterial {
  70062. /**
  70063. * Main color of the grid (e.g. between lines)
  70064. */
  70065. mainColor: BABYLON.Color3;
  70066. /**
  70067. * Color of the grid lines.
  70068. */
  70069. lineColor: BABYLON.Color3;
  70070. /**
  70071. * The scale of the grid compared to unit.
  70072. */
  70073. gridRatio: number;
  70074. /**
  70075. * Allows setting an offset for the grid lines.
  70076. */
  70077. gridOffset: BABYLON.Vector3;
  70078. /**
  70079. * The frequency of thicker lines.
  70080. */
  70081. majorUnitFrequency: number;
  70082. /**
  70083. * The visibility of minor units in the grid.
  70084. */
  70085. minorUnitVisibility: number;
  70086. /**
  70087. * The grid opacity outside of the lines.
  70088. */
  70089. opacity: number;
  70090. /**
  70091. * Determine RBG output is premultiplied by alpha value.
  70092. */
  70093. preMultiplyAlpha: boolean;
  70094. private _opacityTexture;
  70095. opacityTexture: BABYLON.BaseTexture;
  70096. private _gridControl;
  70097. private _renderId;
  70098. /**
  70099. * constructor
  70100. * @param name The name given to the material in order to identify it afterwards.
  70101. * @param scene The scene the material is used in.
  70102. */
  70103. constructor(name: string, scene: BABYLON.Scene);
  70104. /**
  70105. * Returns wehter or not the grid requires alpha blending.
  70106. */
  70107. needAlphaBlending(): boolean;
  70108. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70109. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70110. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70111. /**
  70112. * Dispose the material and its associated resources.
  70113. * @param forceDisposeEffect will also dispose the used effect when true
  70114. */
  70115. dispose(forceDisposeEffect?: boolean): void;
  70116. clone(name: string): GridMaterial;
  70117. serialize(): any;
  70118. getClassName(): string;
  70119. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  70120. }
  70121. }
  70122. declare module BABYLON {
  70123. /** @hidden */
  70124. export var lavaPixelShader: {
  70125. name: string;
  70126. shader: string;
  70127. };
  70128. }
  70129. declare module BABYLON {
  70130. /** @hidden */
  70131. export var lavaVertexShader: {
  70132. name: string;
  70133. shader: string;
  70134. };
  70135. }
  70136. declare module BABYLON {
  70137. export class LavaMaterial extends BABYLON.PushMaterial {
  70138. private _diffuseTexture;
  70139. diffuseTexture: BABYLON.BaseTexture;
  70140. noiseTexture: BABYLON.BaseTexture;
  70141. fogColor: BABYLON.Color3;
  70142. speed: number;
  70143. movingSpeed: number;
  70144. lowFrequencySpeed: number;
  70145. fogDensity: number;
  70146. private _lastTime;
  70147. diffuseColor: BABYLON.Color3;
  70148. private _disableLighting;
  70149. disableLighting: boolean;
  70150. private _unlit;
  70151. unlit: boolean;
  70152. private _maxSimultaneousLights;
  70153. maxSimultaneousLights: number;
  70154. private _scaledDiffuse;
  70155. private _renderId;
  70156. constructor(name: string, scene: BABYLON.Scene);
  70157. needAlphaBlending(): boolean;
  70158. needAlphaTesting(): boolean;
  70159. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70160. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70161. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70162. getAnimatables(): BABYLON.IAnimatable[];
  70163. getActiveTextures(): BABYLON.BaseTexture[];
  70164. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70165. dispose(forceDisposeEffect?: boolean): void;
  70166. clone(name: string): LavaMaterial;
  70167. serialize(): any;
  70168. getClassName(): string;
  70169. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  70170. }
  70171. }
  70172. declare module BABYLON {
  70173. /** @hidden */
  70174. export var mixPixelShader: {
  70175. name: string;
  70176. shader: string;
  70177. };
  70178. }
  70179. declare module BABYLON {
  70180. /** @hidden */
  70181. export var mixVertexShader: {
  70182. name: string;
  70183. shader: string;
  70184. };
  70185. }
  70186. declare module BABYLON {
  70187. export class MixMaterial extends BABYLON.PushMaterial {
  70188. /**
  70189. * Mix textures
  70190. */
  70191. private _mixTexture1;
  70192. mixTexture1: BABYLON.BaseTexture;
  70193. private _mixTexture2;
  70194. mixTexture2: BABYLON.BaseTexture;
  70195. /**
  70196. * Diffuse textures
  70197. */
  70198. private _diffuseTexture1;
  70199. diffuseTexture1: BABYLON.Texture;
  70200. private _diffuseTexture2;
  70201. diffuseTexture2: BABYLON.Texture;
  70202. private _diffuseTexture3;
  70203. diffuseTexture3: BABYLON.Texture;
  70204. private _diffuseTexture4;
  70205. diffuseTexture4: BABYLON.Texture;
  70206. private _diffuseTexture5;
  70207. diffuseTexture5: BABYLON.Texture;
  70208. private _diffuseTexture6;
  70209. diffuseTexture6: BABYLON.Texture;
  70210. private _diffuseTexture7;
  70211. diffuseTexture7: BABYLON.Texture;
  70212. private _diffuseTexture8;
  70213. diffuseTexture8: BABYLON.Texture;
  70214. /**
  70215. * Uniforms
  70216. */
  70217. diffuseColor: BABYLON.Color3;
  70218. specularColor: BABYLON.Color3;
  70219. specularPower: number;
  70220. private _disableLighting;
  70221. disableLighting: boolean;
  70222. private _maxSimultaneousLights;
  70223. maxSimultaneousLights: number;
  70224. private _renderId;
  70225. constructor(name: string, scene: BABYLON.Scene);
  70226. needAlphaBlending(): boolean;
  70227. needAlphaTesting(): boolean;
  70228. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70229. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70230. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70231. getAnimatables(): BABYLON.IAnimatable[];
  70232. getActiveTextures(): BABYLON.BaseTexture[];
  70233. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70234. dispose(forceDisposeEffect?: boolean): void;
  70235. clone(name: string): MixMaterial;
  70236. serialize(): any;
  70237. getClassName(): string;
  70238. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  70239. }
  70240. }
  70241. declare module BABYLON {
  70242. /** @hidden */
  70243. export var normalPixelShader: {
  70244. name: string;
  70245. shader: string;
  70246. };
  70247. }
  70248. declare module BABYLON {
  70249. /** @hidden */
  70250. export var normalVertexShader: {
  70251. name: string;
  70252. shader: string;
  70253. };
  70254. }
  70255. declare module BABYLON {
  70256. export class NormalMaterial extends BABYLON.PushMaterial {
  70257. private _diffuseTexture;
  70258. diffuseTexture: BABYLON.BaseTexture;
  70259. diffuseColor: BABYLON.Color3;
  70260. private _disableLighting;
  70261. disableLighting: boolean;
  70262. private _maxSimultaneousLights;
  70263. maxSimultaneousLights: number;
  70264. private _renderId;
  70265. constructor(name: string, scene: BABYLON.Scene);
  70266. needAlphaBlending(): boolean;
  70267. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70268. needAlphaTesting(): boolean;
  70269. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70270. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70271. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70272. getAnimatables(): BABYLON.IAnimatable[];
  70273. getActiveTextures(): BABYLON.BaseTexture[];
  70274. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70275. dispose(forceDisposeEffect?: boolean): void;
  70276. clone(name: string): NormalMaterial;
  70277. serialize(): any;
  70278. getClassName(): string;
  70279. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  70280. }
  70281. }
  70282. declare module BABYLON {
  70283. /** @hidden */
  70284. export var shadowOnlyPixelShader: {
  70285. name: string;
  70286. shader: string;
  70287. };
  70288. }
  70289. declare module BABYLON {
  70290. /** @hidden */
  70291. export var shadowOnlyVertexShader: {
  70292. name: string;
  70293. shader: string;
  70294. };
  70295. }
  70296. declare module BABYLON {
  70297. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  70298. private _renderId;
  70299. private _activeLight;
  70300. constructor(name: string, scene: BABYLON.Scene);
  70301. shadowColor: BABYLON.Color3;
  70302. needAlphaBlending(): boolean;
  70303. needAlphaTesting(): boolean;
  70304. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70305. activeLight: BABYLON.IShadowLight;
  70306. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70307. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70308. clone(name: string): ShadowOnlyMaterial;
  70309. serialize(): any;
  70310. getClassName(): string;
  70311. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  70312. }
  70313. }
  70314. declare module BABYLON {
  70315. /** @hidden */
  70316. export var simplePixelShader: {
  70317. name: string;
  70318. shader: string;
  70319. };
  70320. }
  70321. declare module BABYLON {
  70322. /** @hidden */
  70323. export var simpleVertexShader: {
  70324. name: string;
  70325. shader: string;
  70326. };
  70327. }
  70328. declare module BABYLON {
  70329. export class SimpleMaterial extends BABYLON.PushMaterial {
  70330. private _diffuseTexture;
  70331. diffuseTexture: BABYLON.BaseTexture;
  70332. diffuseColor: BABYLON.Color3;
  70333. private _disableLighting;
  70334. disableLighting: boolean;
  70335. private _maxSimultaneousLights;
  70336. maxSimultaneousLights: number;
  70337. private _renderId;
  70338. constructor(name: string, scene: BABYLON.Scene);
  70339. needAlphaBlending(): boolean;
  70340. needAlphaTesting(): boolean;
  70341. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70342. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70343. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70344. getAnimatables(): BABYLON.IAnimatable[];
  70345. getActiveTextures(): BABYLON.BaseTexture[];
  70346. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70347. dispose(forceDisposeEffect?: boolean): void;
  70348. clone(name: string): SimpleMaterial;
  70349. serialize(): any;
  70350. getClassName(): string;
  70351. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  70352. }
  70353. }
  70354. declare module BABYLON {
  70355. /** @hidden */
  70356. export var skyPixelShader: {
  70357. name: string;
  70358. shader: string;
  70359. };
  70360. }
  70361. declare module BABYLON {
  70362. /** @hidden */
  70363. export var skyVertexShader: {
  70364. name: string;
  70365. shader: string;
  70366. };
  70367. }
  70368. declare module BABYLON {
  70369. /**
  70370. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  70371. * @see https://doc.babylonjs.com/extensions/sky
  70372. */
  70373. export class SkyMaterial extends BABYLON.PushMaterial {
  70374. /**
  70375. * Defines the overall luminance of sky in interval ]0, 1[.
  70376. */
  70377. luminance: number;
  70378. /**
  70379. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  70380. */
  70381. turbidity: number;
  70382. /**
  70383. * Defines the sky appearance (light intensity).
  70384. */
  70385. rayleigh: number;
  70386. /**
  70387. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  70388. */
  70389. mieCoefficient: number;
  70390. /**
  70391. * Defines the amount of haze particles following the Mie scattering theory.
  70392. */
  70393. mieDirectionalG: number;
  70394. /**
  70395. * Defines the distance of the sun according to the active scene camera.
  70396. */
  70397. distance: number;
  70398. /**
  70399. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  70400. * "inclined".
  70401. */
  70402. inclination: number;
  70403. /**
  70404. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  70405. * an object direction and a reference direction.
  70406. */
  70407. azimuth: number;
  70408. /**
  70409. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  70410. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  70411. */
  70412. sunPosition: BABYLON.Vector3;
  70413. /**
  70414. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  70415. * .sunPosition property.
  70416. */
  70417. useSunPosition: boolean;
  70418. /**
  70419. * Defines an offset vector used to get a horizon offset.
  70420. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  70421. */
  70422. cameraOffset: BABYLON.Vector3;
  70423. private _cameraPosition;
  70424. private _renderId;
  70425. /**
  70426. * Instantiates a new sky material.
  70427. * This material allows to create dynamic and texture free
  70428. * effects for skyboxes by taking care of the atmosphere state.
  70429. * @see https://doc.babylonjs.com/extensions/sky
  70430. * @param name Define the name of the material in the scene
  70431. * @param scene Define the scene the material belong to
  70432. */
  70433. constructor(name: string, scene: BABYLON.Scene);
  70434. /**
  70435. * Specifies if the material will require alpha blending
  70436. * @returns a boolean specifying if alpha blending is needed
  70437. */
  70438. needAlphaBlending(): boolean;
  70439. /**
  70440. * Specifies if this material should be rendered in alpha test mode
  70441. * @returns false as the sky material doesn't need alpha testing.
  70442. */
  70443. needAlphaTesting(): boolean;
  70444. /**
  70445. * Get the texture used for alpha test purpose.
  70446. * @returns null as the sky material has no texture.
  70447. */
  70448. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70449. /**
  70450. * Get if the submesh is ready to be used and all its information available.
  70451. * Child classes can use it to update shaders
  70452. * @param mesh defines the mesh to check
  70453. * @param subMesh defines which submesh to check
  70454. * @param useInstances specifies that instances should be used
  70455. * @returns a boolean indicating that the submesh is ready or not
  70456. */
  70457. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70458. /**
  70459. * Binds the submesh to this material by preparing the effect and shader to draw
  70460. * @param world defines the world transformation matrix
  70461. * @param mesh defines the mesh containing the submesh
  70462. * @param subMesh defines the submesh to bind the material to
  70463. */
  70464. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70465. /**
  70466. * Get the list of animatables in the material.
  70467. * @returns the list of animatables object used in the material
  70468. */
  70469. getAnimatables(): BABYLON.IAnimatable[];
  70470. /**
  70471. * Disposes the material
  70472. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  70473. */
  70474. dispose(forceDisposeEffect?: boolean): void;
  70475. /**
  70476. * Makes a duplicate of the material, and gives it a new name
  70477. * @param name defines the new name for the duplicated material
  70478. * @returns the cloned material
  70479. */
  70480. clone(name: string): SkyMaterial;
  70481. /**
  70482. * Serializes this material in a JSON representation
  70483. * @returns the serialized material object
  70484. */
  70485. serialize(): any;
  70486. /**
  70487. * Gets the current class name of the material e.g. "SkyMaterial"
  70488. * Mainly use in serialization.
  70489. * @returns the class name
  70490. */
  70491. getClassName(): string;
  70492. /**
  70493. * Creates a sky material from parsed material data
  70494. * @param source defines the JSON representation of the material
  70495. * @param scene defines the hosting scene
  70496. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70497. * @returns a new sky material
  70498. */
  70499. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  70500. }
  70501. }
  70502. declare module BABYLON {
  70503. /** @hidden */
  70504. export var terrainPixelShader: {
  70505. name: string;
  70506. shader: string;
  70507. };
  70508. }
  70509. declare module BABYLON {
  70510. /** @hidden */
  70511. export var terrainVertexShader: {
  70512. name: string;
  70513. shader: string;
  70514. };
  70515. }
  70516. declare module BABYLON {
  70517. export class TerrainMaterial extends BABYLON.PushMaterial {
  70518. private _mixTexture;
  70519. mixTexture: BABYLON.BaseTexture;
  70520. private _diffuseTexture1;
  70521. diffuseTexture1: BABYLON.Texture;
  70522. private _diffuseTexture2;
  70523. diffuseTexture2: BABYLON.Texture;
  70524. private _diffuseTexture3;
  70525. diffuseTexture3: BABYLON.Texture;
  70526. private _bumpTexture1;
  70527. bumpTexture1: BABYLON.Texture;
  70528. private _bumpTexture2;
  70529. bumpTexture2: BABYLON.Texture;
  70530. private _bumpTexture3;
  70531. bumpTexture3: BABYLON.Texture;
  70532. diffuseColor: BABYLON.Color3;
  70533. specularColor: BABYLON.Color3;
  70534. specularPower: number;
  70535. private _disableLighting;
  70536. disableLighting: boolean;
  70537. private _maxSimultaneousLights;
  70538. maxSimultaneousLights: number;
  70539. private _renderId;
  70540. constructor(name: string, scene: BABYLON.Scene);
  70541. needAlphaBlending(): boolean;
  70542. needAlphaTesting(): boolean;
  70543. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70544. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70545. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70546. getAnimatables(): BABYLON.IAnimatable[];
  70547. getActiveTextures(): BABYLON.BaseTexture[];
  70548. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70549. dispose(forceDisposeEffect?: boolean): void;
  70550. clone(name: string): TerrainMaterial;
  70551. serialize(): any;
  70552. getClassName(): string;
  70553. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  70554. }
  70555. }
  70556. declare module BABYLON {
  70557. /** @hidden */
  70558. export var triplanarPixelShader: {
  70559. name: string;
  70560. shader: string;
  70561. };
  70562. }
  70563. declare module BABYLON {
  70564. /** @hidden */
  70565. export var triplanarVertexShader: {
  70566. name: string;
  70567. shader: string;
  70568. };
  70569. }
  70570. declare module BABYLON {
  70571. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  70572. mixTexture: BABYLON.BaseTexture;
  70573. private _diffuseTextureX;
  70574. diffuseTextureX: BABYLON.BaseTexture;
  70575. private _diffuseTextureY;
  70576. diffuseTextureY: BABYLON.BaseTexture;
  70577. private _diffuseTextureZ;
  70578. diffuseTextureZ: BABYLON.BaseTexture;
  70579. private _normalTextureX;
  70580. normalTextureX: BABYLON.BaseTexture;
  70581. private _normalTextureY;
  70582. normalTextureY: BABYLON.BaseTexture;
  70583. private _normalTextureZ;
  70584. normalTextureZ: BABYLON.BaseTexture;
  70585. tileSize: number;
  70586. diffuseColor: BABYLON.Color3;
  70587. specularColor: BABYLON.Color3;
  70588. specularPower: number;
  70589. private _disableLighting;
  70590. disableLighting: boolean;
  70591. private _maxSimultaneousLights;
  70592. maxSimultaneousLights: number;
  70593. private _renderId;
  70594. constructor(name: string, scene: BABYLON.Scene);
  70595. needAlphaBlending(): boolean;
  70596. needAlphaTesting(): boolean;
  70597. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70598. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70599. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70600. getAnimatables(): BABYLON.IAnimatable[];
  70601. getActiveTextures(): BABYLON.BaseTexture[];
  70602. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70603. dispose(forceDisposeEffect?: boolean): void;
  70604. clone(name: string): TriPlanarMaterial;
  70605. serialize(): any;
  70606. getClassName(): string;
  70607. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  70608. }
  70609. }
  70610. declare module BABYLON {
  70611. /** @hidden */
  70612. export var waterPixelShader: {
  70613. name: string;
  70614. shader: string;
  70615. };
  70616. }
  70617. declare module BABYLON {
  70618. /** @hidden */
  70619. export var waterVertexShader: {
  70620. name: string;
  70621. shader: string;
  70622. };
  70623. }
  70624. declare module BABYLON {
  70625. export class WaterMaterial extends BABYLON.PushMaterial {
  70626. renderTargetSize: BABYLON.Vector2;
  70627. private _bumpTexture;
  70628. bumpTexture: BABYLON.BaseTexture;
  70629. diffuseColor: BABYLON.Color3;
  70630. specularColor: BABYLON.Color3;
  70631. specularPower: number;
  70632. private _disableLighting;
  70633. disableLighting: boolean;
  70634. private _maxSimultaneousLights;
  70635. maxSimultaneousLights: number;
  70636. /**
  70637. * @param {number}: Represents the wind force
  70638. */
  70639. windForce: number;
  70640. /**
  70641. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  70642. */
  70643. windDirection: BABYLON.Vector2;
  70644. /**
  70645. * @param {number}: Wave height, represents the height of the waves
  70646. */
  70647. waveHeight: number;
  70648. /**
  70649. * @param {number}: Bump height, represents the bump height related to the bump map
  70650. */
  70651. bumpHeight: number;
  70652. /**
  70653. * @param {boolean}: Add a smaller moving bump to less steady waves.
  70654. */
  70655. private _bumpSuperimpose;
  70656. bumpSuperimpose: boolean;
  70657. /**
  70658. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  70659. */
  70660. private _fresnelSeparate;
  70661. fresnelSeparate: boolean;
  70662. /**
  70663. * @param {boolean}: bump Waves modify the reflection.
  70664. */
  70665. private _bumpAffectsReflection;
  70666. bumpAffectsReflection: boolean;
  70667. /**
  70668. * @param {number}: The water color blended with the refraction (near)
  70669. */
  70670. waterColor: BABYLON.Color3;
  70671. /**
  70672. * @param {number}: The blend factor related to the water color
  70673. */
  70674. colorBlendFactor: number;
  70675. /**
  70676. * @param {number}: The water color blended with the reflection (far)
  70677. */
  70678. waterColor2: BABYLON.Color3;
  70679. /**
  70680. * @param {number}: The blend factor related to the water color (reflection, far)
  70681. */
  70682. colorBlendFactor2: number;
  70683. /**
  70684. * @param {number}: Represents the maximum length of a wave
  70685. */
  70686. waveLength: number;
  70687. /**
  70688. * @param {number}: Defines the waves speed
  70689. */
  70690. waveSpeed: number;
  70691. /**
  70692. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  70693. * will avoid calculating useless pixels in the pixel shader of the water material.
  70694. */
  70695. disableClipPlane: boolean;
  70696. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  70697. private _mesh;
  70698. private _refractionRTT;
  70699. private _reflectionRTT;
  70700. private _reflectionTransform;
  70701. private _lastTime;
  70702. private _lastDeltaTime;
  70703. private _renderId;
  70704. private _useLogarithmicDepth;
  70705. private _waitingRenderList;
  70706. private _imageProcessingConfiguration;
  70707. private _imageProcessingObserver;
  70708. /**
  70709. * Gets a boolean indicating that current material needs to register RTT
  70710. */
  70711. readonly hasRenderTargetTextures: boolean;
  70712. /**
  70713. * Constructor
  70714. */
  70715. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  70716. useLogarithmicDepth: boolean;
  70717. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  70718. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  70719. addToRenderList(node: any): void;
  70720. enableRenderTargets(enable: boolean): void;
  70721. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  70722. readonly renderTargetsEnabled: boolean;
  70723. needAlphaBlending(): boolean;
  70724. needAlphaTesting(): boolean;
  70725. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70726. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70727. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70728. private _createRenderTargets;
  70729. getAnimatables(): BABYLON.IAnimatable[];
  70730. getActiveTextures(): BABYLON.BaseTexture[];
  70731. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70732. dispose(forceDisposeEffect?: boolean): void;
  70733. clone(name: string): WaterMaterial;
  70734. serialize(): any;
  70735. getClassName(): string;
  70736. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  70737. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  70738. }
  70739. }
  70740. declare module BABYLON {
  70741. /** @hidden */
  70742. export var asciiartPixelShader: {
  70743. name: string;
  70744. shader: string;
  70745. };
  70746. }
  70747. declare module BABYLON {
  70748. /**
  70749. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  70750. *
  70751. * It basically takes care rendering the font front the given font size to a texture.
  70752. * This is used later on in the postprocess.
  70753. */
  70754. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  70755. private _font;
  70756. private _text;
  70757. private _charSize;
  70758. /**
  70759. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  70760. */
  70761. readonly charSize: number;
  70762. /**
  70763. * Create a new instance of the Ascii Art FontTexture class
  70764. * @param name the name of the texture
  70765. * @param font the font to use, use the W3C CSS notation
  70766. * @param text the caracter set to use in the rendering.
  70767. * @param scene the scene that owns the texture
  70768. */
  70769. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  70770. /**
  70771. * Gets the max char width of a font.
  70772. * @param font the font to use, use the W3C CSS notation
  70773. * @return the max char width
  70774. */
  70775. private getFontWidth;
  70776. /**
  70777. * Gets the max char height of a font.
  70778. * @param font the font to use, use the W3C CSS notation
  70779. * @return the max char height
  70780. */
  70781. private getFontHeight;
  70782. /**
  70783. * Clones the current AsciiArtTexture.
  70784. * @return the clone of the texture.
  70785. */
  70786. clone(): AsciiArtFontTexture;
  70787. /**
  70788. * Parses a json object representing the texture and returns an instance of it.
  70789. * @param source the source JSON representation
  70790. * @param scene the scene to create the texture for
  70791. * @return the parsed texture
  70792. */
  70793. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  70794. }
  70795. /**
  70796. * Option available in the Ascii Art Post Process.
  70797. */
  70798. export interface IAsciiArtPostProcessOptions {
  70799. /**
  70800. * The font to use following the w3c font definition.
  70801. */
  70802. font?: string;
  70803. /**
  70804. * The character set to use in the postprocess.
  70805. */
  70806. characterSet?: string;
  70807. /**
  70808. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  70809. * This number is defined between 0 and 1;
  70810. */
  70811. mixToTile?: number;
  70812. /**
  70813. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  70814. * This number is defined between 0 and 1;
  70815. */
  70816. mixToNormal?: number;
  70817. }
  70818. /**
  70819. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  70820. *
  70821. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70822. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  70823. */
  70824. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  70825. /**
  70826. * The font texture used to render the char in the post process.
  70827. */
  70828. private _asciiArtFontTexture;
  70829. /**
  70830. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  70831. * This number is defined between 0 and 1;
  70832. */
  70833. mixToTile: number;
  70834. /**
  70835. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  70836. * This number is defined between 0 and 1;
  70837. */
  70838. mixToNormal: number;
  70839. /**
  70840. * Instantiates a new Ascii Art Post Process.
  70841. * @param name the name to give to the postprocess
  70842. * @camera the camera to apply the post process to.
  70843. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  70844. */
  70845. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  70846. }
  70847. }
  70848. declare module BABYLON {
  70849. /** @hidden */
  70850. export var digitalrainPixelShader: {
  70851. name: string;
  70852. shader: string;
  70853. };
  70854. }
  70855. declare module BABYLON {
  70856. /**
  70857. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  70858. *
  70859. * It basically takes care rendering the font front the given font size to a texture.
  70860. * This is used later on in the postprocess.
  70861. */
  70862. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  70863. private _font;
  70864. private _text;
  70865. private _charSize;
  70866. /**
  70867. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  70868. */
  70869. readonly charSize: number;
  70870. /**
  70871. * Create a new instance of the Digital Rain FontTexture class
  70872. * @param name the name of the texture
  70873. * @param font the font to use, use the W3C CSS notation
  70874. * @param text the caracter set to use in the rendering.
  70875. * @param scene the scene that owns the texture
  70876. */
  70877. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  70878. /**
  70879. * Gets the max char width of a font.
  70880. * @param font the font to use, use the W3C CSS notation
  70881. * @return the max char width
  70882. */
  70883. private getFontWidth;
  70884. /**
  70885. * Gets the max char height of a font.
  70886. * @param font the font to use, use the W3C CSS notation
  70887. * @return the max char height
  70888. */
  70889. private getFontHeight;
  70890. /**
  70891. * Clones the current DigitalRainFontTexture.
  70892. * @return the clone of the texture.
  70893. */
  70894. clone(): DigitalRainFontTexture;
  70895. /**
  70896. * Parses a json object representing the texture and returns an instance of it.
  70897. * @param source the source JSON representation
  70898. * @param scene the scene to create the texture for
  70899. * @return the parsed texture
  70900. */
  70901. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  70902. }
  70903. /**
  70904. * Option available in the Digital Rain Post Process.
  70905. */
  70906. export interface IDigitalRainPostProcessOptions {
  70907. /**
  70908. * The font to use following the w3c font definition.
  70909. */
  70910. font?: string;
  70911. /**
  70912. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  70913. * This number is defined between 0 and 1;
  70914. */
  70915. mixToTile?: number;
  70916. /**
  70917. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  70918. * This number is defined between 0 and 1;
  70919. */
  70920. mixToNormal?: number;
  70921. }
  70922. /**
  70923. * DigitalRainPostProcess helps rendering everithing in digital rain.
  70924. *
  70925. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70926. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  70927. */
  70928. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  70929. /**
  70930. * The font texture used to render the char in the post process.
  70931. */
  70932. private _digitalRainFontTexture;
  70933. /**
  70934. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  70935. * This number is defined between 0 and 1;
  70936. */
  70937. mixToTile: number;
  70938. /**
  70939. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  70940. * This number is defined between 0 and 1;
  70941. */
  70942. mixToNormal: number;
  70943. /**
  70944. * Instantiates a new Digital Rain Post Process.
  70945. * @param name the name to give to the postprocess
  70946. * @camera the camera to apply the post process to.
  70947. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  70948. */
  70949. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  70950. }
  70951. }
  70952. declare module BABYLON {
  70953. /** @hidden */
  70954. export var oceanPostProcessPixelShader: {
  70955. name: string;
  70956. shader: string;
  70957. };
  70958. }
  70959. declare module BABYLON {
  70960. /**
  70961. * Option available in the Ocean Post Process.
  70962. */
  70963. export interface IOceanPostProcessOptions {
  70964. /**
  70965. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  70966. */
  70967. reflectionSize?: number | {
  70968. width: number;
  70969. height: number;
  70970. } | {
  70971. ratio: number;
  70972. };
  70973. /**
  70974. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  70975. */
  70976. refractionSize?: number | {
  70977. width: number;
  70978. height: number;
  70979. } | {
  70980. ratio: number;
  70981. };
  70982. }
  70983. /**
  70984. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  70985. *
  70986. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70987. * Example usage:
  70988. * var pp = new OceanPostProcess("myOcean", camera);
  70989. * pp.reflectionEnabled = true;
  70990. * pp.refractionEnabled = true;
  70991. */
  70992. export class OceanPostProcess extends BABYLON.PostProcess {
  70993. /**
  70994. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  70995. */
  70996. /**
  70997. * Sets weither or not the real-time reflection is enabled on the ocean.
  70998. * Is set to true, the reflection mirror texture will be used as reflection texture.
  70999. */
  71000. reflectionEnabled: boolean;
  71001. /**
  71002. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  71003. */
  71004. /**
  71005. * Sets weither or not the real-time refraction is enabled on the ocean.
  71006. * Is set to true, the refraction render target texture will be used as refraction texture.
  71007. */
  71008. refractionEnabled: boolean;
  71009. /**
  71010. * Gets wether or not the post-processes is supported by the running hardware.
  71011. * This requires draw buffer supports.
  71012. */
  71013. readonly isSupported: boolean;
  71014. /**
  71015. * This is the reflection mirror texture used to display reflections on the ocean.
  71016. * By default, render list is empty.
  71017. */
  71018. reflectionTexture: BABYLON.MirrorTexture;
  71019. /**
  71020. * This is the refraction render target texture used to display refraction on the ocean.
  71021. * By default, render list is empty.
  71022. */
  71023. refractionTexture: BABYLON.RenderTargetTexture;
  71024. private _time;
  71025. private _cameraRotation;
  71026. private _cameraViewMatrix;
  71027. private _reflectionEnabled;
  71028. private _refractionEnabled;
  71029. private _geometryRenderer;
  71030. /**
  71031. * Instantiates a new Ocean Post Process.
  71032. * @param name the name to give to the postprocess.
  71033. * @camera the camera to apply the post process to.
  71034. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  71035. */
  71036. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  71037. /**
  71038. * Returns the appropriate defines according to the current configuration.
  71039. */
  71040. private _getDefines;
  71041. /**
  71042. * Computes the current camera rotation as the shader requires a camera rotation.
  71043. */
  71044. private _computeCameraRotation;
  71045. }
  71046. }
  71047. declare module BABYLON {
  71048. /** @hidden */
  71049. export var brickProceduralTexturePixelShader: {
  71050. name: string;
  71051. shader: string;
  71052. };
  71053. }
  71054. declare module BABYLON {
  71055. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  71056. private _numberOfBricksHeight;
  71057. private _numberOfBricksWidth;
  71058. private _jointColor;
  71059. private _brickColor;
  71060. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71061. updateShaderUniforms(): void;
  71062. numberOfBricksHeight: number;
  71063. numberOfBricksWidth: number;
  71064. jointColor: BABYLON.Color3;
  71065. brickColor: BABYLON.Color3;
  71066. /**
  71067. * Serializes this brick procedural texture
  71068. * @returns a serialized brick procedural texture object
  71069. */
  71070. serialize(): any;
  71071. /**
  71072. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  71073. * @param parsedTexture defines parsed texture data
  71074. * @param scene defines the current scene
  71075. * @param rootUrl defines the root URL containing brick procedural texture information
  71076. * @returns a parsed Brick Procedural BABYLON.Texture
  71077. */
  71078. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  71079. }
  71080. }
  71081. declare module BABYLON {
  71082. /** @hidden */
  71083. export var cloudProceduralTexturePixelShader: {
  71084. name: string;
  71085. shader: string;
  71086. };
  71087. }
  71088. declare module BABYLON {
  71089. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  71090. private _skyColor;
  71091. private _cloudColor;
  71092. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71093. updateShaderUniforms(): void;
  71094. skyColor: BABYLON.Color4;
  71095. cloudColor: BABYLON.Color4;
  71096. /**
  71097. * Serializes this cloud procedural texture
  71098. * @returns a serialized cloud procedural texture object
  71099. */
  71100. serialize(): any;
  71101. /**
  71102. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  71103. * @param parsedTexture defines parsed texture data
  71104. * @param scene defines the current scene
  71105. * @param rootUrl defines the root URL containing cloud procedural texture information
  71106. * @returns a parsed Cloud Procedural BABYLON.Texture
  71107. */
  71108. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  71109. }
  71110. }
  71111. declare module BABYLON {
  71112. /** @hidden */
  71113. export var fireProceduralTexturePixelShader: {
  71114. name: string;
  71115. shader: string;
  71116. };
  71117. }
  71118. declare module BABYLON {
  71119. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  71120. private _time;
  71121. private _speed;
  71122. private _autoGenerateTime;
  71123. private _fireColors;
  71124. private _alphaThreshold;
  71125. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71126. updateShaderUniforms(): void;
  71127. render(useCameraPostProcess?: boolean): void;
  71128. static readonly PurpleFireColors: BABYLON.Color3[];
  71129. static readonly GreenFireColors: BABYLON.Color3[];
  71130. static readonly RedFireColors: BABYLON.Color3[];
  71131. static readonly BlueFireColors: BABYLON.Color3[];
  71132. autoGenerateTime: boolean;
  71133. fireColors: BABYLON.Color3[];
  71134. time: number;
  71135. speed: BABYLON.Vector2;
  71136. alphaThreshold: number;
  71137. /**
  71138. * Serializes this fire procedural texture
  71139. * @returns a serialized fire procedural texture object
  71140. */
  71141. serialize(): any;
  71142. /**
  71143. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  71144. * @param parsedTexture defines parsed texture data
  71145. * @param scene defines the current scene
  71146. * @param rootUrl defines the root URL containing fire procedural texture information
  71147. * @returns a parsed Fire Procedural BABYLON.Texture
  71148. */
  71149. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  71150. }
  71151. }
  71152. declare module BABYLON {
  71153. /** @hidden */
  71154. export var grassProceduralTexturePixelShader: {
  71155. name: string;
  71156. shader: string;
  71157. };
  71158. }
  71159. declare module BABYLON {
  71160. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  71161. private _grassColors;
  71162. private _groundColor;
  71163. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71164. updateShaderUniforms(): void;
  71165. grassColors: BABYLON.Color3[];
  71166. groundColor: BABYLON.Color3;
  71167. /**
  71168. * Serializes this grass procedural texture
  71169. * @returns a serialized grass procedural texture object
  71170. */
  71171. serialize(): any;
  71172. /**
  71173. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  71174. * @param parsedTexture defines parsed texture data
  71175. * @param scene defines the current scene
  71176. * @param rootUrl defines the root URL containing grass procedural texture information
  71177. * @returns a parsed Grass Procedural BABYLON.Texture
  71178. */
  71179. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  71180. }
  71181. }
  71182. declare module BABYLON {
  71183. /** @hidden */
  71184. export var marbleProceduralTexturePixelShader: {
  71185. name: string;
  71186. shader: string;
  71187. };
  71188. }
  71189. declare module BABYLON {
  71190. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  71191. private _numberOfTilesHeight;
  71192. private _numberOfTilesWidth;
  71193. private _amplitude;
  71194. private _jointColor;
  71195. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71196. updateShaderUniforms(): void;
  71197. numberOfTilesHeight: number;
  71198. amplitude: number;
  71199. numberOfTilesWidth: number;
  71200. jointColor: BABYLON.Color3;
  71201. /**
  71202. * Serializes this marble procedural texture
  71203. * @returns a serialized marble procedural texture object
  71204. */
  71205. serialize(): any;
  71206. /**
  71207. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  71208. * @param parsedTexture defines parsed texture data
  71209. * @param scene defines the current scene
  71210. * @param rootUrl defines the root URL containing marble procedural texture information
  71211. * @returns a parsed Marble Procedural BABYLON.Texture
  71212. */
  71213. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  71214. }
  71215. }
  71216. declare module BABYLON {
  71217. /** @hidden */
  71218. export var normalMapProceduralTexturePixelShader: {
  71219. name: string;
  71220. shader: string;
  71221. };
  71222. }
  71223. declare module BABYLON {
  71224. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  71225. private _baseTexture;
  71226. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71227. updateShaderUniforms(): void;
  71228. render(useCameraPostProcess?: boolean): void;
  71229. resize(size: any, generateMipMaps: any): void;
  71230. baseTexture: BABYLON.Texture;
  71231. /**
  71232. * Serializes this normal map procedural texture
  71233. * @returns a serialized normal map procedural texture object
  71234. */
  71235. serialize(): any;
  71236. /**
  71237. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  71238. * @param parsedTexture defines parsed texture data
  71239. * @param scene defines the current scene
  71240. * @param rootUrl defines the root URL containing normal map procedural texture information
  71241. * @returns a parsed Normal Map Procedural BABYLON.Texture
  71242. */
  71243. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  71244. }
  71245. }
  71246. declare module BABYLON {
  71247. /** @hidden */
  71248. export var perlinNoiseProceduralTexturePixelShader: {
  71249. name: string;
  71250. shader: string;
  71251. };
  71252. }
  71253. declare module BABYLON {
  71254. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  71255. time: number;
  71256. timeScale: number;
  71257. translationSpeed: number;
  71258. private _currentTranslation;
  71259. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71260. updateShaderUniforms(): void;
  71261. render(useCameraPostProcess?: boolean): void;
  71262. resize(size: any, generateMipMaps: any): void;
  71263. /**
  71264. * Serializes this perlin noise procedural texture
  71265. * @returns a serialized perlin noise procedural texture object
  71266. */
  71267. serialize(): any;
  71268. /**
  71269. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  71270. * @param parsedTexture defines parsed texture data
  71271. * @param scene defines the current scene
  71272. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  71273. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  71274. */
  71275. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  71276. }
  71277. }
  71278. declare module BABYLON {
  71279. /** @hidden */
  71280. export var roadProceduralTexturePixelShader: {
  71281. name: string;
  71282. shader: string;
  71283. };
  71284. }
  71285. declare module BABYLON {
  71286. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  71287. private _roadColor;
  71288. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71289. updateShaderUniforms(): void;
  71290. roadColor: BABYLON.Color3;
  71291. /**
  71292. * Serializes this road procedural texture
  71293. * @returns a serialized road procedural texture object
  71294. */
  71295. serialize(): any;
  71296. /**
  71297. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  71298. * @param parsedTexture defines parsed texture data
  71299. * @param scene defines the current scene
  71300. * @param rootUrl defines the root URL containing road procedural texture information
  71301. * @returns a parsed Road Procedural BABYLON.Texture
  71302. */
  71303. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  71304. }
  71305. }
  71306. declare module BABYLON {
  71307. /** @hidden */
  71308. export var starfieldProceduralTexturePixelShader: {
  71309. name: string;
  71310. shader: string;
  71311. };
  71312. }
  71313. declare module BABYLON {
  71314. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  71315. private _time;
  71316. private _alpha;
  71317. private _beta;
  71318. private _zoom;
  71319. private _formuparam;
  71320. private _stepsize;
  71321. private _tile;
  71322. private _brightness;
  71323. private _darkmatter;
  71324. private _distfading;
  71325. private _saturation;
  71326. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71327. updateShaderUniforms(): void;
  71328. time: number;
  71329. alpha: number;
  71330. beta: number;
  71331. formuparam: number;
  71332. stepsize: number;
  71333. zoom: number;
  71334. tile: number;
  71335. brightness: number;
  71336. darkmatter: number;
  71337. distfading: number;
  71338. saturation: number;
  71339. /**
  71340. * Serializes this starfield procedural texture
  71341. * @returns a serialized starfield procedural texture object
  71342. */
  71343. serialize(): any;
  71344. /**
  71345. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  71346. * @param parsedTexture defines parsed texture data
  71347. * @param scene defines the current scene
  71348. * @param rootUrl defines the root URL containing startfield procedural texture information
  71349. * @returns a parsed Starfield Procedural BABYLON.Texture
  71350. */
  71351. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  71352. }
  71353. }
  71354. declare module BABYLON {
  71355. /** @hidden */
  71356. export var woodProceduralTexturePixelShader: {
  71357. name: string;
  71358. shader: string;
  71359. };
  71360. }
  71361. declare module BABYLON {
  71362. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  71363. private _ampScale;
  71364. private _woodColor;
  71365. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71366. updateShaderUniforms(): void;
  71367. ampScale: number;
  71368. woodColor: BABYLON.Color3;
  71369. /**
  71370. * Serializes this wood procedural texture
  71371. * @returns a serialized wood procedural texture object
  71372. */
  71373. serialize(): any;
  71374. /**
  71375. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  71376. * @param parsedTexture defines parsed texture data
  71377. * @param scene defines the current scene
  71378. * @param rootUrl defines the root URL containing wood procedural texture information
  71379. * @returns a parsed Wood Procedural BABYLON.Texture
  71380. */
  71381. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  71382. }
  71383. }