babylon.d.txt 3.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */ private _willBeUnregistered: boolean;
  111. /**
  112. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  113. */
  114. unregisterOnNextCall: boolean;
  115. /**
  116. * Creates a new observer
  117. * @param callback defines the callback to call when the observer is notified
  118. * @param mask defines the mask of the observer (used to filter notifications)
  119. * @param scope defines the current scope used to restore the JS context
  120. */
  121. constructor(
  122. /**
  123. * Defines the callback to call when the observer is notified
  124. */
  125. callback: (eventData: T, eventState: EventState) => void,
  126. /**
  127. * Defines the mask of the observer (used to filter notifications)
  128. */
  129. mask: number,
  130. /**
  131. * Defines the current scope used to restore the JS context
  132. */
  133. scope?: any);
  134. }
  135. /**
  136. * Represent a list of observers registered to multiple Observables object.
  137. */
  138. export class MultiObserver<T> {
  139. private _observers;
  140. private _observables;
  141. /**
  142. * Release associated resources
  143. */
  144. dispose(): void;
  145. /**
  146. * Raise a callback when one of the observable will notify
  147. * @param observables defines a list of observables to watch
  148. * @param callback defines the callback to call on notification
  149. * @param mask defines the mask used to filter notifications
  150. * @param scope defines the current scope used to restore the JS context
  151. * @returns the new MultiObserver
  152. */
  153. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  154. }
  155. /**
  156. * The Observable class is a simple implementation of the Observable pattern.
  157. *
  158. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  159. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  160. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  161. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  162. */
  163. export class Observable<T> {
  164. private _observers;
  165. private _eventState;
  166. private _onObserverAdded;
  167. /**
  168. * Gets the list of observers
  169. */
  170. readonly observers: Array<Observer<T>>;
  171. /**
  172. * Creates a new observable
  173. * @param onObserverAdded defines a callback to call when a new observer is added
  174. */
  175. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  176. /**
  177. * Create a new Observer with the specified callback
  178. * @param callback the callback that will be executed for that Observer
  179. * @param mask the mask used to filter observers
  180. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  181. * @param scope optional scope for the callback to be called from
  182. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  183. * @returns the new observer created for the callback
  184. */
  185. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  186. /**
  187. * Create a new Observer with the specified callback and unregisters after the next notification
  188. * @param callback the callback that will be executed for that Observer
  189. * @returns the new observer created for the callback
  190. */
  191. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  192. /**
  193. * Remove an Observer from the Observable object
  194. * @param observer the instance of the Observer to remove
  195. * @returns false if it doesn't belong to this Observable
  196. */
  197. remove(observer: Nullable<Observer<T>>): boolean;
  198. /**
  199. * Remove a callback from the Observable object
  200. * @param callback the callback to remove
  201. * @param scope optional scope. If used only the callbacks with this scope will be removed
  202. * @returns false if it doesn't belong to this Observable
  203. */
  204. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  205. private _deferUnregister;
  206. private _remove;
  207. /**
  208. * Moves the observable to the top of the observer list making it get called first when notified
  209. * @param observer the observer to move
  210. */
  211. makeObserverTopPriority(observer: Observer<T>): void;
  212. /**
  213. * Moves the observable to the bottom of the observer list making it get called last when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverBottomPriority(observer: Observer<T>): void;
  217. /**
  218. * Notify all Observers by calling their respective callback with the given data
  219. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  220. * @param eventData defines the data to send to all observers
  221. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  222. * @param target defines the original target of the state
  223. * @param currentTarget defines the current target of the state
  224. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  225. */
  226. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  227. /**
  228. * Calling this will execute each callback, expecting it to be a promise or return a value.
  229. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  230. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  231. * and it is crucial that all callbacks will be executed.
  232. * The order of the callbacks is kept, callbacks are not executed parallel.
  233. *
  234. * @param eventData The data to be sent to each callback
  235. * @param mask is used to filter observers defaults to -1
  236. * @param target defines the callback target (see EventState)
  237. * @param currentTarget defines he current object in the bubbling phase
  238. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  239. */
  240. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  241. /**
  242. * Notify a specific observer
  243. * @param observer defines the observer to notify
  244. * @param eventData defines the data to be sent to each callback
  245. * @param mask is used to filter observers defaults to -1
  246. */
  247. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  248. /**
  249. * Gets a boolean indicating if the observable has at least one observer
  250. * @returns true is the Observable has at least one Observer registered
  251. */
  252. hasObservers(): boolean;
  253. /**
  254. * Clear the list of observers
  255. */
  256. clear(): void;
  257. /**
  258. * Clone the current observable
  259. * @returns a new observable
  260. */
  261. clone(): Observable<T>;
  262. /**
  263. * Does this observable handles observer registered with a given mask
  264. * @param mask defines the mask to be tested
  265. * @return whether or not one observer registered with the given mask is handeled
  266. **/
  267. hasSpecificMask(mask?: number): boolean;
  268. }
  269. }
  270. declare module BABYLON {
  271. /**
  272. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  273. * Babylon.js
  274. */
  275. export class DomManagement {
  276. /**
  277. * Checks if the window object exists
  278. * @returns true if the window object exists
  279. */
  280. static IsWindowObjectExist(): boolean;
  281. /**
  282. * Checks if the navigator object exists
  283. * @returns true if the navigator object exists
  284. */
  285. static IsNavigatorAvailable(): boolean;
  286. /**
  287. * Extracts text content from a DOM element hierarchy
  288. * @param element defines the root element
  289. * @returns a string
  290. */
  291. static GetDOMTextContent(element: HTMLElement): string;
  292. }
  293. }
  294. declare module BABYLON {
  295. /**
  296. * Logger used througouht the application to allow configuration of
  297. * the log level required for the messages.
  298. */
  299. export class Logger {
  300. /**
  301. * No log
  302. */
  303. static readonly NoneLogLevel: number;
  304. /**
  305. * Only message logs
  306. */
  307. static readonly MessageLogLevel: number;
  308. /**
  309. * Only warning logs
  310. */
  311. static readonly WarningLogLevel: number;
  312. /**
  313. * Only error logs
  314. */
  315. static readonly ErrorLogLevel: number;
  316. /**
  317. * All logs
  318. */
  319. static readonly AllLogLevel: number;
  320. private static _LogCache;
  321. /**
  322. * Gets a value indicating the number of loading errors
  323. * @ignorenaming
  324. */
  325. static errorsCount: number;
  326. /**
  327. * Callback called when a new log is added
  328. */
  329. static OnNewCacheEntry: (entry: string) => void;
  330. private static _AddLogEntry;
  331. private static _FormatMessage;
  332. private static _LogDisabled;
  333. private static _LogEnabled;
  334. private static _WarnDisabled;
  335. private static _WarnEnabled;
  336. private static _ErrorDisabled;
  337. private static _ErrorEnabled;
  338. /**
  339. * Log a message to the console
  340. */
  341. static Log: (message: string) => void;
  342. /**
  343. * Write a warning message to the console
  344. */
  345. static Warn: (message: string) => void;
  346. /**
  347. * Write an error message to the console
  348. */
  349. static Error: (message: string) => void;
  350. /**
  351. * Gets current log cache (list of logs)
  352. */
  353. static readonly LogCache: string;
  354. /**
  355. * Clears the log cache
  356. */
  357. static ClearLogCache(): void;
  358. /**
  359. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  360. */
  361. static LogLevels: number;
  362. }
  363. }
  364. declare module BABYLON {
  365. /** @hidden */
  366. export class _TypeStore {
  367. /** @hidden */
  368. static RegisteredTypes: {
  369. [key: string]: Object;
  370. };
  371. /** @hidden */
  372. static GetClass(fqdn: string): any;
  373. }
  374. }
  375. declare module BABYLON {
  376. /**
  377. * Class containing a set of static utilities functions for deep copy.
  378. */
  379. export class DeepCopier {
  380. /**
  381. * Tries to copy an object by duplicating every property
  382. * @param source defines the source object
  383. * @param destination defines the target object
  384. * @param doNotCopyList defines a list of properties to avoid
  385. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  386. */
  387. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  388. }
  389. }
  390. declare module BABYLON {
  391. /**
  392. * Class containing a set of static utilities functions for precision date
  393. */
  394. export class PrecisionDate {
  395. /**
  396. * Gets either window.performance.now() if supported or Date.now() else
  397. */
  398. static readonly Now: number;
  399. }
  400. }
  401. declare module BABYLON {
  402. /** @hidden */
  403. export class _DevTools {
  404. static WarnImport(name: string): string;
  405. }
  406. }
  407. declare module BABYLON {
  408. /**
  409. * Interface used to define the mechanism to get data from the network
  410. */
  411. export interface IWebRequest {
  412. /**
  413. * Returns client's response url
  414. */
  415. responseURL: string;
  416. /**
  417. * Returns client's status
  418. */
  419. status: number;
  420. /**
  421. * Returns client's status as a text
  422. */
  423. statusText: string;
  424. }
  425. }
  426. declare module BABYLON {
  427. /**
  428. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  429. */
  430. export class WebRequest implements IWebRequest {
  431. private _xhr;
  432. /**
  433. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  434. * i.e. when loading files, where the server/service expects an Authorization header
  435. */
  436. static CustomRequestHeaders: {
  437. [key: string]: string;
  438. };
  439. /**
  440. * Add callback functions in this array to update all the requests before they get sent to the network
  441. */
  442. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  443. private _injectCustomRequestHeaders;
  444. /**
  445. * Gets or sets a function to be called when loading progress changes
  446. */
  447. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  448. /**
  449. * Returns client's state
  450. */
  451. readonly readyState: number;
  452. /**
  453. * Returns client's status
  454. */
  455. readonly status: number;
  456. /**
  457. * Returns client's status as a text
  458. */
  459. readonly statusText: string;
  460. /**
  461. * Returns client's response
  462. */
  463. readonly response: any;
  464. /**
  465. * Returns client's response url
  466. */
  467. readonly responseURL: string;
  468. /**
  469. * Returns client's response as text
  470. */
  471. readonly responseText: string;
  472. /**
  473. * Gets or sets the expected response type
  474. */
  475. responseType: XMLHttpRequestResponseType;
  476. /** @hidden */
  477. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  478. /** @hidden */
  479. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  480. /**
  481. * Cancels any network activity
  482. */
  483. abort(): void;
  484. /**
  485. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  486. * @param body defines an optional request body
  487. */
  488. send(body?: Document | BodyInit | null): void;
  489. /**
  490. * Sets the request method, request URL
  491. * @param method defines the method to use (GET, POST, etc..)
  492. * @param url defines the url to connect with
  493. */
  494. open(method: string, url: string): void;
  495. }
  496. }
  497. declare module BABYLON {
  498. /**
  499. * File request interface
  500. */
  501. export interface IFileRequest {
  502. /**
  503. * Raised when the request is complete (success or error).
  504. */
  505. onCompleteObservable: Observable<IFileRequest>;
  506. /**
  507. * Aborts the request for a file.
  508. */
  509. abort: () => void;
  510. }
  511. }
  512. declare module BABYLON {
  513. /**
  514. * Scalar computation library
  515. */
  516. export class Scalar {
  517. /**
  518. * Two pi constants convenient for computation.
  519. */
  520. static TwoPi: number;
  521. /**
  522. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  523. * @param a number
  524. * @param b number
  525. * @param epsilon (default = 1.401298E-45)
  526. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  527. */
  528. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  529. /**
  530. * Returns a string : the upper case translation of the number i to hexadecimal.
  531. * @param i number
  532. * @returns the upper case translation of the number i to hexadecimal.
  533. */
  534. static ToHex(i: number): string;
  535. /**
  536. * Returns -1 if value is negative and +1 is value is positive.
  537. * @param value the value
  538. * @returns the value itself if it's equal to zero.
  539. */
  540. static Sign(value: number): number;
  541. /**
  542. * Returns the value itself if it's between min and max.
  543. * Returns min if the value is lower than min.
  544. * Returns max if the value is greater than max.
  545. * @param value the value to clmap
  546. * @param min the min value to clamp to (default: 0)
  547. * @param max the max value to clamp to (default: 1)
  548. * @returns the clamped value
  549. */
  550. static Clamp(value: number, min?: number, max?: number): number;
  551. /**
  552. * the log2 of value.
  553. * @param value the value to compute log2 of
  554. * @returns the log2 of value.
  555. */
  556. static Log2(value: number): number;
  557. /**
  558. * Loops the value, so that it is never larger than length and never smaller than 0.
  559. *
  560. * This is similar to the modulo operator but it works with floating point numbers.
  561. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  562. * With t = 5 and length = 2.5, the result would be 0.0.
  563. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  564. * @param value the value
  565. * @param length the length
  566. * @returns the looped value
  567. */
  568. static Repeat(value: number, length: number): number;
  569. /**
  570. * Normalize the value between 0.0 and 1.0 using min and max values
  571. * @param value value to normalize
  572. * @param min max to normalize between
  573. * @param max min to normalize between
  574. * @returns the normalized value
  575. */
  576. static Normalize(value: number, min: number, max: number): number;
  577. /**
  578. * Denormalize the value from 0.0 and 1.0 using min and max values
  579. * @param normalized value to denormalize
  580. * @param min max to denormalize between
  581. * @param max min to denormalize between
  582. * @returns the denormalized value
  583. */
  584. static Denormalize(normalized: number, min: number, max: number): number;
  585. /**
  586. * Calculates the shortest difference between two given angles given in degrees.
  587. * @param current current angle in degrees
  588. * @param target target angle in degrees
  589. * @returns the delta
  590. */
  591. static DeltaAngle(current: number, target: number): number;
  592. /**
  593. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  594. * @param tx value
  595. * @param length length
  596. * @returns The returned value will move back and forth between 0 and length
  597. */
  598. static PingPong(tx: number, length: number): number;
  599. /**
  600. * Interpolates between min and max with smoothing at the limits.
  601. *
  602. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  603. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  604. * @param from from
  605. * @param to to
  606. * @param tx value
  607. * @returns the smooth stepped value
  608. */
  609. static SmoothStep(from: number, to: number, tx: number): number;
  610. /**
  611. * Moves a value current towards target.
  612. *
  613. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  614. * Negative values of maxDelta pushes the value away from target.
  615. * @param current current value
  616. * @param target target value
  617. * @param maxDelta max distance to move
  618. * @returns resulting value
  619. */
  620. static MoveTowards(current: number, target: number, maxDelta: number): number;
  621. /**
  622. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  623. *
  624. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  625. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  626. * @param current current value
  627. * @param target target value
  628. * @param maxDelta max distance to move
  629. * @returns resulting angle
  630. */
  631. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  632. /**
  633. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  634. * @param start start value
  635. * @param end target value
  636. * @param amount amount to lerp between
  637. * @returns the lerped value
  638. */
  639. static Lerp(start: number, end: number, amount: number): number;
  640. /**
  641. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  642. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  643. * @param start start value
  644. * @param end target value
  645. * @param amount amount to lerp between
  646. * @returns the lerped value
  647. */
  648. static LerpAngle(start: number, end: number, amount: number): number;
  649. /**
  650. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  651. * @param a start value
  652. * @param b target value
  653. * @param value value between a and b
  654. * @returns the inverseLerp value
  655. */
  656. static InverseLerp(a: number, b: number, value: number): number;
  657. /**
  658. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  659. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  660. * @param value1 spline value
  661. * @param tangent1 spline value
  662. * @param value2 spline value
  663. * @param tangent2 spline value
  664. * @param amount input value
  665. * @returns hermite result
  666. */
  667. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  668. /**
  669. * Returns a random float number between and min and max values
  670. * @param min min value of random
  671. * @param max max value of random
  672. * @returns random value
  673. */
  674. static RandomRange(min: number, max: number): number;
  675. /**
  676. * This function returns percentage of a number in a given range.
  677. *
  678. * RangeToPercent(40,20,60) will return 0.5 (50%)
  679. * RangeToPercent(34,0,100) will return 0.34 (34%)
  680. * @param number to convert to percentage
  681. * @param min min range
  682. * @param max max range
  683. * @returns the percentage
  684. */
  685. static RangeToPercent(number: number, min: number, max: number): number;
  686. /**
  687. * This function returns number that corresponds to the percentage in a given range.
  688. *
  689. * PercentToRange(0.34,0,100) will return 34.
  690. * @param percent to convert to number
  691. * @param min min range
  692. * @param max max range
  693. * @returns the number
  694. */
  695. static PercentToRange(percent: number, min: number, max: number): number;
  696. /**
  697. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  698. * @param angle The angle to normalize in radian.
  699. * @return The converted angle.
  700. */
  701. static NormalizeRadians(angle: number): number;
  702. }
  703. }
  704. declare module BABYLON {
  705. /**
  706. * Constant used to convert a value to gamma space
  707. * @ignorenaming
  708. */
  709. export const ToGammaSpace: number;
  710. /**
  711. * Constant used to convert a value to linear space
  712. * @ignorenaming
  713. */
  714. export const ToLinearSpace = 2.2;
  715. /**
  716. * Constant used to define the minimal number value in Babylon.js
  717. * @ignorenaming
  718. */
  719. let Epsilon: number;
  720. }
  721. declare module BABYLON {
  722. /**
  723. * Class used to represent a viewport on screen
  724. */
  725. export class Viewport {
  726. /** viewport left coordinate */
  727. x: number;
  728. /** viewport top coordinate */
  729. y: number;
  730. /**viewport width */
  731. width: number;
  732. /** viewport height */
  733. height: number;
  734. /**
  735. * Creates a Viewport object located at (x, y) and sized (width, height)
  736. * @param x defines viewport left coordinate
  737. * @param y defines viewport top coordinate
  738. * @param width defines the viewport width
  739. * @param height defines the viewport height
  740. */
  741. constructor(
  742. /** viewport left coordinate */
  743. x: number,
  744. /** viewport top coordinate */
  745. y: number,
  746. /**viewport width */
  747. width: number,
  748. /** viewport height */
  749. height: number);
  750. /**
  751. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  752. * @param renderWidth defines the rendering width
  753. * @param renderHeight defines the rendering height
  754. * @returns a new Viewport
  755. */
  756. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  757. /**
  758. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  759. * @param renderWidth defines the rendering width
  760. * @param renderHeight defines the rendering height
  761. * @param ref defines the target viewport
  762. * @returns the current viewport
  763. */
  764. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  765. /**
  766. * Returns a new Viewport copied from the current one
  767. * @returns a new Viewport
  768. */
  769. clone(): Viewport;
  770. }
  771. }
  772. declare module BABYLON {
  773. /**
  774. * Class containing a set of static utilities functions for arrays.
  775. */
  776. export class ArrayTools {
  777. /**
  778. * Returns an array of the given size filled with element built from the given constructor and the paramters
  779. * @param size the number of element to construct and put in the array
  780. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  781. * @returns a new array filled with new objects
  782. */
  783. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  784. }
  785. }
  786. declare module BABYLON {
  787. /**
  788. * @hidden
  789. */
  790. export interface IColor4Like {
  791. r: float;
  792. g: float;
  793. b: float;
  794. a: float;
  795. }
  796. /**
  797. * @hidden
  798. */
  799. export interface IColor3Like {
  800. r: float;
  801. g: float;
  802. b: float;
  803. }
  804. /**
  805. * @hidden
  806. */
  807. export interface IVector4Like {
  808. x: float;
  809. y: float;
  810. z: float;
  811. w: float;
  812. }
  813. /**
  814. * @hidden
  815. */
  816. export interface IVector3Like {
  817. x: float;
  818. y: float;
  819. z: float;
  820. }
  821. /**
  822. * @hidden
  823. */
  824. export interface IVector2Like {
  825. x: float;
  826. y: float;
  827. }
  828. /**
  829. * @hidden
  830. */
  831. export interface IMatrixLike {
  832. toArray(): DeepImmutable<Float32Array>;
  833. updateFlag: int;
  834. }
  835. /**
  836. * @hidden
  837. */
  838. export interface IViewportLike {
  839. x: float;
  840. y: float;
  841. width: float;
  842. height: float;
  843. }
  844. /**
  845. * @hidden
  846. */
  847. export interface IPlaneLike {
  848. normal: IVector3Like;
  849. d: float;
  850. normalize(): void;
  851. }
  852. }
  853. declare module BABYLON {
  854. /**
  855. * Class representing a vector containing 2 coordinates
  856. */
  857. export class Vector2 {
  858. /** defines the first coordinate */
  859. x: number;
  860. /** defines the second coordinate */
  861. y: number;
  862. /**
  863. * Creates a new Vector2 from the given x and y coordinates
  864. * @param x defines the first coordinate
  865. * @param y defines the second coordinate
  866. */
  867. constructor(
  868. /** defines the first coordinate */
  869. x?: number,
  870. /** defines the second coordinate */
  871. y?: number);
  872. /**
  873. * Gets a string with the Vector2 coordinates
  874. * @returns a string with the Vector2 coordinates
  875. */
  876. toString(): string;
  877. /**
  878. * Gets class name
  879. * @returns the string "Vector2"
  880. */
  881. getClassName(): string;
  882. /**
  883. * Gets current vector hash code
  884. * @returns the Vector2 hash code as a number
  885. */
  886. getHashCode(): number;
  887. /**
  888. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  889. * @param array defines the source array
  890. * @param index defines the offset in source array
  891. * @returns the current Vector2
  892. */
  893. toArray(array: FloatArray, index?: number): Vector2;
  894. /**
  895. * Copy the current vector to an array
  896. * @returns a new array with 2 elements: the Vector2 coordinates.
  897. */
  898. asArray(): number[];
  899. /**
  900. * Sets the Vector2 coordinates with the given Vector2 coordinates
  901. * @param source defines the source Vector2
  902. * @returns the current updated Vector2
  903. */
  904. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  905. /**
  906. * Sets the Vector2 coordinates with the given floats
  907. * @param x defines the first coordinate
  908. * @param y defines the second coordinate
  909. * @returns the current updated Vector2
  910. */
  911. copyFromFloats(x: number, y: number): Vector2;
  912. /**
  913. * Sets the Vector2 coordinates with the given floats
  914. * @param x defines the first coordinate
  915. * @param y defines the second coordinate
  916. * @returns the current updated Vector2
  917. */
  918. set(x: number, y: number): Vector2;
  919. /**
  920. * Add another vector with the current one
  921. * @param otherVector defines the other vector
  922. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  923. */
  924. add(otherVector: DeepImmutable<Vector2>): Vector2;
  925. /**
  926. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  927. * @param otherVector defines the other vector
  928. * @param result defines the target vector
  929. * @returns the unmodified current Vector2
  930. */
  931. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  932. /**
  933. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  934. * @param otherVector defines the other vector
  935. * @returns the current updated Vector2
  936. */
  937. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  938. /**
  939. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  940. * @param otherVector defines the other vector
  941. * @returns a new Vector2
  942. */
  943. addVector3(otherVector: Vector3): Vector2;
  944. /**
  945. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  946. * @param otherVector defines the other vector
  947. * @returns a new Vector2
  948. */
  949. subtract(otherVector: Vector2): Vector2;
  950. /**
  951. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  952. * @param otherVector defines the other vector
  953. * @param result defines the target vector
  954. * @returns the unmodified current Vector2
  955. */
  956. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  957. /**
  958. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  959. * @param otherVector defines the other vector
  960. * @returns the current updated Vector2
  961. */
  962. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  963. /**
  964. * Multiplies in place the current Vector2 coordinates by the given ones
  965. * @param otherVector defines the other vector
  966. * @returns the current updated Vector2
  967. */
  968. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  969. /**
  970. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  971. * @param otherVector defines the other vector
  972. * @returns a new Vector2
  973. */
  974. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  975. /**
  976. * Sets "result" coordinates with the multiplication of the current Vector2 and 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. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  982. /**
  983. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  984. * @param x defines the first coordinate
  985. * @param y defines the second coordinate
  986. * @returns a new Vector2
  987. */
  988. multiplyByFloats(x: number, y: number): Vector2;
  989. /**
  990. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  991. * @param otherVector defines the other vector
  992. * @returns a new Vector2
  993. */
  994. divide(otherVector: Vector2): Vector2;
  995. /**
  996. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  997. * @param otherVector defines the other vector
  998. * @param result defines the target vector
  999. * @returns the unmodified current Vector2
  1000. */
  1001. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1002. /**
  1003. * Divides the current Vector2 coordinates by the given ones
  1004. * @param otherVector defines the other vector
  1005. * @returns the current updated Vector2
  1006. */
  1007. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1008. /**
  1009. * Gets a new Vector2 with current Vector2 negated coordinates
  1010. * @returns a new Vector2
  1011. */
  1012. negate(): Vector2;
  1013. /**
  1014. * Multiply the Vector2 coordinates by scale
  1015. * @param scale defines the scaling factor
  1016. * @returns the current updated Vector2
  1017. */
  1018. scaleInPlace(scale: number): Vector2;
  1019. /**
  1020. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1021. * @param scale defines the scaling factor
  1022. * @returns a new Vector2
  1023. */
  1024. scale(scale: number): Vector2;
  1025. /**
  1026. * Scale the current Vector2 values by a factor to a given Vector2
  1027. * @param scale defines the scale factor
  1028. * @param result defines the Vector2 object where to store the result
  1029. * @returns the unmodified current Vector2
  1030. */
  1031. scaleToRef(scale: number, result: Vector2): Vector2;
  1032. /**
  1033. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1034. * @param scale defines the scale factor
  1035. * @param result defines the Vector2 object where to store the result
  1036. * @returns the unmodified current Vector2
  1037. */
  1038. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1039. /**
  1040. * Gets a boolean if two vectors are equals
  1041. * @param otherVector defines the other vector
  1042. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1043. */
  1044. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1045. /**
  1046. * Gets a boolean if two vectors are equals (using an epsilon value)
  1047. * @param otherVector defines the other vector
  1048. * @param epsilon defines the minimal distance to consider equality
  1049. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1050. */
  1051. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1052. /**
  1053. * Gets a new Vector2 from current Vector2 floored values
  1054. * @returns a new Vector2
  1055. */
  1056. floor(): Vector2;
  1057. /**
  1058. * Gets a new Vector2 from current Vector2 floored values
  1059. * @returns a new Vector2
  1060. */
  1061. fract(): Vector2;
  1062. /**
  1063. * Gets the length of the vector
  1064. * @returns the vector length (float)
  1065. */
  1066. length(): number;
  1067. /**
  1068. * Gets the vector squared length
  1069. * @returns the vector squared length (float)
  1070. */
  1071. lengthSquared(): number;
  1072. /**
  1073. * Normalize the vector
  1074. * @returns the current updated Vector2
  1075. */
  1076. normalize(): Vector2;
  1077. /**
  1078. * Gets a new Vector2 copied from the Vector2
  1079. * @returns a new Vector2
  1080. */
  1081. clone(): Vector2;
  1082. /**
  1083. * Gets a new Vector2(0, 0)
  1084. * @returns a new Vector2
  1085. */
  1086. static Zero(): Vector2;
  1087. /**
  1088. * Gets a new Vector2(1, 1)
  1089. * @returns a new Vector2
  1090. */
  1091. static One(): Vector2;
  1092. /**
  1093. * Gets a new Vector2 set from the given index element of the given array
  1094. * @param array defines the data source
  1095. * @param offset defines the offset in the data source
  1096. * @returns a new Vector2
  1097. */
  1098. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1099. /**
  1100. * Sets "result" from the given index element of the given array
  1101. * @param array defines the data source
  1102. * @param offset defines the offset in the data source
  1103. * @param result defines the target vector
  1104. */
  1105. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1106. /**
  1107. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1108. * @param value1 defines 1st point of control
  1109. * @param value2 defines 2nd point of control
  1110. * @param value3 defines 3rd point of control
  1111. * @param value4 defines 4th point of control
  1112. * @param amount defines the interpolation factor
  1113. * @returns a new Vector2
  1114. */
  1115. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1116. /**
  1117. * 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".
  1118. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1119. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1120. * @param value defines the value to clamp
  1121. * @param min defines the lower limit
  1122. * @param max defines the upper limit
  1123. * @returns a new Vector2
  1124. */
  1125. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1126. /**
  1127. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1128. * @param value1 defines the 1st control point
  1129. * @param tangent1 defines the outgoing tangent
  1130. * @param value2 defines the 2nd control point
  1131. * @param tangent2 defines the incoming tangent
  1132. * @param amount defines the interpolation factor
  1133. * @returns a new Vector2
  1134. */
  1135. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1136. /**
  1137. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1138. * @param start defines the start vector
  1139. * @param end defines the end vector
  1140. * @param amount defines the interpolation factor
  1141. * @returns a new Vector2
  1142. */
  1143. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1144. /**
  1145. * Gets the dot product of the vector "left" and the vector "right"
  1146. * @param left defines first vector
  1147. * @param right defines second vector
  1148. * @returns the dot product (float)
  1149. */
  1150. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1151. /**
  1152. * Returns a new Vector2 equal to the normalized given vector
  1153. * @param vector defines the vector to normalize
  1154. * @returns a new Vector2
  1155. */
  1156. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1157. /**
  1158. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1159. * @param left defines 1st vector
  1160. * @param right defines 2nd vector
  1161. * @returns a new Vector2
  1162. */
  1163. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1164. /**
  1165. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1166. * @param left defines 1st vector
  1167. * @param right defines 2nd vector
  1168. * @returns a new Vector2
  1169. */
  1170. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1171. /**
  1172. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1173. * @param vector defines the vector to transform
  1174. * @param transformation defines the matrix to apply
  1175. * @returns a new Vector2
  1176. */
  1177. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1178. /**
  1179. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1180. * @param vector defines the vector to transform
  1181. * @param transformation defines the matrix to apply
  1182. * @param result defines the target vector
  1183. */
  1184. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1185. /**
  1186. * Determines if a given vector is included in a triangle
  1187. * @param p defines the vector to test
  1188. * @param p0 defines 1st triangle point
  1189. * @param p1 defines 2nd triangle point
  1190. * @param p2 defines 3rd triangle point
  1191. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1192. */
  1193. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1194. /**
  1195. * Gets the distance between the vectors "value1" and "value2"
  1196. * @param value1 defines first vector
  1197. * @param value2 defines second vector
  1198. * @returns the distance between vectors
  1199. */
  1200. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1201. /**
  1202. * Returns the squared distance between the vectors "value1" and "value2"
  1203. * @param value1 defines first vector
  1204. * @param value2 defines second vector
  1205. * @returns the squared distance between vectors
  1206. */
  1207. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1208. /**
  1209. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1210. * @param value1 defines first vector
  1211. * @param value2 defines second vector
  1212. * @returns a new Vector2
  1213. */
  1214. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1215. /**
  1216. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1217. * @param p defines the middle point
  1218. * @param segA defines one point of the segment
  1219. * @param segB defines the other point of the segment
  1220. * @returns the shortest distance
  1221. */
  1222. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1223. }
  1224. /**
  1225. * Classed used to store (x,y,z) vector representation
  1226. * A Vector3 is the main object used in 3D geometry
  1227. * It can represent etiher the coordinates of a point the space, either a direction
  1228. * Reminder: js uses a left handed forward facing system
  1229. */
  1230. export class Vector3 {
  1231. /**
  1232. * Defines the first coordinates (on X axis)
  1233. */
  1234. x: number;
  1235. /**
  1236. * Defines the second coordinates (on Y axis)
  1237. */
  1238. y: number;
  1239. /**
  1240. * Defines the third coordinates (on Z axis)
  1241. */
  1242. z: number;
  1243. private static _UpReadOnly;
  1244. private static _ZeroReadOnly;
  1245. /**
  1246. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1247. * @param x defines the first coordinates (on X axis)
  1248. * @param y defines the second coordinates (on Y axis)
  1249. * @param z defines the third coordinates (on Z axis)
  1250. */
  1251. constructor(
  1252. /**
  1253. * Defines the first coordinates (on X axis)
  1254. */
  1255. x?: number,
  1256. /**
  1257. * Defines the second coordinates (on Y axis)
  1258. */
  1259. y?: number,
  1260. /**
  1261. * Defines the third coordinates (on Z axis)
  1262. */
  1263. z?: number);
  1264. /**
  1265. * Creates a string representation of the Vector3
  1266. * @returns a string with the Vector3 coordinates.
  1267. */
  1268. toString(): string;
  1269. /**
  1270. * Gets the class name
  1271. * @returns the string "Vector3"
  1272. */
  1273. getClassName(): string;
  1274. /**
  1275. * Creates the Vector3 hash code
  1276. * @returns a number which tends to be unique between Vector3 instances
  1277. */
  1278. getHashCode(): number;
  1279. /**
  1280. * Creates an array containing three elements : the coordinates of the Vector3
  1281. * @returns a new array of numbers
  1282. */
  1283. asArray(): number[];
  1284. /**
  1285. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1286. * @param array defines the destination array
  1287. * @param index defines the offset in the destination array
  1288. * @returns the current Vector3
  1289. */
  1290. toArray(array: FloatArray, index?: number): Vector3;
  1291. /**
  1292. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1293. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1294. */
  1295. toQuaternion(): Quaternion;
  1296. /**
  1297. * Adds the given vector to the current Vector3
  1298. * @param otherVector defines the second operand
  1299. * @returns the current updated Vector3
  1300. */
  1301. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1302. /**
  1303. * Adds the given coordinates to the current Vector3
  1304. * @param x defines the x coordinate of the operand
  1305. * @param y defines the y coordinate of the operand
  1306. * @param z defines the z coordinate of the operand
  1307. * @returns the current updated Vector3
  1308. */
  1309. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1310. /**
  1311. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1312. * @param otherVector defines the second operand
  1313. * @returns the resulting Vector3
  1314. */
  1315. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1316. /**
  1317. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1318. * @param otherVector defines the second operand
  1319. * @param result defines the Vector3 object where to store the result
  1320. * @returns the current Vector3
  1321. */
  1322. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1323. /**
  1324. * Subtract the given vector from the current Vector3
  1325. * @param otherVector defines the second operand
  1326. * @returns the current updated Vector3
  1327. */
  1328. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1329. /**
  1330. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1331. * @param otherVector defines the second operand
  1332. * @returns the resulting Vector3
  1333. */
  1334. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1335. /**
  1336. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1337. * @param otherVector defines the second operand
  1338. * @param result defines the Vector3 object where to store the result
  1339. * @returns the current Vector3
  1340. */
  1341. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1342. /**
  1343. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1344. * @param x defines the x coordinate of the operand
  1345. * @param y defines the y coordinate of the operand
  1346. * @param z defines the z coordinate of the operand
  1347. * @returns the resulting Vector3
  1348. */
  1349. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1350. /**
  1351. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1352. * @param x defines the x coordinate of the operand
  1353. * @param y defines the y coordinate of the operand
  1354. * @param z defines the z coordinate of the operand
  1355. * @param result defines the Vector3 object where to store the result
  1356. * @returns the current Vector3
  1357. */
  1358. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1359. /**
  1360. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1361. * @returns a new Vector3
  1362. */
  1363. negate(): Vector3;
  1364. /**
  1365. * Multiplies the Vector3 coordinates by the float "scale"
  1366. * @param scale defines the multiplier factor
  1367. * @returns the current updated Vector3
  1368. */
  1369. scaleInPlace(scale: number): Vector3;
  1370. /**
  1371. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1372. * @param scale defines the multiplier factor
  1373. * @returns a new Vector3
  1374. */
  1375. scale(scale: number): Vector3;
  1376. /**
  1377. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1378. * @param scale defines the multiplier factor
  1379. * @param result defines the Vector3 object where to store the result
  1380. * @returns the current Vector3
  1381. */
  1382. scaleToRef(scale: number, result: Vector3): Vector3;
  1383. /**
  1384. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1385. * @param scale defines the scale factor
  1386. * @param result defines the Vector3 object where to store the result
  1387. * @returns the unmodified current Vector3
  1388. */
  1389. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1390. /**
  1391. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1392. * @param otherVector defines the second operand
  1393. * @returns true if both vectors are equals
  1394. */
  1395. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1396. /**
  1397. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1398. * @param otherVector defines the second operand
  1399. * @param epsilon defines the minimal distance to define values as equals
  1400. * @returns true if both vectors are distant less than epsilon
  1401. */
  1402. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1403. /**
  1404. * Returns true if the current Vector3 coordinates equals the given floats
  1405. * @param x defines the x coordinate of the operand
  1406. * @param y defines the y coordinate of the operand
  1407. * @param z defines the z coordinate of the operand
  1408. * @returns true if both vectors are equals
  1409. */
  1410. equalsToFloats(x: number, y: number, z: number): boolean;
  1411. /**
  1412. * Multiplies the current Vector3 coordinates by the given ones
  1413. * @param otherVector defines the second operand
  1414. * @returns the current updated Vector3
  1415. */
  1416. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1417. /**
  1418. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1419. * @param otherVector defines the second operand
  1420. * @returns the new Vector3
  1421. */
  1422. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1423. /**
  1424. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1425. * @param otherVector defines the second operand
  1426. * @param result defines the Vector3 object where to store the result
  1427. * @returns the current Vector3
  1428. */
  1429. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1430. /**
  1431. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1432. * @param x defines the x coordinate of the operand
  1433. * @param y defines the y coordinate of the operand
  1434. * @param z defines the z coordinate of the operand
  1435. * @returns the new Vector3
  1436. */
  1437. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1438. /**
  1439. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1440. * @param otherVector defines the second operand
  1441. * @returns the new Vector3
  1442. */
  1443. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1444. /**
  1445. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1446. * @param otherVector defines the second operand
  1447. * @param result defines the Vector3 object where to store the result
  1448. * @returns the current Vector3
  1449. */
  1450. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1451. /**
  1452. * Divides the current Vector3 coordinates by the given ones.
  1453. * @param otherVector defines the second operand
  1454. * @returns the current updated Vector3
  1455. */
  1456. divideInPlace(otherVector: Vector3): Vector3;
  1457. /**
  1458. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1459. * @param other defines the second operand
  1460. * @returns the current updated Vector3
  1461. */
  1462. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1463. /**
  1464. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1465. * @param other defines the second operand
  1466. * @returns the current updated Vector3
  1467. */
  1468. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1469. /**
  1470. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1471. * @param x defines the x coordinate of the operand
  1472. * @param y defines the y coordinate of the operand
  1473. * @param z defines the z coordinate of the operand
  1474. * @returns the current updated Vector3
  1475. */
  1476. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1477. /**
  1478. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1479. * @param x defines the x coordinate of the operand
  1480. * @param y defines the y coordinate of the operand
  1481. * @param z defines the z coordinate of the operand
  1482. * @returns the current updated Vector3
  1483. */
  1484. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1485. /**
  1486. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1487. * Check if is non uniform within a certain amount of decimal places to account for this
  1488. * @param epsilon the amount the values can differ
  1489. * @returns if the the vector is non uniform to a certain number of decimal places
  1490. */
  1491. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1492. /**
  1493. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1494. */
  1495. readonly isNonUniform: boolean;
  1496. /**
  1497. * Gets a new Vector3 from current Vector3 floored values
  1498. * @returns a new Vector3
  1499. */
  1500. floor(): Vector3;
  1501. /**
  1502. * Gets a new Vector3 from current Vector3 floored values
  1503. * @returns a new Vector3
  1504. */
  1505. fract(): Vector3;
  1506. /**
  1507. * Gets the length of the Vector3
  1508. * @returns the length of the Vector3
  1509. */
  1510. length(): number;
  1511. /**
  1512. * Gets the squared length of the Vector3
  1513. * @returns squared length of the Vector3
  1514. */
  1515. lengthSquared(): number;
  1516. /**
  1517. * Normalize the current Vector3.
  1518. * Please note that this is an in place operation.
  1519. * @returns the current updated Vector3
  1520. */
  1521. normalize(): Vector3;
  1522. /**
  1523. * Reorders the x y z properties of the vector in place
  1524. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1525. * @returns the current updated vector
  1526. */
  1527. reorderInPlace(order: string): this;
  1528. /**
  1529. * Rotates the vector around 0,0,0 by a quaternion
  1530. * @param quaternion the rotation quaternion
  1531. * @param result vector to store the result
  1532. * @returns the resulting vector
  1533. */
  1534. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1535. /**
  1536. * Rotates a vector around a given point
  1537. * @param quaternion the rotation quaternion
  1538. * @param point the point to rotate around
  1539. * @param result vector to store the result
  1540. * @returns the resulting vector
  1541. */
  1542. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1543. /**
  1544. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  1545. * The cross product is then orthogonal to both current and "other"
  1546. * @param other defines the right operand
  1547. * @returns the cross product
  1548. */
  1549. cross(other: Vector3): Vector3;
  1550. /**
  1551. * Normalize the current Vector3 with the given input length.
  1552. * Please note that this is an in place operation.
  1553. * @param len the length of the vector
  1554. * @returns the current updated Vector3
  1555. */
  1556. normalizeFromLength(len: number): Vector3;
  1557. /**
  1558. * Normalize the current Vector3 to a new vector
  1559. * @returns the new Vector3
  1560. */
  1561. normalizeToNew(): Vector3;
  1562. /**
  1563. * Normalize the current Vector3 to the reference
  1564. * @param reference define the Vector3 to update
  1565. * @returns the updated Vector3
  1566. */
  1567. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1568. /**
  1569. * Creates a new Vector3 copied from the current Vector3
  1570. * @returns the new Vector3
  1571. */
  1572. clone(): Vector3;
  1573. /**
  1574. * Copies the given vector coordinates to the current Vector3 ones
  1575. * @param source defines the source Vector3
  1576. * @returns the current updated Vector3
  1577. */
  1578. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1579. /**
  1580. * Copies the given floats to the current Vector3 coordinates
  1581. * @param x defines the x coordinate of the operand
  1582. * @param y defines the y coordinate of the operand
  1583. * @param z defines the z coordinate of the operand
  1584. * @returns the current updated Vector3
  1585. */
  1586. copyFromFloats(x: number, y: number, z: number): Vector3;
  1587. /**
  1588. * Copies the given floats to the current Vector3 coordinates
  1589. * @param x defines the x coordinate of the operand
  1590. * @param y defines the y coordinate of the operand
  1591. * @param z defines the z coordinate of the operand
  1592. * @returns the current updated Vector3
  1593. */
  1594. set(x: number, y: number, z: number): Vector3;
  1595. /**
  1596. * Copies the given float to the current Vector3 coordinates
  1597. * @param v defines the x, y and z coordinates of the operand
  1598. * @returns the current updated Vector3
  1599. */
  1600. setAll(v: number): Vector3;
  1601. /**
  1602. * Get the clip factor between two vectors
  1603. * @param vector0 defines the first operand
  1604. * @param vector1 defines the second operand
  1605. * @param axis defines the axis to use
  1606. * @param size defines the size along the axis
  1607. * @returns the clip factor
  1608. */
  1609. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1610. /**
  1611. * Get angle between two vectors
  1612. * @param vector0 angle between vector0 and vector1
  1613. * @param vector1 angle between vector0 and vector1
  1614. * @param normal direction of the normal
  1615. * @return the angle between vector0 and vector1
  1616. */
  1617. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1618. /**
  1619. * Returns a new Vector3 set from the index "offset" of the given array
  1620. * @param array defines the source array
  1621. * @param offset defines the offset in the source array
  1622. * @returns the new Vector3
  1623. */
  1624. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1625. /**
  1626. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1627. * This function is deprecated. Use FromArray instead
  1628. * @param array defines the source array
  1629. * @param offset defines the offset in the source array
  1630. * @returns the new Vector3
  1631. */
  1632. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1633. /**
  1634. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1635. * @param array defines the source array
  1636. * @param offset defines the offset in the source array
  1637. * @param result defines the Vector3 where to store the result
  1638. */
  1639. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1640. /**
  1641. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1642. * This function is deprecated. Use FromArrayToRef instead.
  1643. * @param array defines the source array
  1644. * @param offset defines the offset in the source array
  1645. * @param result defines the Vector3 where to store the result
  1646. */
  1647. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1648. /**
  1649. * Sets the given vector "result" with the given floats.
  1650. * @param x defines the x coordinate of the source
  1651. * @param y defines the y coordinate of the source
  1652. * @param z defines the z coordinate of the source
  1653. * @param result defines the Vector3 where to store the result
  1654. */
  1655. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1656. /**
  1657. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1658. * @returns a new empty Vector3
  1659. */
  1660. static Zero(): Vector3;
  1661. /**
  1662. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1663. * @returns a new unit Vector3
  1664. */
  1665. static One(): Vector3;
  1666. /**
  1667. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1668. * @returns a new up Vector3
  1669. */
  1670. static Up(): Vector3;
  1671. /**
  1672. * Gets a up Vector3 that must not be updated
  1673. */
  1674. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1675. /**
  1676. * Gets a zero Vector3 that must not be updated
  1677. */
  1678. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1679. /**
  1680. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1681. * @returns a new down Vector3
  1682. */
  1683. static Down(): Vector3;
  1684. /**
  1685. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1686. * @returns a new forward Vector3
  1687. */
  1688. static Forward(): Vector3;
  1689. /**
  1690. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1691. * @returns a new forward Vector3
  1692. */
  1693. static Backward(): Vector3;
  1694. /**
  1695. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1696. * @returns a new right Vector3
  1697. */
  1698. static Right(): Vector3;
  1699. /**
  1700. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1701. * @returns a new left Vector3
  1702. */
  1703. static Left(): Vector3;
  1704. /**
  1705. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1706. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1707. * @param vector defines the Vector3 to transform
  1708. * @param transformation defines the transformation matrix
  1709. * @returns the transformed Vector3
  1710. */
  1711. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1712. /**
  1713. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1714. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1715. * @param vector defines the Vector3 to transform
  1716. * @param transformation defines the transformation matrix
  1717. * @param result defines the Vector3 where to store the result
  1718. */
  1719. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1720. /**
  1721. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1722. * This method computes tranformed coordinates only, not transformed direction vectors
  1723. * @param x define the x coordinate of the source vector
  1724. * @param y define the y coordinate of the source vector
  1725. * @param z define the z coordinate of the source vector
  1726. * @param transformation defines the transformation matrix
  1727. * @param result defines the Vector3 where to store the result
  1728. */
  1729. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1730. /**
  1731. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1732. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1733. * @param vector defines the Vector3 to transform
  1734. * @param transformation defines the transformation matrix
  1735. * @returns the new Vector3
  1736. */
  1737. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1738. /**
  1739. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1740. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1741. * @param vector defines the Vector3 to transform
  1742. * @param transformation defines the transformation matrix
  1743. * @param result defines the Vector3 where to store the result
  1744. */
  1745. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1746. /**
  1747. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1748. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1749. * @param x define the x coordinate of the source vector
  1750. * @param y define the y coordinate of the source vector
  1751. * @param z define the z coordinate of the source vector
  1752. * @param transformation defines the transformation matrix
  1753. * @param result defines the Vector3 where to store the result
  1754. */
  1755. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1756. /**
  1757. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1758. * @param value1 defines the first control point
  1759. * @param value2 defines the second control point
  1760. * @param value3 defines the third control point
  1761. * @param value4 defines the fourth control point
  1762. * @param amount defines the amount on the spline to use
  1763. * @returns the new Vector3
  1764. */
  1765. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1766. /**
  1767. * 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"
  1768. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1769. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1770. * @param value defines the current value
  1771. * @param min defines the lower range value
  1772. * @param max defines the upper range value
  1773. * @returns the new Vector3
  1774. */
  1775. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1776. /**
  1777. * 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"
  1778. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1779. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1780. * @param value defines the current value
  1781. * @param min defines the lower range value
  1782. * @param max defines the upper range value
  1783. * @param result defines the Vector3 where to store the result
  1784. */
  1785. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1786. /**
  1787. * Checks if a given vector is inside a specific range
  1788. * @param v defines the vector to test
  1789. * @param min defines the minimum range
  1790. * @param max defines the maximum range
  1791. */
  1792. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  1793. /**
  1794. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1795. * @param value1 defines the first control point
  1796. * @param tangent1 defines the first tangent vector
  1797. * @param value2 defines the second control point
  1798. * @param tangent2 defines the second tangent vector
  1799. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1800. * @returns the new Vector3
  1801. */
  1802. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1803. /**
  1804. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1805. * @param start defines the start value
  1806. * @param end defines the end value
  1807. * @param amount max defines amount between both (between 0 and 1)
  1808. * @returns the new Vector3
  1809. */
  1810. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1811. /**
  1812. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1813. * @param start defines the start value
  1814. * @param end defines the end value
  1815. * @param amount max defines amount between both (between 0 and 1)
  1816. * @param result defines the Vector3 where to store the result
  1817. */
  1818. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1819. /**
  1820. * Returns the dot product (float) between the vectors "left" and "right"
  1821. * @param left defines the left operand
  1822. * @param right defines the right operand
  1823. * @returns the dot product
  1824. */
  1825. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1826. /**
  1827. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1828. * The cross product is then orthogonal to both "left" and "right"
  1829. * @param left defines the left operand
  1830. * @param right defines the right operand
  1831. * @returns the cross product
  1832. */
  1833. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1834. /**
  1835. * Sets the given vector "result" with the cross product of "left" and "right"
  1836. * The cross product is then orthogonal to both "left" and "right"
  1837. * @param left defines the left operand
  1838. * @param right defines the right operand
  1839. * @param result defines the Vector3 where to store the result
  1840. */
  1841. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1842. /**
  1843. * Returns a new Vector3 as the normalization of the given vector
  1844. * @param vector defines the Vector3 to normalize
  1845. * @returns the new Vector3
  1846. */
  1847. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1848. /**
  1849. * Sets the given vector "result" with the normalization of the given first vector
  1850. * @param vector defines the Vector3 to normalize
  1851. * @param result defines the Vector3 where to store the result
  1852. */
  1853. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1854. /**
  1855. * Project a Vector3 onto screen space
  1856. * @param vector defines the Vector3 to project
  1857. * @param world defines the world matrix to use
  1858. * @param transform defines the transform (view x projection) matrix to use
  1859. * @param viewport defines the screen viewport to use
  1860. * @returns the new Vector3
  1861. */
  1862. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1863. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1864. /**
  1865. * Unproject from screen space to object space
  1866. * @param source defines the screen space Vector3 to use
  1867. * @param viewportWidth defines the current width of the viewport
  1868. * @param viewportHeight defines the current height of the viewport
  1869. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1870. * @param transform defines the transform (view x projection) matrix to use
  1871. * @returns the new Vector3
  1872. */
  1873. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1874. /**
  1875. * Unproject from screen space to object space
  1876. * @param source defines the screen space Vector3 to use
  1877. * @param viewportWidth defines the current width of the viewport
  1878. * @param viewportHeight defines the current height of the viewport
  1879. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1880. * @param view defines the view matrix to use
  1881. * @param projection defines the projection matrix to use
  1882. * @returns the new Vector3
  1883. */
  1884. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1885. /**
  1886. * Unproject from screen space to object space
  1887. * @param source defines the screen space Vector3 to use
  1888. * @param viewportWidth defines the current width of the viewport
  1889. * @param viewportHeight defines the current height of the viewport
  1890. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1891. * @param view defines the view matrix to use
  1892. * @param projection defines the projection matrix to use
  1893. * @param result defines the Vector3 where to store the result
  1894. */
  1895. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1896. /**
  1897. * Unproject from screen space to object space
  1898. * @param sourceX defines the screen space x coordinate to use
  1899. * @param sourceY defines the screen space y coordinate to use
  1900. * @param sourceZ defines the screen space z coordinate to use
  1901. * @param viewportWidth defines the current width of the viewport
  1902. * @param viewportHeight defines the current height of the viewport
  1903. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1904. * @param view defines the view matrix to use
  1905. * @param projection defines the projection matrix to use
  1906. * @param result defines the Vector3 where to store the result
  1907. */
  1908. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1909. /**
  1910. * Gets the minimal coordinate values between two Vector3
  1911. * @param left defines the first operand
  1912. * @param right defines the second operand
  1913. * @returns the new Vector3
  1914. */
  1915. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1916. /**
  1917. * Gets the maximal coordinate values between two Vector3
  1918. * @param left defines the first operand
  1919. * @param right defines the second operand
  1920. * @returns the new Vector3
  1921. */
  1922. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1923. /**
  1924. * Returns the distance between the vectors "value1" and "value2"
  1925. * @param value1 defines the first operand
  1926. * @param value2 defines the second operand
  1927. * @returns the distance
  1928. */
  1929. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1930. /**
  1931. * Returns the squared distance between the vectors "value1" and "value2"
  1932. * @param value1 defines the first operand
  1933. * @param value2 defines the second operand
  1934. * @returns the squared distance
  1935. */
  1936. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1937. /**
  1938. * Returns a new Vector3 located at the center between "value1" and "value2"
  1939. * @param value1 defines the first operand
  1940. * @param value2 defines the second operand
  1941. * @returns the new Vector3
  1942. */
  1943. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1944. /**
  1945. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1946. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1947. * to something in order to rotate it from its local system to the given target system
  1948. * Note: axis1, axis2 and axis3 are normalized during this operation
  1949. * @param axis1 defines the first axis
  1950. * @param axis2 defines the second axis
  1951. * @param axis3 defines the third axis
  1952. * @returns a new Vector3
  1953. */
  1954. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1955. /**
  1956. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1957. * @param axis1 defines the first axis
  1958. * @param axis2 defines the second axis
  1959. * @param axis3 defines the third axis
  1960. * @param ref defines the Vector3 where to store the result
  1961. */
  1962. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1963. }
  1964. /**
  1965. * Vector4 class created for EulerAngle class conversion to Quaternion
  1966. */
  1967. export class Vector4 {
  1968. /** x value of the vector */
  1969. x: number;
  1970. /** y value of the vector */
  1971. y: number;
  1972. /** z value of the vector */
  1973. z: number;
  1974. /** w value of the vector */
  1975. w: number;
  1976. /**
  1977. * Creates a Vector4 object from the given floats.
  1978. * @param x x value of the vector
  1979. * @param y y value of the vector
  1980. * @param z z value of the vector
  1981. * @param w w value of the vector
  1982. */
  1983. constructor(
  1984. /** x value of the vector */
  1985. x: number,
  1986. /** y value of the vector */
  1987. y: number,
  1988. /** z value of the vector */
  1989. z: number,
  1990. /** w value of the vector */
  1991. w: number);
  1992. /**
  1993. * Returns the string with the Vector4 coordinates.
  1994. * @returns a string containing all the vector values
  1995. */
  1996. toString(): string;
  1997. /**
  1998. * Returns the string "Vector4".
  1999. * @returns "Vector4"
  2000. */
  2001. getClassName(): string;
  2002. /**
  2003. * Returns the Vector4 hash code.
  2004. * @returns a unique hash code
  2005. */
  2006. getHashCode(): number;
  2007. /**
  2008. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2009. * @returns the resulting array
  2010. */
  2011. asArray(): number[];
  2012. /**
  2013. * Populates the given array from the given index with the Vector4 coordinates.
  2014. * @param array array to populate
  2015. * @param index index of the array to start at (default: 0)
  2016. * @returns the Vector4.
  2017. */
  2018. toArray(array: FloatArray, index?: number): Vector4;
  2019. /**
  2020. * Adds the given vector to the current Vector4.
  2021. * @param otherVector the vector to add
  2022. * @returns the updated Vector4.
  2023. */
  2024. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2025. /**
  2026. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2027. * @param otherVector the vector to add
  2028. * @returns the resulting vector
  2029. */
  2030. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2031. /**
  2032. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2033. * @param otherVector the vector to add
  2034. * @param result the vector to store the result
  2035. * @returns the current Vector4.
  2036. */
  2037. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2038. /**
  2039. * Subtract in place the given vector from the current Vector4.
  2040. * @param otherVector the vector to subtract
  2041. * @returns the updated Vector4.
  2042. */
  2043. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2044. /**
  2045. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2046. * @param otherVector the vector to add
  2047. * @returns the new vector with the result
  2048. */
  2049. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2050. /**
  2051. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2052. * @param otherVector the vector to subtract
  2053. * @param result the vector to store the result
  2054. * @returns the current Vector4.
  2055. */
  2056. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2057. /**
  2058. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2059. */
  2060. /**
  2061. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2062. * @param x value to subtract
  2063. * @param y value to subtract
  2064. * @param z value to subtract
  2065. * @param w value to subtract
  2066. * @returns new vector containing the result
  2067. */
  2068. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2069. /**
  2070. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2071. * @param x value to subtract
  2072. * @param y value to subtract
  2073. * @param z value to subtract
  2074. * @param w value to subtract
  2075. * @param result the vector to store the result in
  2076. * @returns the current Vector4.
  2077. */
  2078. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2079. /**
  2080. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2081. * @returns a new vector with the negated values
  2082. */
  2083. negate(): Vector4;
  2084. /**
  2085. * Multiplies the current Vector4 coordinates by scale (float).
  2086. * @param scale the number to scale with
  2087. * @returns the updated Vector4.
  2088. */
  2089. scaleInPlace(scale: number): Vector4;
  2090. /**
  2091. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2092. * @param scale the number to scale with
  2093. * @returns a new vector with the result
  2094. */
  2095. scale(scale: number): Vector4;
  2096. /**
  2097. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2098. * @param scale the number to scale with
  2099. * @param result a vector to store the result in
  2100. * @returns the current Vector4.
  2101. */
  2102. scaleToRef(scale: number, result: Vector4): Vector4;
  2103. /**
  2104. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2105. * @param scale defines the scale factor
  2106. * @param result defines the Vector4 object where to store the result
  2107. * @returns the unmodified current Vector4
  2108. */
  2109. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2110. /**
  2111. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2112. * @param otherVector the vector to compare against
  2113. * @returns true if they are equal
  2114. */
  2115. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2116. /**
  2117. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2118. * @param otherVector vector to compare against
  2119. * @param epsilon (Default: very small number)
  2120. * @returns true if they are equal
  2121. */
  2122. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2123. /**
  2124. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2125. * @param x x value to compare against
  2126. * @param y y value to compare against
  2127. * @param z z value to compare against
  2128. * @param w w value to compare against
  2129. * @returns true if equal
  2130. */
  2131. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2132. /**
  2133. * Multiplies in place the current Vector4 by the given one.
  2134. * @param otherVector vector to multiple with
  2135. * @returns the updated Vector4.
  2136. */
  2137. multiplyInPlace(otherVector: Vector4): Vector4;
  2138. /**
  2139. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2140. * @param otherVector vector to multiple with
  2141. * @returns resulting new vector
  2142. */
  2143. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2144. /**
  2145. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2146. * @param otherVector vector to multiple with
  2147. * @param result vector to store the result
  2148. * @returns the current Vector4.
  2149. */
  2150. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2151. /**
  2152. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2153. * @param x x value multiply with
  2154. * @param y y value multiply with
  2155. * @param z z value multiply with
  2156. * @param w w value multiply with
  2157. * @returns resulting new vector
  2158. */
  2159. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2160. /**
  2161. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2162. * @param otherVector vector to devide with
  2163. * @returns resulting new vector
  2164. */
  2165. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2166. /**
  2167. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2168. * @param otherVector vector to devide with
  2169. * @param result vector to store the result
  2170. * @returns the current Vector4.
  2171. */
  2172. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2173. /**
  2174. * Divides the current Vector3 coordinates by the given ones.
  2175. * @param otherVector vector to devide with
  2176. * @returns the updated Vector3.
  2177. */
  2178. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2179. /**
  2180. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2181. * @param other defines the second operand
  2182. * @returns the current updated Vector4
  2183. */
  2184. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2185. /**
  2186. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2187. * @param other defines the second operand
  2188. * @returns the current updated Vector4
  2189. */
  2190. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2191. /**
  2192. * Gets a new Vector4 from current Vector4 floored values
  2193. * @returns a new Vector4
  2194. */
  2195. floor(): Vector4;
  2196. /**
  2197. * Gets a new Vector4 from current Vector3 floored values
  2198. * @returns a new Vector4
  2199. */
  2200. fract(): Vector4;
  2201. /**
  2202. * Returns the Vector4 length (float).
  2203. * @returns the length
  2204. */
  2205. length(): number;
  2206. /**
  2207. * Returns the Vector4 squared length (float).
  2208. * @returns the length squared
  2209. */
  2210. lengthSquared(): number;
  2211. /**
  2212. * Normalizes in place the Vector4.
  2213. * @returns the updated Vector4.
  2214. */
  2215. normalize(): Vector4;
  2216. /**
  2217. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2218. * @returns this converted to a new vector3
  2219. */
  2220. toVector3(): Vector3;
  2221. /**
  2222. * Returns a new Vector4 copied from the current one.
  2223. * @returns the new cloned vector
  2224. */
  2225. clone(): Vector4;
  2226. /**
  2227. * Updates the current Vector4 with the given one coordinates.
  2228. * @param source the source vector to copy from
  2229. * @returns the updated Vector4.
  2230. */
  2231. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2232. /**
  2233. * Updates the current Vector4 coordinates with the given floats.
  2234. * @param x float to copy from
  2235. * @param y float to copy from
  2236. * @param z float to copy from
  2237. * @param w float to copy from
  2238. * @returns the updated Vector4.
  2239. */
  2240. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2241. /**
  2242. * Updates the current Vector4 coordinates with the given floats.
  2243. * @param x float to set from
  2244. * @param y float to set from
  2245. * @param z float to set from
  2246. * @param w float to set from
  2247. * @returns the updated Vector4.
  2248. */
  2249. set(x: number, y: number, z: number, w: number): Vector4;
  2250. /**
  2251. * Copies the given float to the current Vector3 coordinates
  2252. * @param v defines the x, y, z and w coordinates of the operand
  2253. * @returns the current updated Vector3
  2254. */
  2255. setAll(v: number): Vector4;
  2256. /**
  2257. * Returns a new Vector4 set from the starting index of the given array.
  2258. * @param array the array to pull values from
  2259. * @param offset the offset into the array to start at
  2260. * @returns the new vector
  2261. */
  2262. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2263. /**
  2264. * Updates the given vector "result" from the starting index of the given array.
  2265. * @param array the array to pull values from
  2266. * @param offset the offset into the array to start at
  2267. * @param result the vector to store the result in
  2268. */
  2269. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2270. /**
  2271. * Updates the given vector "result" from the starting index of the given Float32Array.
  2272. * @param array the array to pull values from
  2273. * @param offset the offset into the array to start at
  2274. * @param result the vector to store the result in
  2275. */
  2276. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2277. /**
  2278. * Updates the given vector "result" coordinates from the given floats.
  2279. * @param x float to set from
  2280. * @param y float to set from
  2281. * @param z float to set from
  2282. * @param w float to set from
  2283. * @param result the vector to the floats in
  2284. */
  2285. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2286. /**
  2287. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2288. * @returns the new vector
  2289. */
  2290. static Zero(): Vector4;
  2291. /**
  2292. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2293. * @returns the new vector
  2294. */
  2295. static One(): Vector4;
  2296. /**
  2297. * Returns a new normalized Vector4 from the given one.
  2298. * @param vector the vector to normalize
  2299. * @returns the vector
  2300. */
  2301. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Updates the given vector "result" from the normalization of the given one.
  2304. * @param vector the vector to normalize
  2305. * @param result the vector to store the result in
  2306. */
  2307. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2308. /**
  2309. * Returns a vector with the minimum values from the left and right vectors
  2310. * @param left left vector to minimize
  2311. * @param right right vector to minimize
  2312. * @returns a new vector with the minimum of the left and right vector values
  2313. */
  2314. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2315. /**
  2316. * Returns a vector with the maximum values from the left and right vectors
  2317. * @param left left vector to maximize
  2318. * @param right right vector to maximize
  2319. * @returns a new vector with the maximum of the left and right vector values
  2320. */
  2321. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2322. /**
  2323. * Returns the distance (float) between the vectors "value1" and "value2".
  2324. * @param value1 value to calulate the distance between
  2325. * @param value2 value to calulate the distance between
  2326. * @return the distance between the two vectors
  2327. */
  2328. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2329. /**
  2330. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2331. * @param value1 value to calulate the distance between
  2332. * @param value2 value to calulate the distance between
  2333. * @return the distance between the two vectors squared
  2334. */
  2335. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2336. /**
  2337. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2338. * @param value1 value to calulate the center between
  2339. * @param value2 value to calulate the center between
  2340. * @return the center between the two vectors
  2341. */
  2342. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2343. /**
  2344. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2345. * This methods computes transformed normalized direction vectors only.
  2346. * @param vector the vector to transform
  2347. * @param transformation the transformation matrix to apply
  2348. * @returns the new vector
  2349. */
  2350. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2351. /**
  2352. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2353. * This methods computes transformed normalized direction vectors only.
  2354. * @param vector the vector to transform
  2355. * @param transformation the transformation matrix to apply
  2356. * @param result the vector to store the result in
  2357. */
  2358. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2359. /**
  2360. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2361. * This methods computes transformed normalized direction vectors only.
  2362. * @param x value to transform
  2363. * @param y value to transform
  2364. * @param z value to transform
  2365. * @param w value to transform
  2366. * @param transformation the transformation matrix to apply
  2367. * @param result the vector to store the results in
  2368. */
  2369. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2370. /**
  2371. * Creates a new Vector4 from a Vector3
  2372. * @param source defines the source data
  2373. * @param w defines the 4th component (default is 0)
  2374. * @returns a new Vector4
  2375. */
  2376. static FromVector3(source: Vector3, w?: number): Vector4;
  2377. }
  2378. /**
  2379. * Class used to store quaternion data
  2380. * @see https://en.wikipedia.org/wiki/Quaternion
  2381. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2382. */
  2383. export class Quaternion {
  2384. /** defines the first component (0 by default) */
  2385. x: number;
  2386. /** defines the second component (0 by default) */
  2387. y: number;
  2388. /** defines the third component (0 by default) */
  2389. z: number;
  2390. /** defines the fourth component (1.0 by default) */
  2391. w: number;
  2392. /**
  2393. * Creates a new Quaternion from the given floats
  2394. * @param x defines the first component (0 by default)
  2395. * @param y defines the second component (0 by default)
  2396. * @param z defines the third component (0 by default)
  2397. * @param w defines the fourth component (1.0 by default)
  2398. */
  2399. constructor(
  2400. /** defines the first component (0 by default) */
  2401. x?: number,
  2402. /** defines the second component (0 by default) */
  2403. y?: number,
  2404. /** defines the third component (0 by default) */
  2405. z?: number,
  2406. /** defines the fourth component (1.0 by default) */
  2407. w?: number);
  2408. /**
  2409. * Gets a string representation for the current quaternion
  2410. * @returns a string with the Quaternion coordinates
  2411. */
  2412. toString(): string;
  2413. /**
  2414. * Gets the class name of the quaternion
  2415. * @returns the string "Quaternion"
  2416. */
  2417. getClassName(): string;
  2418. /**
  2419. * Gets a hash code for this quaternion
  2420. * @returns the quaternion hash code
  2421. */
  2422. getHashCode(): number;
  2423. /**
  2424. * Copy the quaternion to an array
  2425. * @returns a new array populated with 4 elements from the quaternion coordinates
  2426. */
  2427. asArray(): number[];
  2428. /**
  2429. * Check if two quaternions are equals
  2430. * @param otherQuaternion defines the second operand
  2431. * @return true if the current quaternion and the given one coordinates are strictly equals
  2432. */
  2433. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2434. /**
  2435. * Clone the current quaternion
  2436. * @returns a new quaternion copied from the current one
  2437. */
  2438. clone(): Quaternion;
  2439. /**
  2440. * Copy a quaternion to the current one
  2441. * @param other defines the other quaternion
  2442. * @returns the updated current quaternion
  2443. */
  2444. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2445. /**
  2446. * Updates the current quaternion with the given float coordinates
  2447. * @param x defines the x coordinate
  2448. * @param y defines the y coordinate
  2449. * @param z defines the z coordinate
  2450. * @param w defines the w coordinate
  2451. * @returns the updated current quaternion
  2452. */
  2453. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2454. /**
  2455. * Updates the current quaternion from the given float coordinates
  2456. * @param x defines the x coordinate
  2457. * @param y defines the y coordinate
  2458. * @param z defines the z coordinate
  2459. * @param w defines the w coordinate
  2460. * @returns the updated current quaternion
  2461. */
  2462. set(x: number, y: number, z: number, w: number): Quaternion;
  2463. /**
  2464. * Adds two quaternions
  2465. * @param other defines the second operand
  2466. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2467. */
  2468. add(other: DeepImmutable<Quaternion>): Quaternion;
  2469. /**
  2470. * Add a quaternion to the current one
  2471. * @param other defines the quaternion to add
  2472. * @returns the current quaternion
  2473. */
  2474. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2475. /**
  2476. * Subtract two quaternions
  2477. * @param other defines the second operand
  2478. * @returns a new quaternion as the subtraction result of the given one from the current one
  2479. */
  2480. subtract(other: Quaternion): Quaternion;
  2481. /**
  2482. * Multiplies the current quaternion by a scale factor
  2483. * @param value defines the scale factor
  2484. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2485. */
  2486. scale(value: number): Quaternion;
  2487. /**
  2488. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2489. * @param scale defines the scale factor
  2490. * @param result defines the Quaternion object where to store the result
  2491. * @returns the unmodified current quaternion
  2492. */
  2493. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2494. /**
  2495. * Multiplies in place the current quaternion by a scale factor
  2496. * @param value defines the scale factor
  2497. * @returns the current modified quaternion
  2498. */
  2499. scaleInPlace(value: number): Quaternion;
  2500. /**
  2501. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2502. * @param scale defines the scale factor
  2503. * @param result defines the Quaternion object where to store the result
  2504. * @returns the unmodified current quaternion
  2505. */
  2506. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2507. /**
  2508. * Multiplies two quaternions
  2509. * @param q1 defines the second operand
  2510. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2511. */
  2512. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2513. /**
  2514. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2515. * @param q1 defines the second operand
  2516. * @param result defines the target quaternion
  2517. * @returns the current quaternion
  2518. */
  2519. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2520. /**
  2521. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2522. * @param q1 defines the second operand
  2523. * @returns the currentupdated quaternion
  2524. */
  2525. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2526. /**
  2527. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2528. * @param ref defines the target quaternion
  2529. * @returns the current quaternion
  2530. */
  2531. conjugateToRef(ref: Quaternion): Quaternion;
  2532. /**
  2533. * Conjugates in place (1-q) the current quaternion
  2534. * @returns the current updated quaternion
  2535. */
  2536. conjugateInPlace(): Quaternion;
  2537. /**
  2538. * Conjugates in place (1-q) the current quaternion
  2539. * @returns a new quaternion
  2540. */
  2541. conjugate(): Quaternion;
  2542. /**
  2543. * Gets length of current quaternion
  2544. * @returns the quaternion length (float)
  2545. */
  2546. length(): number;
  2547. /**
  2548. * Normalize in place the current quaternion
  2549. * @returns the current updated quaternion
  2550. */
  2551. normalize(): Quaternion;
  2552. /**
  2553. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2554. * @param order is a reserved parameter and is ignore for now
  2555. * @returns a new Vector3 containing the Euler angles
  2556. */
  2557. toEulerAngles(order?: string): Vector3;
  2558. /**
  2559. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2560. * @param result defines the vector which will be filled with the Euler angles
  2561. * @param order is a reserved parameter and is ignore for now
  2562. * @returns the current unchanged quaternion
  2563. */
  2564. toEulerAnglesToRef(result: Vector3): Quaternion;
  2565. /**
  2566. * Updates the given rotation matrix with the current quaternion values
  2567. * @param result defines the target matrix
  2568. * @returns the current unchanged quaternion
  2569. */
  2570. toRotationMatrix(result: Matrix): Quaternion;
  2571. /**
  2572. * Updates the current quaternion from the given rotation matrix values
  2573. * @param matrix defines the source matrix
  2574. * @returns the current updated quaternion
  2575. */
  2576. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2577. /**
  2578. * Creates a new quaternion from a rotation matrix
  2579. * @param matrix defines the source matrix
  2580. * @returns a new quaternion created from the given rotation matrix values
  2581. */
  2582. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2583. /**
  2584. * Updates the given quaternion with the given rotation matrix values
  2585. * @param matrix defines the source matrix
  2586. * @param result defines the target quaternion
  2587. */
  2588. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2589. /**
  2590. * Returns the dot product (float) between the quaternions "left" and "right"
  2591. * @param left defines the left operand
  2592. * @param right defines the right operand
  2593. * @returns the dot product
  2594. */
  2595. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2596. /**
  2597. * Checks if the two quaternions are close to each other
  2598. * @param quat0 defines the first quaternion to check
  2599. * @param quat1 defines the second quaternion to check
  2600. * @returns true if the two quaternions are close to each other
  2601. */
  2602. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2603. /**
  2604. * Creates an empty quaternion
  2605. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2606. */
  2607. static Zero(): Quaternion;
  2608. /**
  2609. * Inverse a given quaternion
  2610. * @param q defines the source quaternion
  2611. * @returns a new quaternion as the inverted current quaternion
  2612. */
  2613. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2614. /**
  2615. * Inverse a given quaternion
  2616. * @param q defines the source quaternion
  2617. * @param result the quaternion the result will be stored in
  2618. * @returns the result quaternion
  2619. */
  2620. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2621. /**
  2622. * Creates an identity quaternion
  2623. * @returns the identity quaternion
  2624. */
  2625. static Identity(): Quaternion;
  2626. /**
  2627. * Gets a boolean indicating if the given quaternion is identity
  2628. * @param quaternion defines the quaternion to check
  2629. * @returns true if the quaternion is identity
  2630. */
  2631. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2632. /**
  2633. * Creates a quaternion from a rotation around an axis
  2634. * @param axis defines the axis to use
  2635. * @param angle defines the angle to use
  2636. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2637. */
  2638. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2639. /**
  2640. * Creates a rotation around an axis and stores it into the given quaternion
  2641. * @param axis defines the axis to use
  2642. * @param angle defines the angle to use
  2643. * @param result defines the target quaternion
  2644. * @returns the target quaternion
  2645. */
  2646. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2647. /**
  2648. * Creates a new quaternion from data stored into an array
  2649. * @param array defines the data source
  2650. * @param offset defines the offset in the source array where the data starts
  2651. * @returns a new quaternion
  2652. */
  2653. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2654. /**
  2655. * Create a quaternion from Euler rotation angles
  2656. * @param x Pitch
  2657. * @param y Yaw
  2658. * @param z Roll
  2659. * @returns the new Quaternion
  2660. */
  2661. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2662. /**
  2663. * Updates a quaternion from Euler rotation angles
  2664. * @param x Pitch
  2665. * @param y Yaw
  2666. * @param z Roll
  2667. * @param result the quaternion to store the result
  2668. * @returns the updated quaternion
  2669. */
  2670. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2671. /**
  2672. * Create a quaternion from Euler rotation vector
  2673. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2674. * @returns the new Quaternion
  2675. */
  2676. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2677. /**
  2678. * Updates a quaternion from Euler rotation vector
  2679. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2680. * @param result the quaternion to store the result
  2681. * @returns the updated quaternion
  2682. */
  2683. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2684. /**
  2685. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2686. * @param yaw defines the rotation around Y axis
  2687. * @param pitch defines the rotation around X axis
  2688. * @param roll defines the rotation around Z axis
  2689. * @returns the new quaternion
  2690. */
  2691. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2692. /**
  2693. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2694. * @param yaw defines the rotation around Y axis
  2695. * @param pitch defines the rotation around X axis
  2696. * @param roll defines the rotation around Z axis
  2697. * @param result defines the target quaternion
  2698. */
  2699. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2700. /**
  2701. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2702. * @param alpha defines the rotation around first axis
  2703. * @param beta defines the rotation around second axis
  2704. * @param gamma defines the rotation around third axis
  2705. * @returns the new quaternion
  2706. */
  2707. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2708. /**
  2709. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2710. * @param alpha defines the rotation around first axis
  2711. * @param beta defines the rotation around second axis
  2712. * @param gamma defines the rotation around third axis
  2713. * @param result defines the target quaternion
  2714. */
  2715. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2716. /**
  2717. * 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)
  2718. * @param axis1 defines the first axis
  2719. * @param axis2 defines the second axis
  2720. * @param axis3 defines the third axis
  2721. * @returns the new quaternion
  2722. */
  2723. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2724. /**
  2725. * 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
  2726. * @param axis1 defines the first axis
  2727. * @param axis2 defines the second axis
  2728. * @param axis3 defines the third axis
  2729. * @param ref defines the target quaternion
  2730. */
  2731. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2732. /**
  2733. * Interpolates between two quaternions
  2734. * @param left defines first quaternion
  2735. * @param right defines second quaternion
  2736. * @param amount defines the gradient to use
  2737. * @returns the new interpolated quaternion
  2738. */
  2739. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2740. /**
  2741. * Interpolates between two quaternions and stores it into a target quaternion
  2742. * @param left defines first quaternion
  2743. * @param right defines second quaternion
  2744. * @param amount defines the gradient to use
  2745. * @param result defines the target quaternion
  2746. */
  2747. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2748. /**
  2749. * Interpolate between two quaternions using Hermite interpolation
  2750. * @param value1 defines first quaternion
  2751. * @param tangent1 defines the incoming tangent
  2752. * @param value2 defines second quaternion
  2753. * @param tangent2 defines the outgoing tangent
  2754. * @param amount defines the target quaternion
  2755. * @returns the new interpolated quaternion
  2756. */
  2757. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2758. }
  2759. /**
  2760. * Class used to store matrix data (4x4)
  2761. */
  2762. export class Matrix {
  2763. private static _updateFlagSeed;
  2764. private static _identityReadOnly;
  2765. private _isIdentity;
  2766. private _isIdentityDirty;
  2767. private _isIdentity3x2;
  2768. private _isIdentity3x2Dirty;
  2769. /**
  2770. * Gets the update flag of the matrix which is an unique number for the matrix.
  2771. * It will be incremented every time the matrix data change.
  2772. * You can use it to speed the comparison between two versions of the same matrix.
  2773. */
  2774. updateFlag: number;
  2775. private readonly _m;
  2776. /**
  2777. * Gets the internal data of the matrix
  2778. */
  2779. readonly m: DeepImmutable<Float32Array>;
  2780. /** @hidden */ private _markAsUpdated(): void;
  2781. /** @hidden */
  2782. private _updateIdentityStatus;
  2783. /**
  2784. * Creates an empty matrix (filled with zeros)
  2785. */
  2786. constructor();
  2787. /**
  2788. * Check if the current matrix is identity
  2789. * @returns true is the matrix is the identity matrix
  2790. */
  2791. isIdentity(): boolean;
  2792. /**
  2793. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2794. * @returns true is the matrix is the identity matrix
  2795. */
  2796. isIdentityAs3x2(): boolean;
  2797. /**
  2798. * Gets the determinant of the matrix
  2799. * @returns the matrix determinant
  2800. */
  2801. determinant(): number;
  2802. /**
  2803. * Returns the matrix as a Float32Array
  2804. * @returns the matrix underlying array
  2805. */
  2806. toArray(): DeepImmutable<Float32Array>;
  2807. /**
  2808. * Returns the matrix as a Float32Array
  2809. * @returns the matrix underlying array.
  2810. */
  2811. asArray(): DeepImmutable<Float32Array>;
  2812. /**
  2813. * Inverts the current matrix in place
  2814. * @returns the current inverted matrix
  2815. */
  2816. invert(): Matrix;
  2817. /**
  2818. * Sets all the matrix elements to zero
  2819. * @returns the current matrix
  2820. */
  2821. reset(): Matrix;
  2822. /**
  2823. * Adds the current matrix with a second one
  2824. * @param other defines the matrix to add
  2825. * @returns a new matrix as the addition of the current matrix and the given one
  2826. */
  2827. add(other: DeepImmutable<Matrix>): Matrix;
  2828. /**
  2829. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2830. * @param other defines the matrix to add
  2831. * @param result defines the target matrix
  2832. * @returns the current matrix
  2833. */
  2834. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2835. /**
  2836. * Adds in place the given matrix to the current matrix
  2837. * @param other defines the second operand
  2838. * @returns the current updated matrix
  2839. */
  2840. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2841. /**
  2842. * Sets the given matrix to the current inverted Matrix
  2843. * @param other defines the target matrix
  2844. * @returns the unmodified current matrix
  2845. */
  2846. invertToRef(other: Matrix): Matrix;
  2847. /**
  2848. * add a value at the specified position in the current Matrix
  2849. * @param index the index of the value within the matrix. between 0 and 15.
  2850. * @param value the value to be added
  2851. * @returns the current updated matrix
  2852. */
  2853. addAtIndex(index: number, value: number): Matrix;
  2854. /**
  2855. * mutiply the specified position in the current Matrix by a value
  2856. * @param index the index of the value within the matrix. between 0 and 15.
  2857. * @param value the value to be added
  2858. * @returns the current updated matrix
  2859. */
  2860. multiplyAtIndex(index: number, value: number): Matrix;
  2861. /**
  2862. * Inserts the translation vector (using 3 floats) in the current matrix
  2863. * @param x defines the 1st component of the translation
  2864. * @param y defines the 2nd component of the translation
  2865. * @param z defines the 3rd component of the translation
  2866. * @returns the current updated matrix
  2867. */
  2868. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2869. /**
  2870. * Adds the translation vector (using 3 floats) in the current matrix
  2871. * @param x defines the 1st component of the translation
  2872. * @param y defines the 2nd component of the translation
  2873. * @param z defines the 3rd component of the translation
  2874. * @returns the current updated matrix
  2875. */
  2876. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2877. /**
  2878. * Inserts the translation vector in the current matrix
  2879. * @param vector3 defines the translation to insert
  2880. * @returns the current updated matrix
  2881. */
  2882. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2883. /**
  2884. * Gets the translation value of the current matrix
  2885. * @returns a new Vector3 as the extracted translation from the matrix
  2886. */
  2887. getTranslation(): Vector3;
  2888. /**
  2889. * Fill a Vector3 with the extracted translation from the matrix
  2890. * @param result defines the Vector3 where to store the translation
  2891. * @returns the current matrix
  2892. */
  2893. getTranslationToRef(result: Vector3): Matrix;
  2894. /**
  2895. * Remove rotation and scaling part from the matrix
  2896. * @returns the updated matrix
  2897. */
  2898. removeRotationAndScaling(): Matrix;
  2899. /**
  2900. * Multiply two matrices
  2901. * @param other defines the second operand
  2902. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2903. */
  2904. multiply(other: DeepImmutable<Matrix>): Matrix;
  2905. /**
  2906. * Copy the current matrix from the given one
  2907. * @param other defines the source matrix
  2908. * @returns the current updated matrix
  2909. */
  2910. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2911. /**
  2912. * Populates the given array from the starting index with the current matrix values
  2913. * @param array defines the target array
  2914. * @param offset defines the offset in the target array where to start storing values
  2915. * @returns the current matrix
  2916. */
  2917. copyToArray(array: Float32Array, offset?: number): Matrix;
  2918. /**
  2919. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2920. * @param other defines the second operand
  2921. * @param result defines the matrix where to store the multiplication
  2922. * @returns the current matrix
  2923. */
  2924. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2925. /**
  2926. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2927. * @param other defines the second operand
  2928. * @param result defines the array where to store the multiplication
  2929. * @param offset defines the offset in the target array where to start storing values
  2930. * @returns the current matrix
  2931. */
  2932. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2933. /**
  2934. * Check equality between this matrix and a second one
  2935. * @param value defines the second matrix to compare
  2936. * @returns true is the current matrix and the given one values are strictly equal
  2937. */
  2938. equals(value: DeepImmutable<Matrix>): boolean;
  2939. /**
  2940. * Clone the current matrix
  2941. * @returns a new matrix from the current matrix
  2942. */
  2943. clone(): Matrix;
  2944. /**
  2945. * Returns the name of the current matrix class
  2946. * @returns the string "Matrix"
  2947. */
  2948. getClassName(): string;
  2949. /**
  2950. * Gets the hash code of the current matrix
  2951. * @returns the hash code
  2952. */
  2953. getHashCode(): number;
  2954. /**
  2955. * Decomposes the current Matrix into a translation, rotation and scaling components
  2956. * @param scale defines the scale vector3 given as a reference to update
  2957. * @param rotation defines the rotation quaternion given as a reference to update
  2958. * @param translation defines the translation vector3 given as a reference to update
  2959. * @returns true if operation was successful
  2960. */
  2961. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  2962. /**
  2963. * Gets specific row of the matrix
  2964. * @param index defines the number of the row to get
  2965. * @returns the index-th row of the current matrix as a new Vector4
  2966. */
  2967. getRow(index: number): Nullable<Vector4>;
  2968. /**
  2969. * Sets the index-th row of the current matrix to the vector4 values
  2970. * @param index defines the number of the row to set
  2971. * @param row defines the target vector4
  2972. * @returns the updated current matrix
  2973. */
  2974. setRow(index: number, row: Vector4): Matrix;
  2975. /**
  2976. * Compute the transpose of the matrix
  2977. * @returns the new transposed matrix
  2978. */
  2979. transpose(): Matrix;
  2980. /**
  2981. * Compute the transpose of the matrix and store it in a given matrix
  2982. * @param result defines the target matrix
  2983. * @returns the current matrix
  2984. */
  2985. transposeToRef(result: Matrix): Matrix;
  2986. /**
  2987. * Sets the index-th row of the current matrix with the given 4 x float values
  2988. * @param index defines the row index
  2989. * @param x defines the x component to set
  2990. * @param y defines the y component to set
  2991. * @param z defines the z component to set
  2992. * @param w defines the w component to set
  2993. * @returns the updated current matrix
  2994. */
  2995. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  2996. /**
  2997. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  2998. * @param scale defines the scale factor
  2999. * @returns a new matrix
  3000. */
  3001. scale(scale: number): Matrix;
  3002. /**
  3003. * Scale the current matrix values by a factor to a given result matrix
  3004. * @param scale defines the scale factor
  3005. * @param result defines the matrix to store the result
  3006. * @returns the current matrix
  3007. */
  3008. scaleToRef(scale: number, result: Matrix): Matrix;
  3009. /**
  3010. * Scale the current matrix values by a factor and add the result to a given matrix
  3011. * @param scale defines the scale factor
  3012. * @param result defines the Matrix to store the result
  3013. * @returns the current matrix
  3014. */
  3015. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3016. /**
  3017. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3018. * @param ref matrix to store the result
  3019. */
  3020. toNormalMatrix(ref: Matrix): void;
  3021. /**
  3022. * Gets only rotation part of the current matrix
  3023. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3024. */
  3025. getRotationMatrix(): Matrix;
  3026. /**
  3027. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3028. * @param result defines the target matrix to store data to
  3029. * @returns the current matrix
  3030. */
  3031. getRotationMatrixToRef(result: Matrix): Matrix;
  3032. /**
  3033. * Toggles model matrix from being right handed to left handed in place and vice versa
  3034. */
  3035. toggleModelMatrixHandInPlace(): void;
  3036. /**
  3037. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3038. */
  3039. toggleProjectionMatrixHandInPlace(): void;
  3040. /**
  3041. * Creates a matrix from an array
  3042. * @param array defines the source array
  3043. * @param offset defines an offset in the source array
  3044. * @returns a new Matrix set from the starting index of the given array
  3045. */
  3046. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3047. /**
  3048. * Copy the content of an array into a given matrix
  3049. * @param array defines the source array
  3050. * @param offset defines an offset in the source array
  3051. * @param result defines the target matrix
  3052. */
  3053. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3054. /**
  3055. * Stores an array into a matrix after having multiplied each component by a given factor
  3056. * @param array defines the source array
  3057. * @param offset defines the offset in the source array
  3058. * @param scale defines the scaling factor
  3059. * @param result defines the target matrix
  3060. */
  3061. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3062. /**
  3063. * Gets an identity matrix that must not be updated
  3064. */
  3065. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3066. /**
  3067. * Stores a list of values (16) inside a given matrix
  3068. * @param initialM11 defines 1st value of 1st row
  3069. * @param initialM12 defines 2nd value of 1st row
  3070. * @param initialM13 defines 3rd value of 1st row
  3071. * @param initialM14 defines 4th value of 1st row
  3072. * @param initialM21 defines 1st value of 2nd row
  3073. * @param initialM22 defines 2nd value of 2nd row
  3074. * @param initialM23 defines 3rd value of 2nd row
  3075. * @param initialM24 defines 4th value of 2nd row
  3076. * @param initialM31 defines 1st value of 3rd row
  3077. * @param initialM32 defines 2nd value of 3rd row
  3078. * @param initialM33 defines 3rd value of 3rd row
  3079. * @param initialM34 defines 4th value of 3rd row
  3080. * @param initialM41 defines 1st value of 4th row
  3081. * @param initialM42 defines 2nd value of 4th row
  3082. * @param initialM43 defines 3rd value of 4th row
  3083. * @param initialM44 defines 4th value of 4th row
  3084. * @param result defines the target matrix
  3085. */
  3086. 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;
  3087. /**
  3088. * Creates new matrix from a list of values (16)
  3089. * @param initialM11 defines 1st value of 1st row
  3090. * @param initialM12 defines 2nd value of 1st row
  3091. * @param initialM13 defines 3rd value of 1st row
  3092. * @param initialM14 defines 4th value of 1st row
  3093. * @param initialM21 defines 1st value of 2nd row
  3094. * @param initialM22 defines 2nd value of 2nd row
  3095. * @param initialM23 defines 3rd value of 2nd row
  3096. * @param initialM24 defines 4th value of 2nd row
  3097. * @param initialM31 defines 1st value of 3rd row
  3098. * @param initialM32 defines 2nd value of 3rd row
  3099. * @param initialM33 defines 3rd value of 3rd row
  3100. * @param initialM34 defines 4th value of 3rd row
  3101. * @param initialM41 defines 1st value of 4th row
  3102. * @param initialM42 defines 2nd value of 4th row
  3103. * @param initialM43 defines 3rd value of 4th row
  3104. * @param initialM44 defines 4th value of 4th row
  3105. * @returns the new matrix
  3106. */
  3107. 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;
  3108. /**
  3109. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3110. * @param scale defines the scale vector3
  3111. * @param rotation defines the rotation quaternion
  3112. * @param translation defines the translation vector3
  3113. * @returns a new matrix
  3114. */
  3115. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3116. /**
  3117. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3118. * @param scale defines the scale vector3
  3119. * @param rotation defines the rotation quaternion
  3120. * @param translation defines the translation vector3
  3121. * @param result defines the target matrix
  3122. */
  3123. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3124. /**
  3125. * Creates a new identity matrix
  3126. * @returns a new identity matrix
  3127. */
  3128. static Identity(): Matrix;
  3129. /**
  3130. * Creates a new identity matrix and stores the result in a given matrix
  3131. * @param result defines the target matrix
  3132. */
  3133. static IdentityToRef(result: Matrix): void;
  3134. /**
  3135. * Creates a new zero matrix
  3136. * @returns a new zero matrix
  3137. */
  3138. static Zero(): Matrix;
  3139. /**
  3140. * Creates a new rotation matrix for "angle" radians around the X axis
  3141. * @param angle defines the angle (in radians) to use
  3142. * @return the new matrix
  3143. */
  3144. static RotationX(angle: number): Matrix;
  3145. /**
  3146. * Creates a new matrix as the invert of a given matrix
  3147. * @param source defines the source matrix
  3148. * @returns the new matrix
  3149. */
  3150. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3151. /**
  3152. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3153. * @param angle defines the angle (in radians) to use
  3154. * @param result defines the target matrix
  3155. */
  3156. static RotationXToRef(angle: number, result: Matrix): void;
  3157. /**
  3158. * Creates a new rotation matrix for "angle" radians around the Y axis
  3159. * @param angle defines the angle (in radians) to use
  3160. * @return the new matrix
  3161. */
  3162. static RotationY(angle: number): Matrix;
  3163. /**
  3164. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3165. * @param angle defines the angle (in radians) to use
  3166. * @param result defines the target matrix
  3167. */
  3168. static RotationYToRef(angle: number, result: Matrix): void;
  3169. /**
  3170. * Creates a new rotation matrix for "angle" radians around the Z axis
  3171. * @param angle defines the angle (in radians) to use
  3172. * @return the new matrix
  3173. */
  3174. static RotationZ(angle: number): Matrix;
  3175. /**
  3176. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3177. * @param angle defines the angle (in radians) to use
  3178. * @param result defines the target matrix
  3179. */
  3180. static RotationZToRef(angle: number, result: Matrix): void;
  3181. /**
  3182. * Creates a new rotation matrix for "angle" radians around the given axis
  3183. * @param axis defines the axis to use
  3184. * @param angle defines the angle (in radians) to use
  3185. * @return the new matrix
  3186. */
  3187. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3188. /**
  3189. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3190. * @param axis defines the axis to use
  3191. * @param angle defines the angle (in radians) to use
  3192. * @param result defines the target matrix
  3193. */
  3194. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3195. /**
  3196. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3197. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3198. * @param from defines the vector to align
  3199. * @param to defines the vector to align to
  3200. * @param result defines the target matrix
  3201. */
  3202. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3203. /**
  3204. * Creates a rotation matrix
  3205. * @param yaw defines the yaw angle in radians (Y axis)
  3206. * @param pitch defines the pitch angle in radians (X axis)
  3207. * @param roll defines the roll angle in radians (X axis)
  3208. * @returns the new rotation matrix
  3209. */
  3210. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3211. /**
  3212. * Creates a rotation matrix and stores it in a given matrix
  3213. * @param yaw defines the yaw angle in radians (Y axis)
  3214. * @param pitch defines the pitch angle in radians (X axis)
  3215. * @param roll defines the roll angle in radians (X axis)
  3216. * @param result defines the target matrix
  3217. */
  3218. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3219. /**
  3220. * Creates a scaling matrix
  3221. * @param x defines the scale factor on X axis
  3222. * @param y defines the scale factor on Y axis
  3223. * @param z defines the scale factor on Z axis
  3224. * @returns the new matrix
  3225. */
  3226. static Scaling(x: number, y: number, z: number): Matrix;
  3227. /**
  3228. * Creates a scaling matrix and stores it in a given matrix
  3229. * @param x defines the scale factor on X axis
  3230. * @param y defines the scale factor on Y axis
  3231. * @param z defines the scale factor on Z axis
  3232. * @param result defines the target matrix
  3233. */
  3234. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3235. /**
  3236. * Creates a translation matrix
  3237. * @param x defines the translation on X axis
  3238. * @param y defines the translation on Y axis
  3239. * @param z defines the translationon Z axis
  3240. * @returns the new matrix
  3241. */
  3242. static Translation(x: number, y: number, z: number): Matrix;
  3243. /**
  3244. * Creates a translation matrix and stores it in a given matrix
  3245. * @param x defines the translation on X axis
  3246. * @param y defines the translation on Y axis
  3247. * @param z defines the translationon Z axis
  3248. * @param result defines the target matrix
  3249. */
  3250. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3251. /**
  3252. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3253. * @param startValue defines the start value
  3254. * @param endValue defines the end value
  3255. * @param gradient defines the gradient factor
  3256. * @returns the new matrix
  3257. */
  3258. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3259. /**
  3260. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3261. * @param startValue defines the start value
  3262. * @param endValue defines the end value
  3263. * @param gradient defines the gradient factor
  3264. * @param result defines the Matrix object where to store data
  3265. */
  3266. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3267. /**
  3268. * Builds a new matrix whose values are computed by:
  3269. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3270. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3271. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3272. * @param startValue defines the first matrix
  3273. * @param endValue defines the second matrix
  3274. * @param gradient defines the gradient between the two matrices
  3275. * @returns the new matrix
  3276. */
  3277. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3278. /**
  3279. * Update a matrix to values which are computed by:
  3280. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3281. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3282. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3283. * @param startValue defines the first matrix
  3284. * @param endValue defines the second matrix
  3285. * @param gradient defines the gradient between the two matrices
  3286. * @param result defines the target matrix
  3287. */
  3288. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3289. /**
  3290. * 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"
  3291. * This function works in left handed mode
  3292. * @param eye defines the final position of the entity
  3293. * @param target defines where the entity should look at
  3294. * @param up defines the up vector for the entity
  3295. * @returns the new matrix
  3296. */
  3297. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3298. /**
  3299. * 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".
  3300. * This function works in left handed mode
  3301. * @param eye defines the final position of the entity
  3302. * @param target defines where the entity should look at
  3303. * @param up defines the up vector for the entity
  3304. * @param result defines the target matrix
  3305. */
  3306. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3307. /**
  3308. * 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"
  3309. * This function works in right handed mode
  3310. * @param eye defines the final position of the entity
  3311. * @param target defines where the entity should look at
  3312. * @param up defines the up vector for the entity
  3313. * @returns the new matrix
  3314. */
  3315. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3316. /**
  3317. * 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".
  3318. * This function works in right handed mode
  3319. * @param eye defines the final position of the entity
  3320. * @param target defines where the entity should look at
  3321. * @param up defines the up vector for the entity
  3322. * @param result defines the target matrix
  3323. */
  3324. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3325. /**
  3326. * Create a left-handed orthographic projection matrix
  3327. * @param width defines the viewport width
  3328. * @param height defines the viewport height
  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 OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3334. /**
  3335. * Store a left-handed orthographic projection to a given matrix
  3336. * @param width defines the viewport width
  3337. * @param height defines the viewport height
  3338. * @param znear defines the near clip plane
  3339. * @param zfar defines the far clip plane
  3340. * @param result defines the target matrix
  3341. */
  3342. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3343. /**
  3344. * Create a left-handed orthographic projection matrix
  3345. * @param left defines the viewport left coordinate
  3346. * @param right defines the viewport right coordinate
  3347. * @param bottom defines the viewport bottom coordinate
  3348. * @param top defines the viewport top coordinate
  3349. * @param znear defines the near clip plane
  3350. * @param zfar defines the far clip plane
  3351. * @returns a new matrix as a left-handed orthographic projection matrix
  3352. */
  3353. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3354. /**
  3355. * Stores a left-handed orthographic projection into a given matrix
  3356. * @param left defines the viewport left coordinate
  3357. * @param right defines the viewport right coordinate
  3358. * @param bottom defines the viewport bottom coordinate
  3359. * @param top defines the viewport top coordinate
  3360. * @param znear defines the near clip plane
  3361. * @param zfar defines the far clip plane
  3362. * @param result defines the target matrix
  3363. */
  3364. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3365. /**
  3366. * Creates a right-handed orthographic projection matrix
  3367. * @param left defines the viewport left coordinate
  3368. * @param right defines the viewport right coordinate
  3369. * @param bottom defines the viewport bottom coordinate
  3370. * @param top defines the viewport top coordinate
  3371. * @param znear defines the near clip plane
  3372. * @param zfar defines the far clip plane
  3373. * @returns a new matrix as a right-handed orthographic projection matrix
  3374. */
  3375. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3376. /**
  3377. * Stores a right-handed orthographic projection into a given matrix
  3378. * @param left defines the viewport left coordinate
  3379. * @param right defines the viewport right coordinate
  3380. * @param bottom defines the viewport bottom coordinate
  3381. * @param top defines the viewport top coordinate
  3382. * @param znear defines the near clip plane
  3383. * @param zfar defines the far clip plane
  3384. * @param result defines the target matrix
  3385. */
  3386. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3387. /**
  3388. * Creates a left-handed perspective projection matrix
  3389. * @param width defines the viewport width
  3390. * @param height defines the viewport height
  3391. * @param znear defines the near clip plane
  3392. * @param zfar defines the far clip plane
  3393. * @returns a new matrix as a left-handed perspective projection matrix
  3394. */
  3395. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3396. /**
  3397. * Creates a left-handed perspective projection matrix
  3398. * @param fov defines the horizontal field of view
  3399. * @param aspect defines the aspect ratio
  3400. * @param znear defines the near clip plane
  3401. * @param zfar defines the far clip plane
  3402. * @returns a new matrix as a left-handed perspective projection matrix
  3403. */
  3404. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3405. /**
  3406. * Stores a left-handed perspective projection into a given matrix
  3407. * @param fov defines the horizontal field of view
  3408. * @param aspect defines the aspect ratio
  3409. * @param znear defines the near clip plane
  3410. * @param zfar defines the far clip plane
  3411. * @param result defines the target matrix
  3412. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3413. */
  3414. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3415. /**
  3416. * Creates a right-handed perspective projection matrix
  3417. * @param fov defines the horizontal field of view
  3418. * @param aspect defines the aspect ratio
  3419. * @param znear defines the near clip plane
  3420. * @param zfar defines the far clip plane
  3421. * @returns a new matrix as a right-handed perspective projection matrix
  3422. */
  3423. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3424. /**
  3425. * Stores a right-handed perspective projection into a given matrix
  3426. * @param fov defines the horizontal field of view
  3427. * @param aspect defines the aspect ratio
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @param result defines the target matrix
  3431. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3432. */
  3433. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3434. /**
  3435. * Stores a perspective projection for WebVR info a given matrix
  3436. * @param fov defines the field of view
  3437. * @param znear defines the near clip plane
  3438. * @param zfar defines the far clip plane
  3439. * @param result defines the target matrix
  3440. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3441. */
  3442. static PerspectiveFovWebVRToRef(fov: {
  3443. upDegrees: number;
  3444. downDegrees: number;
  3445. leftDegrees: number;
  3446. rightDegrees: number;
  3447. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3448. /**
  3449. * Computes a complete transformation matrix
  3450. * @param viewport defines the viewport to use
  3451. * @param world defines the world matrix
  3452. * @param view defines the view matrix
  3453. * @param projection defines the projection matrix
  3454. * @param zmin defines the near clip plane
  3455. * @param zmax defines the far clip plane
  3456. * @returns the transformation matrix
  3457. */
  3458. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3459. /**
  3460. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3461. * @param matrix defines the matrix to use
  3462. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3463. */
  3464. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3465. /**
  3466. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3467. * @param matrix defines the matrix to use
  3468. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3469. */
  3470. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3471. /**
  3472. * Compute the transpose of a given matrix
  3473. * @param matrix defines the matrix to transpose
  3474. * @returns the new matrix
  3475. */
  3476. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3477. /**
  3478. * Compute the transpose of a matrix and store it in a target matrix
  3479. * @param matrix defines the matrix to transpose
  3480. * @param result defines the target matrix
  3481. */
  3482. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3483. /**
  3484. * Computes a reflection matrix from a plane
  3485. * @param plane defines the reflection plane
  3486. * @returns a new matrix
  3487. */
  3488. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  3489. /**
  3490. * Computes a reflection matrix from a plane
  3491. * @param plane defines the reflection plane
  3492. * @param result defines the target matrix
  3493. */
  3494. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  3495. /**
  3496. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3497. * @param xaxis defines the value of the 1st axis
  3498. * @param yaxis defines the value of the 2nd axis
  3499. * @param zaxis defines the value of the 3rd axis
  3500. * @param result defines the target matrix
  3501. */
  3502. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3503. /**
  3504. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3505. * @param quat defines the quaternion to use
  3506. * @param result defines the target matrix
  3507. */
  3508. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3509. }
  3510. /**
  3511. * @hidden
  3512. */
  3513. export class TmpVectors {
  3514. static Vector2: Vector2[];
  3515. static Vector3: Vector3[];
  3516. static Vector4: Vector4[];
  3517. static Quaternion: Quaternion[];
  3518. static Matrix: Matrix[];
  3519. }
  3520. }
  3521. declare module BABYLON {
  3522. /**
  3523. * Class used to hold a RBG color
  3524. */
  3525. export class Color3 {
  3526. /**
  3527. * Defines the red component (between 0 and 1, default is 0)
  3528. */
  3529. r: number;
  3530. /**
  3531. * Defines the green component (between 0 and 1, default is 0)
  3532. */
  3533. g: number;
  3534. /**
  3535. * Defines the blue component (between 0 and 1, default is 0)
  3536. */
  3537. b: number;
  3538. /**
  3539. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  3540. * @param r defines the red component (between 0 and 1, default is 0)
  3541. * @param g defines the green component (between 0 and 1, default is 0)
  3542. * @param b defines the blue component (between 0 and 1, default is 0)
  3543. */
  3544. constructor(
  3545. /**
  3546. * Defines the red component (between 0 and 1, default is 0)
  3547. */
  3548. r?: number,
  3549. /**
  3550. * Defines the green component (between 0 and 1, default is 0)
  3551. */
  3552. g?: number,
  3553. /**
  3554. * Defines the blue component (between 0 and 1, default is 0)
  3555. */
  3556. b?: number);
  3557. /**
  3558. * Creates a string with the Color3 current values
  3559. * @returns the string representation of the Color3 object
  3560. */
  3561. toString(): string;
  3562. /**
  3563. * Returns the string "Color3"
  3564. * @returns "Color3"
  3565. */
  3566. getClassName(): string;
  3567. /**
  3568. * Compute the Color3 hash code
  3569. * @returns an unique number that can be used to hash Color3 objects
  3570. */
  3571. getHashCode(): number;
  3572. /**
  3573. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  3574. * @param array defines the array where to store the r,g,b components
  3575. * @param index defines an optional index in the target array to define where to start storing values
  3576. * @returns the current Color3 object
  3577. */
  3578. toArray(array: FloatArray, index?: number): Color3;
  3579. /**
  3580. * Returns a new Color4 object from the current Color3 and the given alpha
  3581. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  3582. * @returns a new Color4 object
  3583. */
  3584. toColor4(alpha?: number): Color4;
  3585. /**
  3586. * Returns a new array populated with 3 numeric elements : red, green and blue values
  3587. * @returns the new array
  3588. */
  3589. asArray(): number[];
  3590. /**
  3591. * Returns the luminance value
  3592. * @returns a float value
  3593. */
  3594. toLuminance(): number;
  3595. /**
  3596. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  3597. * @param otherColor defines the second operand
  3598. * @returns the new Color3 object
  3599. */
  3600. multiply(otherColor: DeepImmutable<Color3>): Color3;
  3601. /**
  3602. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  3603. * @param otherColor defines the second operand
  3604. * @param result defines the Color3 object where to store the result
  3605. * @returns the current Color3
  3606. */
  3607. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3608. /**
  3609. * Determines equality between Color3 objects
  3610. * @param otherColor defines the second operand
  3611. * @returns true if the rgb values are equal to the given ones
  3612. */
  3613. equals(otherColor: DeepImmutable<Color3>): boolean;
  3614. /**
  3615. * Determines equality between the current Color3 object and a set of r,b,g values
  3616. * @param r defines the red component to check
  3617. * @param g defines the green component to check
  3618. * @param b defines the blue component to check
  3619. * @returns true if the rgb values are equal to the given ones
  3620. */
  3621. equalsFloats(r: number, g: number, b: number): boolean;
  3622. /**
  3623. * Multiplies in place each rgb value by scale
  3624. * @param scale defines the scaling factor
  3625. * @returns the updated Color3
  3626. */
  3627. scale(scale: number): Color3;
  3628. /**
  3629. * Multiplies the rgb values by scale and stores the result into "result"
  3630. * @param scale defines the scaling factor
  3631. * @param result defines the Color3 object where to store the result
  3632. * @returns the unmodified current Color3
  3633. */
  3634. scaleToRef(scale: number, result: Color3): Color3;
  3635. /**
  3636. * Scale the current Color3 values by a factor and add the result to a given Color3
  3637. * @param scale defines the scale factor
  3638. * @param result defines color to store the result into
  3639. * @returns the unmodified current Color3
  3640. */
  3641. scaleAndAddToRef(scale: number, result: Color3): Color3;
  3642. /**
  3643. * Clamps the rgb values by the min and max values and stores the result into "result"
  3644. * @param min defines minimum clamping value (default is 0)
  3645. * @param max defines maximum clamping value (default is 1)
  3646. * @param result defines color to store the result into
  3647. * @returns the original Color3
  3648. */
  3649. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  3650. /**
  3651. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  3652. * @param otherColor defines the second operand
  3653. * @returns the new Color3
  3654. */
  3655. add(otherColor: DeepImmutable<Color3>): Color3;
  3656. /**
  3657. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  3658. * @param otherColor defines the second operand
  3659. * @param result defines Color3 object to store the result into
  3660. * @returns the unmodified current Color3
  3661. */
  3662. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3663. /**
  3664. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  3665. * @param otherColor defines the second operand
  3666. * @returns the new Color3
  3667. */
  3668. subtract(otherColor: DeepImmutable<Color3>): Color3;
  3669. /**
  3670. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  3671. * @param otherColor defines the second operand
  3672. * @param result defines Color3 object to store the result into
  3673. * @returns the unmodified current Color3
  3674. */
  3675. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3676. /**
  3677. * Copy the current object
  3678. * @returns a new Color3 copied the current one
  3679. */
  3680. clone(): Color3;
  3681. /**
  3682. * Copies the rgb values from the source in the current Color3
  3683. * @param source defines the source Color3 object
  3684. * @returns the updated Color3 object
  3685. */
  3686. copyFrom(source: DeepImmutable<Color3>): Color3;
  3687. /**
  3688. * Updates the Color3 rgb values from the given floats
  3689. * @param r defines the red component to read from
  3690. * @param g defines the green component to read from
  3691. * @param b defines the blue component to read from
  3692. * @returns the current Color3 object
  3693. */
  3694. copyFromFloats(r: number, g: number, b: number): Color3;
  3695. /**
  3696. * Updates the Color3 rgb values from the given floats
  3697. * @param r defines the red component to read from
  3698. * @param g defines the green component to read from
  3699. * @param b defines the blue component to read from
  3700. * @returns the current Color3 object
  3701. */
  3702. set(r: number, g: number, b: number): Color3;
  3703. /**
  3704. * Compute the Color3 hexadecimal code as a string
  3705. * @returns a string containing the hexadecimal representation of the Color3 object
  3706. */
  3707. toHexString(): string;
  3708. /**
  3709. * Computes a new Color3 converted from the current one to linear space
  3710. * @returns a new Color3 object
  3711. */
  3712. toLinearSpace(): Color3;
  3713. /**
  3714. * Converts current color in rgb space to HSV values
  3715. * @returns a new color3 representing the HSV values
  3716. */
  3717. toHSV(): Color3;
  3718. /**
  3719. * Converts current color in rgb space to HSV values
  3720. * @param result defines the Color3 where to store the HSV values
  3721. */
  3722. toHSVToRef(result: Color3): void;
  3723. /**
  3724. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  3725. * @param convertedColor defines the Color3 object where to store the linear space version
  3726. * @returns the unmodified Color3
  3727. */
  3728. toLinearSpaceToRef(convertedColor: Color3): Color3;
  3729. /**
  3730. * Computes a new Color3 converted from the current one to gamma space
  3731. * @returns a new Color3 object
  3732. */
  3733. toGammaSpace(): Color3;
  3734. /**
  3735. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  3736. * @param convertedColor defines the Color3 object where to store the gamma space version
  3737. * @returns the unmodified Color3
  3738. */
  3739. toGammaSpaceToRef(convertedColor: Color3): Color3;
  3740. private static _BlackReadOnly;
  3741. /**
  3742. * Convert Hue, saturation and value to a Color3 (RGB)
  3743. * @param hue defines the hue
  3744. * @param saturation defines the saturation
  3745. * @param value defines the value
  3746. * @param result defines the Color3 where to store the RGB values
  3747. */
  3748. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  3749. /**
  3750. * Creates a new Color3 from the string containing valid hexadecimal values
  3751. * @param hex defines a string containing valid hexadecimal values
  3752. * @returns a new Color3 object
  3753. */
  3754. static FromHexString(hex: string): Color3;
  3755. /**
  3756. * Creates a new Color3 from the starting index of the given array
  3757. * @param array defines the source array
  3758. * @param offset defines an offset in the source array
  3759. * @returns a new Color3 object
  3760. */
  3761. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  3762. /**
  3763. * Creates a new Color3 from integer values (< 256)
  3764. * @param r defines the red component to read from (value between 0 and 255)
  3765. * @param g defines the green component to read from (value between 0 and 255)
  3766. * @param b defines the blue component to read from (value between 0 and 255)
  3767. * @returns a new Color3 object
  3768. */
  3769. static FromInts(r: number, g: number, b: number): Color3;
  3770. /**
  3771. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3772. * @param start defines the start Color3 value
  3773. * @param end defines the end Color3 value
  3774. * @param amount defines the gradient value between start and end
  3775. * @returns a new Color3 object
  3776. */
  3777. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  3778. /**
  3779. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3780. * @param left defines the start value
  3781. * @param right defines the end value
  3782. * @param amount defines the gradient factor
  3783. * @param result defines the Color3 object where to store the result
  3784. */
  3785. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  3786. /**
  3787. * Returns a Color3 value containing a red color
  3788. * @returns a new Color3 object
  3789. */
  3790. static Red(): Color3;
  3791. /**
  3792. * Returns a Color3 value containing a green color
  3793. * @returns a new Color3 object
  3794. */
  3795. static Green(): Color3;
  3796. /**
  3797. * Returns a Color3 value containing a blue color
  3798. * @returns a new Color3 object
  3799. */
  3800. static Blue(): Color3;
  3801. /**
  3802. * Returns a Color3 value containing a black color
  3803. * @returns a new Color3 object
  3804. */
  3805. static Black(): Color3;
  3806. /**
  3807. * Gets a Color3 value containing a black color that must not be updated
  3808. */
  3809. static readonly BlackReadOnly: DeepImmutable<Color3>;
  3810. /**
  3811. * Returns a Color3 value containing a white color
  3812. * @returns a new Color3 object
  3813. */
  3814. static White(): Color3;
  3815. /**
  3816. * Returns a Color3 value containing a purple color
  3817. * @returns a new Color3 object
  3818. */
  3819. static Purple(): Color3;
  3820. /**
  3821. * Returns a Color3 value containing a magenta color
  3822. * @returns a new Color3 object
  3823. */
  3824. static Magenta(): Color3;
  3825. /**
  3826. * Returns a Color3 value containing a yellow color
  3827. * @returns a new Color3 object
  3828. */
  3829. static Yellow(): Color3;
  3830. /**
  3831. * Returns a Color3 value containing a gray color
  3832. * @returns a new Color3 object
  3833. */
  3834. static Gray(): Color3;
  3835. /**
  3836. * Returns a Color3 value containing a teal color
  3837. * @returns a new Color3 object
  3838. */
  3839. static Teal(): Color3;
  3840. /**
  3841. * Returns a Color3 value containing a random color
  3842. * @returns a new Color3 object
  3843. */
  3844. static Random(): Color3;
  3845. }
  3846. /**
  3847. * Class used to hold a RBGA color
  3848. */
  3849. export class Color4 {
  3850. /**
  3851. * Defines the red component (between 0 and 1, default is 0)
  3852. */
  3853. r: number;
  3854. /**
  3855. * Defines the green component (between 0 and 1, default is 0)
  3856. */
  3857. g: number;
  3858. /**
  3859. * Defines the blue component (between 0 and 1, default is 0)
  3860. */
  3861. b: number;
  3862. /**
  3863. * Defines the alpha component (between 0 and 1, default is 1)
  3864. */
  3865. a: number;
  3866. /**
  3867. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  3868. * @param r defines the red component (between 0 and 1, default is 0)
  3869. * @param g defines the green component (between 0 and 1, default is 0)
  3870. * @param b defines the blue component (between 0 and 1, default is 0)
  3871. * @param a defines the alpha component (between 0 and 1, default is 1)
  3872. */
  3873. constructor(
  3874. /**
  3875. * Defines the red component (between 0 and 1, default is 0)
  3876. */
  3877. r?: number,
  3878. /**
  3879. * Defines the green component (between 0 and 1, default is 0)
  3880. */
  3881. g?: number,
  3882. /**
  3883. * Defines the blue component (between 0 and 1, default is 0)
  3884. */
  3885. b?: number,
  3886. /**
  3887. * Defines the alpha component (between 0 and 1, default is 1)
  3888. */
  3889. a?: number);
  3890. /**
  3891. * Adds in place the given Color4 values to the current Color4 object
  3892. * @param right defines the second operand
  3893. * @returns the current updated Color4 object
  3894. */
  3895. addInPlace(right: DeepImmutable<Color4>): Color4;
  3896. /**
  3897. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  3898. * @returns the new array
  3899. */
  3900. asArray(): number[];
  3901. /**
  3902. * Stores from the starting index in the given array the Color4 successive values
  3903. * @param array defines the array where to store the r,g,b components
  3904. * @param index defines an optional index in the target array to define where to start storing values
  3905. * @returns the current Color4 object
  3906. */
  3907. toArray(array: number[], index?: number): Color4;
  3908. /**
  3909. * Determines equality between Color4 objects
  3910. * @param otherColor defines the second operand
  3911. * @returns true if the rgba values are equal to the given ones
  3912. */
  3913. equals(otherColor: DeepImmutable<Color4>): boolean;
  3914. /**
  3915. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  3916. * @param right defines the second operand
  3917. * @returns a new Color4 object
  3918. */
  3919. add(right: DeepImmutable<Color4>): Color4;
  3920. /**
  3921. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  3922. * @param right defines the second operand
  3923. * @returns a new Color4 object
  3924. */
  3925. subtract(right: DeepImmutable<Color4>): Color4;
  3926. /**
  3927. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  3928. * @param right defines the second operand
  3929. * @param result defines the Color4 object where to store the result
  3930. * @returns the current Color4 object
  3931. */
  3932. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  3933. /**
  3934. * Creates a new Color4 with the current Color4 values multiplied by scale
  3935. * @param scale defines the scaling factor to apply
  3936. * @returns a new Color4 object
  3937. */
  3938. scale(scale: number): Color4;
  3939. /**
  3940. * Multiplies the current Color4 values by scale and stores the result in "result"
  3941. * @param scale defines the scaling factor to apply
  3942. * @param result defines the Color4 object where to store the result
  3943. * @returns the current unmodified Color4
  3944. */
  3945. scaleToRef(scale: number, result: Color4): Color4;
  3946. /**
  3947. * Scale the current Color4 values by a factor and add the result to a given Color4
  3948. * @param scale defines the scale factor
  3949. * @param result defines the Color4 object where to store the result
  3950. * @returns the unmodified current Color4
  3951. */
  3952. scaleAndAddToRef(scale: number, result: Color4): Color4;
  3953. /**
  3954. * Clamps the rgb values by the min and max values and stores the result into "result"
  3955. * @param min defines minimum clamping value (default is 0)
  3956. * @param max defines maximum clamping value (default is 1)
  3957. * @param result defines color to store the result into.
  3958. * @returns the cuurent Color4
  3959. */
  3960. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  3961. /**
  3962. * Multipy an Color4 value by another and return a new Color4 object
  3963. * @param color defines the Color4 value to multiply by
  3964. * @returns a new Color4 object
  3965. */
  3966. multiply(color: Color4): Color4;
  3967. /**
  3968. * Multipy a Color4 value by another and push the result in a reference value
  3969. * @param color defines the Color4 value to multiply by
  3970. * @param result defines the Color4 to fill the result in
  3971. * @returns the result Color4
  3972. */
  3973. multiplyToRef(color: Color4, result: Color4): Color4;
  3974. /**
  3975. * Creates a string with the Color4 current values
  3976. * @returns the string representation of the Color4 object
  3977. */
  3978. toString(): string;
  3979. /**
  3980. * Returns the string "Color4"
  3981. * @returns "Color4"
  3982. */
  3983. getClassName(): string;
  3984. /**
  3985. * Compute the Color4 hash code
  3986. * @returns an unique number that can be used to hash Color4 objects
  3987. */
  3988. getHashCode(): number;
  3989. /**
  3990. * Creates a new Color4 copied from the current one
  3991. * @returns a new Color4 object
  3992. */
  3993. clone(): Color4;
  3994. /**
  3995. * Copies the given Color4 values into the current one
  3996. * @param source defines the source Color4 object
  3997. * @returns the current updated Color4 object
  3998. */
  3999. copyFrom(source: Color4): Color4;
  4000. /**
  4001. * Copies the given float values into the current one
  4002. * @param r defines the red component to read from
  4003. * @param g defines the green component to read from
  4004. * @param b defines the blue component to read from
  4005. * @param a defines the alpha component to read from
  4006. * @returns the current updated Color4 object
  4007. */
  4008. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  4009. /**
  4010. * Copies the given float values into the current one
  4011. * @param r defines the red component to read from
  4012. * @param g defines the green component to read from
  4013. * @param b defines the blue component to read from
  4014. * @param a defines the alpha component to read from
  4015. * @returns the current updated Color4 object
  4016. */
  4017. set(r: number, g: number, b: number, a: number): Color4;
  4018. /**
  4019. * Compute the Color4 hexadecimal code as a string
  4020. * @returns a string containing the hexadecimal representation of the Color4 object
  4021. */
  4022. toHexString(): string;
  4023. /**
  4024. * Computes a new Color4 converted from the current one to linear space
  4025. * @returns a new Color4 object
  4026. */
  4027. toLinearSpace(): Color4;
  4028. /**
  4029. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  4030. * @param convertedColor defines the Color4 object where to store the linear space version
  4031. * @returns the unmodified Color4
  4032. */
  4033. toLinearSpaceToRef(convertedColor: Color4): Color4;
  4034. /**
  4035. * Computes a new Color4 converted from the current one to gamma space
  4036. * @returns a new Color4 object
  4037. */
  4038. toGammaSpace(): Color4;
  4039. /**
  4040. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  4041. * @param convertedColor defines the Color4 object where to store the gamma space version
  4042. * @returns the unmodified Color4
  4043. */
  4044. toGammaSpaceToRef(convertedColor: Color4): Color4;
  4045. /**
  4046. * Creates a new Color4 from the string containing valid hexadecimal values
  4047. * @param hex defines a string containing valid hexadecimal values
  4048. * @returns a new Color4 object
  4049. */
  4050. static FromHexString(hex: string): Color4;
  4051. /**
  4052. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4053. * @param left defines the start value
  4054. * @param right defines the end value
  4055. * @param amount defines the gradient factor
  4056. * @returns a new Color4 object
  4057. */
  4058. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  4059. /**
  4060. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4061. * @param left defines the start value
  4062. * @param right defines the end value
  4063. * @param amount defines the gradient factor
  4064. * @param result defines the Color4 object where to store data
  4065. */
  4066. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  4067. /**
  4068. * Creates a new Color4 from a Color3 and an alpha value
  4069. * @param color3 defines the source Color3 to read from
  4070. * @param alpha defines the alpha component (1.0 by default)
  4071. * @returns a new Color4 object
  4072. */
  4073. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  4074. /**
  4075. * Creates a new Color4 from the starting index element of the given array
  4076. * @param array defines the source array to read from
  4077. * @param offset defines the offset in the source array
  4078. * @returns a new Color4 object
  4079. */
  4080. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  4081. /**
  4082. * Creates a new Color3 from integer values (< 256)
  4083. * @param r defines the red component to read from (value between 0 and 255)
  4084. * @param g defines the green component to read from (value between 0 and 255)
  4085. * @param b defines the blue component to read from (value between 0 and 255)
  4086. * @param a defines the alpha component to read from (value between 0 and 255)
  4087. * @returns a new Color3 object
  4088. */
  4089. static FromInts(r: number, g: number, b: number, a: number): Color4;
  4090. /**
  4091. * Check the content of a given array and convert it to an array containing RGBA data
  4092. * If the original array was already containing count * 4 values then it is returned directly
  4093. * @param colors defines the array to check
  4094. * @param count defines the number of RGBA data to expect
  4095. * @returns an array containing count * 4 values (RGBA)
  4096. */
  4097. static CheckColors4(colors: number[], count: number): number[];
  4098. }
  4099. /**
  4100. * @hidden
  4101. */
  4102. export class TmpColors {
  4103. static Color3: Color3[];
  4104. static Color4: Color4[];
  4105. }
  4106. }
  4107. declare module BABYLON {
  4108. /**
  4109. * Class representing spherical harmonics coefficients to the 3rd degree
  4110. */
  4111. export class SphericalHarmonics {
  4112. /**
  4113. * Defines whether or not the harmonics have been prescaled for rendering.
  4114. */
  4115. preScaled: boolean;
  4116. /**
  4117. * The l0,0 coefficients of the spherical harmonics
  4118. */
  4119. l00: Vector3;
  4120. /**
  4121. * The l1,-1 coefficients of the spherical harmonics
  4122. */
  4123. l1_1: Vector3;
  4124. /**
  4125. * The l1,0 coefficients of the spherical harmonics
  4126. */
  4127. l10: Vector3;
  4128. /**
  4129. * The l1,1 coefficients of the spherical harmonics
  4130. */
  4131. l11: Vector3;
  4132. /**
  4133. * The l2,-2 coefficients of the spherical harmonics
  4134. */
  4135. l2_2: Vector3;
  4136. /**
  4137. * The l2,-1 coefficients of the spherical harmonics
  4138. */
  4139. l2_1: Vector3;
  4140. /**
  4141. * The l2,0 coefficients of the spherical harmonics
  4142. */
  4143. l20: Vector3;
  4144. /**
  4145. * The l2,1 coefficients of the spherical harmonics
  4146. */
  4147. l21: Vector3;
  4148. /**
  4149. * The l2,2 coefficients of the spherical harmonics
  4150. */
  4151. l22: Vector3;
  4152. /**
  4153. * Adds a light to the spherical harmonics
  4154. * @param direction the direction of the light
  4155. * @param color the color of the light
  4156. * @param deltaSolidAngle the delta solid angle of the light
  4157. */
  4158. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  4159. /**
  4160. * Scales the spherical harmonics by the given amount
  4161. * @param scale the amount to scale
  4162. */
  4163. scaleInPlace(scale: number): void;
  4164. /**
  4165. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  4166. *
  4167. * ```
  4168. * E_lm = A_l * L_lm
  4169. * ```
  4170. *
  4171. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  4172. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  4173. * the scaling factors are given in equation 9.
  4174. */
  4175. convertIncidentRadianceToIrradiance(): void;
  4176. /**
  4177. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  4178. *
  4179. * ```
  4180. * L = (1/pi) * E * rho
  4181. * ```
  4182. *
  4183. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  4184. */
  4185. convertIrradianceToLambertianRadiance(): void;
  4186. /**
  4187. * Integrates the reconstruction coefficients directly in to the SH preventing further
  4188. * required operations at run time.
  4189. *
  4190. * This is simply done by scaling back the SH with Ylm constants parameter.
  4191. * The trigonometric part being applied by the shader at run time.
  4192. */
  4193. preScaleForRendering(): void;
  4194. /**
  4195. * Constructs a spherical harmonics from an array.
  4196. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  4197. * @returns the spherical harmonics
  4198. */
  4199. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  4200. /**
  4201. * Gets the spherical harmonics from polynomial
  4202. * @param polynomial the spherical polynomial
  4203. * @returns the spherical harmonics
  4204. */
  4205. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  4206. }
  4207. /**
  4208. * Class representing spherical polynomial coefficients to the 3rd degree
  4209. */
  4210. export class SphericalPolynomial {
  4211. private _harmonics;
  4212. /**
  4213. * The spherical harmonics used to create the polynomials.
  4214. */
  4215. readonly preScaledHarmonics: SphericalHarmonics;
  4216. /**
  4217. * The x coefficients of the spherical polynomial
  4218. */
  4219. x: Vector3;
  4220. /**
  4221. * The y coefficients of the spherical polynomial
  4222. */
  4223. y: Vector3;
  4224. /**
  4225. * The z coefficients of the spherical polynomial
  4226. */
  4227. z: Vector3;
  4228. /**
  4229. * The xx coefficients of the spherical polynomial
  4230. */
  4231. xx: Vector3;
  4232. /**
  4233. * The yy coefficients of the spherical polynomial
  4234. */
  4235. yy: Vector3;
  4236. /**
  4237. * The zz coefficients of the spherical polynomial
  4238. */
  4239. zz: Vector3;
  4240. /**
  4241. * The xy coefficients of the spherical polynomial
  4242. */
  4243. xy: Vector3;
  4244. /**
  4245. * The yz coefficients of the spherical polynomial
  4246. */
  4247. yz: Vector3;
  4248. /**
  4249. * The zx coefficients of the spherical polynomial
  4250. */
  4251. zx: Vector3;
  4252. /**
  4253. * Adds an ambient color to the spherical polynomial
  4254. * @param color the color to add
  4255. */
  4256. addAmbient(color: Color3): void;
  4257. /**
  4258. * Scales the spherical polynomial by the given amount
  4259. * @param scale the amount to scale
  4260. */
  4261. scaleInPlace(scale: number): void;
  4262. /**
  4263. * Gets the spherical polynomial from harmonics
  4264. * @param harmonics the spherical harmonics
  4265. * @returns the spherical polynomial
  4266. */
  4267. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  4268. /**
  4269. * Constructs a spherical polynomial from an array.
  4270. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  4271. * @returns the spherical polynomial
  4272. */
  4273. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  4274. }
  4275. }
  4276. declare module BABYLON {
  4277. /**
  4278. * Define options used to create a render target texture
  4279. */
  4280. export class RenderTargetCreationOptions {
  4281. /**
  4282. * Specifies is mipmaps must be generated
  4283. */
  4284. generateMipMaps?: boolean;
  4285. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  4286. generateDepthBuffer?: boolean;
  4287. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  4288. generateStencilBuffer?: boolean;
  4289. /** Defines texture type (int by default) */
  4290. type?: number;
  4291. /** Defines sampling mode (trilinear by default) */
  4292. samplingMode?: number;
  4293. /** Defines format (RGBA by default) */
  4294. format?: number;
  4295. }
  4296. }
  4297. declare module BABYLON {
  4298. /**
  4299. * @hidden
  4300. **/
  4301. export class _TimeToken { private _startTimeQuery: Nullable<WebGLQuery>; private _endTimeQuery: Nullable<WebGLQuery>; private _timeElapsedQuery: Nullable<WebGLQuery>; private _timeElapsedQueryEnded: boolean;
  4302. }
  4303. }
  4304. declare module BABYLON {
  4305. /** Defines the cross module used constants to avoid circular dependncies */
  4306. export class Constants {
  4307. /** Defines that alpha blending is disabled */
  4308. static readonly ALPHA_DISABLE: number;
  4309. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4310. static readonly ALPHA_ADD: number;
  4311. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4312. static readonly ALPHA_COMBINE: number;
  4313. /** Defines that alpha blending to DEST - SRC * DEST */
  4314. static readonly ALPHA_SUBTRACT: number;
  4315. /** Defines that alpha blending to SRC * DEST */
  4316. static readonly ALPHA_MULTIPLY: number;
  4317. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4318. static readonly ALPHA_MAXIMIZED: number;
  4319. /** Defines that alpha blending to SRC + DEST */
  4320. static readonly ALPHA_ONEONE: number;
  4321. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4322. static readonly ALPHA_PREMULTIPLIED: number;
  4323. /**
  4324. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4325. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4326. */
  4327. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4328. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4329. static readonly ALPHA_INTERPOLATE: number;
  4330. /**
  4331. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4332. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4333. */
  4334. static readonly ALPHA_SCREENMODE: number;
  4335. /**
  4336. * Defines that alpha blending to SRC + DST
  4337. * Alpha will be set to SRC ALPHA + DST ALPHA
  4338. */
  4339. static readonly ALPHA_ONEONE_ONEONE: number;
  4340. /**
  4341. * Defines that alpha blending to SRC * DST ALPHA + DST
  4342. * Alpha will be set to 0
  4343. */
  4344. static readonly ALPHA_ALPHATOCOLOR: number;
  4345. /**
  4346. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  4347. */
  4348. static readonly ALPHA_REVERSEONEMINUS: number;
  4349. /**
  4350. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  4351. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  4352. */
  4353. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  4354. /**
  4355. * Defines that alpha blending to SRC + DST
  4356. * Alpha will be set to SRC ALPHA
  4357. */
  4358. static readonly ALPHA_ONEONE_ONEZERO: number;
  4359. /** Defines that alpha blending equation a SUM */
  4360. static readonly ALPHA_EQUATION_ADD: number;
  4361. /** Defines that alpha blending equation a SUBSTRACTION */
  4362. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  4363. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  4364. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  4365. /** Defines that alpha blending equation a MAX operation */
  4366. static readonly ALPHA_EQUATION_MAX: number;
  4367. /** Defines that alpha blending equation a MIN operation */
  4368. static readonly ALPHA_EQUATION_MIN: number;
  4369. /**
  4370. * Defines that alpha blending equation a DARKEN operation:
  4371. * It takes the min of the src and sums the alpha channels.
  4372. */
  4373. static readonly ALPHA_EQUATION_DARKEN: number;
  4374. /** Defines that the ressource is not delayed*/
  4375. static readonly DELAYLOADSTATE_NONE: number;
  4376. /** Defines that the ressource was successfully delay loaded */
  4377. static readonly DELAYLOADSTATE_LOADED: number;
  4378. /** Defines that the ressource is currently delay loading */
  4379. static readonly DELAYLOADSTATE_LOADING: number;
  4380. /** Defines that the ressource is delayed and has not started loading */
  4381. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4382. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4383. static readonly NEVER: number;
  4384. /** 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 */
  4385. static readonly ALWAYS: number;
  4386. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4387. static readonly LESS: number;
  4388. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4389. static readonly EQUAL: number;
  4390. /** 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 */
  4391. static readonly LEQUAL: number;
  4392. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4393. static readonly GREATER: number;
  4394. /** 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 */
  4395. static readonly GEQUAL: number;
  4396. /** 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 */
  4397. static readonly NOTEQUAL: number;
  4398. /** Passed to stencilOperation to specify that stencil value must be kept */
  4399. static readonly KEEP: number;
  4400. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4401. static readonly REPLACE: number;
  4402. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4403. static readonly INCR: number;
  4404. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4405. static readonly DECR: number;
  4406. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4407. static readonly INVERT: number;
  4408. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4409. static readonly INCR_WRAP: number;
  4410. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4411. static readonly DECR_WRAP: number;
  4412. /** Texture is not repeating outside of 0..1 UVs */
  4413. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4414. /** Texture is repeating outside of 0..1 UVs */
  4415. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4416. /** Texture is repeating and mirrored */
  4417. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4418. /** ALPHA */
  4419. static readonly TEXTUREFORMAT_ALPHA: number;
  4420. /** LUMINANCE */
  4421. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4422. /** LUMINANCE_ALPHA */
  4423. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4424. /** RGB */
  4425. static readonly TEXTUREFORMAT_RGB: number;
  4426. /** RGBA */
  4427. static readonly TEXTUREFORMAT_RGBA: number;
  4428. /** RED */
  4429. static readonly TEXTUREFORMAT_RED: number;
  4430. /** RED (2nd reference) */
  4431. static readonly TEXTUREFORMAT_R: number;
  4432. /** RG */
  4433. static readonly TEXTUREFORMAT_RG: number;
  4434. /** RED_INTEGER */
  4435. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4436. /** RED_INTEGER (2nd reference) */
  4437. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4438. /** RG_INTEGER */
  4439. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4440. /** RGB_INTEGER */
  4441. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4442. /** RGBA_INTEGER */
  4443. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4444. /** UNSIGNED_BYTE */
  4445. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4446. /** UNSIGNED_BYTE (2nd reference) */
  4447. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4448. /** FLOAT */
  4449. static readonly TEXTURETYPE_FLOAT: number;
  4450. /** HALF_FLOAT */
  4451. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4452. /** BYTE */
  4453. static readonly TEXTURETYPE_BYTE: number;
  4454. /** SHORT */
  4455. static readonly TEXTURETYPE_SHORT: number;
  4456. /** UNSIGNED_SHORT */
  4457. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4458. /** INT */
  4459. static readonly TEXTURETYPE_INT: number;
  4460. /** UNSIGNED_INT */
  4461. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4462. /** UNSIGNED_SHORT_4_4_4_4 */
  4463. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4464. /** UNSIGNED_SHORT_5_5_5_1 */
  4465. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4466. /** UNSIGNED_SHORT_5_6_5 */
  4467. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4468. /** UNSIGNED_INT_2_10_10_10_REV */
  4469. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4470. /** UNSIGNED_INT_24_8 */
  4471. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4472. /** UNSIGNED_INT_10F_11F_11F_REV */
  4473. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4474. /** UNSIGNED_INT_5_9_9_9_REV */
  4475. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4476. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4477. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4478. /** nearest is mag = nearest and min = nearest and mip = linear */
  4479. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4480. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4481. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4482. /** Trilinear is mag = linear and min = linear and mip = linear */
  4483. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4484. /** nearest is mag = nearest and min = nearest and mip = linear */
  4485. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4486. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4487. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4488. /** Trilinear is mag = linear and min = linear and mip = linear */
  4489. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4490. /** mag = nearest and min = nearest and mip = nearest */
  4491. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4492. /** mag = nearest and min = linear and mip = nearest */
  4493. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4494. /** mag = nearest and min = linear and mip = linear */
  4495. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4496. /** mag = nearest and min = linear and mip = none */
  4497. static readonly TEXTURE_NEAREST_LINEAR: number;
  4498. /** mag = nearest and min = nearest and mip = none */
  4499. static readonly TEXTURE_NEAREST_NEAREST: number;
  4500. /** mag = linear and min = nearest and mip = nearest */
  4501. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4502. /** mag = linear and min = nearest and mip = linear */
  4503. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4504. /** mag = linear and min = linear and mip = none */
  4505. static readonly TEXTURE_LINEAR_LINEAR: number;
  4506. /** mag = linear and min = nearest and mip = none */
  4507. static readonly TEXTURE_LINEAR_NEAREST: number;
  4508. /** Explicit coordinates mode */
  4509. static readonly TEXTURE_EXPLICIT_MODE: number;
  4510. /** Spherical coordinates mode */
  4511. static readonly TEXTURE_SPHERICAL_MODE: number;
  4512. /** Planar coordinates mode */
  4513. static readonly TEXTURE_PLANAR_MODE: number;
  4514. /** Cubic coordinates mode */
  4515. static readonly TEXTURE_CUBIC_MODE: number;
  4516. /** Projection coordinates mode */
  4517. static readonly TEXTURE_PROJECTION_MODE: number;
  4518. /** Skybox coordinates mode */
  4519. static readonly TEXTURE_SKYBOX_MODE: number;
  4520. /** Inverse Cubic coordinates mode */
  4521. static readonly TEXTURE_INVCUBIC_MODE: number;
  4522. /** Equirectangular coordinates mode */
  4523. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4524. /** Equirectangular Fixed coordinates mode */
  4525. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4526. /** Equirectangular Fixed Mirrored coordinates mode */
  4527. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4528. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4529. static readonly SCALEMODE_FLOOR: number;
  4530. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4531. static readonly SCALEMODE_NEAREST: number;
  4532. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4533. static readonly SCALEMODE_CEILING: number;
  4534. /**
  4535. * The dirty texture flag value
  4536. */
  4537. static readonly MATERIAL_TextureDirtyFlag: number;
  4538. /**
  4539. * The dirty light flag value
  4540. */
  4541. static readonly MATERIAL_LightDirtyFlag: number;
  4542. /**
  4543. * The dirty fresnel flag value
  4544. */
  4545. static readonly MATERIAL_FresnelDirtyFlag: number;
  4546. /**
  4547. * The dirty attribute flag value
  4548. */
  4549. static readonly MATERIAL_AttributesDirtyFlag: number;
  4550. /**
  4551. * The dirty misc flag value
  4552. */
  4553. static readonly MATERIAL_MiscDirtyFlag: number;
  4554. /**
  4555. * The all dirty flag value
  4556. */
  4557. static readonly MATERIAL_AllDirtyFlag: number;
  4558. /**
  4559. * Returns the triangle fill mode
  4560. */
  4561. static readonly MATERIAL_TriangleFillMode: number;
  4562. /**
  4563. * Returns the wireframe mode
  4564. */
  4565. static readonly MATERIAL_WireFrameFillMode: number;
  4566. /**
  4567. * Returns the point fill mode
  4568. */
  4569. static readonly MATERIAL_PointFillMode: number;
  4570. /**
  4571. * Returns the point list draw mode
  4572. */
  4573. static readonly MATERIAL_PointListDrawMode: number;
  4574. /**
  4575. * Returns the line list draw mode
  4576. */
  4577. static readonly MATERIAL_LineListDrawMode: number;
  4578. /**
  4579. * Returns the line loop draw mode
  4580. */
  4581. static readonly MATERIAL_LineLoopDrawMode: number;
  4582. /**
  4583. * Returns the line strip draw mode
  4584. */
  4585. static readonly MATERIAL_LineStripDrawMode: number;
  4586. /**
  4587. * Returns the triangle strip draw mode
  4588. */
  4589. static readonly MATERIAL_TriangleStripDrawMode: number;
  4590. /**
  4591. * Returns the triangle fan draw mode
  4592. */
  4593. static readonly MATERIAL_TriangleFanDrawMode: number;
  4594. /**
  4595. * Stores the clock-wise side orientation
  4596. */
  4597. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4598. /**
  4599. * Stores the counter clock-wise side orientation
  4600. */
  4601. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4602. /**
  4603. * Nothing
  4604. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4605. */
  4606. static readonly ACTION_NothingTrigger: number;
  4607. /**
  4608. * On pick
  4609. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4610. */
  4611. static readonly ACTION_OnPickTrigger: number;
  4612. /**
  4613. * On left pick
  4614. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4615. */
  4616. static readonly ACTION_OnLeftPickTrigger: number;
  4617. /**
  4618. * On right pick
  4619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4620. */
  4621. static readonly ACTION_OnRightPickTrigger: number;
  4622. /**
  4623. * On center pick
  4624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4625. */
  4626. static readonly ACTION_OnCenterPickTrigger: number;
  4627. /**
  4628. * On pick down
  4629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4630. */
  4631. static readonly ACTION_OnPickDownTrigger: number;
  4632. /**
  4633. * On double pick
  4634. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4635. */
  4636. static readonly ACTION_OnDoublePickTrigger: number;
  4637. /**
  4638. * On pick up
  4639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4640. */
  4641. static readonly ACTION_OnPickUpTrigger: number;
  4642. /**
  4643. * On pick out.
  4644. * This trigger will only be raised if you also declared a OnPickDown
  4645. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4646. */
  4647. static readonly ACTION_OnPickOutTrigger: number;
  4648. /**
  4649. * On long press
  4650. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4651. */
  4652. static readonly ACTION_OnLongPressTrigger: number;
  4653. /**
  4654. * On pointer over
  4655. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4656. */
  4657. static readonly ACTION_OnPointerOverTrigger: number;
  4658. /**
  4659. * On pointer out
  4660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4661. */
  4662. static readonly ACTION_OnPointerOutTrigger: number;
  4663. /**
  4664. * On every frame
  4665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4666. */
  4667. static readonly ACTION_OnEveryFrameTrigger: number;
  4668. /**
  4669. * On intersection enter
  4670. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4671. */
  4672. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4673. /**
  4674. * On intersection exit
  4675. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4676. */
  4677. static readonly ACTION_OnIntersectionExitTrigger: number;
  4678. /**
  4679. * On key down
  4680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4681. */
  4682. static readonly ACTION_OnKeyDownTrigger: number;
  4683. /**
  4684. * On key up
  4685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4686. */
  4687. static readonly ACTION_OnKeyUpTrigger: number;
  4688. /**
  4689. * Billboard mode will only apply to Y axis
  4690. */
  4691. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4692. /**
  4693. * Billboard mode will apply to all axes
  4694. */
  4695. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4696. /**
  4697. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4698. */
  4699. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4700. /**
  4701. * Gets or sets base Assets URL
  4702. */
  4703. static PARTICLES_BaseAssetsUrl: string;
  4704. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4705. * Test order :
  4706. * Is the bounding sphere outside the frustum ?
  4707. * If not, are the bounding box vertices outside the frustum ?
  4708. * It not, then the cullable object is in the frustum.
  4709. */
  4710. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4711. /** Culling strategy : Bounding Sphere Only.
  4712. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4713. * It's also less accurate than the standard because some not visible objects can still be selected.
  4714. * Test : is the bounding sphere outside the frustum ?
  4715. * If not, then the cullable object is in the frustum.
  4716. */
  4717. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4718. /** Culling strategy : Optimistic Inclusion.
  4719. * This in an inclusion test first, then the standard exclusion test.
  4720. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4721. * 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.
  4722. * Anyway, it's as accurate as the standard strategy.
  4723. * Test :
  4724. * Is the cullable object bounding sphere center in the frustum ?
  4725. * If not, apply the default culling strategy.
  4726. */
  4727. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4728. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4729. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4730. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4731. * 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.
  4732. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4733. * Test :
  4734. * Is the cullable object bounding sphere center in the frustum ?
  4735. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4736. */
  4737. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4738. /**
  4739. * No logging while loading
  4740. */
  4741. static readonly SCENELOADER_NO_LOGGING: number;
  4742. /**
  4743. * Minimal logging while loading
  4744. */
  4745. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4746. /**
  4747. * Summary logging while loading
  4748. */
  4749. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4750. /**
  4751. * Detailled logging while loading
  4752. */
  4753. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4754. }
  4755. }
  4756. declare module BABYLON {
  4757. /**
  4758. * This represents the required contract to create a new type of texture loader.
  4759. */
  4760. export interface IInternalTextureLoader {
  4761. /**
  4762. * Defines wether the loader supports cascade loading the different faces.
  4763. */
  4764. supportCascades: boolean;
  4765. /**
  4766. * This returns if the loader support the current file information.
  4767. * @param extension defines the file extension of the file being loaded
  4768. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4769. * @param fallback defines the fallback internal texture if any
  4770. * @param isBase64 defines whether the texture is encoded as a base64
  4771. * @param isBuffer defines whether the texture data are stored as a buffer
  4772. * @returns true if the loader can load the specified file
  4773. */
  4774. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  4775. /**
  4776. * Transform the url before loading if required.
  4777. * @param rootUrl the url of the texture
  4778. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4779. * @returns the transformed texture
  4780. */
  4781. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  4782. /**
  4783. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  4784. * @param rootUrl the url of the texture
  4785. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4786. * @returns the fallback texture
  4787. */
  4788. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  4789. /**
  4790. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  4791. * @param data contains the texture data
  4792. * @param texture defines the BabylonJS internal texture
  4793. * @param createPolynomials will be true if polynomials have been requested
  4794. * @param onLoad defines the callback to trigger once the texture is ready
  4795. * @param onError defines the callback to trigger in case of error
  4796. */
  4797. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  4798. /**
  4799. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  4800. * @param data contains the texture data
  4801. * @param texture defines the BabylonJS internal texture
  4802. * @param callback defines the method to call once ready to upload
  4803. */
  4804. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  4805. }
  4806. }
  4807. declare module BABYLON {
  4808. /**
  4809. * Class used to store and describe the pipeline context associated with an effect
  4810. */
  4811. export interface IPipelineContext {
  4812. /**
  4813. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4814. */
  4815. isAsync: boolean;
  4816. /**
  4817. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4818. */
  4819. isReady: boolean;
  4820. /** @hidden */ private _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4821. }
  4822. }
  4823. declare module BABYLON {
  4824. /**
  4825. * Class used to store gfx data (like WebGLBuffer)
  4826. */
  4827. export class DataBuffer {
  4828. /**
  4829. * Gets or sets the number of objects referencing this buffer
  4830. */
  4831. references: number;
  4832. /** Gets or sets the size of the underlying buffer */
  4833. capacity: number;
  4834. /**
  4835. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  4836. */
  4837. is32Bits: boolean;
  4838. /**
  4839. * Gets the underlying buffer
  4840. */
  4841. readonly underlyingResource: any;
  4842. }
  4843. }
  4844. declare module BABYLON {
  4845. /** @hidden */
  4846. export interface IShaderProcessor {
  4847. attributeProcessor?: (attribute: string) => string;
  4848. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4849. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4850. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4851. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4852. lineProcessor?: (line: string, isFragment: boolean) => string;
  4853. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4854. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4855. }
  4856. }
  4857. declare module BABYLON {
  4858. /** @hidden */
  4859. export interface ProcessingOptions {
  4860. defines: string[];
  4861. indexParameters: any;
  4862. isFragment: boolean;
  4863. shouldUseHighPrecisionShader: boolean;
  4864. supportsUniformBuffers: boolean;
  4865. shadersRepository: string;
  4866. includesShadersStore: {
  4867. [key: string]: string;
  4868. };
  4869. processor?: IShaderProcessor;
  4870. version: string;
  4871. platformName: string;
  4872. lookForClosingBracketForUniformBuffer?: boolean;
  4873. }
  4874. }
  4875. declare module BABYLON {
  4876. /**
  4877. * Helper to manipulate strings
  4878. */
  4879. export class StringTools {
  4880. /**
  4881. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4882. * @param str Source string
  4883. * @param suffix Suffix to search for in the source string
  4884. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4885. */
  4886. static EndsWith(str: string, suffix: string): boolean;
  4887. /**
  4888. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4889. * @param str Source string
  4890. * @param suffix Suffix to search for in the source string
  4891. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4892. */
  4893. static StartsWith(str: string, suffix: string): boolean;
  4894. }
  4895. }
  4896. declare module BABYLON {
  4897. /** @hidden */
  4898. export class ShaderCodeNode {
  4899. line: string;
  4900. children: ShaderCodeNode[];
  4901. additionalDefineKey?: string;
  4902. additionalDefineValue?: string;
  4903. isValid(preprocessors: {
  4904. [key: string]: string;
  4905. }): boolean;
  4906. process(preprocessors: {
  4907. [key: string]: string;
  4908. }, options: ProcessingOptions): string;
  4909. }
  4910. }
  4911. declare module BABYLON {
  4912. /** @hidden */
  4913. export class ShaderCodeCursor {
  4914. private _lines;
  4915. lineIndex: number;
  4916. readonly currentLine: string;
  4917. readonly canRead: boolean;
  4918. lines: string[];
  4919. }
  4920. }
  4921. declare module BABYLON {
  4922. /** @hidden */
  4923. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4924. process(preprocessors: {
  4925. [key: string]: string;
  4926. }, options: ProcessingOptions): string;
  4927. }
  4928. }
  4929. declare module BABYLON {
  4930. /** @hidden */
  4931. export class ShaderDefineExpression {
  4932. isTrue(preprocessors: {
  4933. [key: string]: string;
  4934. }): boolean;
  4935. }
  4936. }
  4937. declare module BABYLON {
  4938. /** @hidden */
  4939. export class ShaderCodeTestNode extends ShaderCodeNode {
  4940. testExpression: ShaderDefineExpression;
  4941. isValid(preprocessors: {
  4942. [key: string]: string;
  4943. }): boolean;
  4944. }
  4945. }
  4946. declare module BABYLON {
  4947. /** @hidden */
  4948. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4949. define: string;
  4950. not: boolean;
  4951. constructor(define: string, not?: boolean);
  4952. isTrue(preprocessors: {
  4953. [key: string]: string;
  4954. }): boolean;
  4955. }
  4956. }
  4957. declare module BABYLON {
  4958. /** @hidden */
  4959. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4960. leftOperand: ShaderDefineExpression;
  4961. rightOperand: ShaderDefineExpression;
  4962. isTrue(preprocessors: {
  4963. [key: string]: string;
  4964. }): boolean;
  4965. }
  4966. }
  4967. declare module BABYLON {
  4968. /** @hidden */
  4969. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4970. leftOperand: ShaderDefineExpression;
  4971. rightOperand: ShaderDefineExpression;
  4972. isTrue(preprocessors: {
  4973. [key: string]: string;
  4974. }): boolean;
  4975. }
  4976. }
  4977. declare module BABYLON {
  4978. /** @hidden */
  4979. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4980. define: string;
  4981. operand: string;
  4982. testValue: string;
  4983. constructor(define: string, operand: string, testValue: string);
  4984. isTrue(preprocessors: {
  4985. [key: string]: string;
  4986. }): boolean;
  4987. }
  4988. }
  4989. declare module BABYLON {
  4990. /**
  4991. * @ignore
  4992. * Application error to support additional information when loading a file
  4993. */
  4994. export class LoadFileError extends Error {
  4995. /** defines the optional web request */
  4996. request?: WebRequest | undefined;
  4997. private static _setPrototypeOf;
  4998. /**
  4999. * Creates a new LoadFileError
  5000. * @param message defines the message of the error
  5001. * @param request defines the optional web request
  5002. */
  5003. constructor(message: string,
  5004. /** defines the optional web request */
  5005. request?: WebRequest | undefined);
  5006. }
  5007. }
  5008. declare module BABYLON {
  5009. /**
  5010. * Class used to enable access to offline support
  5011. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  5012. */
  5013. export interface IOfflineProvider {
  5014. /**
  5015. * Gets a boolean indicating if scene must be saved in the database
  5016. */
  5017. enableSceneOffline: boolean;
  5018. /**
  5019. * Gets a boolean indicating if textures must be saved in the database
  5020. */
  5021. enableTexturesOffline: boolean;
  5022. /**
  5023. * Open the offline support and make it available
  5024. * @param successCallback defines the callback to call on success
  5025. * @param errorCallback defines the callback to call on error
  5026. */
  5027. open(successCallback: () => void, errorCallback: () => void): void;
  5028. /**
  5029. * Loads an image from the offline support
  5030. * @param url defines the url to load from
  5031. * @param image defines the target DOM image
  5032. */
  5033. loadImage(url: string, image: HTMLImageElement): void;
  5034. /**
  5035. * Loads a file from offline support
  5036. * @param url defines the URL to load from
  5037. * @param sceneLoaded defines a callback to call on success
  5038. * @param progressCallBack defines a callback to call when progress changed
  5039. * @param errorCallback defines a callback to call on error
  5040. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  5041. */
  5042. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  5043. }
  5044. }
  5045. declare module BABYLON {
  5046. /**
  5047. * Class used to help managing file picking and drag'n'drop
  5048. * File Storage
  5049. */
  5050. export class FilesInputStore {
  5051. /**
  5052. * List of files ready to be loaded
  5053. */
  5054. static FilesToLoad: {
  5055. [key: string]: File;
  5056. };
  5057. }
  5058. }
  5059. declare module BABYLON {
  5060. /**
  5061. * Class used to define a retry strategy when error happens while loading assets
  5062. */
  5063. export class RetryStrategy {
  5064. /**
  5065. * Function used to defines an exponential back off strategy
  5066. * @param maxRetries defines the maximum number of retries (3 by default)
  5067. * @param baseInterval defines the interval between retries
  5068. * @returns the strategy function to use
  5069. */
  5070. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  5071. }
  5072. }
  5073. declare module BABYLON {
  5074. /**
  5075. * @hidden
  5076. */
  5077. export class FileTools {
  5078. /**
  5079. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  5080. */
  5081. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  5082. /**
  5083. * Gets or sets the base URL to use to load assets
  5084. */
  5085. static BaseUrl: string;
  5086. /**
  5087. * Default behaviour for cors in the application.
  5088. * It can be a string if the expected behavior is identical in the entire app.
  5089. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  5090. */
  5091. static CorsBehavior: string | ((url: string | string[]) => string);
  5092. /**
  5093. * Gets or sets a function used to pre-process url before using them to load assets
  5094. */
  5095. static PreprocessUrl: (url: string) => string;
  5096. /**
  5097. * Removes unwanted characters from an url
  5098. * @param url defines the url to clean
  5099. * @returns the cleaned url
  5100. */
  5101. private static _CleanUrl;
  5102. /**
  5103. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  5104. * @param url define the url we are trying
  5105. * @param element define the dom element where to configure the cors policy
  5106. */
  5107. static SetCorsBehavior(url: string | string[], element: {
  5108. crossOrigin: string | null;
  5109. }): void;
  5110. /**
  5111. * Loads an image as an HTMLImageElement.
  5112. * @param input url string, ArrayBuffer, or Blob to load
  5113. * @param onLoad callback called when the image successfully loads
  5114. * @param onError callback called when the image fails to load
  5115. * @param offlineProvider offline provider for caching
  5116. * @returns the HTMLImageElement of the loaded image
  5117. */
  5118. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  5119. /**
  5120. * Loads a file
  5121. * @param fileToLoad defines the file to load
  5122. * @param callback defines the callback to call when data is loaded
  5123. * @param progressCallBack defines the callback to call during loading process
  5124. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  5125. * @returns a file request object
  5126. */
  5127. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  5128. /**
  5129. * Loads a file
  5130. * @param url url string, ArrayBuffer, or Blob to load
  5131. * @param onSuccess callback called when the file successfully loads
  5132. * @param onProgress callback called while file is loading (if the server supports this mode)
  5133. * @param offlineProvider defines the offline provider for caching
  5134. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  5135. * @param onError callback called when the file fails to load
  5136. * @returns a file request object
  5137. */
  5138. 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;
  5139. /**
  5140. * Checks if the loaded document was accessed via `file:`-Protocol.
  5141. * @returns boolean
  5142. */
  5143. static IsFileURL(): boolean;
  5144. }
  5145. }
  5146. declare module BABYLON {
  5147. /** @hidden */
  5148. export class ShaderProcessor {
  5149. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5150. private static _ProcessPrecision;
  5151. private static _ExtractOperation;
  5152. private static _BuildSubExpression;
  5153. private static _BuildExpression;
  5154. private static _MoveCursorWithinIf;
  5155. private static _MoveCursor;
  5156. private static _EvaluatePreProcessors;
  5157. private static _PreparePreProcessors;
  5158. private static _ProcessShaderConversion;
  5159. private static _ProcessIncludes;
  5160. }
  5161. }
  5162. declare module BABYLON {
  5163. /**
  5164. * Interface used to define common properties for effect fallbacks
  5165. */
  5166. export interface IEffectFallbacks {
  5167. /**
  5168. * Removes the defines that should be removed when falling back.
  5169. * @param currentDefines defines the current define statements for the shader.
  5170. * @param effect defines the current effect we try to compile
  5171. * @returns The resulting defines with defines of the current rank removed.
  5172. */
  5173. reduce(currentDefines: string, effect: Effect): string;
  5174. /**
  5175. * Removes the fallback from the bound mesh.
  5176. */
  5177. unBindMesh(): void;
  5178. /**
  5179. * Checks to see if more fallbacks are still availible.
  5180. */
  5181. hasMoreFallbacks: boolean;
  5182. }
  5183. }
  5184. declare module BABYLON {
  5185. /**
  5186. * Class used to evalaute queries containing `and` and `or` operators
  5187. */
  5188. export class AndOrNotEvaluator {
  5189. /**
  5190. * Evaluate a query
  5191. * @param query defines the query to evaluate
  5192. * @param evaluateCallback defines the callback used to filter result
  5193. * @returns true if the query matches
  5194. */
  5195. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5196. private static _HandleParenthesisContent;
  5197. private static _SimplifyNegation;
  5198. }
  5199. }
  5200. declare module BABYLON {
  5201. /**
  5202. * Class used to store custom tags
  5203. */
  5204. export class Tags {
  5205. /**
  5206. * Adds support for tags on the given object
  5207. * @param obj defines the object to use
  5208. */
  5209. static EnableFor(obj: any): void;
  5210. /**
  5211. * Removes tags support
  5212. * @param obj defines the object to use
  5213. */
  5214. static DisableFor(obj: any): void;
  5215. /**
  5216. * Gets a boolean indicating if the given object has tags
  5217. * @param obj defines the object to use
  5218. * @returns a boolean
  5219. */
  5220. static HasTags(obj: any): boolean;
  5221. /**
  5222. * Gets the tags available on a given object
  5223. * @param obj defines the object to use
  5224. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5225. * @returns the tags
  5226. */
  5227. static GetTags(obj: any, asString?: boolean): any;
  5228. /**
  5229. * Adds tags to an object
  5230. * @param obj defines the object to use
  5231. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5232. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5233. */
  5234. static AddTagsTo(obj: any, tagsString: string): void;
  5235. /**
  5236. * @hidden
  5237. */ private static _AddTagTo(obj: any, tag: string): void;
  5238. /**
  5239. * Removes specific tags from a specific object
  5240. * @param obj defines the object to use
  5241. * @param tagsString defines the tags to remove
  5242. */
  5243. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5244. /**
  5245. * @hidden
  5246. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5247. /**
  5248. * Defines if tags hosted on an object match a given query
  5249. * @param obj defines the object to use
  5250. * @param tagsQuery defines the tag query
  5251. * @returns a boolean
  5252. */
  5253. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5254. }
  5255. }
  5256. declare module BABYLON {
  5257. /**
  5258. * Defines potential orientation for back face culling
  5259. */
  5260. export enum Orientation {
  5261. /**
  5262. * Clockwise
  5263. */
  5264. CW = 0,
  5265. /** Counter clockwise */
  5266. CCW = 1
  5267. }
  5268. /** Class used to represent a Bezier curve */
  5269. export class BezierCurve {
  5270. /**
  5271. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5272. * @param t defines the time
  5273. * @param x1 defines the left coordinate on X axis
  5274. * @param y1 defines the left coordinate on Y axis
  5275. * @param x2 defines the right coordinate on X axis
  5276. * @param y2 defines the right coordinate on Y axis
  5277. * @returns the interpolated value
  5278. */
  5279. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5280. }
  5281. /**
  5282. * Defines angle representation
  5283. */
  5284. export class Angle {
  5285. private _radians;
  5286. /**
  5287. * Creates an Angle object of "radians" radians (float).
  5288. * @param radians the angle in radians
  5289. */
  5290. constructor(radians: number);
  5291. /**
  5292. * Get value in degrees
  5293. * @returns the Angle value in degrees (float)
  5294. */
  5295. degrees(): number;
  5296. /**
  5297. * Get value in radians
  5298. * @returns the Angle value in radians (float)
  5299. */
  5300. radians(): number;
  5301. /**
  5302. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5303. * @param a defines first vector
  5304. * @param b defines second vector
  5305. * @returns a new Angle
  5306. */
  5307. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5308. /**
  5309. * Gets a new Angle object from the given float in radians
  5310. * @param radians defines the angle value in radians
  5311. * @returns a new Angle
  5312. */
  5313. static FromRadians(radians: number): Angle;
  5314. /**
  5315. * Gets a new Angle object from the given float in degrees
  5316. * @param degrees defines the angle value in degrees
  5317. * @returns a new Angle
  5318. */
  5319. static FromDegrees(degrees: number): Angle;
  5320. }
  5321. /**
  5322. * This represents an arc in a 2d space.
  5323. */
  5324. export class Arc2 {
  5325. /** Defines the start point of the arc */
  5326. startPoint: Vector2;
  5327. /** Defines the mid point of the arc */
  5328. midPoint: Vector2;
  5329. /** Defines the end point of the arc */
  5330. endPoint: Vector2;
  5331. /**
  5332. * Defines the center point of the arc.
  5333. */
  5334. centerPoint: Vector2;
  5335. /**
  5336. * Defines the radius of the arc.
  5337. */
  5338. radius: number;
  5339. /**
  5340. * Defines the angle of the arc (from mid point to end point).
  5341. */
  5342. angle: Angle;
  5343. /**
  5344. * Defines the start angle of the arc (from start point to middle point).
  5345. */
  5346. startAngle: Angle;
  5347. /**
  5348. * Defines the orientation of the arc (clock wise/counter clock wise).
  5349. */
  5350. orientation: Orientation;
  5351. /**
  5352. * Creates an Arc object from the three given points : start, middle and end.
  5353. * @param startPoint Defines the start point of the arc
  5354. * @param midPoint Defines the midlle point of the arc
  5355. * @param endPoint Defines the end point of the arc
  5356. */
  5357. constructor(
  5358. /** Defines the start point of the arc */
  5359. startPoint: Vector2,
  5360. /** Defines the mid point of the arc */
  5361. midPoint: Vector2,
  5362. /** Defines the end point of the arc */
  5363. endPoint: Vector2);
  5364. }
  5365. /**
  5366. * Represents a 2D path made up of multiple 2D points
  5367. */
  5368. export class Path2 {
  5369. private _points;
  5370. private _length;
  5371. /**
  5372. * If the path start and end point are the same
  5373. */
  5374. closed: boolean;
  5375. /**
  5376. * Creates a Path2 object from the starting 2D coordinates x and y.
  5377. * @param x the starting points x value
  5378. * @param y the starting points y value
  5379. */
  5380. constructor(x: number, y: number);
  5381. /**
  5382. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5383. * @param x the added points x value
  5384. * @param y the added points y value
  5385. * @returns the updated Path2.
  5386. */
  5387. addLineTo(x: number, y: number): Path2;
  5388. /**
  5389. * 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.
  5390. * @param midX middle point x value
  5391. * @param midY middle point y value
  5392. * @param endX end point x value
  5393. * @param endY end point y value
  5394. * @param numberOfSegments (default: 36)
  5395. * @returns the updated Path2.
  5396. */
  5397. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5398. /**
  5399. * Closes the Path2.
  5400. * @returns the Path2.
  5401. */
  5402. close(): Path2;
  5403. /**
  5404. * Gets the sum of the distance between each sequential point in the path
  5405. * @returns the Path2 total length (float).
  5406. */
  5407. length(): number;
  5408. /**
  5409. * Gets the points which construct the path
  5410. * @returns the Path2 internal array of points.
  5411. */
  5412. getPoints(): Vector2[];
  5413. /**
  5414. * Retreives the point at the distance aways from the starting point
  5415. * @param normalizedLengthPosition the length along the path to retreive the point from
  5416. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5417. */
  5418. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5419. /**
  5420. * Creates a new path starting from an x and y position
  5421. * @param x starting x value
  5422. * @param y starting y value
  5423. * @returns a new Path2 starting at the coordinates (x, y).
  5424. */
  5425. static StartingAt(x: number, y: number): Path2;
  5426. }
  5427. /**
  5428. * Represents a 3D path made up of multiple 3D points
  5429. */
  5430. export class Path3D {
  5431. /**
  5432. * an array of Vector3, the curve axis of the Path3D
  5433. */
  5434. path: Vector3[];
  5435. private _curve;
  5436. private _distances;
  5437. private _tangents;
  5438. private _normals;
  5439. private _binormals;
  5440. private _raw;
  5441. /**
  5442. * new Path3D(path, normal, raw)
  5443. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5444. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5445. * @param path an array of Vector3, the curve axis of the Path3D
  5446. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5447. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5448. */
  5449. constructor(
  5450. /**
  5451. * an array of Vector3, the curve axis of the Path3D
  5452. */
  5453. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5454. /**
  5455. * Returns the Path3D array of successive Vector3 designing its curve.
  5456. * @returns the Path3D array of successive Vector3 designing its curve.
  5457. */
  5458. getCurve(): Vector3[];
  5459. /**
  5460. * Returns an array populated with tangent vectors on each Path3D curve point.
  5461. * @returns an array populated with tangent vectors on each Path3D curve point.
  5462. */
  5463. getTangents(): Vector3[];
  5464. /**
  5465. * Returns an array populated with normal vectors on each Path3D curve point.
  5466. * @returns an array populated with normal vectors on each Path3D curve point.
  5467. */
  5468. getNormals(): Vector3[];
  5469. /**
  5470. * Returns an array populated with binormal vectors on each Path3D curve point.
  5471. * @returns an array populated with binormal vectors on each Path3D curve point.
  5472. */
  5473. getBinormals(): Vector3[];
  5474. /**
  5475. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5476. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5477. */
  5478. getDistances(): number[];
  5479. /**
  5480. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5481. * @param path path which all values are copied into the curves points
  5482. * @param firstNormal which should be projected onto the curve
  5483. * @returns the same object updated.
  5484. */
  5485. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5486. private _compute;
  5487. private _getFirstNonNullVector;
  5488. private _getLastNonNullVector;
  5489. private _normalVector;
  5490. }
  5491. /**
  5492. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5493. * A Curve3 is designed from a series of successive Vector3.
  5494. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5495. */
  5496. export class Curve3 {
  5497. private _points;
  5498. private _length;
  5499. /**
  5500. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5501. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5502. * @param v1 (Vector3) the control point
  5503. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5504. * @param nbPoints (integer) the wanted number of points in the curve
  5505. * @returns the created Curve3
  5506. */
  5507. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5508. /**
  5509. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5510. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5511. * @param v1 (Vector3) the first control point
  5512. * @param v2 (Vector3) the second control point
  5513. * @param v3 (Vector3) the end point of the Cubic Bezier
  5514. * @param nbPoints (integer) the wanted number of points in the curve
  5515. * @returns the created Curve3
  5516. */
  5517. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5518. /**
  5519. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5520. * @param p1 (Vector3) the origin point of the Hermite Spline
  5521. * @param t1 (Vector3) the tangent vector at the origin point
  5522. * @param p2 (Vector3) the end point of the Hermite Spline
  5523. * @param t2 (Vector3) the tangent vector at the end point
  5524. * @param nbPoints (integer) the wanted number of points in the curve
  5525. * @returns the created Curve3
  5526. */
  5527. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5528. /**
  5529. * Returns a Curve3 object along a CatmullRom Spline curve :
  5530. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5531. * @param nbPoints (integer) the wanted number of points between each curve control points
  5532. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5533. * @returns the created Curve3
  5534. */
  5535. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5536. /**
  5537. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5538. * A Curve3 is designed from a series of successive Vector3.
  5539. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5540. * @param points points which make up the curve
  5541. */
  5542. constructor(points: Vector3[]);
  5543. /**
  5544. * @returns the Curve3 stored array of successive Vector3
  5545. */
  5546. getPoints(): Vector3[];
  5547. /**
  5548. * @returns the computed length (float) of the curve.
  5549. */
  5550. length(): number;
  5551. /**
  5552. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5553. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5554. * curveA and curveB keep unchanged.
  5555. * @param curve the curve to continue from this curve
  5556. * @returns the newly constructed curve
  5557. */
  5558. continue(curve: DeepImmutable<Curve3>): Curve3;
  5559. private _computeLength;
  5560. }
  5561. }
  5562. declare module BABYLON {
  5563. /**
  5564. * This represents the main contract an easing function should follow.
  5565. * Easing functions are used throughout the animation system.
  5566. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5567. */
  5568. export interface IEasingFunction {
  5569. /**
  5570. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5571. * of the easing function.
  5572. * The link below provides some of the most common examples of easing functions.
  5573. * @see https://easings.net/
  5574. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5575. * @returns the corresponding value on the curve defined by the easing function
  5576. */
  5577. ease(gradient: number): number;
  5578. }
  5579. /**
  5580. * Base class used for every default easing function.
  5581. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5582. */
  5583. export class EasingFunction implements IEasingFunction {
  5584. /**
  5585. * Interpolation follows the mathematical formula associated with the easing function.
  5586. */
  5587. static readonly EASINGMODE_EASEIN: number;
  5588. /**
  5589. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5590. */
  5591. static readonly EASINGMODE_EASEOUT: number;
  5592. /**
  5593. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5594. */
  5595. static readonly EASINGMODE_EASEINOUT: number;
  5596. private _easingMode;
  5597. /**
  5598. * Sets the easing mode of the current function.
  5599. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5600. */
  5601. setEasingMode(easingMode: number): void;
  5602. /**
  5603. * Gets the current easing mode.
  5604. * @returns the easing mode
  5605. */
  5606. getEasingMode(): number;
  5607. /**
  5608. * @hidden
  5609. */
  5610. easeInCore(gradient: number): number;
  5611. /**
  5612. * Given an input gradient between 0 and 1, this returns the corresponding value
  5613. * of the easing function.
  5614. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5615. * @returns the corresponding value on the curve defined by the easing function
  5616. */
  5617. ease(gradient: number): number;
  5618. }
  5619. /**
  5620. * Easing function with a circle shape (see link below).
  5621. * @see https://easings.net/#easeInCirc
  5622. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5623. */
  5624. export class CircleEase extends EasingFunction implements IEasingFunction {
  5625. /** @hidden */
  5626. easeInCore(gradient: number): number;
  5627. }
  5628. /**
  5629. * Easing function with a ease back shape (see link below).
  5630. * @see https://easings.net/#easeInBack
  5631. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5632. */
  5633. export class BackEase extends EasingFunction implements IEasingFunction {
  5634. /** Defines the amplitude of the function */
  5635. amplitude: number;
  5636. /**
  5637. * Instantiates a back ease easing
  5638. * @see https://easings.net/#easeInBack
  5639. * @param amplitude Defines the amplitude of the function
  5640. */
  5641. constructor(
  5642. /** Defines the amplitude of the function */
  5643. amplitude?: number);
  5644. /** @hidden */
  5645. easeInCore(gradient: number): number;
  5646. }
  5647. /**
  5648. * Easing function with a bouncing shape (see link below).
  5649. * @see https://easings.net/#easeInBounce
  5650. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5651. */
  5652. export class BounceEase extends EasingFunction implements IEasingFunction {
  5653. /** Defines the number of bounces */
  5654. bounces: number;
  5655. /** Defines the amplitude of the bounce */
  5656. bounciness: number;
  5657. /**
  5658. * Instantiates a bounce easing
  5659. * @see https://easings.net/#easeInBounce
  5660. * @param bounces Defines the number of bounces
  5661. * @param bounciness Defines the amplitude of the bounce
  5662. */
  5663. constructor(
  5664. /** Defines the number of bounces */
  5665. bounces?: number,
  5666. /** Defines the amplitude of the bounce */
  5667. bounciness?: number);
  5668. /** @hidden */
  5669. easeInCore(gradient: number): number;
  5670. }
  5671. /**
  5672. * Easing function with a power of 3 shape (see link below).
  5673. * @see https://easings.net/#easeInCubic
  5674. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5675. */
  5676. export class CubicEase extends EasingFunction implements IEasingFunction {
  5677. /** @hidden */
  5678. easeInCore(gradient: number): number;
  5679. }
  5680. /**
  5681. * Easing function with an elastic shape (see link below).
  5682. * @see https://easings.net/#easeInElastic
  5683. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5684. */
  5685. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5686. /** Defines the number of oscillations*/
  5687. oscillations: number;
  5688. /** Defines the amplitude of the oscillations*/
  5689. springiness: number;
  5690. /**
  5691. * Instantiates an elastic easing function
  5692. * @see https://easings.net/#easeInElastic
  5693. * @param oscillations Defines the number of oscillations
  5694. * @param springiness Defines the amplitude of the oscillations
  5695. */
  5696. constructor(
  5697. /** Defines the number of oscillations*/
  5698. oscillations?: number,
  5699. /** Defines the amplitude of the oscillations*/
  5700. springiness?: number);
  5701. /** @hidden */
  5702. easeInCore(gradient: number): number;
  5703. }
  5704. /**
  5705. * Easing function with an exponential shape (see link below).
  5706. * @see https://easings.net/#easeInExpo
  5707. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5708. */
  5709. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5710. /** Defines the exponent of the function */
  5711. exponent: number;
  5712. /**
  5713. * Instantiates an exponential easing function
  5714. * @see https://easings.net/#easeInExpo
  5715. * @param exponent Defines the exponent of the function
  5716. */
  5717. constructor(
  5718. /** Defines the exponent of the function */
  5719. exponent?: number);
  5720. /** @hidden */
  5721. easeInCore(gradient: number): number;
  5722. }
  5723. /**
  5724. * Easing function with a power shape (see link below).
  5725. * @see https://easings.net/#easeInQuad
  5726. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5727. */
  5728. export class PowerEase extends EasingFunction implements IEasingFunction {
  5729. /** Defines the power of the function */
  5730. power: number;
  5731. /**
  5732. * Instantiates an power base easing function
  5733. * @see https://easings.net/#easeInQuad
  5734. * @param power Defines the power of the function
  5735. */
  5736. constructor(
  5737. /** Defines the power of the function */
  5738. power?: number);
  5739. /** @hidden */
  5740. easeInCore(gradient: number): number;
  5741. }
  5742. /**
  5743. * Easing function with a power of 2 shape (see link below).
  5744. * @see https://easings.net/#easeInQuad
  5745. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5746. */
  5747. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5748. /** @hidden */
  5749. easeInCore(gradient: number): number;
  5750. }
  5751. /**
  5752. * Easing function with a power of 4 shape (see link below).
  5753. * @see https://easings.net/#easeInQuart
  5754. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5755. */
  5756. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5757. /** @hidden */
  5758. easeInCore(gradient: number): number;
  5759. }
  5760. /**
  5761. * Easing function with a power of 5 shape (see link below).
  5762. * @see https://easings.net/#easeInQuint
  5763. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5764. */
  5765. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5766. /** @hidden */
  5767. easeInCore(gradient: number): number;
  5768. }
  5769. /**
  5770. * Easing function with a sin shape (see link below).
  5771. * @see https://easings.net/#easeInSine
  5772. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5773. */
  5774. export class SineEase extends EasingFunction implements IEasingFunction {
  5775. /** @hidden */
  5776. easeInCore(gradient: number): number;
  5777. }
  5778. /**
  5779. * Easing function with a bezier shape (see link below).
  5780. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5781. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5782. */
  5783. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5784. /** Defines the x component of the start tangent in the bezier curve */
  5785. x1: number;
  5786. /** Defines the y component of the start tangent in the bezier curve */
  5787. y1: number;
  5788. /** Defines the x component of the end tangent in the bezier curve */
  5789. x2: number;
  5790. /** Defines the y component of the end tangent in the bezier curve */
  5791. y2: number;
  5792. /**
  5793. * Instantiates a bezier function
  5794. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5795. * @param x1 Defines the x component of the start tangent in the bezier curve
  5796. * @param y1 Defines the y component of the start tangent in the bezier curve
  5797. * @param x2 Defines the x component of the end tangent in the bezier curve
  5798. * @param y2 Defines the y component of the end tangent in the bezier curve
  5799. */
  5800. constructor(
  5801. /** Defines the x component of the start tangent in the bezier curve */
  5802. x1?: number,
  5803. /** Defines the y component of the start tangent in the bezier curve */
  5804. y1?: number,
  5805. /** Defines the x component of the end tangent in the bezier curve */
  5806. x2?: number,
  5807. /** Defines the y component of the end tangent in the bezier curve */
  5808. y2?: number);
  5809. /** @hidden */
  5810. easeInCore(gradient: number): number;
  5811. }
  5812. }
  5813. declare module BABYLON {
  5814. /**
  5815. * Defines an interface which represents an animation key frame
  5816. */
  5817. export interface IAnimationKey {
  5818. /**
  5819. * Frame of the key frame
  5820. */
  5821. frame: number;
  5822. /**
  5823. * Value at the specifies key frame
  5824. */
  5825. value: any;
  5826. /**
  5827. * The input tangent for the cubic hermite spline
  5828. */
  5829. inTangent?: any;
  5830. /**
  5831. * The output tangent for the cubic hermite spline
  5832. */
  5833. outTangent?: any;
  5834. /**
  5835. * The animation interpolation type
  5836. */
  5837. interpolation?: AnimationKeyInterpolation;
  5838. }
  5839. /**
  5840. * Enum for the animation key frame interpolation type
  5841. */
  5842. export enum AnimationKeyInterpolation {
  5843. /**
  5844. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5845. */
  5846. STEP = 1
  5847. }
  5848. }
  5849. declare module BABYLON {
  5850. /**
  5851. * Represents the range of an animation
  5852. */
  5853. export class AnimationRange {
  5854. /**The name of the animation range**/
  5855. name: string;
  5856. /**The starting frame of the animation */
  5857. from: number;
  5858. /**The ending frame of the animation*/
  5859. to: number;
  5860. /**
  5861. * Initializes the range of an animation
  5862. * @param name The name of the animation range
  5863. * @param from The starting frame of the animation
  5864. * @param to The ending frame of the animation
  5865. */
  5866. constructor(
  5867. /**The name of the animation range**/
  5868. name: string,
  5869. /**The starting frame of the animation */
  5870. from: number,
  5871. /**The ending frame of the animation*/
  5872. to: number);
  5873. /**
  5874. * Makes a copy of the animation range
  5875. * @returns A copy of the animation range
  5876. */
  5877. clone(): AnimationRange;
  5878. }
  5879. }
  5880. declare module BABYLON {
  5881. /**
  5882. * Composed of a frame, and an action function
  5883. */
  5884. export class AnimationEvent {
  5885. /** The frame for which the event is triggered **/
  5886. frame: number;
  5887. /** The event to perform when triggered **/
  5888. action: (currentFrame: number) => void;
  5889. /** Specifies if the event should be triggered only once**/
  5890. onlyOnce?: boolean | undefined;
  5891. /**
  5892. * Specifies if the animation event is done
  5893. */
  5894. isDone: boolean;
  5895. /**
  5896. * Initializes the animation event
  5897. * @param frame The frame for which the event is triggered
  5898. * @param action The event to perform when triggered
  5899. * @param onlyOnce Specifies if the event should be triggered only once
  5900. */
  5901. constructor(
  5902. /** The frame for which the event is triggered **/
  5903. frame: number,
  5904. /** The event to perform when triggered **/
  5905. action: (currentFrame: number) => void,
  5906. /** Specifies if the event should be triggered only once**/
  5907. onlyOnce?: boolean | undefined);
  5908. /** @hidden */ private _clone(): AnimationEvent;
  5909. }
  5910. }
  5911. declare module BABYLON {
  5912. /**
  5913. * Interface used to define a behavior
  5914. */
  5915. export interface Behavior<T> {
  5916. /** gets or sets behavior's name */
  5917. name: string;
  5918. /**
  5919. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5920. */
  5921. init(): void;
  5922. /**
  5923. * Called when the behavior is attached to a target
  5924. * @param target defines the target where the behavior is attached to
  5925. */
  5926. attach(target: T): void;
  5927. /**
  5928. * Called when the behavior is detached from its target
  5929. */
  5930. detach(): void;
  5931. }
  5932. /**
  5933. * Interface implemented by classes supporting behaviors
  5934. */
  5935. export interface IBehaviorAware<T> {
  5936. /**
  5937. * Attach a behavior
  5938. * @param behavior defines the behavior to attach
  5939. * @returns the current host
  5940. */
  5941. addBehavior(behavior: Behavior<T>): T;
  5942. /**
  5943. * Remove a behavior from the current object
  5944. * @param behavior defines the behavior to detach
  5945. * @returns the current host
  5946. */
  5947. removeBehavior(behavior: Behavior<T>): T;
  5948. /**
  5949. * Gets a behavior using its name to search
  5950. * @param name defines the name to search
  5951. * @returns the behavior or null if not found
  5952. */
  5953. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5954. }
  5955. }
  5956. declare module BABYLON {
  5957. /**
  5958. * Defines an array and its length.
  5959. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5960. */
  5961. export interface ISmartArrayLike<T> {
  5962. /**
  5963. * The data of the array.
  5964. */
  5965. data: Array<T>;
  5966. /**
  5967. * The active length of the array.
  5968. */
  5969. length: number;
  5970. }
  5971. /**
  5972. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5973. */
  5974. export class SmartArray<T> implements ISmartArrayLike<T> {
  5975. /**
  5976. * The full set of data from the array.
  5977. */
  5978. data: Array<T>;
  5979. /**
  5980. * The active length of the array.
  5981. */
  5982. length: number;
  5983. protected _id: number;
  5984. /**
  5985. * Instantiates a Smart Array.
  5986. * @param capacity defines the default capacity of the array.
  5987. */
  5988. constructor(capacity: number);
  5989. /**
  5990. * Pushes a value at the end of the active data.
  5991. * @param value defines the object to push in the array.
  5992. */
  5993. push(value: T): void;
  5994. /**
  5995. * Iterates over the active data and apply the lambda to them.
  5996. * @param func defines the action to apply on each value.
  5997. */
  5998. forEach(func: (content: T) => void): void;
  5999. /**
  6000. * Sorts the full sets of data.
  6001. * @param compareFn defines the comparison function to apply.
  6002. */
  6003. sort(compareFn: (a: T, b: T) => number): void;
  6004. /**
  6005. * Resets the active data to an empty array.
  6006. */
  6007. reset(): void;
  6008. /**
  6009. * Releases all the data from the array as well as the array.
  6010. */
  6011. dispose(): void;
  6012. /**
  6013. * Concats the active data with a given array.
  6014. * @param array defines the data to concatenate with.
  6015. */
  6016. concat(array: any): void;
  6017. /**
  6018. * Returns the position of a value in the active data.
  6019. * @param value defines the value to find the index for
  6020. * @returns the index if found in the active data otherwise -1
  6021. */
  6022. indexOf(value: T): number;
  6023. /**
  6024. * Returns whether an element is part of the active data.
  6025. * @param value defines the value to look for
  6026. * @returns true if found in the active data otherwise false
  6027. */
  6028. contains(value: T): boolean;
  6029. private static _GlobalId;
  6030. }
  6031. /**
  6032. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6033. * The data in this array can only be present once
  6034. */
  6035. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6036. private _duplicateId;
  6037. /**
  6038. * Pushes a value at the end of the active data.
  6039. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6040. * @param value defines the object to push in the array.
  6041. */
  6042. push(value: T): void;
  6043. /**
  6044. * Pushes a value at the end of the active data.
  6045. * If the data is already present, it won t be added again
  6046. * @param value defines the object to push in the array.
  6047. * @returns true if added false if it was already present
  6048. */
  6049. pushNoDuplicate(value: T): boolean;
  6050. /**
  6051. * Resets the active data to an empty array.
  6052. */
  6053. reset(): void;
  6054. /**
  6055. * Concats the active data with a given array.
  6056. * This ensures no dupplicate will be present in the result.
  6057. * @param array defines the data to concatenate with.
  6058. */
  6059. concatWithNoDuplicate(array: any): void;
  6060. }
  6061. }
  6062. declare module BABYLON {
  6063. /**
  6064. * @ignore
  6065. * This is a list of all the different input types that are available in the application.
  6066. * Fo instance: ArcRotateCameraGamepadInput...
  6067. */
  6068. export var CameraInputTypes: {};
  6069. /**
  6070. * This is the contract to implement in order to create a new input class.
  6071. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6072. */
  6073. export interface ICameraInput<TCamera extends Camera> {
  6074. /**
  6075. * Defines the camera the input is attached to.
  6076. */
  6077. camera: Nullable<TCamera>;
  6078. /**
  6079. * Gets the class name of the current intput.
  6080. * @returns the class name
  6081. */
  6082. getClassName(): string;
  6083. /**
  6084. * Get the friendly name associated with the input class.
  6085. * @returns the input friendly name
  6086. */
  6087. getSimpleName(): string;
  6088. /**
  6089. * Attach the input controls to a specific dom element to get the input from.
  6090. * @param element Defines the element the controls should be listened from
  6091. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6092. */
  6093. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6094. /**
  6095. * Detach the current controls from the specified dom element.
  6096. * @param element Defines the element to stop listening the inputs from
  6097. */
  6098. detachControl(element: Nullable<HTMLElement>): void;
  6099. /**
  6100. * Update the current camera state depending on the inputs that have been used this frame.
  6101. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6102. */
  6103. checkInputs?: () => void;
  6104. }
  6105. /**
  6106. * Represents a map of input types to input instance or input index to input instance.
  6107. */
  6108. export interface CameraInputsMap<TCamera extends Camera> {
  6109. /**
  6110. * Accessor to the input by input type.
  6111. */
  6112. [name: string]: ICameraInput<TCamera>;
  6113. /**
  6114. * Accessor to the input by input index.
  6115. */
  6116. [idx: number]: ICameraInput<TCamera>;
  6117. }
  6118. /**
  6119. * This represents the input manager used within a camera.
  6120. * It helps dealing with all the different kind of input attached to a camera.
  6121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6122. */
  6123. export class CameraInputsManager<TCamera extends Camera> {
  6124. /**
  6125. * Defines the list of inputs attahed to the camera.
  6126. */
  6127. attached: CameraInputsMap<TCamera>;
  6128. /**
  6129. * Defines the dom element the camera is collecting inputs from.
  6130. * This is null if the controls have not been attached.
  6131. */
  6132. attachedElement: Nullable<HTMLElement>;
  6133. /**
  6134. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6135. */
  6136. noPreventDefault: boolean;
  6137. /**
  6138. * Defined the camera the input manager belongs to.
  6139. */
  6140. camera: TCamera;
  6141. /**
  6142. * Update the current camera state depending on the inputs that have been used this frame.
  6143. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6144. */
  6145. checkInputs: () => void;
  6146. /**
  6147. * Instantiate a new Camera Input Manager.
  6148. * @param camera Defines the camera the input manager blongs to
  6149. */
  6150. constructor(camera: TCamera);
  6151. /**
  6152. * Add an input method to a camera
  6153. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6154. * @param input camera input method
  6155. */
  6156. add(input: ICameraInput<TCamera>): void;
  6157. /**
  6158. * Remove a specific input method from a camera
  6159. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6160. * @param inputToRemove camera input method
  6161. */
  6162. remove(inputToRemove: ICameraInput<TCamera>): void;
  6163. /**
  6164. * Remove a specific input type from a camera
  6165. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6166. * @param inputType the type of the input to remove
  6167. */
  6168. removeByType(inputType: string): void;
  6169. private _addCheckInputs;
  6170. /**
  6171. * Attach the input controls to the currently attached dom element to listen the events from.
  6172. * @param input Defines the input to attach
  6173. */
  6174. attachInput(input: ICameraInput<TCamera>): void;
  6175. /**
  6176. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6177. * @param element Defines the dom element to collect the events from
  6178. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6179. */
  6180. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6181. /**
  6182. * Detach the current manager inputs controls from a specific dom element.
  6183. * @param element Defines the dom element to collect the events from
  6184. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6185. */
  6186. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6187. /**
  6188. * Rebuild the dynamic inputCheck function from the current list of
  6189. * defined inputs in the manager.
  6190. */
  6191. rebuildInputCheck(): void;
  6192. /**
  6193. * Remove all attached input methods from a camera
  6194. */
  6195. clear(): void;
  6196. /**
  6197. * Serialize the current input manager attached to a camera.
  6198. * This ensures than once parsed,
  6199. * the input associated to the camera will be identical to the current ones
  6200. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6201. */
  6202. serialize(serializedCamera: any): void;
  6203. /**
  6204. * Parses an input manager serialized JSON to restore the previous list of inputs
  6205. * and states associated to a camera.
  6206. * @param parsedCamera Defines the JSON to parse
  6207. */
  6208. parse(parsedCamera: any): void;
  6209. }
  6210. }
  6211. declare module BABYLON {
  6212. /**
  6213. * Class used to store data that will be store in GPU memory
  6214. */
  6215. export class Buffer {
  6216. private _engine;
  6217. private _buffer;
  6218. /** @hidden */ private _data: Nullable<DataArray>;
  6219. private _updatable;
  6220. private _instanced;
  6221. /**
  6222. * Gets the byte stride.
  6223. */
  6224. readonly byteStride: number;
  6225. /**
  6226. * Constructor
  6227. * @param engine the engine
  6228. * @param data the data to use for this buffer
  6229. * @param updatable whether the data is updatable
  6230. * @param stride the stride (optional)
  6231. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6232. * @param instanced whether the buffer is instanced (optional)
  6233. * @param useBytes set to true if the stride in in bytes (optional)
  6234. */
  6235. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6236. /**
  6237. * Create a new VertexBuffer based on the current buffer
  6238. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6239. * @param offset defines offset in the buffer (0 by default)
  6240. * @param size defines the size in floats of attributes (position is 3 for instance)
  6241. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6242. * @param instanced defines if the vertex buffer contains indexed data
  6243. * @param useBytes defines if the offset and stride are in bytes
  6244. * @returns the new vertex buffer
  6245. */
  6246. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6247. /**
  6248. * Gets a boolean indicating if the Buffer is updatable?
  6249. * @returns true if the buffer is updatable
  6250. */
  6251. isUpdatable(): boolean;
  6252. /**
  6253. * Gets current buffer's data
  6254. * @returns a DataArray or null
  6255. */
  6256. getData(): Nullable<DataArray>;
  6257. /**
  6258. * Gets underlying native buffer
  6259. * @returns underlying native buffer
  6260. */
  6261. getBuffer(): Nullable<DataBuffer>;
  6262. /**
  6263. * Gets the stride in float32 units (i.e. byte stride / 4).
  6264. * May not be an integer if the byte stride is not divisible by 4.
  6265. * DEPRECATED. Use byteStride instead.
  6266. * @returns the stride in float32 units
  6267. */
  6268. getStrideSize(): number;
  6269. /**
  6270. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6271. * @param data defines the data to store
  6272. */
  6273. create(data?: Nullable<DataArray>): void;
  6274. /** @hidden */ private _rebuild(): void;
  6275. /**
  6276. * Update current buffer data
  6277. * @param data defines the data to store
  6278. */
  6279. update(data: DataArray): void;
  6280. /**
  6281. * Updates the data directly.
  6282. * @param data the new data
  6283. * @param offset the new offset
  6284. * @param vertexCount the vertex count (optional)
  6285. * @param useBytes set to true if the offset is in bytes
  6286. */
  6287. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6288. /**
  6289. * Release all resources
  6290. */
  6291. dispose(): void;
  6292. }
  6293. /**
  6294. * Specialized buffer used to store vertex data
  6295. */
  6296. export class VertexBuffer {
  6297. /** @hidden */ private _buffer: Buffer;
  6298. private _kind;
  6299. private _size;
  6300. private _ownsBuffer;
  6301. private _instanced;
  6302. private _instanceDivisor;
  6303. /**
  6304. * The byte type.
  6305. */
  6306. static readonly BYTE: number;
  6307. /**
  6308. * The unsigned byte type.
  6309. */
  6310. static readonly UNSIGNED_BYTE: number;
  6311. /**
  6312. * The short type.
  6313. */
  6314. static readonly SHORT: number;
  6315. /**
  6316. * The unsigned short type.
  6317. */
  6318. static readonly UNSIGNED_SHORT: number;
  6319. /**
  6320. * The integer type.
  6321. */
  6322. static readonly INT: number;
  6323. /**
  6324. * The unsigned integer type.
  6325. */
  6326. static readonly UNSIGNED_INT: number;
  6327. /**
  6328. * The float type.
  6329. */
  6330. static readonly FLOAT: number;
  6331. /**
  6332. * Gets or sets the instance divisor when in instanced mode
  6333. */
  6334. instanceDivisor: number;
  6335. /**
  6336. * Gets the byte stride.
  6337. */
  6338. readonly byteStride: number;
  6339. /**
  6340. * Gets the byte offset.
  6341. */
  6342. readonly byteOffset: number;
  6343. /**
  6344. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6345. */
  6346. readonly normalized: boolean;
  6347. /**
  6348. * Gets the data type of each component in the array.
  6349. */
  6350. readonly type: number;
  6351. /**
  6352. * Constructor
  6353. * @param engine the engine
  6354. * @param data the data to use for this vertex buffer
  6355. * @param kind the vertex buffer kind
  6356. * @param updatable whether the data is updatable
  6357. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6358. * @param stride the stride (optional)
  6359. * @param instanced whether the buffer is instanced (optional)
  6360. * @param offset the offset of the data (optional)
  6361. * @param size the number of components (optional)
  6362. * @param type the type of the component (optional)
  6363. * @param normalized whether the data contains normalized data (optional)
  6364. * @param useBytes set to true if stride and offset are in bytes (optional)
  6365. */
  6366. 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);
  6367. /** @hidden */ private _rebuild(): void;
  6368. /**
  6369. * Returns the kind of the VertexBuffer (string)
  6370. * @returns a string
  6371. */
  6372. getKind(): string;
  6373. /**
  6374. * Gets a boolean indicating if the VertexBuffer is updatable?
  6375. * @returns true if the buffer is updatable
  6376. */
  6377. isUpdatable(): boolean;
  6378. /**
  6379. * Gets current buffer's data
  6380. * @returns a DataArray or null
  6381. */
  6382. getData(): Nullable<DataArray>;
  6383. /**
  6384. * Gets underlying native buffer
  6385. * @returns underlying native buffer
  6386. */
  6387. getBuffer(): Nullable<DataBuffer>;
  6388. /**
  6389. * Gets the stride in float32 units (i.e. byte stride / 4).
  6390. * May not be an integer if the byte stride is not divisible by 4.
  6391. * DEPRECATED. Use byteStride instead.
  6392. * @returns the stride in float32 units
  6393. */
  6394. getStrideSize(): number;
  6395. /**
  6396. * Returns the offset as a multiple of the type byte length.
  6397. * DEPRECATED. Use byteOffset instead.
  6398. * @returns the offset in bytes
  6399. */
  6400. getOffset(): number;
  6401. /**
  6402. * Returns the number of components per vertex attribute (integer)
  6403. * @returns the size in float
  6404. */
  6405. getSize(): number;
  6406. /**
  6407. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6408. * @returns true if this buffer is instanced
  6409. */
  6410. getIsInstanced(): boolean;
  6411. /**
  6412. * Returns the instancing divisor, zero for non-instanced (integer).
  6413. * @returns a number
  6414. */
  6415. getInstanceDivisor(): number;
  6416. /**
  6417. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6418. * @param data defines the data to store
  6419. */
  6420. create(data?: DataArray): void;
  6421. /**
  6422. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6423. * This function will create a new buffer if the current one is not updatable
  6424. * @param data defines the data to store
  6425. */
  6426. update(data: DataArray): void;
  6427. /**
  6428. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6429. * Returns the directly updated WebGLBuffer.
  6430. * @param data the new data
  6431. * @param offset the new offset
  6432. * @param useBytes set to true if the offset is in bytes
  6433. */
  6434. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6435. /**
  6436. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6437. */
  6438. dispose(): void;
  6439. /**
  6440. * Enumerates each value of this vertex buffer as numbers.
  6441. * @param count the number of values to enumerate
  6442. * @param callback the callback function called for each value
  6443. */
  6444. forEach(count: number, callback: (value: number, index: number) => void): void;
  6445. /**
  6446. * Positions
  6447. */
  6448. static readonly PositionKind: string;
  6449. /**
  6450. * Normals
  6451. */
  6452. static readonly NormalKind: string;
  6453. /**
  6454. * Tangents
  6455. */
  6456. static readonly TangentKind: string;
  6457. /**
  6458. * Texture coordinates
  6459. */
  6460. static readonly UVKind: string;
  6461. /**
  6462. * Texture coordinates 2
  6463. */
  6464. static readonly UV2Kind: string;
  6465. /**
  6466. * Texture coordinates 3
  6467. */
  6468. static readonly UV3Kind: string;
  6469. /**
  6470. * Texture coordinates 4
  6471. */
  6472. static readonly UV4Kind: string;
  6473. /**
  6474. * Texture coordinates 5
  6475. */
  6476. static readonly UV5Kind: string;
  6477. /**
  6478. * Texture coordinates 6
  6479. */
  6480. static readonly UV6Kind: string;
  6481. /**
  6482. * Colors
  6483. */
  6484. static readonly ColorKind: string;
  6485. /**
  6486. * Matrix indices (for bones)
  6487. */
  6488. static readonly MatricesIndicesKind: string;
  6489. /**
  6490. * Matrix weights (for bones)
  6491. */
  6492. static readonly MatricesWeightsKind: string;
  6493. /**
  6494. * Additional matrix indices (for bones)
  6495. */
  6496. static readonly MatricesIndicesExtraKind: string;
  6497. /**
  6498. * Additional matrix weights (for bones)
  6499. */
  6500. static readonly MatricesWeightsExtraKind: string;
  6501. /**
  6502. * Deduces the stride given a kind.
  6503. * @param kind The kind string to deduce
  6504. * @returns The deduced stride
  6505. */
  6506. static DeduceStride(kind: string): number;
  6507. /**
  6508. * Gets the byte length of the given type.
  6509. * @param type the type
  6510. * @returns the number of bytes
  6511. */
  6512. static GetTypeByteLength(type: number): number;
  6513. /**
  6514. * Enumerates each value of the given parameters as numbers.
  6515. * @param data the data to enumerate
  6516. * @param byteOffset the byte offset of the data
  6517. * @param byteStride the byte stride of the data
  6518. * @param componentCount the number of components per element
  6519. * @param componentType the type of the component
  6520. * @param count the number of values to enumerate
  6521. * @param normalized whether the data is normalized
  6522. * @param callback the callback function called for each value
  6523. */
  6524. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6525. private static _GetFloatValue;
  6526. }
  6527. }
  6528. declare module BABYLON {
  6529. /**
  6530. * @hidden
  6531. */
  6532. export class IntersectionInfo {
  6533. bu: Nullable<number>;
  6534. bv: Nullable<number>;
  6535. distance: number;
  6536. faceId: number;
  6537. subMeshId: number;
  6538. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6539. }
  6540. }
  6541. declare module BABYLON {
  6542. /**
  6543. * Represens a plane by the equation ax + by + cz + d = 0
  6544. */
  6545. export class Plane {
  6546. private static _TmpMatrix;
  6547. /**
  6548. * Normal of the plane (a,b,c)
  6549. */
  6550. normal: Vector3;
  6551. /**
  6552. * d component of the plane
  6553. */
  6554. d: number;
  6555. /**
  6556. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6557. * @param a a component of the plane
  6558. * @param b b component of the plane
  6559. * @param c c component of the plane
  6560. * @param d d component of the plane
  6561. */
  6562. constructor(a: number, b: number, c: number, d: number);
  6563. /**
  6564. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6565. */
  6566. asArray(): number[];
  6567. /**
  6568. * @returns a new plane copied from the current Plane.
  6569. */
  6570. clone(): Plane;
  6571. /**
  6572. * @returns the string "Plane".
  6573. */
  6574. getClassName(): string;
  6575. /**
  6576. * @returns the Plane hash code.
  6577. */
  6578. getHashCode(): number;
  6579. /**
  6580. * Normalize the current Plane in place.
  6581. * @returns the updated Plane.
  6582. */
  6583. normalize(): Plane;
  6584. /**
  6585. * Applies a transformation the plane and returns the result
  6586. * @param transformation the transformation matrix to be applied to the plane
  6587. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6588. */
  6589. transform(transformation: DeepImmutable<Matrix>): Plane;
  6590. /**
  6591. * Calcualtte the dot product between the point and the plane normal
  6592. * @param point point to calculate the dot product with
  6593. * @returns the dot product (float) of the point coordinates and the plane normal.
  6594. */
  6595. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6596. /**
  6597. * Updates the current Plane from the plane defined by the three given points.
  6598. * @param point1 one of the points used to contruct the plane
  6599. * @param point2 one of the points used to contruct the plane
  6600. * @param point3 one of the points used to contruct the plane
  6601. * @returns the updated Plane.
  6602. */
  6603. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6604. /**
  6605. * Checks if the plane is facing a given direction
  6606. * @param direction the direction to check if the plane is facing
  6607. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6608. * @returns True is the vector "direction" is the same side than the plane normal.
  6609. */
  6610. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6611. /**
  6612. * Calculates the distance to a point
  6613. * @param point point to calculate distance to
  6614. * @returns the signed distance (float) from the given point to the Plane.
  6615. */
  6616. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6617. /**
  6618. * Creates a plane from an array
  6619. * @param array the array to create a plane from
  6620. * @returns a new Plane from the given array.
  6621. */
  6622. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6623. /**
  6624. * Creates a plane from three points
  6625. * @param point1 point used to create the plane
  6626. * @param point2 point used to create the plane
  6627. * @param point3 point used to create the plane
  6628. * @returns a new Plane defined by the three given points.
  6629. */
  6630. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6631. /**
  6632. * Creates a plane from an origin point and a normal
  6633. * @param origin origin of the plane to be constructed
  6634. * @param normal normal of the plane to be constructed
  6635. * @returns a new Plane the normal vector to this plane at the given origin point.
  6636. * Note : the vector "normal" is updated because normalized.
  6637. */
  6638. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6639. /**
  6640. * Calculates the distance from a plane and a point
  6641. * @param origin origin of the plane to be constructed
  6642. * @param normal normal of the plane to be constructed
  6643. * @param point point to calculate distance to
  6644. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6645. */
  6646. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6647. }
  6648. }
  6649. declare module BABYLON {
  6650. /**
  6651. * Class used to store bounding sphere information
  6652. */
  6653. export class BoundingSphere {
  6654. /**
  6655. * Gets the center of the bounding sphere in local space
  6656. */
  6657. readonly center: Vector3;
  6658. /**
  6659. * Radius of the bounding sphere in local space
  6660. */
  6661. radius: number;
  6662. /**
  6663. * Gets the center of the bounding sphere in world space
  6664. */
  6665. readonly centerWorld: Vector3;
  6666. /**
  6667. * Radius of the bounding sphere in world space
  6668. */
  6669. radiusWorld: number;
  6670. /**
  6671. * Gets the minimum vector in local space
  6672. */
  6673. readonly minimum: Vector3;
  6674. /**
  6675. * Gets the maximum vector in local space
  6676. */
  6677. readonly maximum: Vector3;
  6678. private _worldMatrix;
  6679. private static readonly TmpVector3;
  6680. /**
  6681. * Creates a new bounding sphere
  6682. * @param min defines the minimum vector (in local space)
  6683. * @param max defines the maximum vector (in local space)
  6684. * @param worldMatrix defines the new world matrix
  6685. */
  6686. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6687. /**
  6688. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6689. * @param min defines the new minimum vector (in local space)
  6690. * @param max defines the new maximum vector (in local space)
  6691. * @param worldMatrix defines the new world matrix
  6692. */
  6693. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6694. /**
  6695. * Scale the current bounding sphere by applying a scale factor
  6696. * @param factor defines the scale factor to apply
  6697. * @returns the current bounding box
  6698. */
  6699. scale(factor: number): BoundingSphere;
  6700. /**
  6701. * Gets the world matrix of the bounding box
  6702. * @returns a matrix
  6703. */
  6704. getWorldMatrix(): DeepImmutable<Matrix>;
  6705. /** @hidden */ private _update(worldMatrix: DeepImmutable<Matrix>): void;
  6706. /**
  6707. * Tests if the bounding sphere is intersecting the frustum planes
  6708. * @param frustumPlanes defines the frustum planes to test
  6709. * @returns true if there is an intersection
  6710. */
  6711. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6712. /**
  6713. * Tests if the bounding sphere center is in between the frustum planes.
  6714. * Used for optimistic fast inclusion.
  6715. * @param frustumPlanes defines the frustum planes to test
  6716. * @returns true if the sphere center is in between the frustum planes
  6717. */
  6718. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6719. /**
  6720. * Tests if a point is inside the bounding sphere
  6721. * @param point defines the point to test
  6722. * @returns true if the point is inside the bounding sphere
  6723. */
  6724. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6725. /**
  6726. * Checks if two sphere intersct
  6727. * @param sphere0 sphere 0
  6728. * @param sphere1 sphere 1
  6729. * @returns true if the speres intersect
  6730. */
  6731. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6732. }
  6733. }
  6734. declare module BABYLON {
  6735. /**
  6736. * Class used to store bounding box information
  6737. */
  6738. export class BoundingBox implements ICullable {
  6739. /**
  6740. * Gets the 8 vectors representing the bounding box in local space
  6741. */
  6742. readonly vectors: Vector3[];
  6743. /**
  6744. * Gets the center of the bounding box in local space
  6745. */
  6746. readonly center: Vector3;
  6747. /**
  6748. * Gets the center of the bounding box in world space
  6749. */
  6750. readonly centerWorld: Vector3;
  6751. /**
  6752. * Gets the extend size in local space
  6753. */
  6754. readonly extendSize: Vector3;
  6755. /**
  6756. * Gets the extend size in world space
  6757. */
  6758. readonly extendSizeWorld: Vector3;
  6759. /**
  6760. * Gets the OBB (object bounding box) directions
  6761. */
  6762. readonly directions: Vector3[];
  6763. /**
  6764. * Gets the 8 vectors representing the bounding box in world space
  6765. */
  6766. readonly vectorsWorld: Vector3[];
  6767. /**
  6768. * Gets the minimum vector in world space
  6769. */
  6770. readonly minimumWorld: Vector3;
  6771. /**
  6772. * Gets the maximum vector in world space
  6773. */
  6774. readonly maximumWorld: Vector3;
  6775. /**
  6776. * Gets the minimum vector in local space
  6777. */
  6778. readonly minimum: Vector3;
  6779. /**
  6780. * Gets the maximum vector in local space
  6781. */
  6782. readonly maximum: Vector3;
  6783. private _worldMatrix;
  6784. private static readonly TmpVector3;
  6785. /**
  6786. * @hidden
  6787. */ private _tag: number;
  6788. /**
  6789. * Creates a new bounding box
  6790. * @param min defines the minimum vector (in local space)
  6791. * @param max defines the maximum vector (in local space)
  6792. * @param worldMatrix defines the new world matrix
  6793. */
  6794. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6795. /**
  6796. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6797. * @param min defines the new minimum vector (in local space)
  6798. * @param max defines the new maximum vector (in local space)
  6799. * @param worldMatrix defines the new world matrix
  6800. */
  6801. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6802. /**
  6803. * Scale the current bounding box by applying a scale factor
  6804. * @param factor defines the scale factor to apply
  6805. * @returns the current bounding box
  6806. */
  6807. scale(factor: number): BoundingBox;
  6808. /**
  6809. * Gets the world matrix of the bounding box
  6810. * @returns a matrix
  6811. */
  6812. getWorldMatrix(): DeepImmutable<Matrix>;
  6813. /** @hidden */ private _update(world: DeepImmutable<Matrix>): void;
  6814. /**
  6815. * Tests if the bounding box is intersecting the frustum planes
  6816. * @param frustumPlanes defines the frustum planes to test
  6817. * @returns true if there is an intersection
  6818. */
  6819. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6820. /**
  6821. * Tests if the bounding box is entirely inside the frustum planes
  6822. * @param frustumPlanes defines the frustum planes to test
  6823. * @returns true if there is an inclusion
  6824. */
  6825. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6826. /**
  6827. * Tests if a point is inside the bounding box
  6828. * @param point defines the point to test
  6829. * @returns true if the point is inside the bounding box
  6830. */
  6831. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6832. /**
  6833. * Tests if the bounding box intersects with a bounding sphere
  6834. * @param sphere defines the sphere to test
  6835. * @returns true if there is an intersection
  6836. */
  6837. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6838. /**
  6839. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6840. * @param min defines the min vector to use
  6841. * @param max defines the max vector to use
  6842. * @returns true if there is an intersection
  6843. */
  6844. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6845. /**
  6846. * Tests if two bounding boxes are intersections
  6847. * @param box0 defines the first box to test
  6848. * @param box1 defines the second box to test
  6849. * @returns true if there is an intersection
  6850. */
  6851. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6852. /**
  6853. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6854. * @param minPoint defines the minimum vector of the bounding box
  6855. * @param maxPoint defines the maximum vector of the bounding box
  6856. * @param sphereCenter defines the sphere center
  6857. * @param sphereRadius defines the sphere radius
  6858. * @returns true if there is an intersection
  6859. */
  6860. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6861. /**
  6862. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6863. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6864. * @param frustumPlanes defines the frustum planes to test
  6865. * @return true if there is an inclusion
  6866. */
  6867. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6868. /**
  6869. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6870. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6871. * @param frustumPlanes defines the frustum planes to test
  6872. * @return true if there is an intersection
  6873. */
  6874. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6875. }
  6876. }
  6877. declare module BABYLON {
  6878. /** @hidden */
  6879. export class Collider {
  6880. /** Define if a collision was found */
  6881. collisionFound: boolean;
  6882. /**
  6883. * Define last intersection point in local space
  6884. */
  6885. intersectionPoint: Vector3;
  6886. /**
  6887. * Define last collided mesh
  6888. */
  6889. collidedMesh: Nullable<AbstractMesh>;
  6890. private _collisionPoint;
  6891. private _planeIntersectionPoint;
  6892. private _tempVector;
  6893. private _tempVector2;
  6894. private _tempVector3;
  6895. private _tempVector4;
  6896. private _edge;
  6897. private _baseToVertex;
  6898. private _destinationPoint;
  6899. private _slidePlaneNormal;
  6900. private _displacementVector;
  6901. /** @hidden */ private _radius: Vector3;
  6902. /** @hidden */ private _retry: number;
  6903. private _velocity;
  6904. private _basePoint;
  6905. private _epsilon;
  6906. /** @hidden */ private _velocityWorldLength: number;
  6907. /** @hidden */ private _basePointWorld: Vector3;
  6908. private _velocityWorld;
  6909. private _normalizedVelocity;
  6910. /** @hidden */ private _initialVelocity: Vector3;
  6911. /** @hidden */ private _initialPosition: Vector3;
  6912. private _nearestDistance;
  6913. private _collisionMask;
  6914. collisionMask: number;
  6915. /**
  6916. * Gets the plane normal used to compute the sliding response (in local space)
  6917. */
  6918. readonly slidePlaneNormal: Vector3;
  6919. /** @hidden */ private _initialize(source: Vector3, dir: Vector3, e: number): void;
  6920. /** @hidden */ private _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6921. /** @hidden */ private _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6922. /** @hidden */ private _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6923. /** @hidden */ private _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6924. /** @hidden */ private _getResponse(pos: Vector3, vel: Vector3): void;
  6925. }
  6926. }
  6927. declare module BABYLON {
  6928. /**
  6929. * Interface for cullable objects
  6930. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6931. */
  6932. export interface ICullable {
  6933. /**
  6934. * Checks if the object or part of the object is in the frustum
  6935. * @param frustumPlanes Camera near/planes
  6936. * @returns true if the object is in frustum otherwise false
  6937. */
  6938. isInFrustum(frustumPlanes: Plane[]): boolean;
  6939. /**
  6940. * Checks if a cullable object (mesh...) is in the camera frustum
  6941. * Unlike isInFrustum this cheks the full bounding box
  6942. * @param frustumPlanes Camera near/planes
  6943. * @returns true if the object is in frustum otherwise false
  6944. */
  6945. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6946. }
  6947. /**
  6948. * Info for a bounding data of a mesh
  6949. */
  6950. export class BoundingInfo implements ICullable {
  6951. /**
  6952. * Bounding box for the mesh
  6953. */
  6954. readonly boundingBox: BoundingBox;
  6955. /**
  6956. * Bounding sphere for the mesh
  6957. */
  6958. readonly boundingSphere: BoundingSphere;
  6959. private _isLocked;
  6960. private static readonly TmpVector3;
  6961. /**
  6962. * Constructs bounding info
  6963. * @param minimum min vector of the bounding box/sphere
  6964. * @param maximum max vector of the bounding box/sphere
  6965. * @param worldMatrix defines the new world matrix
  6966. */
  6967. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6968. /**
  6969. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6970. * @param min defines the new minimum vector (in local space)
  6971. * @param max defines the new maximum vector (in local space)
  6972. * @param worldMatrix defines the new world matrix
  6973. */
  6974. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6975. /**
  6976. * min vector of the bounding box/sphere
  6977. */
  6978. readonly minimum: Vector3;
  6979. /**
  6980. * max vector of the bounding box/sphere
  6981. */
  6982. readonly maximum: Vector3;
  6983. /**
  6984. * If the info is locked and won't be updated to avoid perf overhead
  6985. */
  6986. isLocked: boolean;
  6987. /**
  6988. * Updates the bounding sphere and box
  6989. * @param world world matrix to be used to update
  6990. */
  6991. update(world: DeepImmutable<Matrix>): void;
  6992. /**
  6993. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6994. * @param center New center of the bounding info
  6995. * @param extend New extend of the bounding info
  6996. * @returns the current bounding info
  6997. */
  6998. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6999. /**
  7000. * Scale the current bounding info by applying a scale factor
  7001. * @param factor defines the scale factor to apply
  7002. * @returns the current bounding info
  7003. */
  7004. scale(factor: number): BoundingInfo;
  7005. /**
  7006. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7007. * @param frustumPlanes defines the frustum to test
  7008. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7009. * @returns true if the bounding info is in the frustum planes
  7010. */
  7011. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7012. /**
  7013. * Gets the world distance between the min and max points of the bounding box
  7014. */
  7015. readonly diagonalLength: number;
  7016. /**
  7017. * Checks if a cullable object (mesh...) is in the camera frustum
  7018. * Unlike isInFrustum this cheks the full bounding box
  7019. * @param frustumPlanes Camera near/planes
  7020. * @returns true if the object is in frustum otherwise false
  7021. */
  7022. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7023. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  7024. /**
  7025. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7026. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7027. * @param point the point to check intersection with
  7028. * @returns if the point intersects
  7029. */
  7030. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7031. /**
  7032. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7033. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7034. * @param boundingInfo the bounding info to check intersection with
  7035. * @param precise if the intersection should be done using OBB
  7036. * @returns if the bounding info intersects
  7037. */
  7038. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7039. }
  7040. }
  7041. declare module BABYLON {
  7042. /**
  7043. * Extracts minimum and maximum values from a list of indexed positions
  7044. * @param positions defines the positions to use
  7045. * @param indices defines the indices to the positions
  7046. * @param indexStart defines the start index
  7047. * @param indexCount defines the end index
  7048. * @param bias defines bias value to add to the result
  7049. * @return minimum and maximum values
  7050. */
  7051. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7052. minimum: Vector3;
  7053. maximum: Vector3;
  7054. };
  7055. /**
  7056. * Extracts minimum and maximum values from a list of positions
  7057. * @param positions defines the positions to use
  7058. * @param start defines the start index in the positions array
  7059. * @param count defines the number of positions to handle
  7060. * @param bias defines bias value to add to the result
  7061. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7062. * @return minimum and maximum values
  7063. */
  7064. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7065. minimum: Vector3;
  7066. maximum: Vector3;
  7067. };
  7068. }
  7069. declare module BABYLON {
  7070. /** @hidden */
  7071. export class WebGLDataBuffer extends DataBuffer {
  7072. private _buffer;
  7073. constructor(resource: WebGLBuffer);
  7074. readonly underlyingResource: any;
  7075. }
  7076. }
  7077. declare module BABYLON {
  7078. /** @hidden */
  7079. export class WebGLPipelineContext implements IPipelineContext {
  7080. engine: ThinEngine;
  7081. program: Nullable<WebGLProgram>;
  7082. context?: WebGLRenderingContext;
  7083. vertexShader?: WebGLShader;
  7084. fragmentShader?: WebGLShader;
  7085. isParallelCompiled: boolean;
  7086. onCompiled?: () => void;
  7087. transformFeedback?: WebGLTransformFeedback | null;
  7088. readonly isAsync: boolean;
  7089. readonly isReady: boolean; private _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7090. }
  7091. }
  7092. declare module BABYLON {
  7093. interface ThinEngine {
  7094. /**
  7095. * Create an uniform buffer
  7096. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7097. * @param elements defines the content of the uniform buffer
  7098. * @returns the webGL uniform buffer
  7099. */
  7100. createUniformBuffer(elements: FloatArray): DataBuffer;
  7101. /**
  7102. * Create a dynamic uniform buffer
  7103. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7104. * @param elements defines the content of the uniform buffer
  7105. * @returns the webGL uniform buffer
  7106. */
  7107. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7108. /**
  7109. * Update an existing uniform buffer
  7110. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7111. * @param uniformBuffer defines the target uniform buffer
  7112. * @param elements defines the content to update
  7113. * @param offset defines the offset in the uniform buffer where update should start
  7114. * @param count defines the size of the data to update
  7115. */
  7116. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7117. /**
  7118. * Bind an uniform buffer to the current webGL context
  7119. * @param buffer defines the buffer to bind
  7120. */
  7121. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7122. /**
  7123. * Bind a buffer to the current webGL context at a given location
  7124. * @param buffer defines the buffer to bind
  7125. * @param location defines the index where to bind the buffer
  7126. */
  7127. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7128. /**
  7129. * Bind a specific block at a given index in a specific shader program
  7130. * @param pipelineContext defines the pipeline context to use
  7131. * @param blockName defines the block name
  7132. * @param index defines the index where to bind the block
  7133. */
  7134. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7135. }
  7136. }
  7137. declare module BABYLON {
  7138. /**
  7139. * Uniform buffer objects.
  7140. *
  7141. * Handles blocks of uniform on the GPU.
  7142. *
  7143. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7144. *
  7145. * For more information, please refer to :
  7146. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7147. */
  7148. export class UniformBuffer {
  7149. private _engine;
  7150. private _buffer;
  7151. private _data;
  7152. private _bufferData;
  7153. private _dynamic?;
  7154. private _uniformLocations;
  7155. private _uniformSizes;
  7156. private _uniformLocationPointer;
  7157. private _needSync;
  7158. private _noUBO;
  7159. private _currentEffect;
  7160. private static _MAX_UNIFORM_SIZE;
  7161. private static _tempBuffer;
  7162. /**
  7163. * Lambda to Update a 3x3 Matrix 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7168. /**
  7169. * Lambda to Update a 2x2 Matrix 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7174. /**
  7175. * Lambda to Update a single 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. updateFloat: (name: string, x: number) => void;
  7180. /**
  7181. * Lambda to Update a vec2 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7186. /**
  7187. * Lambda to Update a vec3 of float 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7192. /**
  7193. * Lambda to Update a vec4 of float 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7198. /**
  7199. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  7204. /**
  7205. * Lambda to Update vec3 of float from a Vector 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. updateVector3: (name: string, vector: Vector3) => void;
  7210. /**
  7211. * Lambda to Update vec4 of float from a Vector 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. updateVector4: (name: string, vector: Vector4) => void;
  7216. /**
  7217. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7218. * This is dynamic to allow compat with webgl 1 and 2.
  7219. * You will need to pass the name of the uniform as well as the value.
  7220. */
  7221. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7222. /**
  7223. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7224. * This is dynamic to allow compat with webgl 1 and 2.
  7225. * You will need to pass the name of the uniform as well as the value.
  7226. */
  7227. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7228. /**
  7229. * Instantiates a new Uniform buffer objects.
  7230. *
  7231. * Handles blocks of uniform on the GPU.
  7232. *
  7233. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7234. *
  7235. * For more information, please refer to :
  7236. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7237. * @param engine Define the engine the buffer is associated with
  7238. * @param data Define the data contained in the buffer
  7239. * @param dynamic Define if the buffer is updatable
  7240. */
  7241. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7242. /**
  7243. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7244. * or just falling back on setUniformXXX calls.
  7245. */
  7246. readonly useUbo: boolean;
  7247. /**
  7248. * Indicates if the WebGL underlying uniform buffer is in sync
  7249. * with the javascript cache data.
  7250. */
  7251. readonly isSync: boolean;
  7252. /**
  7253. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7254. * Also, a dynamic UniformBuffer will disable cache verification and always
  7255. * update the underlying WebGL uniform buffer to the GPU.
  7256. * @returns if Dynamic, otherwise false
  7257. */
  7258. isDynamic(): boolean;
  7259. /**
  7260. * The data cache on JS side.
  7261. * @returns the underlying data as a float array
  7262. */
  7263. getData(): Float32Array;
  7264. /**
  7265. * The underlying WebGL Uniform buffer.
  7266. * @returns the webgl buffer
  7267. */
  7268. getBuffer(): Nullable<DataBuffer>;
  7269. /**
  7270. * std140 layout specifies how to align data within an UBO structure.
  7271. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7272. * for specs.
  7273. */
  7274. private _fillAlignment;
  7275. /**
  7276. * Adds an uniform in the buffer.
  7277. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7278. * for the layout to be correct !
  7279. * @param name Name of the uniform, as used in the uniform block in the shader.
  7280. * @param size Data size, or data directly.
  7281. */
  7282. addUniform(name: string, size: number | number[]): void;
  7283. /**
  7284. * Adds a Matrix 4x4 to the uniform buffer.
  7285. * @param name Name of the uniform, as used in the uniform block in the shader.
  7286. * @param mat A 4x4 matrix.
  7287. */
  7288. addMatrix(name: string, mat: Matrix): void;
  7289. /**
  7290. * Adds a vec2 to the uniform buffer.
  7291. * @param name Name of the uniform, as used in the uniform block in the shader.
  7292. * @param x Define the x component value of the vec2
  7293. * @param y Define the y component value of the vec2
  7294. */
  7295. addFloat2(name: string, x: number, y: number): void;
  7296. /**
  7297. * Adds a vec3 to the uniform buffer.
  7298. * @param name Name of the uniform, as used in the uniform block in the shader.
  7299. * @param x Define the x component value of the vec3
  7300. * @param y Define the y component value of the vec3
  7301. * @param z Define the z component value of the vec3
  7302. */
  7303. addFloat3(name: string, x: number, y: number, z: number): void;
  7304. /**
  7305. * Adds a vec3 to the uniform buffer.
  7306. * @param name Name of the uniform, as used in the uniform block in the shader.
  7307. * @param color Define the vec3 from a Color
  7308. */
  7309. addColor3(name: string, color: Color3): void;
  7310. /**
  7311. * Adds a vec4 to the uniform buffer.
  7312. * @param name Name of the uniform, as used in the uniform block in the shader.
  7313. * @param color Define the rgb components from a Color
  7314. * @param alpha Define the a component of the vec4
  7315. */
  7316. addColor4(name: string, color: Color3, alpha: number): void;
  7317. /**
  7318. * Adds a vec3 to the uniform buffer.
  7319. * @param name Name of the uniform, as used in the uniform block in the shader.
  7320. * @param vector Define the vec3 components from a Vector
  7321. */
  7322. addVector3(name: string, vector: Vector3): void;
  7323. /**
  7324. * Adds a Matrix 3x3 to the uniform buffer.
  7325. * @param name Name of the uniform, as used in the uniform block in the shader.
  7326. */
  7327. addMatrix3x3(name: string): void;
  7328. /**
  7329. * Adds a Matrix 2x2 to the uniform buffer.
  7330. * @param name Name of the uniform, as used in the uniform block in the shader.
  7331. */
  7332. addMatrix2x2(name: string): void;
  7333. /**
  7334. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7335. */
  7336. create(): void;
  7337. /** @hidden */ private _rebuild(): void;
  7338. /**
  7339. * Updates the WebGL Uniform Buffer on the GPU.
  7340. * If the `dynamic` flag is set to true, no cache comparison is done.
  7341. * Otherwise, the buffer will be updated only if the cache differs.
  7342. */
  7343. update(): void;
  7344. /**
  7345. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7346. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7347. * @param data Define the flattened data
  7348. * @param size Define the size of the data.
  7349. */
  7350. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7351. private _valueCache;
  7352. private _cacheMatrix;
  7353. private _updateMatrix3x3ForUniform;
  7354. private _updateMatrix3x3ForEffect;
  7355. private _updateMatrix2x2ForEffect;
  7356. private _updateMatrix2x2ForUniform;
  7357. private _updateFloatForEffect;
  7358. private _updateFloatForUniform;
  7359. private _updateFloat2ForEffect;
  7360. private _updateFloat2ForUniform;
  7361. private _updateFloat3ForEffect;
  7362. private _updateFloat3ForUniform;
  7363. private _updateFloat4ForEffect;
  7364. private _updateFloat4ForUniform;
  7365. private _updateMatrixForEffect;
  7366. private _updateMatrixForUniform;
  7367. private _updateVector3ForEffect;
  7368. private _updateVector3ForUniform;
  7369. private _updateVector4ForEffect;
  7370. private _updateVector4ForUniform;
  7371. private _updateColor3ForEffect;
  7372. private _updateColor3ForUniform;
  7373. private _updateColor4ForEffect;
  7374. private _updateColor4ForUniform;
  7375. /**
  7376. * Sets a sampler uniform on the effect.
  7377. * @param name Define the name of the sampler.
  7378. * @param texture Define the texture to set in the sampler
  7379. */
  7380. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7381. /**
  7382. * Directly updates the value of the uniform in the cache AND on the GPU.
  7383. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7384. * @param data Define the flattened data
  7385. */
  7386. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7387. /**
  7388. * Binds this uniform buffer to an effect.
  7389. * @param effect Define the effect to bind the buffer to
  7390. * @param name Name of the uniform block in the shader.
  7391. */
  7392. bindToEffect(effect: Effect, name: string): void;
  7393. /**
  7394. * Disposes the uniform buffer.
  7395. */
  7396. dispose(): void;
  7397. }
  7398. }
  7399. declare module BABYLON {
  7400. /**
  7401. * Enum that determines the text-wrapping mode to use.
  7402. */
  7403. export enum InspectableType {
  7404. /**
  7405. * Checkbox for booleans
  7406. */
  7407. Checkbox = 0,
  7408. /**
  7409. * Sliders for numbers
  7410. */
  7411. Slider = 1,
  7412. /**
  7413. * Vector3
  7414. */
  7415. Vector3 = 2,
  7416. /**
  7417. * Quaternions
  7418. */
  7419. Quaternion = 3,
  7420. /**
  7421. * Color3
  7422. */
  7423. Color3 = 4,
  7424. /**
  7425. * String
  7426. */
  7427. String = 5
  7428. }
  7429. /**
  7430. * Interface used to define custom inspectable properties.
  7431. * This interface is used by the inspector to display custom property grids
  7432. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7433. */
  7434. export interface IInspectable {
  7435. /**
  7436. * Gets the label to display
  7437. */
  7438. label: string;
  7439. /**
  7440. * Gets the name of the property to edit
  7441. */
  7442. propertyName: string;
  7443. /**
  7444. * Gets the type of the editor to use
  7445. */
  7446. type: InspectableType;
  7447. /**
  7448. * Gets the minimum value of the property when using in "slider" mode
  7449. */
  7450. min?: number;
  7451. /**
  7452. * Gets the maximum value of the property when using in "slider" mode
  7453. */
  7454. max?: number;
  7455. /**
  7456. * Gets the setp to use when using in "slider" mode
  7457. */
  7458. step?: number;
  7459. }
  7460. }
  7461. declare module BABYLON {
  7462. /**
  7463. * Class used to provide helper for timing
  7464. */
  7465. export class TimingTools {
  7466. /**
  7467. * Polyfill for setImmediate
  7468. * @param action defines the action to execute after the current execution block
  7469. */
  7470. static SetImmediate(action: () => void): void;
  7471. }
  7472. }
  7473. declare module BABYLON {
  7474. /**
  7475. * Class used to enable instatition of objects by class name
  7476. */
  7477. export class InstantiationTools {
  7478. /**
  7479. * Use this object to register external classes like custom textures or material
  7480. * to allow the laoders to instantiate them
  7481. */
  7482. static RegisteredExternalClasses: {
  7483. [key: string]: Object;
  7484. };
  7485. /**
  7486. * Tries to instantiate a new object from a given class name
  7487. * @param className defines the class name to instantiate
  7488. * @returns the new object or null if the system was not able to do the instantiation
  7489. */
  7490. static Instantiate(className: string): any;
  7491. }
  7492. }
  7493. declare module BABYLON {
  7494. /**
  7495. * Define options used to create a depth texture
  7496. */
  7497. export class DepthTextureCreationOptions {
  7498. /** Specifies whether or not a stencil should be allocated in the texture */
  7499. generateStencil?: boolean;
  7500. /** Specifies whether or not bilinear filtering is enable on the texture */
  7501. bilinearFiltering?: boolean;
  7502. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7503. comparisonFunction?: number;
  7504. /** Specifies if the created texture is a cube texture */
  7505. isCube?: boolean;
  7506. }
  7507. }
  7508. declare module BABYLON {
  7509. interface ThinEngine {
  7510. /**
  7511. * Creates a depth stencil cube texture.
  7512. * This is only available in WebGL 2.
  7513. * @param size The size of face edge in the cube texture.
  7514. * @param options The options defining the cube texture.
  7515. * @returns The cube texture
  7516. */ private _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7517. /**
  7518. * Creates a cube texture
  7519. * @param rootUrl defines the url where the files to load is located
  7520. * @param scene defines the current scene
  7521. * @param files defines the list of files to load (1 per face)
  7522. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7523. * @param onLoad defines an optional callback raised when the texture is loaded
  7524. * @param onError defines an optional callback raised if there is an issue to load the texture
  7525. * @param format defines the format of the data
  7526. * @param forcedExtension defines the extension to use to pick the right loader
  7527. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7528. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7529. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7530. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7531. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7532. * @returns the cube texture as an InternalTexture
  7533. */
  7534. 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;
  7535. /**
  7536. * Creates a cube texture
  7537. * @param rootUrl defines the url where the files to load is located
  7538. * @param scene defines the current scene
  7539. * @param files defines the list of files to load (1 per face)
  7540. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7541. * @param onLoad defines an optional callback raised when the texture is loaded
  7542. * @param onError defines an optional callback raised if there is an issue to load the texture
  7543. * @param format defines the format of the data
  7544. * @param forcedExtension defines the extension to use to pick the right loader
  7545. * @returns the cube texture as an InternalTexture
  7546. */
  7547. 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;
  7548. /**
  7549. * Creates a cube texture
  7550. * @param rootUrl defines the url where the files to load is located
  7551. * @param scene defines the current scene
  7552. * @param files defines the list of files to load (1 per face)
  7553. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7554. * @param onLoad defines an optional callback raised when the texture is loaded
  7555. * @param onError defines an optional callback raised if there is an issue to load the texture
  7556. * @param format defines the format of the data
  7557. * @param forcedExtension defines the extension to use to pick the right loader
  7558. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7559. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7560. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7561. * @returns the cube texture as an InternalTexture
  7562. */
  7563. 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;
  7564. /** @hidden */ private _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7565. /** @hidden */ private _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7566. /** @hidden */ private _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7567. /** @hidden */ private _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7568. }
  7569. }
  7570. declare module BABYLON {
  7571. /**
  7572. * Class for creating a cube texture
  7573. */
  7574. export class CubeTexture extends BaseTexture {
  7575. private _delayedOnLoad;
  7576. /**
  7577. * The url of the texture
  7578. */
  7579. url: string;
  7580. /**
  7581. * Gets or sets the center of the bounding box associated with the cube texture.
  7582. * It must define where the camera used to render the texture was set
  7583. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7584. */
  7585. boundingBoxPosition: Vector3;
  7586. private _boundingBoxSize;
  7587. /**
  7588. * Gets or sets the size of the bounding box associated with the cube texture
  7589. * When defined, the cubemap will switch to local mode
  7590. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7591. * @example https://www.babylonjs-playground.com/#RNASML
  7592. */
  7593. /**
  7594. * Returns the bounding box size
  7595. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7596. */
  7597. boundingBoxSize: Vector3;
  7598. protected _rotationY: number;
  7599. /**
  7600. * Sets texture matrix rotation angle around Y axis in radians.
  7601. */
  7602. /**
  7603. * Gets texture matrix rotation angle around Y axis radians.
  7604. */
  7605. rotationY: number;
  7606. /**
  7607. * Are mip maps generated for this texture or not.
  7608. */
  7609. readonly noMipmap: boolean;
  7610. private _noMipmap;
  7611. private _files;
  7612. protected _forcedExtension: Nullable<string>;
  7613. private _extensions;
  7614. private _textureMatrix;
  7615. private _format;
  7616. private _createPolynomials;
  7617. /** @hidden */ private _prefiltered: boolean;
  7618. /**
  7619. * Creates a cube texture from an array of image urls
  7620. * @param files defines an array of image urls
  7621. * @param scene defines the hosting scene
  7622. * @param noMipmap specifies if mip maps are not used
  7623. * @returns a cube texture
  7624. */
  7625. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7626. /**
  7627. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7628. * @param url defines the url of the prefiltered texture
  7629. * @param scene defines the scene the texture is attached to
  7630. * @param forcedExtension defines the extension of the file if different from the url
  7631. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7632. * @return the prefiltered texture
  7633. */
  7634. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7635. /**
  7636. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7637. * as prefiltered data.
  7638. * @param rootUrl defines the url of the texture or the root name of the six images
  7639. * @param scene defines the scene the texture is attached to
  7640. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7641. * @param noMipmap defines if mipmaps should be created or not
  7642. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7643. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7644. * @param onError defines a callback triggered in case of error during load
  7645. * @param format defines the internal format to use for the texture once loaded
  7646. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7647. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7648. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7649. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7650. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7651. * @return the cube texture
  7652. */
  7653. 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);
  7654. /**
  7655. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7656. */
  7657. readonly isPrefiltered: boolean;
  7658. /**
  7659. * Get the current class name of the texture useful for serialization or dynamic coding.
  7660. * @returns "CubeTexture"
  7661. */
  7662. getClassName(): string;
  7663. /**
  7664. * Update the url (and optional buffer) of this texture if url was null during construction.
  7665. * @param url the url of the texture
  7666. * @param forcedExtension defines the extension to use
  7667. * @param onLoad callback called when the texture is loaded (defaults to null)
  7668. */
  7669. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7670. /**
  7671. * Delays loading of the cube texture
  7672. * @param forcedExtension defines the extension to use
  7673. */
  7674. delayLoad(forcedExtension?: string): void;
  7675. /**
  7676. * Returns the reflection texture matrix
  7677. * @returns the reflection texture matrix
  7678. */
  7679. getReflectionTextureMatrix(): Matrix;
  7680. /**
  7681. * Sets the reflection texture matrix
  7682. * @param value Reflection texture matrix
  7683. */
  7684. setReflectionTextureMatrix(value: Matrix): void;
  7685. /**
  7686. * Parses text to create a cube texture
  7687. * @param parsedTexture define the serialized text to read from
  7688. * @param scene defines the hosting scene
  7689. * @param rootUrl defines the root url of the cube texture
  7690. * @returns a cube texture
  7691. */
  7692. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7693. /**
  7694. * Makes a clone, or deep copy, of the cube texture
  7695. * @returns a new cube texture
  7696. */
  7697. clone(): CubeTexture;
  7698. }
  7699. }
  7700. declare module BABYLON {
  7701. /**
  7702. * Manages the defines for the Material
  7703. */
  7704. export class MaterialDefines {
  7705. /** @hidden */
  7706. protected _keys: string[];
  7707. private _isDirty;
  7708. /** @hidden */ private _renderId: number;
  7709. /** @hidden */ private _areLightsDirty: boolean;
  7710. /** @hidden */ private _areLightsDisposed: boolean;
  7711. /** @hidden */ private _areAttributesDirty: boolean;
  7712. /** @hidden */ private _areTexturesDirty: boolean;
  7713. /** @hidden */ private _areFresnelDirty: boolean;
  7714. /** @hidden */ private _areMiscDirty: boolean;
  7715. /** @hidden */ private _areImageProcessingDirty: boolean;
  7716. /** @hidden */ private _normals: boolean;
  7717. /** @hidden */ private _uvs: boolean;
  7718. /** @hidden */ private _needNormals: boolean;
  7719. /** @hidden */ private _needUVs: boolean;
  7720. [id: string]: any;
  7721. /**
  7722. * Specifies if the material needs to be re-calculated
  7723. */
  7724. readonly isDirty: boolean;
  7725. /**
  7726. * Marks the material to indicate that it has been re-calculated
  7727. */
  7728. markAsProcessed(): void;
  7729. /**
  7730. * Marks the material to indicate that it needs to be re-calculated
  7731. */
  7732. markAsUnprocessed(): void;
  7733. /**
  7734. * Marks the material to indicate all of its defines need to be re-calculated
  7735. */
  7736. markAllAsDirty(): void;
  7737. /**
  7738. * Marks the material to indicate that image processing needs to be re-calculated
  7739. */
  7740. markAsImageProcessingDirty(): void;
  7741. /**
  7742. * Marks the material to indicate the lights need to be re-calculated
  7743. * @param disposed Defines whether the light is dirty due to dispose or not
  7744. */
  7745. markAsLightDirty(disposed?: boolean): void;
  7746. /**
  7747. * Marks the attribute state as changed
  7748. */
  7749. markAsAttributesDirty(): void;
  7750. /**
  7751. * Marks the texture state as changed
  7752. */
  7753. markAsTexturesDirty(): void;
  7754. /**
  7755. * Marks the fresnel state as changed
  7756. */
  7757. markAsFresnelDirty(): void;
  7758. /**
  7759. * Marks the misc state as changed
  7760. */
  7761. markAsMiscDirty(): void;
  7762. /**
  7763. * Rebuilds the material defines
  7764. */
  7765. rebuild(): void;
  7766. /**
  7767. * Specifies if two material defines are equal
  7768. * @param other - A material define instance to compare to
  7769. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7770. */
  7771. isEqual(other: MaterialDefines): boolean;
  7772. /**
  7773. * Clones this instance's defines to another instance
  7774. * @param other - material defines to clone values to
  7775. */
  7776. cloneTo(other: MaterialDefines): void;
  7777. /**
  7778. * Resets the material define values
  7779. */
  7780. reset(): void;
  7781. /**
  7782. * Converts the material define values to a string
  7783. * @returns - String of material define information
  7784. */
  7785. toString(): string;
  7786. }
  7787. }
  7788. declare module BABYLON {
  7789. /**
  7790. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7791. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7792. * 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;
  7793. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7794. */
  7795. export class ColorCurves {
  7796. private _dirty;
  7797. private _tempColor;
  7798. private _globalCurve;
  7799. private _highlightsCurve;
  7800. private _midtonesCurve;
  7801. private _shadowsCurve;
  7802. private _positiveCurve;
  7803. private _negativeCurve;
  7804. private _globalHue;
  7805. private _globalDensity;
  7806. private _globalSaturation;
  7807. private _globalExposure;
  7808. /**
  7809. * Gets the global Hue value.
  7810. * 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).
  7811. */
  7812. /**
  7813. * Sets the global Hue value.
  7814. * 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).
  7815. */
  7816. globalHue: number;
  7817. /**
  7818. * Gets the global Density value.
  7819. * 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.
  7820. * Values less than zero provide a filter of opposite hue.
  7821. */
  7822. /**
  7823. * Sets the global Density value.
  7824. * 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.
  7825. * Values less than zero provide a filter of opposite hue.
  7826. */
  7827. globalDensity: number;
  7828. /**
  7829. * Gets the global Saturation 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 saturation and negative values decrease saturation.
  7831. */
  7832. /**
  7833. * Sets the global Saturation value.
  7834. * 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.
  7835. */
  7836. globalSaturation: number;
  7837. /**
  7838. * Gets the global Exposure value.
  7839. * 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.
  7840. */
  7841. /**
  7842. * Sets the global Exposure value.
  7843. * 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.
  7844. */
  7845. globalExposure: number;
  7846. private _highlightsHue;
  7847. private _highlightsDensity;
  7848. private _highlightsSaturation;
  7849. private _highlightsExposure;
  7850. /**
  7851. * Gets the highlights Hue value.
  7852. * 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).
  7853. */
  7854. /**
  7855. * Sets the highlights Hue value.
  7856. * 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).
  7857. */
  7858. highlightsHue: number;
  7859. /**
  7860. * Gets the highlights Density value.
  7861. * 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.
  7862. * Values less than zero provide a filter of opposite hue.
  7863. */
  7864. /**
  7865. * Sets the highlights Density value.
  7866. * 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.
  7867. * Values less than zero provide a filter of opposite hue.
  7868. */
  7869. highlightsDensity: number;
  7870. /**
  7871. * Gets the highlights Saturation 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 saturation and negative values decrease saturation.
  7873. */
  7874. /**
  7875. * Sets the highlights Saturation value.
  7876. * 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.
  7877. */
  7878. highlightsSaturation: number;
  7879. /**
  7880. * Gets the highlights Exposure value.
  7881. * 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.
  7882. */
  7883. /**
  7884. * Sets the highlights Exposure value.
  7885. * 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.
  7886. */
  7887. highlightsExposure: number;
  7888. private _midtonesHue;
  7889. private _midtonesDensity;
  7890. private _midtonesSaturation;
  7891. private _midtonesExposure;
  7892. /**
  7893. * Gets the midtones Hue value.
  7894. * 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).
  7895. */
  7896. /**
  7897. * Sets the midtones Hue value.
  7898. * 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).
  7899. */
  7900. midtonesHue: number;
  7901. /**
  7902. * Gets the midtones Density value.
  7903. * 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.
  7904. * Values less than zero provide a filter of opposite hue.
  7905. */
  7906. /**
  7907. * Sets the midtones Density value.
  7908. * 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.
  7909. * Values less than zero provide a filter of opposite hue.
  7910. */
  7911. midtonesDensity: number;
  7912. /**
  7913. * Gets the midtones Saturation 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 saturation and negative values decrease saturation.
  7915. */
  7916. /**
  7917. * Sets the midtones Saturation value.
  7918. * 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.
  7919. */
  7920. midtonesSaturation: number;
  7921. /**
  7922. * Gets the midtones Exposure value.
  7923. * 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.
  7924. */
  7925. /**
  7926. * Sets the midtones Exposure value.
  7927. * 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.
  7928. */
  7929. midtonesExposure: number;
  7930. private _shadowsHue;
  7931. private _shadowsDensity;
  7932. private _shadowsSaturation;
  7933. private _shadowsExposure;
  7934. /**
  7935. * Gets the shadows Hue value.
  7936. * 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).
  7937. */
  7938. /**
  7939. * Sets the shadows Hue value.
  7940. * 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).
  7941. */
  7942. shadowsHue: number;
  7943. /**
  7944. * Gets the shadows Density value.
  7945. * 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.
  7946. * Values less than zero provide a filter of opposite hue.
  7947. */
  7948. /**
  7949. * Sets the shadows Density value.
  7950. * 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.
  7951. * Values less than zero provide a filter of opposite hue.
  7952. */
  7953. shadowsDensity: number;
  7954. /**
  7955. * Gets the shadows Saturation 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 saturation and negative values decrease saturation.
  7957. */
  7958. /**
  7959. * Sets the shadows Saturation value.
  7960. * 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.
  7961. */
  7962. shadowsSaturation: number;
  7963. /**
  7964. * Gets the shadows Exposure value.
  7965. * 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.
  7966. */
  7967. /**
  7968. * Sets the shadows Exposure value.
  7969. * 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.
  7970. */
  7971. shadowsExposure: number;
  7972. /**
  7973. * Returns the class name
  7974. * @returns The class name
  7975. */
  7976. getClassName(): string;
  7977. /**
  7978. * Binds the color curves to the shader.
  7979. * @param colorCurves The color curve to bind
  7980. * @param effect The effect to bind to
  7981. * @param positiveUniform The positive uniform shader parameter
  7982. * @param neutralUniform The neutral uniform shader parameter
  7983. * @param negativeUniform The negative uniform shader parameter
  7984. */
  7985. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7986. /**
  7987. * Prepare the list of uniforms associated with the ColorCurves effects.
  7988. * @param uniformsList The list of uniforms used in the effect
  7989. */
  7990. static PrepareUniforms(uniformsList: string[]): void;
  7991. /**
  7992. * Returns color grading data based on a hue, density, saturation and exposure value.
  7993. * @param filterHue The hue of the color filter.
  7994. * @param filterDensity The density of the color filter.
  7995. * @param saturation The saturation.
  7996. * @param exposure The exposure.
  7997. * @param result The result data container.
  7998. */
  7999. private getColorGradingDataToRef;
  8000. /**
  8001. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8002. * @param value The input slider value in range [-100,100].
  8003. * @returns Adjusted value.
  8004. */
  8005. private static applyColorGradingSliderNonlinear;
  8006. /**
  8007. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8008. * @param hue The hue (H) input.
  8009. * @param saturation The saturation (S) input.
  8010. * @param brightness The brightness (B) input.
  8011. * @result An RGBA color represented as Vector4.
  8012. */
  8013. private static fromHSBToRef;
  8014. /**
  8015. * Returns a value clamped between min and max
  8016. * @param value The value to clamp
  8017. * @param min The minimum of value
  8018. * @param max The maximum of value
  8019. * @returns The clamped value.
  8020. */
  8021. private static clamp;
  8022. /**
  8023. * Clones the current color curve instance.
  8024. * @return The cloned curves
  8025. */
  8026. clone(): ColorCurves;
  8027. /**
  8028. * Serializes the current color curve instance to a json representation.
  8029. * @return a JSON representation
  8030. */
  8031. serialize(): any;
  8032. /**
  8033. * Parses the color curve from a json representation.
  8034. * @param source the JSON source to parse
  8035. * @return The parsed curves
  8036. */
  8037. static Parse(source: any): ColorCurves;
  8038. }
  8039. }
  8040. declare module BABYLON {
  8041. /**
  8042. * Interface to follow in your material defines to integrate easily the
  8043. * Image proccessing functions.
  8044. * @hidden
  8045. */
  8046. export interface IImageProcessingConfigurationDefines {
  8047. IMAGEPROCESSING: boolean;
  8048. VIGNETTE: boolean;
  8049. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8050. VIGNETTEBLENDMODEOPAQUE: boolean;
  8051. TONEMAPPING: boolean;
  8052. TONEMAPPING_ACES: boolean;
  8053. CONTRAST: boolean;
  8054. EXPOSURE: boolean;
  8055. COLORCURVES: boolean;
  8056. COLORGRADING: boolean;
  8057. COLORGRADING3D: boolean;
  8058. SAMPLER3DGREENDEPTH: boolean;
  8059. SAMPLER3DBGRMAP: boolean;
  8060. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8061. }
  8062. /**
  8063. * @hidden
  8064. */
  8065. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8066. IMAGEPROCESSING: boolean;
  8067. VIGNETTE: boolean;
  8068. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8069. VIGNETTEBLENDMODEOPAQUE: boolean;
  8070. TONEMAPPING: boolean;
  8071. TONEMAPPING_ACES: boolean;
  8072. CONTRAST: boolean;
  8073. COLORCURVES: boolean;
  8074. COLORGRADING: boolean;
  8075. COLORGRADING3D: boolean;
  8076. SAMPLER3DGREENDEPTH: boolean;
  8077. SAMPLER3DBGRMAP: boolean;
  8078. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8079. EXPOSURE: boolean;
  8080. constructor();
  8081. }
  8082. /**
  8083. * This groups together the common properties used for image processing either in direct forward pass
  8084. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8085. * or not.
  8086. */
  8087. export class ImageProcessingConfiguration {
  8088. /**
  8089. * Default tone mapping applied in BabylonJS.
  8090. */
  8091. static readonly TONEMAPPING_STANDARD: number;
  8092. /**
  8093. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8094. * to other engines rendering to increase portability.
  8095. */
  8096. static readonly TONEMAPPING_ACES: number;
  8097. /**
  8098. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8099. */
  8100. colorCurves: Nullable<ColorCurves>;
  8101. private _colorCurvesEnabled;
  8102. /**
  8103. * Gets wether the color curves effect is enabled.
  8104. */
  8105. /**
  8106. * Sets wether the color curves effect is enabled.
  8107. */
  8108. colorCurvesEnabled: boolean;
  8109. private _colorGradingTexture;
  8110. /**
  8111. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8112. */
  8113. /**
  8114. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8115. */
  8116. colorGradingTexture: Nullable<BaseTexture>;
  8117. private _colorGradingEnabled;
  8118. /**
  8119. * Gets wether the color grading effect is enabled.
  8120. */
  8121. /**
  8122. * Sets wether the color grading effect is enabled.
  8123. */
  8124. colorGradingEnabled: boolean;
  8125. private _colorGradingWithGreenDepth;
  8126. /**
  8127. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8128. */
  8129. /**
  8130. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8131. */
  8132. colorGradingWithGreenDepth: boolean;
  8133. private _colorGradingBGR;
  8134. /**
  8135. * Gets wether the color grading texture contains BGR values.
  8136. */
  8137. /**
  8138. * Sets wether the color grading texture contains BGR values.
  8139. */
  8140. colorGradingBGR: boolean;
  8141. /** @hidden */ private _exposure: number;
  8142. /**
  8143. * Gets the Exposure used in the effect.
  8144. */
  8145. /**
  8146. * Sets the Exposure used in the effect.
  8147. */
  8148. exposure: number;
  8149. private _toneMappingEnabled;
  8150. /**
  8151. * Gets wether the tone mapping effect is enabled.
  8152. */
  8153. /**
  8154. * Sets wether the tone mapping effect is enabled.
  8155. */
  8156. toneMappingEnabled: boolean;
  8157. private _toneMappingType;
  8158. /**
  8159. * Gets the type of tone mapping effect.
  8160. */
  8161. /**
  8162. * Sets the type of tone mapping effect used in BabylonJS.
  8163. */
  8164. toneMappingType: number;
  8165. protected _contrast: number;
  8166. /**
  8167. * Gets the contrast used in the effect.
  8168. */
  8169. /**
  8170. * Sets the contrast used in the effect.
  8171. */
  8172. contrast: number;
  8173. /**
  8174. * Vignette stretch size.
  8175. */
  8176. vignetteStretch: number;
  8177. /**
  8178. * Vignette centre X Offset.
  8179. */
  8180. vignetteCentreX: number;
  8181. /**
  8182. * Vignette centre Y Offset.
  8183. */
  8184. vignetteCentreY: number;
  8185. /**
  8186. * Vignette weight or intensity of the vignette effect.
  8187. */
  8188. vignetteWeight: number;
  8189. /**
  8190. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8191. * if vignetteEnabled is set to true.
  8192. */
  8193. vignetteColor: Color4;
  8194. /**
  8195. * Camera field of view used by the Vignette effect.
  8196. */
  8197. vignetteCameraFov: number;
  8198. private _vignetteBlendMode;
  8199. /**
  8200. * Gets the vignette blend mode allowing different kind of effect.
  8201. */
  8202. /**
  8203. * Sets the vignette blend mode allowing different kind of effect.
  8204. */
  8205. vignetteBlendMode: number;
  8206. private _vignetteEnabled;
  8207. /**
  8208. * Gets wether the vignette effect is enabled.
  8209. */
  8210. /**
  8211. * Sets wether the vignette effect is enabled.
  8212. */
  8213. vignetteEnabled: boolean;
  8214. private _applyByPostProcess;
  8215. /**
  8216. * Gets wether the image processing is applied through a post process or not.
  8217. */
  8218. /**
  8219. * Sets wether the image processing is applied through a post process or not.
  8220. */
  8221. applyByPostProcess: boolean;
  8222. private _isEnabled;
  8223. /**
  8224. * Gets wether the image processing is enabled or not.
  8225. */
  8226. /**
  8227. * Sets wether the image processing is enabled or not.
  8228. */
  8229. isEnabled: boolean;
  8230. /**
  8231. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8232. */
  8233. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8234. /**
  8235. * Method called each time the image processing information changes requires to recompile the effect.
  8236. */
  8237. protected _updateParameters(): void;
  8238. /**
  8239. * Gets the current class name.
  8240. * @return "ImageProcessingConfiguration"
  8241. */
  8242. getClassName(): string;
  8243. /**
  8244. * Prepare the list of uniforms associated with the Image Processing effects.
  8245. * @param uniforms The list of uniforms used in the effect
  8246. * @param defines the list of defines currently in use
  8247. */
  8248. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8249. /**
  8250. * Prepare the list of samplers associated with the Image Processing effects.
  8251. * @param samplersList The list of uniforms used in the effect
  8252. * @param defines the list of defines currently in use
  8253. */
  8254. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8255. /**
  8256. * Prepare the list of defines associated to the shader.
  8257. * @param defines the list of defines to complete
  8258. * @param forPostProcess Define if we are currently in post process mode or not
  8259. */
  8260. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8261. /**
  8262. * Returns true if all the image processing information are ready.
  8263. * @returns True if ready, otherwise, false
  8264. */
  8265. isReady(): boolean;
  8266. /**
  8267. * Binds the image processing to the shader.
  8268. * @param effect The effect to bind to
  8269. * @param aspectRatio Define the current aspect ratio of the effect
  8270. */
  8271. bind(effect: Effect, aspectRatio?: number): void;
  8272. /**
  8273. * Clones the current image processing instance.
  8274. * @return The cloned image processing
  8275. */
  8276. clone(): ImageProcessingConfiguration;
  8277. /**
  8278. * Serializes the current image processing instance to a json representation.
  8279. * @return a JSON representation
  8280. */
  8281. serialize(): any;
  8282. /**
  8283. * Parses the image processing from a json representation.
  8284. * @param source the JSON source to parse
  8285. * @return The parsed image processing
  8286. */
  8287. static Parse(source: any): ImageProcessingConfiguration;
  8288. private static _VIGNETTEMODE_MULTIPLY;
  8289. private static _VIGNETTEMODE_OPAQUE;
  8290. /**
  8291. * Used to apply the vignette as a mix with the pixel color.
  8292. */
  8293. static readonly VIGNETTEMODE_MULTIPLY: number;
  8294. /**
  8295. * Used to apply the vignette as a replacement of the pixel color.
  8296. */
  8297. static readonly VIGNETTEMODE_OPAQUE: number;
  8298. }
  8299. }
  8300. declare module BABYLON {
  8301. /** @hidden */
  8302. export var postprocessVertexShader: {
  8303. name: string;
  8304. shader: string;
  8305. };
  8306. }
  8307. declare module BABYLON {
  8308. interface ThinEngine {
  8309. /**
  8310. * Creates a new render target texture
  8311. * @param size defines the size of the texture
  8312. * @param options defines the options used to create the texture
  8313. * @returns a new render target texture stored in an InternalTexture
  8314. */
  8315. createRenderTargetTexture(size: number | {
  8316. width: number;
  8317. height: number;
  8318. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8319. }
  8320. }
  8321. declare module BABYLON {
  8322. /** Defines supported spaces */
  8323. export enum Space {
  8324. /** Local (object) space */
  8325. LOCAL = 0,
  8326. /** World space */
  8327. WORLD = 1,
  8328. /** Bone space */
  8329. BONE = 2
  8330. }
  8331. /** Defines the 3 main axes */
  8332. export class Axis {
  8333. /** X axis */
  8334. static X: Vector3;
  8335. /** Y axis */
  8336. static Y: Vector3;
  8337. /** Z axis */
  8338. static Z: Vector3;
  8339. }
  8340. }
  8341. declare module BABYLON {
  8342. /**
  8343. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8344. * This is the base of the follow, arc rotate cameras and Free camera
  8345. * @see http://doc.babylonjs.com/features/cameras
  8346. */
  8347. export class TargetCamera extends Camera {
  8348. private static _RigCamTransformMatrix;
  8349. private static _TargetTransformMatrix;
  8350. private static _TargetFocalPoint;
  8351. /**
  8352. * Define the current direction the camera is moving to
  8353. */
  8354. cameraDirection: Vector3;
  8355. /**
  8356. * Define the current rotation the camera is rotating to
  8357. */
  8358. cameraRotation: Vector2;
  8359. /**
  8360. * When set, the up vector of the camera will be updated by the rotation of the camera
  8361. */
  8362. updateUpVectorFromRotation: boolean;
  8363. private _tmpQuaternion;
  8364. /**
  8365. * Define the current rotation of the camera
  8366. */
  8367. rotation: Vector3;
  8368. /**
  8369. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8370. */
  8371. rotationQuaternion: Quaternion;
  8372. /**
  8373. * Define the current speed of the camera
  8374. */
  8375. speed: number;
  8376. /**
  8377. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8378. * around all axis.
  8379. */
  8380. noRotationConstraint: boolean;
  8381. /**
  8382. * Define the current target of the camera as an object or a position.
  8383. */
  8384. lockedTarget: any;
  8385. /** @hidden */ private _currentTarget: Vector3;
  8386. /** @hidden */ private _initialFocalDistance: number;
  8387. /** @hidden */ private _viewMatrix: Matrix;
  8388. /** @hidden */ private _camMatrix: Matrix;
  8389. /** @hidden */ private _cameraTransformMatrix: Matrix;
  8390. /** @hidden */ private _cameraRotationMatrix: Matrix;
  8391. /** @hidden */ private _referencePoint: Vector3;
  8392. /** @hidden */ private _transformedReferencePoint: Vector3;
  8393. protected _globalCurrentTarget: Vector3;
  8394. protected _globalCurrentUpVector: Vector3;
  8395. /** @hidden */ private _reset: () => void;
  8396. private _defaultUp;
  8397. /**
  8398. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8399. * This is the base of the follow, arc rotate cameras and Free camera
  8400. * @see http://doc.babylonjs.com/features/cameras
  8401. * @param name Defines the name of the camera in the scene
  8402. * @param position Defines the start position of the camera in the scene
  8403. * @param scene Defines the scene the camera belongs to
  8404. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8405. */
  8406. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8407. /**
  8408. * Gets the position in front of the camera at a given distance.
  8409. * @param distance The distance from the camera we want the position to be
  8410. * @returns the position
  8411. */
  8412. getFrontPosition(distance: number): Vector3;
  8413. /** @hidden */ private _getLockedTargetPosition(): Nullable<Vector3>;
  8414. private _storedPosition;
  8415. private _storedRotation;
  8416. private _storedRotationQuaternion;
  8417. /**
  8418. * Store current camera state of the camera (fov, position, rotation, etc..)
  8419. * @returns the camera
  8420. */
  8421. storeState(): Camera;
  8422. /**
  8423. * Restored camera state. You must call storeState() first
  8424. * @returns whether it was successful or not
  8425. * @hidden
  8426. */ private _restoreStateValues(): boolean;
  8427. /** @hidden */ private _initCache(): void;
  8428. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  8429. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  8430. /** @hidden */ private _computeLocalCameraSpeed(): number;
  8431. /**
  8432. * Defines the target the camera should look at.
  8433. * @param target Defines the new target as a Vector or a mesh
  8434. */
  8435. setTarget(target: Vector3): void;
  8436. /**
  8437. * Return the current target position of the camera. This value is expressed in local space.
  8438. * @returns the target position
  8439. */
  8440. getTarget(): Vector3;
  8441. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  8442. /** @hidden */ private _updatePosition(): void;
  8443. /** @hidden */ private _checkInputs(): void;
  8444. protected _updateCameraRotationMatrix(): void;
  8445. /**
  8446. * 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)
  8447. * @returns the current camera
  8448. */
  8449. private _rotateUpVectorWithCameraRotationMatrix;
  8450. private _cachedRotationZ;
  8451. private _cachedQuaternionRotationZ;
  8452. /** @hidden */ private _getViewMatrix(): Matrix;
  8453. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8454. /**
  8455. * @hidden
  8456. */
  8457. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8458. /**
  8459. * @hidden
  8460. */ private _updateRigCameras(): void;
  8461. private _getRigCamPositionAndTarget;
  8462. /**
  8463. * Gets the current object class name.
  8464. * @return the class name
  8465. */
  8466. getClassName(): string;
  8467. }
  8468. }
  8469. declare module BABYLON {
  8470. /**
  8471. * Gather the list of keyboard event types as constants.
  8472. */
  8473. export class KeyboardEventTypes {
  8474. /**
  8475. * The keydown event is fired when a key becomes active (pressed).
  8476. */
  8477. static readonly KEYDOWN: number;
  8478. /**
  8479. * The keyup event is fired when a key has been released.
  8480. */
  8481. static readonly KEYUP: number;
  8482. }
  8483. /**
  8484. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8485. */
  8486. export class KeyboardInfo {
  8487. /**
  8488. * Defines the type of event (KeyboardEventTypes)
  8489. */
  8490. type: number;
  8491. /**
  8492. * Defines the related dom event
  8493. */
  8494. event: KeyboardEvent;
  8495. /**
  8496. * Instantiates a new keyboard info.
  8497. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8498. * @param type Defines the type of event (KeyboardEventTypes)
  8499. * @param event Defines the related dom event
  8500. */
  8501. constructor(
  8502. /**
  8503. * Defines the type of event (KeyboardEventTypes)
  8504. */
  8505. type: number,
  8506. /**
  8507. * Defines the related dom event
  8508. */
  8509. event: KeyboardEvent);
  8510. }
  8511. /**
  8512. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8513. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8514. */
  8515. export class KeyboardInfoPre extends KeyboardInfo {
  8516. /**
  8517. * Defines the type of event (KeyboardEventTypes)
  8518. */
  8519. type: number;
  8520. /**
  8521. * Defines the related dom event
  8522. */
  8523. event: KeyboardEvent;
  8524. /**
  8525. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8526. */
  8527. skipOnPointerObservable: boolean;
  8528. /**
  8529. * Instantiates a new keyboard pre info.
  8530. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8531. * @param type Defines the type of event (KeyboardEventTypes)
  8532. * @param event Defines the related dom event
  8533. */
  8534. constructor(
  8535. /**
  8536. * Defines the type of event (KeyboardEventTypes)
  8537. */
  8538. type: number,
  8539. /**
  8540. * Defines the related dom event
  8541. */
  8542. event: KeyboardEvent);
  8543. }
  8544. }
  8545. declare module BABYLON {
  8546. /**
  8547. * Manage the keyboard inputs to control the movement of a free camera.
  8548. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8549. */
  8550. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8551. /**
  8552. * Defines the camera the input is attached to.
  8553. */
  8554. camera: FreeCamera;
  8555. /**
  8556. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8557. */
  8558. keysUp: number[];
  8559. /**
  8560. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8561. */
  8562. keysDown: number[];
  8563. /**
  8564. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8565. */
  8566. keysLeft: number[];
  8567. /**
  8568. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8569. */
  8570. keysRight: number[];
  8571. private _keys;
  8572. private _onCanvasBlurObserver;
  8573. private _onKeyboardObserver;
  8574. private _engine;
  8575. private _scene;
  8576. /**
  8577. * Attach the input controls to a specific dom element to get the input from.
  8578. * @param element Defines the element the controls should be listened from
  8579. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8580. */
  8581. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8582. /**
  8583. * Detach the current controls from the specified dom element.
  8584. * @param element Defines the element to stop listening the inputs from
  8585. */
  8586. detachControl(element: Nullable<HTMLElement>): void;
  8587. /**
  8588. * Update the current camera state depending on the inputs that have been used this frame.
  8589. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8590. */
  8591. checkInputs(): void;
  8592. /**
  8593. * Gets the class name of the current intput.
  8594. * @returns the class name
  8595. */
  8596. getClassName(): string;
  8597. /** @hidden */ private _onLostFocus(): void;
  8598. /**
  8599. * Get the friendly name associated with the input class.
  8600. * @returns the input friendly name
  8601. */
  8602. getSimpleName(): string;
  8603. }
  8604. }
  8605. declare module BABYLON {
  8606. /**
  8607. * Interface describing all the common properties and methods a shadow light needs to implement.
  8608. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8609. * as well as binding the different shadow properties to the effects.
  8610. */
  8611. export interface IShadowLight extends Light {
  8612. /**
  8613. * The light id in the scene (used in scene.findLighById for instance)
  8614. */
  8615. id: string;
  8616. /**
  8617. * The position the shdow will be casted from.
  8618. */
  8619. position: Vector3;
  8620. /**
  8621. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8622. */
  8623. direction: Vector3;
  8624. /**
  8625. * The transformed position. Position of the light in world space taking parenting in account.
  8626. */
  8627. transformedPosition: Vector3;
  8628. /**
  8629. * The transformed direction. Direction of the light in world space taking parenting in account.
  8630. */
  8631. transformedDirection: Vector3;
  8632. /**
  8633. * The friendly name of the light in the scene.
  8634. */
  8635. name: string;
  8636. /**
  8637. * Defines the shadow projection clipping minimum z value.
  8638. */
  8639. shadowMinZ: number;
  8640. /**
  8641. * Defines the shadow projection clipping maximum z value.
  8642. */
  8643. shadowMaxZ: number;
  8644. /**
  8645. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8646. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8647. */
  8648. computeTransformedInformation(): boolean;
  8649. /**
  8650. * Gets the scene the light belongs to.
  8651. * @returns The scene
  8652. */
  8653. getScene(): Scene;
  8654. /**
  8655. * Callback defining a custom Projection Matrix Builder.
  8656. * This can be used to override the default projection matrix computation.
  8657. */
  8658. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8659. /**
  8660. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8661. * @param matrix The materix to updated with the projection information
  8662. * @param viewMatrix The transform matrix of the light
  8663. * @param renderList The list of mesh to render in the map
  8664. * @returns The current light
  8665. */
  8666. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8667. /**
  8668. * Gets the current depth scale used in ESM.
  8669. * @returns The scale
  8670. */
  8671. getDepthScale(): number;
  8672. /**
  8673. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8674. * @returns true if a cube texture needs to be use
  8675. */
  8676. needCube(): boolean;
  8677. /**
  8678. * Detects if the projection matrix requires to be recomputed this frame.
  8679. * @returns true if it requires to be recomputed otherwise, false.
  8680. */
  8681. needProjectionMatrixCompute(): boolean;
  8682. /**
  8683. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8684. */
  8685. forceProjectionMatrixCompute(): void;
  8686. /**
  8687. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8688. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8689. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8690. */
  8691. getShadowDirection(faceIndex?: number): Vector3;
  8692. /**
  8693. * Gets the minZ used for shadow according to both the scene and the light.
  8694. * @param activeCamera The camera we are returning the min for
  8695. * @returns the depth min z
  8696. */
  8697. getDepthMinZ(activeCamera: Camera): number;
  8698. /**
  8699. * Gets the maxZ used for shadow according to both the scene and the light.
  8700. * @param activeCamera The camera we are returning the max for
  8701. * @returns the depth max z
  8702. */
  8703. getDepthMaxZ(activeCamera: Camera): number;
  8704. }
  8705. /**
  8706. * Base implementation IShadowLight
  8707. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8708. */
  8709. export abstract class ShadowLight extends Light implements IShadowLight {
  8710. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8711. protected _position: Vector3;
  8712. protected _setPosition(value: Vector3): void;
  8713. /**
  8714. * Sets the position the shadow will be casted from. Also use as the light position for both
  8715. * point and spot lights.
  8716. */
  8717. /**
  8718. * Sets the position the shadow will be casted from. Also use as the light position for both
  8719. * point and spot lights.
  8720. */
  8721. position: Vector3;
  8722. protected _direction: Vector3;
  8723. protected _setDirection(value: Vector3): void;
  8724. /**
  8725. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8726. * Also use as the light direction on spot and directional lights.
  8727. */
  8728. /**
  8729. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8730. * Also use as the light direction on spot and directional lights.
  8731. */
  8732. direction: Vector3;
  8733. private _shadowMinZ;
  8734. /**
  8735. * Gets the shadow projection clipping minimum z value.
  8736. */
  8737. /**
  8738. * Sets the shadow projection clipping minimum z value.
  8739. */
  8740. shadowMinZ: number;
  8741. private _shadowMaxZ;
  8742. /**
  8743. * Sets the shadow projection clipping maximum z value.
  8744. */
  8745. /**
  8746. * Gets the shadow projection clipping maximum z value.
  8747. */
  8748. shadowMaxZ: number;
  8749. /**
  8750. * Callback defining a custom Projection Matrix Builder.
  8751. * This can be used to override the default projection matrix computation.
  8752. */
  8753. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8754. /**
  8755. * The transformed position. Position of the light in world space taking parenting in account.
  8756. */
  8757. transformedPosition: Vector3;
  8758. /**
  8759. * The transformed direction. Direction of the light in world space taking parenting in account.
  8760. */
  8761. transformedDirection: Vector3;
  8762. private _needProjectionMatrixCompute;
  8763. /**
  8764. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8765. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8766. */
  8767. computeTransformedInformation(): boolean;
  8768. /**
  8769. * Return the depth scale used for the shadow map.
  8770. * @returns the depth scale.
  8771. */
  8772. getDepthScale(): number;
  8773. /**
  8774. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8775. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8776. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8777. */
  8778. getShadowDirection(faceIndex?: number): Vector3;
  8779. /**
  8780. * Returns the ShadowLight absolute position in the World.
  8781. * @returns the position vector in world space
  8782. */
  8783. getAbsolutePosition(): Vector3;
  8784. /**
  8785. * Sets the ShadowLight direction toward the passed target.
  8786. * @param target The point to target in local space
  8787. * @returns the updated ShadowLight direction
  8788. */
  8789. setDirectionToTarget(target: Vector3): Vector3;
  8790. /**
  8791. * Returns the light rotation in euler definition.
  8792. * @returns the x y z rotation in local space.
  8793. */
  8794. getRotation(): Vector3;
  8795. /**
  8796. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8797. * @returns true if a cube texture needs to be use
  8798. */
  8799. needCube(): boolean;
  8800. /**
  8801. * Detects if the projection matrix requires to be recomputed this frame.
  8802. * @returns true if it requires to be recomputed otherwise, false.
  8803. */
  8804. needProjectionMatrixCompute(): boolean;
  8805. /**
  8806. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8807. */
  8808. forceProjectionMatrixCompute(): void;
  8809. /** @hidden */ private _initCache(): void;
  8810. /** @hidden */ private _isSynchronized(): boolean;
  8811. /**
  8812. * Computes the world matrix of the node
  8813. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8814. * @returns the world matrix
  8815. */
  8816. computeWorldMatrix(force?: boolean): Matrix;
  8817. /**
  8818. * Gets the minZ used for shadow according to both the scene and the light.
  8819. * @param activeCamera The camera we are returning the min for
  8820. * @returns the depth min z
  8821. */
  8822. getDepthMinZ(activeCamera: Camera): number;
  8823. /**
  8824. * Gets the maxZ used for shadow according to both the scene and the light.
  8825. * @param activeCamera The camera we are returning the max for
  8826. * @returns the depth max z
  8827. */
  8828. getDepthMaxZ(activeCamera: Camera): number;
  8829. /**
  8830. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8831. * @param matrix The materix to updated with the projection information
  8832. * @param viewMatrix The transform matrix of the light
  8833. * @param renderList The list of mesh to render in the map
  8834. * @returns The current light
  8835. */
  8836. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8837. }
  8838. }
  8839. declare module BABYLON {
  8840. /**
  8841. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8842. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8843. */
  8844. export class EffectFallbacks implements IEffectFallbacks {
  8845. private _defines;
  8846. private _currentRank;
  8847. private _maxRank;
  8848. private _mesh;
  8849. /**
  8850. * Removes the fallback from the bound mesh.
  8851. */
  8852. unBindMesh(): void;
  8853. /**
  8854. * Adds a fallback on the specified property.
  8855. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8856. * @param define The name of the define in the shader
  8857. */
  8858. addFallback(rank: number, define: string): void;
  8859. /**
  8860. * Sets the mesh to use CPU skinning when needing to fallback.
  8861. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8862. * @param mesh The mesh to use the fallbacks.
  8863. */
  8864. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8865. /**
  8866. * Checks to see if more fallbacks are still availible.
  8867. */
  8868. readonly hasMoreFallbacks: boolean;
  8869. /**
  8870. * Removes the defines that should be removed when falling back.
  8871. * @param currentDefines defines the current define statements for the shader.
  8872. * @param effect defines the current effect we try to compile
  8873. * @returns The resulting defines with defines of the current rank removed.
  8874. */
  8875. reduce(currentDefines: string, effect: Effect): string;
  8876. }
  8877. }
  8878. declare module BABYLON {
  8879. /**
  8880. * "Static Class" containing the most commonly used helper while dealing with material for
  8881. * rendering purpose.
  8882. *
  8883. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8884. *
  8885. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8886. */
  8887. export class MaterialHelper {
  8888. /**
  8889. * Bind the current view position to an effect.
  8890. * @param effect The effect to be bound
  8891. * @param scene The scene the eyes position is used from
  8892. */
  8893. static BindEyePosition(effect: Effect, scene: Scene): void;
  8894. /**
  8895. * Helps preparing the defines values about the UVs in used in the effect.
  8896. * UVs are shared as much as we can accross channels in the shaders.
  8897. * @param texture The texture we are preparing the UVs for
  8898. * @param defines The defines to update
  8899. * @param key The channel key "diffuse", "specular"... used in the shader
  8900. */
  8901. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8902. /**
  8903. * Binds a texture matrix value to its corrsponding uniform
  8904. * @param texture The texture to bind the matrix for
  8905. * @param uniformBuffer The uniform buffer receivin the data
  8906. * @param key The channel key "diffuse", "specular"... used in the shader
  8907. */
  8908. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8909. /**
  8910. * Gets the current status of the fog (should it be enabled?)
  8911. * @param mesh defines the mesh to evaluate for fog support
  8912. * @param scene defines the hosting scene
  8913. * @returns true if fog must be enabled
  8914. */
  8915. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8916. /**
  8917. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8918. * @param mesh defines the current mesh
  8919. * @param scene defines the current scene
  8920. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8921. * @param pointsCloud defines if point cloud rendering has to be turned on
  8922. * @param fogEnabled defines if fog has to be turned on
  8923. * @param alphaTest defines if alpha testing has to be turned on
  8924. * @param defines defines the current list of defines
  8925. */
  8926. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8927. /**
  8928. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8929. * @param scene defines the current scene
  8930. * @param engine defines the current engine
  8931. * @param defines specifies the list of active defines
  8932. * @param useInstances defines if instances have to be turned on
  8933. * @param useClipPlane defines if clip plane have to be turned on
  8934. */
  8935. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8936. /**
  8937. * Prepares the defines for bones
  8938. * @param mesh The mesh containing the geometry data we will draw
  8939. * @param defines The defines to update
  8940. */
  8941. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8942. /**
  8943. * Prepares the defines for morph targets
  8944. * @param mesh The mesh containing the geometry data we will draw
  8945. * @param defines The defines to update
  8946. */
  8947. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8948. /**
  8949. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8950. * @param mesh The mesh containing the geometry data we will draw
  8951. * @param defines The defines to update
  8952. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8953. * @param useBones Precise whether bones should be used or not (override mesh info)
  8954. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8955. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8956. * @returns false if defines are considered not dirty and have not been checked
  8957. */
  8958. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8959. /**
  8960. * Prepares the defines related to multiview
  8961. * @param scene The scene we are intending to draw
  8962. * @param defines The defines to update
  8963. */
  8964. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8965. /**
  8966. * Prepares the defines related to the light information passed in parameter
  8967. * @param scene The scene we are intending to draw
  8968. * @param mesh The mesh the effect is compiling for
  8969. * @param light The light the effect is compiling for
  8970. * @param lightIndex The index of the light
  8971. * @param defines The defines to update
  8972. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8973. * @param state Defines the current state regarding what is needed (normals, etc...)
  8974. */
  8975. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8976. needNormals: boolean;
  8977. needRebuild: boolean;
  8978. shadowEnabled: boolean;
  8979. specularEnabled: boolean;
  8980. lightmapMode: boolean;
  8981. }): void;
  8982. /**
  8983. * Prepares the defines related to the light information passed in parameter
  8984. * @param scene The scene we are intending to draw
  8985. * @param mesh The mesh the effect is compiling for
  8986. * @param defines The defines to update
  8987. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8988. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8989. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8990. * @returns true if normals will be required for the rest of the effect
  8991. */
  8992. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8993. /**
  8994. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8995. * @param lightIndex defines the light index
  8996. * @param uniformsList The uniform list
  8997. * @param samplersList The sampler list
  8998. * @param projectedLightTexture defines if projected texture must be used
  8999. * @param uniformBuffersList defines an optional list of uniform buffers
  9000. */
  9001. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9002. /**
  9003. * Prepares the uniforms and samplers list to be used in the effect
  9004. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9005. * @param samplersList The sampler list
  9006. * @param defines The defines helping in the list generation
  9007. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9008. */
  9009. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9010. /**
  9011. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9012. * @param defines The defines to update while falling back
  9013. * @param fallbacks The authorized effect fallbacks
  9014. * @param maxSimultaneousLights The maximum number of lights allowed
  9015. * @param rank the current rank of the Effect
  9016. * @returns The newly affected rank
  9017. */
  9018. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9019. private static _TmpMorphInfluencers;
  9020. /**
  9021. * Prepares the list of attributes required for morph targets according to the effect defines.
  9022. * @param attribs The current list of supported attribs
  9023. * @param mesh The mesh to prepare the morph targets attributes for
  9024. * @param influencers The number of influencers
  9025. */
  9026. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9027. /**
  9028. * Prepares the list of attributes required for morph targets according to the effect defines.
  9029. * @param attribs The current list of supported attribs
  9030. * @param mesh The mesh to prepare the morph targets attributes for
  9031. * @param defines The current Defines of the effect
  9032. */
  9033. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9034. /**
  9035. * Prepares the list of attributes required for bones according to the effect defines.
  9036. * @param attribs The current list of supported attribs
  9037. * @param mesh The mesh to prepare the bones attributes for
  9038. * @param defines The current Defines of the effect
  9039. * @param fallbacks The current efffect fallback strategy
  9040. */
  9041. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9042. /**
  9043. * Check and prepare the list of attributes required for instances according to the effect defines.
  9044. * @param attribs The current list of supported attribs
  9045. * @param defines The current MaterialDefines of the effect
  9046. */
  9047. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9048. /**
  9049. * Add the list of attributes required for instances to the attribs array.
  9050. * @param attribs The current list of supported attribs
  9051. */
  9052. static PushAttributesForInstances(attribs: string[]): void;
  9053. /**
  9054. * Binds the light shadow information to the effect for the given mesh.
  9055. * @param light The light containing the generator
  9056. * @param scene The scene the lights belongs to
  9057. * @param mesh The mesh we are binding the information to render
  9058. * @param lightIndex The light index in the effect used to render the mesh
  9059. * @param effect The effect we are binding the data to
  9060. */
  9061. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9062. /**
  9063. * Binds the light information to the effect.
  9064. * @param light The light containing the generator
  9065. * @param effect The effect we are binding the data to
  9066. * @param lightIndex The light index in the effect used to render
  9067. */
  9068. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9069. /**
  9070. * Binds the lights information from the scene to the effect for the given mesh.
  9071. * @param light Light to bind
  9072. * @param lightIndex Light index
  9073. * @param scene The scene where the light belongs to
  9074. * @param mesh The mesh we are binding the information to render
  9075. * @param effect The effect we are binding the data to
  9076. * @param useSpecular Defines if specular is supported
  9077. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9078. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9079. */
  9080. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9081. /**
  9082. * Binds the lights information from the scene to the effect for the given mesh.
  9083. * @param scene The scene the lights belongs to
  9084. * @param mesh The mesh we are binding the information to render
  9085. * @param effect The effect we are binding the data to
  9086. * @param defines The generated defines for the effect
  9087. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9088. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9089. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9090. */
  9091. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9092. private static _tempFogColor;
  9093. /**
  9094. * Binds the fog information from the scene to the effect for the given mesh.
  9095. * @param scene The scene the lights belongs to
  9096. * @param mesh The mesh we are binding the information to render
  9097. * @param effect The effect we are binding the data to
  9098. * @param linearSpace Defines if the fog effect is applied in linear space
  9099. */
  9100. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9101. /**
  9102. * Binds the bones information from the mesh to the effect.
  9103. * @param mesh The mesh we are binding the information to render
  9104. * @param effect The effect we are binding the data to
  9105. */
  9106. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9107. /**
  9108. * Binds the morph targets information from the mesh to the effect.
  9109. * @param abstractMesh The mesh we are binding the information to render
  9110. * @param effect The effect we are binding the data to
  9111. */
  9112. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9113. /**
  9114. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9115. * @param defines The generated defines used in the effect
  9116. * @param effect The effect we are binding the data to
  9117. * @param scene The scene we are willing to render with logarithmic scale for
  9118. */
  9119. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9120. /**
  9121. * Binds the clip plane information from the scene to the effect.
  9122. * @param scene The scene the clip plane information are extracted from
  9123. * @param effect The effect we are binding the data to
  9124. */
  9125. static BindClipPlane(effect: Effect, scene: Scene): void;
  9126. }
  9127. }
  9128. declare module BABYLON {
  9129. /** @hidden */
  9130. export var packingFunctions: {
  9131. name: string;
  9132. shader: string;
  9133. };
  9134. }
  9135. declare module BABYLON {
  9136. /** @hidden */
  9137. export var shadowMapPixelShader: {
  9138. name: string;
  9139. shader: string;
  9140. };
  9141. }
  9142. declare module BABYLON {
  9143. /** @hidden */
  9144. export var bonesDeclaration: {
  9145. name: string;
  9146. shader: string;
  9147. };
  9148. }
  9149. declare module BABYLON {
  9150. /** @hidden */
  9151. export var morphTargetsVertexGlobalDeclaration: {
  9152. name: string;
  9153. shader: string;
  9154. };
  9155. }
  9156. declare module BABYLON {
  9157. /** @hidden */
  9158. export var morphTargetsVertexDeclaration: {
  9159. name: string;
  9160. shader: string;
  9161. };
  9162. }
  9163. declare module BABYLON {
  9164. /** @hidden */
  9165. export var instancesDeclaration: {
  9166. name: string;
  9167. shader: string;
  9168. };
  9169. }
  9170. declare module BABYLON {
  9171. /** @hidden */
  9172. export var helperFunctions: {
  9173. name: string;
  9174. shader: string;
  9175. };
  9176. }
  9177. declare module BABYLON {
  9178. /** @hidden */
  9179. export var morphTargetsVertex: {
  9180. name: string;
  9181. shader: string;
  9182. };
  9183. }
  9184. declare module BABYLON {
  9185. /** @hidden */
  9186. export var instancesVertex: {
  9187. name: string;
  9188. shader: string;
  9189. };
  9190. }
  9191. declare module BABYLON {
  9192. /** @hidden */
  9193. export var bonesVertex: {
  9194. name: string;
  9195. shader: string;
  9196. };
  9197. }
  9198. declare module BABYLON {
  9199. /** @hidden */
  9200. export var shadowMapVertexShader: {
  9201. name: string;
  9202. shader: string;
  9203. };
  9204. }
  9205. declare module BABYLON {
  9206. /** @hidden */
  9207. export var depthBoxBlurPixelShader: {
  9208. name: string;
  9209. shader: string;
  9210. };
  9211. }
  9212. declare module BABYLON {
  9213. /**
  9214. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9215. */
  9216. export interface ICustomShaderOptions {
  9217. /**
  9218. * Gets or sets the custom shader name to use
  9219. */
  9220. shaderName: string;
  9221. /**
  9222. * The list of attribute names used in the shader
  9223. */
  9224. attributes?: string[];
  9225. /**
  9226. * The list of unifrom names used in the shader
  9227. */
  9228. uniforms?: string[];
  9229. /**
  9230. * The list of sampler names used in the shader
  9231. */
  9232. samplers?: string[];
  9233. /**
  9234. * The list of defines used in the shader
  9235. */
  9236. defines?: string[];
  9237. }
  9238. /**
  9239. * Interface to implement to create a shadow generator compatible with BJS.
  9240. */
  9241. export interface IShadowGenerator {
  9242. /**
  9243. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9244. * @returns The render target texture if present otherwise, null
  9245. */
  9246. getShadowMap(): Nullable<RenderTargetTexture>;
  9247. /**
  9248. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9249. * @returns The render target texture if the shadow map is present otherwise, null
  9250. */
  9251. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9252. /**
  9253. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9254. * @param subMesh The submesh we want to render in the shadow map
  9255. * @param useInstances Defines wether will draw in the map using instances
  9256. * @returns true if ready otherwise, false
  9257. */
  9258. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9259. /**
  9260. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9261. * @param defines Defines of the material we want to update
  9262. * @param lightIndex Index of the light in the enabled light list of the material
  9263. */
  9264. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9265. /**
  9266. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9267. * defined in the generator but impacting the effect).
  9268. * It implies the unifroms available on the materials are the standard BJS ones.
  9269. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9270. * @param effect The effect we are binfing the information for
  9271. */
  9272. bindShadowLight(lightIndex: string, effect: Effect): void;
  9273. /**
  9274. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9275. * (eq to shadow prjection matrix * light transform matrix)
  9276. * @returns The transform matrix used to create the shadow map
  9277. */
  9278. getTransformMatrix(): Matrix;
  9279. /**
  9280. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9281. * Cube and 2D textures for instance.
  9282. */
  9283. recreateShadowMap(): void;
  9284. /**
  9285. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9286. * @param onCompiled Callback triggered at the and of the effects compilation
  9287. * @param options Sets of optional options forcing the compilation with different modes
  9288. */
  9289. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9290. useInstances: boolean;
  9291. }>): void;
  9292. /**
  9293. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9294. * @param options Sets of optional options forcing the compilation with different modes
  9295. * @returns A promise that resolves when the compilation completes
  9296. */
  9297. forceCompilationAsync(options?: Partial<{
  9298. useInstances: boolean;
  9299. }>): Promise<void>;
  9300. /**
  9301. * Serializes the shadow generator setup to a json object.
  9302. * @returns The serialized JSON object
  9303. */
  9304. serialize(): any;
  9305. /**
  9306. * Disposes the Shadow map and related Textures and effects.
  9307. */
  9308. dispose(): void;
  9309. }
  9310. /**
  9311. * Default implementation IShadowGenerator.
  9312. * This is the main object responsible of generating shadows in the framework.
  9313. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9314. */
  9315. export class ShadowGenerator implements IShadowGenerator {
  9316. /**
  9317. * Shadow generator mode None: no filtering applied.
  9318. */
  9319. static readonly FILTER_NONE: number;
  9320. /**
  9321. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9322. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9323. */
  9324. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9325. /**
  9326. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9327. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9328. */
  9329. static readonly FILTER_POISSONSAMPLING: number;
  9330. /**
  9331. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9332. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9333. */
  9334. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9335. /**
  9336. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9337. * edge artifacts on steep falloff.
  9338. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9339. */
  9340. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9341. /**
  9342. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9343. * edge artifacts on steep falloff.
  9344. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9345. */
  9346. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9347. /**
  9348. * Shadow generator mode PCF: Percentage Closer Filtering
  9349. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9350. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9351. */
  9352. static readonly FILTER_PCF: number;
  9353. /**
  9354. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9355. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9356. * Contact Hardening
  9357. */
  9358. static readonly FILTER_PCSS: number;
  9359. /**
  9360. * Reserved for PCF and PCSS
  9361. * Highest Quality.
  9362. *
  9363. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9364. *
  9365. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9366. */
  9367. static readonly QUALITY_HIGH: number;
  9368. /**
  9369. * Reserved for PCF and PCSS
  9370. * Good tradeoff for quality/perf cross devices
  9371. *
  9372. * Execute PCF on a 3*3 kernel.
  9373. *
  9374. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9375. */
  9376. static readonly QUALITY_MEDIUM: number;
  9377. /**
  9378. * Reserved for PCF and PCSS
  9379. * The lowest quality but the fastest.
  9380. *
  9381. * Execute PCF on a 1*1 kernel.
  9382. *
  9383. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9384. */
  9385. static readonly QUALITY_LOW: number;
  9386. /** Gets or sets the custom shader name to use */
  9387. customShaderOptions: ICustomShaderOptions;
  9388. /**
  9389. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9390. */
  9391. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9392. /**
  9393. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9394. */
  9395. onAfterShadowMapRenderObservable: Observable<Effect>;
  9396. /**
  9397. * Observable triggered before a mesh is rendered in the shadow map.
  9398. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9399. */
  9400. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9401. /**
  9402. * Observable triggered after a mesh is rendered in the shadow map.
  9403. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9404. */
  9405. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9406. private _bias;
  9407. /**
  9408. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9409. */
  9410. /**
  9411. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9412. */
  9413. bias: number;
  9414. private _normalBias;
  9415. /**
  9416. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9417. */
  9418. /**
  9419. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9420. */
  9421. normalBias: number;
  9422. private _blurBoxOffset;
  9423. /**
  9424. * Gets the blur box offset: offset applied during the blur pass.
  9425. * Only useful if useKernelBlur = false
  9426. */
  9427. /**
  9428. * Sets the blur box offset: offset applied during the blur pass.
  9429. * Only useful if useKernelBlur = false
  9430. */
  9431. blurBoxOffset: number;
  9432. private _blurScale;
  9433. /**
  9434. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9435. * 2 means half of the size.
  9436. */
  9437. /**
  9438. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9439. * 2 means half of the size.
  9440. */
  9441. blurScale: number;
  9442. private _blurKernel;
  9443. /**
  9444. * Gets the blur kernel: kernel size of the blur pass.
  9445. * Only useful if useKernelBlur = true
  9446. */
  9447. /**
  9448. * Sets the blur kernel: kernel size of the blur pass.
  9449. * Only useful if useKernelBlur = true
  9450. */
  9451. blurKernel: number;
  9452. private _useKernelBlur;
  9453. /**
  9454. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9455. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9456. */
  9457. /**
  9458. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9459. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9460. */
  9461. useKernelBlur: boolean;
  9462. private _depthScale;
  9463. /**
  9464. * Gets the depth scale used in ESM mode.
  9465. */
  9466. /**
  9467. * Sets the depth scale used in ESM mode.
  9468. * This can override the scale stored on the light.
  9469. */
  9470. depthScale: number;
  9471. private _filter;
  9472. /**
  9473. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9474. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9475. */
  9476. /**
  9477. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9478. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9479. */
  9480. filter: number;
  9481. /**
  9482. * Gets if the current filter is set to Poisson Sampling.
  9483. */
  9484. /**
  9485. * Sets the current filter to Poisson Sampling.
  9486. */
  9487. usePoissonSampling: boolean;
  9488. /**
  9489. * Gets if the current filter is set to ESM.
  9490. */
  9491. /**
  9492. * Sets the current filter is to ESM.
  9493. */
  9494. useExponentialShadowMap: boolean;
  9495. /**
  9496. * Gets if the current filter is set to filtered ESM.
  9497. */
  9498. /**
  9499. * Gets if the current filter is set to filtered ESM.
  9500. */
  9501. useBlurExponentialShadowMap: boolean;
  9502. /**
  9503. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9504. * exponential to prevent steep falloff artifacts).
  9505. */
  9506. /**
  9507. * Sets the current filter to "close ESM" (using the inverse of the
  9508. * exponential to prevent steep falloff artifacts).
  9509. */
  9510. useCloseExponentialShadowMap: boolean;
  9511. /**
  9512. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9513. * exponential to prevent steep falloff artifacts).
  9514. */
  9515. /**
  9516. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9517. * exponential to prevent steep falloff artifacts).
  9518. */
  9519. useBlurCloseExponentialShadowMap: boolean;
  9520. /**
  9521. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9522. */
  9523. /**
  9524. * Sets the current filter to "PCF" (percentage closer filtering).
  9525. */
  9526. usePercentageCloserFiltering: boolean;
  9527. private _filteringQuality;
  9528. /**
  9529. * Gets the PCF or PCSS Quality.
  9530. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9531. */
  9532. /**
  9533. * Sets the PCF or PCSS Quality.
  9534. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9535. */
  9536. filteringQuality: number;
  9537. /**
  9538. * Gets if the current filter is set to "PCSS" (contact hardening).
  9539. */
  9540. /**
  9541. * Sets the current filter to "PCSS" (contact hardening).
  9542. */
  9543. useContactHardeningShadow: boolean;
  9544. private _contactHardeningLightSizeUVRatio;
  9545. /**
  9546. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9547. * Using a ratio helps keeping shape stability independently of the map size.
  9548. *
  9549. * It does not account for the light projection as it was having too much
  9550. * instability during the light setup or during light position changes.
  9551. *
  9552. * Only valid if useContactHardeningShadow is true.
  9553. */
  9554. /**
  9555. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9556. * Using a ratio helps keeping shape stability independently of the map size.
  9557. *
  9558. * It does not account for the light projection as it was having too much
  9559. * instability during the light setup or during light position changes.
  9560. *
  9561. * Only valid if useContactHardeningShadow is true.
  9562. */
  9563. contactHardeningLightSizeUVRatio: number;
  9564. private _darkness;
  9565. /** Gets or sets the actual darkness of a shadow */
  9566. darkness: number;
  9567. /**
  9568. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9569. * 0 means strongest and 1 would means no shadow.
  9570. * @returns the darkness.
  9571. */
  9572. getDarkness(): number;
  9573. /**
  9574. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9575. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9576. * @returns the shadow generator allowing fluent coding.
  9577. */
  9578. setDarkness(darkness: number): ShadowGenerator;
  9579. private _transparencyShadow;
  9580. /** Gets or sets the ability to have transparent shadow */
  9581. transparencyShadow: boolean;
  9582. /**
  9583. * Sets the ability to have transparent shadow (boolean).
  9584. * @param transparent True if transparent else False
  9585. * @returns the shadow generator allowing fluent coding
  9586. */
  9587. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9588. private _shadowMap;
  9589. private _shadowMap2;
  9590. /**
  9591. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9592. * @returns The render target texture if present otherwise, null
  9593. */
  9594. getShadowMap(): Nullable<RenderTargetTexture>;
  9595. /**
  9596. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9597. * @returns The render target texture if the shadow map is present otherwise, null
  9598. */
  9599. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9600. /**
  9601. * Gets the class name of that object
  9602. * @returns "ShadowGenerator"
  9603. */
  9604. getClassName(): string;
  9605. /**
  9606. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9607. * @param mesh Mesh to add
  9608. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9609. * @returns the Shadow Generator itself
  9610. */
  9611. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9612. /**
  9613. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9614. * @param mesh Mesh to remove
  9615. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9616. * @returns the Shadow Generator itself
  9617. */
  9618. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9619. /**
  9620. * Controls the extent to which the shadows fade out at the edge of the frustum
  9621. * Used only by directionals and spots
  9622. */
  9623. frustumEdgeFalloff: number;
  9624. private _light;
  9625. /**
  9626. * Returns the associated light object.
  9627. * @returns the light generating the shadow
  9628. */
  9629. getLight(): IShadowLight;
  9630. /**
  9631. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9632. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9633. * It might on the other hand introduce peter panning.
  9634. */
  9635. forceBackFacesOnly: boolean;
  9636. private _scene;
  9637. private _lightDirection;
  9638. private _effect;
  9639. private _viewMatrix;
  9640. private _projectionMatrix;
  9641. private _transformMatrix;
  9642. private _cachedPosition;
  9643. private _cachedDirection;
  9644. private _cachedDefines;
  9645. private _currentRenderID;
  9646. private _boxBlurPostprocess;
  9647. private _kernelBlurXPostprocess;
  9648. private _kernelBlurYPostprocess;
  9649. private _blurPostProcesses;
  9650. private _mapSize;
  9651. private _currentFaceIndex;
  9652. private _currentFaceIndexCache;
  9653. private _textureType;
  9654. private _defaultTextureMatrix;
  9655. private _storedUniqueId;
  9656. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9657. /**
  9658. * Creates a ShadowGenerator object.
  9659. * A ShadowGenerator is the required tool to use the shadows.
  9660. * Each light casting shadows needs to use its own ShadowGenerator.
  9661. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9662. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9663. * @param light The light object generating the shadows.
  9664. * @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.
  9665. */
  9666. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9667. private _initializeGenerator;
  9668. private _initializeShadowMap;
  9669. private _initializeBlurRTTAndPostProcesses;
  9670. private _renderForShadowMap;
  9671. private _renderSubMeshForShadowMap;
  9672. private _applyFilterValues;
  9673. /**
  9674. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9675. * @param onCompiled Callback triggered at the and of the effects compilation
  9676. * @param options Sets of optional options forcing the compilation with different modes
  9677. */
  9678. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9679. useInstances: boolean;
  9680. }>): void;
  9681. /**
  9682. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9683. * @param options Sets of optional options forcing the compilation with different modes
  9684. * @returns A promise that resolves when the compilation completes
  9685. */
  9686. forceCompilationAsync(options?: Partial<{
  9687. useInstances: boolean;
  9688. }>): Promise<void>;
  9689. /**
  9690. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9691. * @param subMesh The submesh we want to render in the shadow map
  9692. * @param useInstances Defines wether will draw in the map using instances
  9693. * @returns true if ready otherwise, false
  9694. */
  9695. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9696. /**
  9697. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9698. * @param defines Defines of the material we want to update
  9699. * @param lightIndex Index of the light in the enabled light list of the material
  9700. */
  9701. prepareDefines(defines: any, lightIndex: number): void;
  9702. /**
  9703. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9704. * defined in the generator but impacting the effect).
  9705. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9706. * @param effect The effect we are binfing the information for
  9707. */
  9708. bindShadowLight(lightIndex: string, effect: Effect): void;
  9709. /**
  9710. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9711. * (eq to shadow prjection matrix * light transform matrix)
  9712. * @returns The transform matrix used to create the shadow map
  9713. */
  9714. getTransformMatrix(): Matrix;
  9715. /**
  9716. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9717. * Cube and 2D textures for instance.
  9718. */
  9719. recreateShadowMap(): void;
  9720. private _disposeBlurPostProcesses;
  9721. private _disposeRTTandPostProcesses;
  9722. /**
  9723. * Disposes the ShadowGenerator.
  9724. * Returns nothing.
  9725. */
  9726. dispose(): void;
  9727. /**
  9728. * Serializes the shadow generator setup to a json object.
  9729. * @returns The serialized JSON object
  9730. */
  9731. serialize(): any;
  9732. /**
  9733. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9734. * @param parsedShadowGenerator The JSON object to parse
  9735. * @param scene The scene to create the shadow map for
  9736. * @returns The parsed shadow generator
  9737. */
  9738. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9739. }
  9740. }
  9741. declare module BABYLON {
  9742. /**
  9743. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9744. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9745. * 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.
  9746. */
  9747. export abstract class Light extends Node {
  9748. /**
  9749. * Falloff Default: light is falling off following the material specification:
  9750. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9751. */
  9752. static readonly FALLOFF_DEFAULT: number;
  9753. /**
  9754. * Falloff Physical: light is falling off following the inverse squared distance law.
  9755. */
  9756. static readonly FALLOFF_PHYSICAL: number;
  9757. /**
  9758. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9759. * to enhance interoperability with other engines.
  9760. */
  9761. static readonly FALLOFF_GLTF: number;
  9762. /**
  9763. * Falloff Standard: light is falling off like in the standard material
  9764. * to enhance interoperability with other materials.
  9765. */
  9766. static readonly FALLOFF_STANDARD: number;
  9767. /**
  9768. * If every light affecting the material is in this lightmapMode,
  9769. * material.lightmapTexture adds or multiplies
  9770. * (depends on material.useLightmapAsShadowmap)
  9771. * after every other light calculations.
  9772. */
  9773. static readonly LIGHTMAP_DEFAULT: number;
  9774. /**
  9775. * material.lightmapTexture as only diffuse lighting from this light
  9776. * adds only specular lighting from this light
  9777. * adds dynamic shadows
  9778. */
  9779. static readonly LIGHTMAP_SPECULAR: number;
  9780. /**
  9781. * material.lightmapTexture as only lighting
  9782. * no light calculation from this light
  9783. * only adds dynamic shadows from this light
  9784. */
  9785. static readonly LIGHTMAP_SHADOWSONLY: number;
  9786. /**
  9787. * Each light type uses the default quantity according to its type:
  9788. * point/spot lights use luminous intensity
  9789. * directional lights use illuminance
  9790. */
  9791. static readonly INTENSITYMODE_AUTOMATIC: number;
  9792. /**
  9793. * lumen (lm)
  9794. */
  9795. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9796. /**
  9797. * candela (lm/sr)
  9798. */
  9799. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9800. /**
  9801. * lux (lm/m^2)
  9802. */
  9803. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9804. /**
  9805. * nit (cd/m^2)
  9806. */
  9807. static readonly INTENSITYMODE_LUMINANCE: number;
  9808. /**
  9809. * Light type const id of the point light.
  9810. */
  9811. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9812. /**
  9813. * Light type const id of the directional light.
  9814. */
  9815. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9816. /**
  9817. * Light type const id of the spot light.
  9818. */
  9819. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9820. /**
  9821. * Light type const id of the hemispheric light.
  9822. */
  9823. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9824. /**
  9825. * Diffuse gives the basic color to an object.
  9826. */
  9827. diffuse: Color3;
  9828. /**
  9829. * Specular produces a highlight color on an object.
  9830. * Note: This is note affecting PBR materials.
  9831. */
  9832. specular: Color3;
  9833. /**
  9834. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9835. * falling off base on range or angle.
  9836. * This can be set to any values in Light.FALLOFF_x.
  9837. *
  9838. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9839. * other types of materials.
  9840. */
  9841. falloffType: number;
  9842. /**
  9843. * Strength of the light.
  9844. * Note: By default it is define in the framework own unit.
  9845. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9846. */
  9847. intensity: number;
  9848. private _range;
  9849. protected _inverseSquaredRange: number;
  9850. /**
  9851. * Defines how far from the source the light is impacting in scene units.
  9852. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9853. */
  9854. /**
  9855. * Defines how far from the source the light is impacting in scene units.
  9856. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9857. */
  9858. range: number;
  9859. /**
  9860. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9861. * of light.
  9862. */
  9863. private _photometricScale;
  9864. private _intensityMode;
  9865. /**
  9866. * Gets the photometric scale used to interpret the intensity.
  9867. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9868. */
  9869. /**
  9870. * Sets the photometric scale used to interpret the intensity.
  9871. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9872. */
  9873. intensityMode: number;
  9874. private _radius;
  9875. /**
  9876. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9877. */
  9878. /**
  9879. * sets the light radius used by PBR Materials to simulate soft area lights.
  9880. */
  9881. radius: number;
  9882. private _renderPriority;
  9883. /**
  9884. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9885. * exceeding the number allowed of the materials.
  9886. */
  9887. renderPriority: number;
  9888. private _shadowEnabled;
  9889. /**
  9890. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9891. * the current shadow generator.
  9892. */
  9893. /**
  9894. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9895. * the current shadow generator.
  9896. */
  9897. shadowEnabled: boolean;
  9898. private _includedOnlyMeshes;
  9899. /**
  9900. * Gets the only meshes impacted by this light.
  9901. */
  9902. /**
  9903. * Sets the only meshes impacted by this light.
  9904. */
  9905. includedOnlyMeshes: AbstractMesh[];
  9906. private _excludedMeshes;
  9907. /**
  9908. * Gets the meshes not impacted by this light.
  9909. */
  9910. /**
  9911. * Sets the meshes not impacted by this light.
  9912. */
  9913. excludedMeshes: AbstractMesh[];
  9914. private _excludeWithLayerMask;
  9915. /**
  9916. * Gets the layer id use to find what meshes are not impacted by the light.
  9917. * Inactive if 0
  9918. */
  9919. /**
  9920. * Sets the layer id use to find what meshes are not impacted by the light.
  9921. * Inactive if 0
  9922. */
  9923. excludeWithLayerMask: number;
  9924. private _includeOnlyWithLayerMask;
  9925. /**
  9926. * Gets the layer id use to find what meshes are impacted by the light.
  9927. * Inactive if 0
  9928. */
  9929. /**
  9930. * Sets the layer id use to find what meshes are impacted by the light.
  9931. * Inactive if 0
  9932. */
  9933. includeOnlyWithLayerMask: number;
  9934. private _lightmapMode;
  9935. /**
  9936. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9937. */
  9938. /**
  9939. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9940. */
  9941. lightmapMode: number;
  9942. /**
  9943. * Shadow generator associted to the light.
  9944. * @hidden Internal use only.
  9945. */ private _shadowGenerator: Nullable<IShadowGenerator>;
  9946. /**
  9947. * @hidden Internal use only.
  9948. */ private _excludedMeshesIds: string[];
  9949. /**
  9950. * @hidden Internal use only.
  9951. */ private _includedOnlyMeshesIds: string[];
  9952. /**
  9953. * The current light unifom buffer.
  9954. * @hidden Internal use only.
  9955. */ private _uniformBuffer: UniformBuffer;
  9956. /**
  9957. * Creates a Light object in the scene.
  9958. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9959. * @param name The firendly name of the light
  9960. * @param scene The scene the light belongs too
  9961. */
  9962. constructor(name: string, scene: Scene);
  9963. protected abstract _buildUniformLayout(): void;
  9964. /**
  9965. * Sets the passed Effect "effect" with the Light information.
  9966. * @param effect The effect to update
  9967. * @param lightIndex The index of the light in the effect to update
  9968. * @returns The light
  9969. */
  9970. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9971. /**
  9972. * Sets the passed Effect "effect" with the Light information.
  9973. * @param effect The effect to update
  9974. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9975. * @returns The light
  9976. */
  9977. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9978. /**
  9979. * Returns the string "Light".
  9980. * @returns the class name
  9981. */
  9982. getClassName(): string;
  9983. /** @hidden */ protected readonly _isLight: boolean;
  9984. /**
  9985. * Converts the light information to a readable string for debug purpose.
  9986. * @param fullDetails Supports for multiple levels of logging within scene loading
  9987. * @returns the human readable light info
  9988. */
  9989. toString(fullDetails?: boolean): string;
  9990. /** @hidden */
  9991. protected _syncParentEnabledState(): void;
  9992. /**
  9993. * Set the enabled state of this node.
  9994. * @param value - the new enabled state
  9995. */
  9996. setEnabled(value: boolean): void;
  9997. /**
  9998. * Returns the Light associated shadow generator if any.
  9999. * @return the associated shadow generator.
  10000. */
  10001. getShadowGenerator(): Nullable<IShadowGenerator>;
  10002. /**
  10003. * Returns a Vector3, the absolute light position in the World.
  10004. * @returns the world space position of the light
  10005. */
  10006. getAbsolutePosition(): Vector3;
  10007. /**
  10008. * Specifies if the light will affect the passed mesh.
  10009. * @param mesh The mesh to test against the light
  10010. * @return true the mesh is affected otherwise, false.
  10011. */
  10012. canAffectMesh(mesh: AbstractMesh): boolean;
  10013. /**
  10014. * Sort function to order lights for rendering.
  10015. * @param a First Light object to compare to second.
  10016. * @param b Second Light object to compare first.
  10017. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10018. */
  10019. static CompareLightsPriority(a: Light, b: Light): number;
  10020. /**
  10021. * Releases resources associated with this node.
  10022. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10023. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10024. */
  10025. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10026. /**
  10027. * Returns the light type ID (integer).
  10028. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10029. */
  10030. getTypeID(): number;
  10031. /**
  10032. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10033. * @returns the scaled intensity in intensity mode unit
  10034. */
  10035. getScaledIntensity(): number;
  10036. /**
  10037. * Returns a new Light object, named "name", from the current one.
  10038. * @param name The name of the cloned light
  10039. * @returns the new created light
  10040. */
  10041. clone(name: string): Nullable<Light>;
  10042. /**
  10043. * Serializes the current light into a Serialization object.
  10044. * @returns the serialized object.
  10045. */
  10046. serialize(): any;
  10047. /**
  10048. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10049. * This new light is named "name" and added to the passed scene.
  10050. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10051. * @param name The friendly name of the light
  10052. * @param scene The scene the new light will belong to
  10053. * @returns the constructor function
  10054. */
  10055. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10056. /**
  10057. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10058. * @param parsedLight The JSON representation of the light
  10059. * @param scene The scene to create the parsed light in
  10060. * @returns the created light after parsing
  10061. */
  10062. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10063. private _hookArrayForExcluded;
  10064. private _hookArrayForIncludedOnly;
  10065. private _resyncMeshes;
  10066. /**
  10067. * Forces the meshes to update their light related information in their rendering used effects
  10068. * @hidden Internal Use Only
  10069. */ private _markMeshesAsLightDirty(): void;
  10070. /**
  10071. * Recomputes the cached photometric scale if needed.
  10072. */
  10073. private _computePhotometricScale;
  10074. /**
  10075. * Returns the Photometric Scale according to the light type and intensity mode.
  10076. */
  10077. private _getPhotometricScale;
  10078. /**
  10079. * Reorder the light in the scene according to their defined priority.
  10080. * @hidden Internal Use Only
  10081. */ private _reorderLightsInScene(): void;
  10082. /**
  10083. * Prepares the list of defines specific to the light type.
  10084. * @param defines the list of defines
  10085. * @param lightIndex defines the index of the light for the effect
  10086. */
  10087. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10088. }
  10089. }
  10090. declare module BABYLON {
  10091. /**
  10092. * Interface used to define Action
  10093. */
  10094. export interface IAction {
  10095. /**
  10096. * Trigger for the action
  10097. */
  10098. trigger: number;
  10099. /** Options of the trigger */
  10100. triggerOptions: any;
  10101. /**
  10102. * Gets the trigger parameters
  10103. * @returns the trigger parameters
  10104. */
  10105. getTriggerParameter(): any;
  10106. /**
  10107. * Internal only - executes current action event
  10108. * @hidden
  10109. */ private _executeCurrent(evt?: ActionEvent): void;
  10110. /**
  10111. * Serialize placeholder for child classes
  10112. * @param parent of child
  10113. * @returns the serialized object
  10114. */
  10115. serialize(parent: any): any;
  10116. /**
  10117. * Internal only
  10118. * @hidden
  10119. */ private _prepare(): void;
  10120. /**
  10121. * Internal only - manager for action
  10122. * @hidden
  10123. */ private _actionManager: AbstractActionManager;
  10124. /**
  10125. * Adds action to chain of actions, may be a DoNothingAction
  10126. * @param action defines the next action to execute
  10127. * @returns The action passed in
  10128. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10129. */
  10130. then(action: IAction): IAction;
  10131. }
  10132. /**
  10133. * The action to be carried out following a trigger
  10134. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10135. */
  10136. export class Action implements IAction {
  10137. /** the trigger, with or without parameters, for the action */
  10138. triggerOptions: any;
  10139. /**
  10140. * Trigger for the action
  10141. */
  10142. trigger: number;
  10143. /**
  10144. * Internal only - manager for action
  10145. * @hidden
  10146. */ private _actionManager: ActionManager;
  10147. private _nextActiveAction;
  10148. private _child;
  10149. private _condition?;
  10150. private _triggerParameter;
  10151. /**
  10152. * An event triggered prior to action being executed.
  10153. */
  10154. onBeforeExecuteObservable: Observable<Action>;
  10155. /**
  10156. * Creates a new Action
  10157. * @param triggerOptions the trigger, with or without parameters, for the action
  10158. * @param condition an optional determinant of action
  10159. */
  10160. constructor(
  10161. /** the trigger, with or without parameters, for the action */
  10162. triggerOptions: any, condition?: Condition);
  10163. /**
  10164. * Internal only
  10165. * @hidden
  10166. */ private _prepare(): void;
  10167. /**
  10168. * Gets the trigger parameters
  10169. * @returns the trigger parameters
  10170. */
  10171. getTriggerParameter(): any;
  10172. /**
  10173. * Internal only - executes current action event
  10174. * @hidden
  10175. */ private _executeCurrent(evt?: ActionEvent): void;
  10176. /**
  10177. * Execute placeholder for child classes
  10178. * @param evt optional action event
  10179. */
  10180. execute(evt?: ActionEvent): void;
  10181. /**
  10182. * Skips to next active action
  10183. */
  10184. skipToNextActiveAction(): void;
  10185. /**
  10186. * Adds action to chain of actions, may be a DoNothingAction
  10187. * @param action defines the next action to execute
  10188. * @returns The action passed in
  10189. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10190. */
  10191. then(action: Action): Action;
  10192. /**
  10193. * Internal only
  10194. * @hidden
  10195. */ private _getProperty(propertyPath: string): string;
  10196. /**
  10197. * Internal only
  10198. * @hidden
  10199. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10200. /**
  10201. * Serialize placeholder for child classes
  10202. * @param parent of child
  10203. * @returns the serialized object
  10204. */
  10205. serialize(parent: any): any;
  10206. /**
  10207. * Internal only called by serialize
  10208. * @hidden
  10209. */
  10210. protected _serialize(serializedAction: any, parent?: any): any;
  10211. /**
  10212. * Internal only
  10213. * @hidden
  10214. */ private static _SerializeValueAsString: (value: any) => string;
  10215. /**
  10216. * Internal only
  10217. * @hidden
  10218. */ private static _GetTargetProperty: (target: Node | Scene) => {
  10219. name: string;
  10220. targetType: string;
  10221. value: string;
  10222. };
  10223. }
  10224. }
  10225. declare module BABYLON {
  10226. /**
  10227. * A Condition applied to an Action
  10228. */
  10229. export class Condition {
  10230. /**
  10231. * Internal only - manager for action
  10232. * @hidden
  10233. */ private _actionManager: ActionManager;
  10234. /**
  10235. * Internal only
  10236. * @hidden
  10237. */ private _evaluationId: number;
  10238. /**
  10239. * Internal only
  10240. * @hidden
  10241. */ private _currentResult: boolean;
  10242. /**
  10243. * Creates a new Condition
  10244. * @param actionManager the manager of the action the condition is applied to
  10245. */
  10246. constructor(actionManager: ActionManager);
  10247. /**
  10248. * Check if the current condition is valid
  10249. * @returns a boolean
  10250. */
  10251. isValid(): boolean;
  10252. /**
  10253. * Internal only
  10254. * @hidden
  10255. */ private _getProperty(propertyPath: string): string;
  10256. /**
  10257. * Internal only
  10258. * @hidden
  10259. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10260. /**
  10261. * Serialize placeholder for child classes
  10262. * @returns the serialized object
  10263. */
  10264. serialize(): any;
  10265. /**
  10266. * Internal only
  10267. * @hidden
  10268. */
  10269. protected _serialize(serializedCondition: any): any;
  10270. }
  10271. /**
  10272. * Defines specific conditional operators as extensions of Condition
  10273. */
  10274. export class ValueCondition extends Condition {
  10275. /** path to specify the property of the target the conditional operator uses */
  10276. propertyPath: string;
  10277. /** the value compared by the conditional operator against the current value of the property */
  10278. value: any;
  10279. /** the conditional operator, default ValueCondition.IsEqual */
  10280. operator: number;
  10281. /**
  10282. * Internal only
  10283. * @hidden
  10284. */
  10285. private static _IsEqual;
  10286. /**
  10287. * Internal only
  10288. * @hidden
  10289. */
  10290. private static _IsDifferent;
  10291. /**
  10292. * Internal only
  10293. * @hidden
  10294. */
  10295. private static _IsGreater;
  10296. /**
  10297. * Internal only
  10298. * @hidden
  10299. */
  10300. private static _IsLesser;
  10301. /**
  10302. * returns the number for IsEqual
  10303. */
  10304. static readonly IsEqual: number;
  10305. /**
  10306. * Returns the number for IsDifferent
  10307. */
  10308. static readonly IsDifferent: number;
  10309. /**
  10310. * Returns the number for IsGreater
  10311. */
  10312. static readonly IsGreater: number;
  10313. /**
  10314. * Returns the number for IsLesser
  10315. */
  10316. static readonly IsLesser: number;
  10317. /**
  10318. * Internal only The action manager for the condition
  10319. * @hidden
  10320. */ private _actionManager: ActionManager;
  10321. /**
  10322. * Internal only
  10323. * @hidden
  10324. */
  10325. private _target;
  10326. /**
  10327. * Internal only
  10328. * @hidden
  10329. */
  10330. private _effectiveTarget;
  10331. /**
  10332. * Internal only
  10333. * @hidden
  10334. */
  10335. private _property;
  10336. /**
  10337. * Creates a new ValueCondition
  10338. * @param actionManager manager for the action the condition applies to
  10339. * @param target for the action
  10340. * @param propertyPath path to specify the property of the target the conditional operator uses
  10341. * @param value the value compared by the conditional operator against the current value of the property
  10342. * @param operator the conditional operator, default ValueCondition.IsEqual
  10343. */
  10344. constructor(actionManager: ActionManager, target: any,
  10345. /** path to specify the property of the target the conditional operator uses */
  10346. propertyPath: string,
  10347. /** the value compared by the conditional operator against the current value of the property */
  10348. value: any,
  10349. /** the conditional operator, default ValueCondition.IsEqual */
  10350. operator?: number);
  10351. /**
  10352. * Compares the given value with the property value for the specified conditional operator
  10353. * @returns the result of the comparison
  10354. */
  10355. isValid(): boolean;
  10356. /**
  10357. * Serialize the ValueCondition into a JSON compatible object
  10358. * @returns serialization object
  10359. */
  10360. serialize(): any;
  10361. /**
  10362. * Gets the name of the conditional operator for the ValueCondition
  10363. * @param operator the conditional operator
  10364. * @returns the name
  10365. */
  10366. static GetOperatorName(operator: number): string;
  10367. }
  10368. /**
  10369. * Defines a predicate condition as an extension of Condition
  10370. */
  10371. export class PredicateCondition extends Condition {
  10372. /** defines the predicate function used to validate the condition */
  10373. predicate: () => boolean;
  10374. /**
  10375. * Internal only - manager for action
  10376. * @hidden
  10377. */ private _actionManager: ActionManager;
  10378. /**
  10379. * Creates a new PredicateCondition
  10380. * @param actionManager manager for the action the condition applies to
  10381. * @param predicate defines the predicate function used to validate the condition
  10382. */
  10383. constructor(actionManager: ActionManager,
  10384. /** defines the predicate function used to validate the condition */
  10385. predicate: () => boolean);
  10386. /**
  10387. * @returns the validity of the predicate condition
  10388. */
  10389. isValid(): boolean;
  10390. }
  10391. /**
  10392. * Defines a state condition as an extension of Condition
  10393. */
  10394. export class StateCondition extends Condition {
  10395. /** Value to compare with target state */
  10396. value: string;
  10397. /**
  10398. * Internal only - manager for action
  10399. * @hidden
  10400. */ private _actionManager: ActionManager;
  10401. /**
  10402. * Internal only
  10403. * @hidden
  10404. */
  10405. private _target;
  10406. /**
  10407. * Creates a new StateCondition
  10408. * @param actionManager manager for the action the condition applies to
  10409. * @param target of the condition
  10410. * @param value to compare with target state
  10411. */
  10412. constructor(actionManager: ActionManager, target: any,
  10413. /** Value to compare with target state */
  10414. value: string);
  10415. /**
  10416. * Gets a boolean indicating if the current condition is met
  10417. * @returns the validity of the state
  10418. */
  10419. isValid(): boolean;
  10420. /**
  10421. * Serialize the StateCondition into a JSON compatible object
  10422. * @returns serialization object
  10423. */
  10424. serialize(): any;
  10425. }
  10426. }
  10427. declare module BABYLON {
  10428. /**
  10429. * This defines an action responsible to toggle a boolean once triggered.
  10430. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10431. */
  10432. export class SwitchBooleanAction extends Action {
  10433. /**
  10434. * The path to the boolean property in the target object
  10435. */
  10436. propertyPath: string;
  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 boolean
  10444. * @param propertyPath defines the path to the boolean property in the target object
  10445. * @param condition defines the trigger related conditions
  10446. */
  10447. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10448. /** @hidden */ private _prepare(): void;
  10449. /**
  10450. * Execute the action toggle the boolean value.
  10451. */
  10452. execute(): void;
  10453. /**
  10454. * Serializes the actions and its related information.
  10455. * @param parent defines the object to serialize in
  10456. * @returns the serialized object
  10457. */
  10458. serialize(parent: any): any;
  10459. }
  10460. /**
  10461. * This defines an action responsible to set a the state field of the target
  10462. * to a desired value once triggered.
  10463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10464. */
  10465. export class SetStateAction extends Action {
  10466. /**
  10467. * The value to store in the state field.
  10468. */
  10469. value: string;
  10470. private _target;
  10471. /**
  10472. * Instantiate the action
  10473. * @param triggerOptions defines the trigger options
  10474. * @param target defines the object containing the state property
  10475. * @param value defines the value to store in the state field
  10476. * @param condition defines the trigger related conditions
  10477. */
  10478. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10479. /**
  10480. * Execute the action and store the value on the target state property.
  10481. */
  10482. execute(): void;
  10483. /**
  10484. * Serializes the actions and its related information.
  10485. * @param parent defines the object to serialize in
  10486. * @returns the serialized object
  10487. */
  10488. serialize(parent: any): any;
  10489. }
  10490. /**
  10491. * This defines an action responsible to set a property of the target
  10492. * to a desired value once triggered.
  10493. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10494. */
  10495. export class SetValueAction extends Action {
  10496. /**
  10497. * The path of the property to set in the target.
  10498. */
  10499. propertyPath: string;
  10500. /**
  10501. * The value to set in the property
  10502. */
  10503. value: any;
  10504. private _target;
  10505. private _effectiveTarget;
  10506. private _property;
  10507. /**
  10508. * Instantiate the action
  10509. * @param triggerOptions defines the trigger options
  10510. * @param target defines the object containing the property
  10511. * @param propertyPath defines the path of the property to set in the target
  10512. * @param value defines the value to set in the property
  10513. * @param condition defines the trigger related conditions
  10514. */
  10515. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10516. /** @hidden */ private _prepare(): void;
  10517. /**
  10518. * Execute the action and set the targetted property to the desired value.
  10519. */
  10520. execute(): void;
  10521. /**
  10522. * Serializes the actions and its related information.
  10523. * @param parent defines the object to serialize in
  10524. * @returns the serialized object
  10525. */
  10526. serialize(parent: any): any;
  10527. }
  10528. /**
  10529. * This defines an action responsible to increment the target value
  10530. * to a desired value once triggered.
  10531. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10532. */
  10533. export class IncrementValueAction extends Action {
  10534. /**
  10535. * The path of the property to increment in the target.
  10536. */
  10537. propertyPath: string;
  10538. /**
  10539. * The value we should increment the property by.
  10540. */
  10541. value: any;
  10542. private _target;
  10543. private _effectiveTarget;
  10544. private _property;
  10545. /**
  10546. * Instantiate the action
  10547. * @param triggerOptions defines the trigger options
  10548. * @param target defines the object containing the property
  10549. * @param propertyPath defines the path of the property to increment in the target
  10550. * @param value defines the value value we should increment the property by
  10551. * @param condition defines the trigger related conditions
  10552. */
  10553. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10554. /** @hidden */ private _prepare(): void;
  10555. /**
  10556. * Execute the action and increment the target of the value amount.
  10557. */
  10558. execute(): void;
  10559. /**
  10560. * Serializes the actions and its related information.
  10561. * @param parent defines the object to serialize in
  10562. * @returns the serialized object
  10563. */
  10564. serialize(parent: any): any;
  10565. }
  10566. /**
  10567. * This defines an action responsible to start an animation once triggered.
  10568. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10569. */
  10570. export class PlayAnimationAction extends Action {
  10571. /**
  10572. * Where the animation should start (animation frame)
  10573. */
  10574. from: number;
  10575. /**
  10576. * Where the animation should stop (animation frame)
  10577. */
  10578. to: number;
  10579. /**
  10580. * Define if the animation should loop or stop after the first play.
  10581. */
  10582. loop?: boolean;
  10583. private _target;
  10584. /**
  10585. * Instantiate the action
  10586. * @param triggerOptions defines the trigger options
  10587. * @param target defines the target animation or animation name
  10588. * @param from defines from where the animation should start (animation frame)
  10589. * @param end defines where the animation should stop (animation frame)
  10590. * @param loop defines if the animation should loop or stop after the first play
  10591. * @param condition defines the trigger related conditions
  10592. */
  10593. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10594. /** @hidden */ private _prepare(): void;
  10595. /**
  10596. * Execute the action and play the animation.
  10597. */
  10598. execute(): void;
  10599. /**
  10600. * Serializes the actions and its related information.
  10601. * @param parent defines the object to serialize in
  10602. * @returns the serialized object
  10603. */
  10604. serialize(parent: any): any;
  10605. }
  10606. /**
  10607. * This defines an action responsible to stop an animation once triggered.
  10608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10609. */
  10610. export class StopAnimationAction extends Action {
  10611. private _target;
  10612. /**
  10613. * Instantiate the action
  10614. * @param triggerOptions defines the trigger options
  10615. * @param target defines the target animation or animation name
  10616. * @param condition defines the trigger related conditions
  10617. */
  10618. constructor(triggerOptions: any, target: any, condition?: Condition);
  10619. /** @hidden */ private _prepare(): void;
  10620. /**
  10621. * Execute the action and stop the animation.
  10622. */
  10623. execute(): void;
  10624. /**
  10625. * Serializes the actions and its related information.
  10626. * @param parent defines the object to serialize in
  10627. * @returns the serialized object
  10628. */
  10629. serialize(parent: any): any;
  10630. }
  10631. /**
  10632. * This defines an action responsible that does nothing once triggered.
  10633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10634. */
  10635. export class DoNothingAction extends Action {
  10636. /**
  10637. * Instantiate the action
  10638. * @param triggerOptions defines the trigger options
  10639. * @param condition defines the trigger related conditions
  10640. */
  10641. constructor(triggerOptions?: any, condition?: Condition);
  10642. /**
  10643. * Execute the action and do nothing.
  10644. */
  10645. execute(): void;
  10646. /**
  10647. * Serializes the actions and its related information.
  10648. * @param parent defines the object to serialize in
  10649. * @returns the serialized object
  10650. */
  10651. serialize(parent: any): any;
  10652. }
  10653. /**
  10654. * This defines an action responsible to trigger several actions once triggered.
  10655. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10656. */
  10657. export class CombineAction extends Action {
  10658. /**
  10659. * The list of aggregated animations to run.
  10660. */
  10661. children: Action[];
  10662. /**
  10663. * Instantiate the action
  10664. * @param triggerOptions defines the trigger options
  10665. * @param children defines the list of aggregated animations to run
  10666. * @param condition defines the trigger related conditions
  10667. */
  10668. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10669. /** @hidden */ private _prepare(): void;
  10670. /**
  10671. * Execute the action and executes all the aggregated actions.
  10672. */
  10673. execute(evt: ActionEvent): void;
  10674. /**
  10675. * Serializes the actions and its related information.
  10676. * @param parent defines the object to serialize in
  10677. * @returns the serialized object
  10678. */
  10679. serialize(parent: any): any;
  10680. }
  10681. /**
  10682. * This defines an action responsible to run code (external event) once triggered.
  10683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10684. */
  10685. export class ExecuteCodeAction extends Action {
  10686. /**
  10687. * The callback function to run.
  10688. */
  10689. func: (evt: ActionEvent) => void;
  10690. /**
  10691. * Instantiate the action
  10692. * @param triggerOptions defines the trigger options
  10693. * @param func defines the callback function to run
  10694. * @param condition defines the trigger related conditions
  10695. */
  10696. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10697. /**
  10698. * Execute the action and run the attached code.
  10699. */
  10700. execute(evt: ActionEvent): void;
  10701. }
  10702. /**
  10703. * This defines an action responsible to set the parent property of the target once triggered.
  10704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10705. */
  10706. export class SetParentAction extends Action {
  10707. private _parent;
  10708. private _target;
  10709. /**
  10710. * Instantiate the action
  10711. * @param triggerOptions defines the trigger options
  10712. * @param target defines the target containing the parent property
  10713. * @param parent defines from where the animation should start (animation frame)
  10714. * @param condition defines the trigger related conditions
  10715. */
  10716. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10717. /** @hidden */ private _prepare(): void;
  10718. /**
  10719. * Execute the action and set the parent property.
  10720. */
  10721. execute(): void;
  10722. /**
  10723. * Serializes the actions and its related information.
  10724. * @param parent defines the object to serialize in
  10725. * @returns the serialized object
  10726. */
  10727. serialize(parent: any): any;
  10728. }
  10729. }
  10730. declare module BABYLON {
  10731. /**
  10732. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10733. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10735. */
  10736. export class ActionManager extends AbstractActionManager {
  10737. /**
  10738. * Nothing
  10739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10740. */
  10741. static readonly NothingTrigger: number;
  10742. /**
  10743. * On pick
  10744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10745. */
  10746. static readonly OnPickTrigger: number;
  10747. /**
  10748. * On left pick
  10749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10750. */
  10751. static readonly OnLeftPickTrigger: number;
  10752. /**
  10753. * On right pick
  10754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10755. */
  10756. static readonly OnRightPickTrigger: number;
  10757. /**
  10758. * On center pick
  10759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10760. */
  10761. static readonly OnCenterPickTrigger: number;
  10762. /**
  10763. * On pick down
  10764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10765. */
  10766. static readonly OnPickDownTrigger: number;
  10767. /**
  10768. * On double pick
  10769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10770. */
  10771. static readonly OnDoublePickTrigger: number;
  10772. /**
  10773. * On pick up
  10774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10775. */
  10776. static readonly OnPickUpTrigger: number;
  10777. /**
  10778. * On pick out.
  10779. * This trigger will only be raised if you also declared a OnPickDown
  10780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10781. */
  10782. static readonly OnPickOutTrigger: number;
  10783. /**
  10784. * On long press
  10785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10786. */
  10787. static readonly OnLongPressTrigger: number;
  10788. /**
  10789. * On pointer over
  10790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10791. */
  10792. static readonly OnPointerOverTrigger: number;
  10793. /**
  10794. * On pointer out
  10795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10796. */
  10797. static readonly OnPointerOutTrigger: number;
  10798. /**
  10799. * On every frame
  10800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10801. */
  10802. static readonly OnEveryFrameTrigger: number;
  10803. /**
  10804. * On intersection enter
  10805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10806. */
  10807. static readonly OnIntersectionEnterTrigger: number;
  10808. /**
  10809. * On intersection exit
  10810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10811. */
  10812. static readonly OnIntersectionExitTrigger: number;
  10813. /**
  10814. * On key down
  10815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10816. */
  10817. static readonly OnKeyDownTrigger: number;
  10818. /**
  10819. * On key up
  10820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10821. */
  10822. static readonly OnKeyUpTrigger: number;
  10823. private _scene;
  10824. /**
  10825. * Creates a new action manager
  10826. * @param scene defines the hosting scene
  10827. */
  10828. constructor(scene: Scene);
  10829. /**
  10830. * Releases all associated resources
  10831. */
  10832. dispose(): void;
  10833. /**
  10834. * Gets hosting scene
  10835. * @returns the hosting scene
  10836. */
  10837. getScene(): Scene;
  10838. /**
  10839. * Does this action manager handles actions of any of the given triggers
  10840. * @param triggers defines the triggers to be tested
  10841. * @return a boolean indicating whether one (or more) of the triggers is handled
  10842. */
  10843. hasSpecificTriggers(triggers: number[]): boolean;
  10844. /**
  10845. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10846. * speed.
  10847. * @param triggerA defines the trigger to be tested
  10848. * @param triggerB defines the trigger to be tested
  10849. * @return a boolean indicating whether one (or more) of the triggers is handled
  10850. */
  10851. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10852. /**
  10853. * Does this action manager handles actions of a given trigger
  10854. * @param trigger defines the trigger to be tested
  10855. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10856. * @return whether the trigger is handled
  10857. */
  10858. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10859. /**
  10860. * Does this action manager has pointer triggers
  10861. */
  10862. readonly hasPointerTriggers: boolean;
  10863. /**
  10864. * Does this action manager has pick triggers
  10865. */
  10866. readonly hasPickTriggers: boolean;
  10867. /**
  10868. * Registers an action to this action manager
  10869. * @param action defines the action to be registered
  10870. * @return the action amended (prepared) after registration
  10871. */
  10872. registerAction(action: IAction): Nullable<IAction>;
  10873. /**
  10874. * Unregisters an action to this action manager
  10875. * @param action defines the action to be unregistered
  10876. * @return a boolean indicating whether the action has been unregistered
  10877. */
  10878. unregisterAction(action: IAction): Boolean;
  10879. /**
  10880. * Process a specific trigger
  10881. * @param trigger defines the trigger to process
  10882. * @param evt defines the event details to be processed
  10883. */
  10884. processTrigger(trigger: number, evt?: IActionEvent): void;
  10885. /** @hidden */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10886. /** @hidden */ private _getProperty(propertyPath: string): string;
  10887. /**
  10888. * Serialize this manager to a JSON object
  10889. * @param name defines the property name to store this manager
  10890. * @returns a JSON representation of this manager
  10891. */
  10892. serialize(name: string): any;
  10893. /**
  10894. * Creates a new ActionManager from a JSON data
  10895. * @param parsedActions defines the JSON data to read from
  10896. * @param object defines the hosting mesh
  10897. * @param scene defines the hosting scene
  10898. */
  10899. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10900. /**
  10901. * Get a trigger name by index
  10902. * @param trigger defines the trigger index
  10903. * @returns a trigger name
  10904. */
  10905. static GetTriggerName(trigger: number): string;
  10906. }
  10907. }
  10908. declare module BABYLON {
  10909. /**
  10910. * Class representing a ray with position and direction
  10911. */
  10912. export class Ray {
  10913. /** origin point */
  10914. origin: Vector3;
  10915. /** direction */
  10916. direction: Vector3;
  10917. /** length of the ray */
  10918. length: number;
  10919. private static readonly TmpVector3;
  10920. private _tmpRay;
  10921. /**
  10922. * Creates a new ray
  10923. * @param origin origin point
  10924. * @param direction direction
  10925. * @param length length of the ray
  10926. */
  10927. constructor(
  10928. /** origin point */
  10929. origin: Vector3,
  10930. /** direction */
  10931. direction: Vector3,
  10932. /** length of the ray */
  10933. length?: number);
  10934. /**
  10935. * Checks if the ray intersects a box
  10936. * @param minimum bound of the box
  10937. * @param maximum bound of the box
  10938. * @param intersectionTreshold extra extend to be added to the box in all direction
  10939. * @returns if the box was hit
  10940. */
  10941. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10942. /**
  10943. * Checks if the ray intersects a box
  10944. * @param box the bounding box to check
  10945. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10946. * @returns if the box was hit
  10947. */
  10948. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10949. /**
  10950. * If the ray hits a sphere
  10951. * @param sphere the bounding sphere to check
  10952. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10953. * @returns true if it hits the sphere
  10954. */
  10955. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10956. /**
  10957. * If the ray hits a triange
  10958. * @param vertex0 triangle vertex
  10959. * @param vertex1 triangle vertex
  10960. * @param vertex2 triangle vertex
  10961. * @returns intersection information if hit
  10962. */
  10963. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10964. /**
  10965. * Checks if ray intersects a plane
  10966. * @param plane the plane to check
  10967. * @returns the distance away it was hit
  10968. */
  10969. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10970. /**
  10971. * Calculate the intercept of a ray on a given axis
  10972. * @param axis to check 'x' | 'y' | 'z'
  10973. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10974. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10975. */
  10976. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10977. /**
  10978. * Checks if ray intersects a mesh
  10979. * @param mesh the mesh to check
  10980. * @param fastCheck if only the bounding box should checked
  10981. * @returns picking info of the intersecton
  10982. */
  10983. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10984. /**
  10985. * Checks if ray intersects a mesh
  10986. * @param meshes the meshes to check
  10987. * @param fastCheck if only the bounding box should checked
  10988. * @param results array to store result in
  10989. * @returns Array of picking infos
  10990. */
  10991. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10992. private _comparePickingInfo;
  10993. private static smallnum;
  10994. private static rayl;
  10995. /**
  10996. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10997. * @param sega the first point of the segment to test the intersection against
  10998. * @param segb the second point of the segment to test the intersection against
  10999. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11000. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11001. */
  11002. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11003. /**
  11004. * Update the ray from viewport position
  11005. * @param x position
  11006. * @param y y position
  11007. * @param viewportWidth viewport width
  11008. * @param viewportHeight viewport height
  11009. * @param world world matrix
  11010. * @param view view matrix
  11011. * @param projection projection matrix
  11012. * @returns this ray updated
  11013. */
  11014. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11015. /**
  11016. * Creates a ray with origin and direction of 0,0,0
  11017. * @returns the new ray
  11018. */
  11019. static Zero(): Ray;
  11020. /**
  11021. * Creates a new ray from screen space and viewport
  11022. * @param x position
  11023. * @param y y position
  11024. * @param viewportWidth viewport width
  11025. * @param viewportHeight viewport height
  11026. * @param world world matrix
  11027. * @param view view matrix
  11028. * @param projection projection matrix
  11029. * @returns new ray
  11030. */
  11031. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11032. /**
  11033. * 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
  11034. * transformed to the given world matrix.
  11035. * @param origin The origin point
  11036. * @param end The end point
  11037. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11038. * @returns the new ray
  11039. */
  11040. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11041. /**
  11042. * Transforms a ray by a matrix
  11043. * @param ray ray to transform
  11044. * @param matrix matrix to apply
  11045. * @returns the resulting new ray
  11046. */
  11047. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11048. /**
  11049. * Transforms a ray by a matrix
  11050. * @param ray ray to transform
  11051. * @param matrix matrix to apply
  11052. * @param result ray to store result in
  11053. */
  11054. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11055. /**
  11056. * Unproject a ray from screen space to object space
  11057. * @param sourceX defines the screen space x coordinate to use
  11058. * @param sourceY defines the screen space y coordinate to use
  11059. * @param viewportWidth defines the current width of the viewport
  11060. * @param viewportHeight defines the current height of the viewport
  11061. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11062. * @param view defines the view matrix to use
  11063. * @param projection defines the projection matrix to use
  11064. */
  11065. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11066. }
  11067. /**
  11068. * Type used to define predicate used to select faces when a mesh intersection is detected
  11069. */
  11070. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11071. interface Scene {
  11072. /** @hidden */ private _tempPickingRay: Nullable<Ray>;
  11073. /** @hidden */ private _cachedRayForTransform: Ray;
  11074. /** @hidden */ private _pickWithRayInverseMatrix: Matrix;
  11075. /** @hidden */ private _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11076. /** @hidden */ private _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11077. }
  11078. }
  11079. declare module BABYLON {
  11080. /**
  11081. * Groups all the scene component constants in one place to ease maintenance.
  11082. * @hidden
  11083. */
  11084. export class SceneComponentConstants {
  11085. static readonly NAME_EFFECTLAYER: string;
  11086. static readonly NAME_LAYER: string;
  11087. static readonly NAME_LENSFLARESYSTEM: string;
  11088. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11089. static readonly NAME_PARTICLESYSTEM: string;
  11090. static readonly NAME_GAMEPAD: string;
  11091. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11092. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11093. static readonly NAME_DEPTHRENDERER: string;
  11094. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11095. static readonly NAME_SPRITE: string;
  11096. static readonly NAME_OUTLINERENDERER: string;
  11097. static readonly NAME_PROCEDURALTEXTURE: string;
  11098. static readonly NAME_SHADOWGENERATOR: string;
  11099. static readonly NAME_OCTREE: string;
  11100. static readonly NAME_PHYSICSENGINE: string;
  11101. static readonly NAME_AUDIO: string;
  11102. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11103. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11104. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11105. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11106. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11107. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11108. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11109. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11110. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11111. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11112. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11113. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11114. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11115. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11116. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11117. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11118. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11119. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11120. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11121. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11122. static readonly STEP_AFTERRENDER_AUDIO: number;
  11123. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11124. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11125. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11126. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11127. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11128. static readonly STEP_POINTERMOVE_SPRITE: number;
  11129. static readonly STEP_POINTERDOWN_SPRITE: number;
  11130. static readonly STEP_POINTERUP_SPRITE: number;
  11131. }
  11132. /**
  11133. * This represents a scene component.
  11134. *
  11135. * This is used to decouple the dependency the scene is having on the different workloads like
  11136. * layers, post processes...
  11137. */
  11138. export interface ISceneComponent {
  11139. /**
  11140. * The name of the component. Each component must have a unique name.
  11141. */
  11142. name: string;
  11143. /**
  11144. * The scene the component belongs to.
  11145. */
  11146. scene: Scene;
  11147. /**
  11148. * Register the component to one instance of a scene.
  11149. */
  11150. register(): void;
  11151. /**
  11152. * Rebuilds the elements related to this component in case of
  11153. * context lost for instance.
  11154. */
  11155. rebuild(): void;
  11156. /**
  11157. * Disposes the component and the associated ressources.
  11158. */
  11159. dispose(): void;
  11160. }
  11161. /**
  11162. * This represents a SERIALIZABLE scene component.
  11163. *
  11164. * This extends Scene Component to add Serialization methods on top.
  11165. */
  11166. export interface ISceneSerializableComponent extends ISceneComponent {
  11167. /**
  11168. * Adds all the elements from the container to the scene
  11169. * @param container the container holding the elements
  11170. */
  11171. addFromContainer(container: AbstractScene): void;
  11172. /**
  11173. * Removes all the elements in the container from the scene
  11174. * @param container contains the elements to remove
  11175. * @param dispose if the removed element should be disposed (default: false)
  11176. */
  11177. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11178. /**
  11179. * Serializes the component data to the specified json object
  11180. * @param serializationObject The object to serialize to
  11181. */
  11182. serialize(serializationObject: any): void;
  11183. }
  11184. /**
  11185. * Strong typing of a Mesh related stage step action
  11186. */
  11187. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11188. /**
  11189. * Strong typing of a Evaluate Sub Mesh related stage step action
  11190. */
  11191. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11192. /**
  11193. * Strong typing of a Active Mesh related stage step action
  11194. */
  11195. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11196. /**
  11197. * Strong typing of a Camera related stage step action
  11198. */
  11199. export type CameraStageAction = (camera: Camera) => void;
  11200. /**
  11201. * Strong typing of a Camera Frame buffer related stage step action
  11202. */
  11203. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11204. /**
  11205. * Strong typing of a Render Target related stage step action
  11206. */
  11207. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11208. /**
  11209. * Strong typing of a RenderingGroup related stage step action
  11210. */
  11211. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11212. /**
  11213. * Strong typing of a Mesh Render related stage step action
  11214. */
  11215. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11216. /**
  11217. * Strong typing of a simple stage step action
  11218. */
  11219. export type SimpleStageAction = () => void;
  11220. /**
  11221. * Strong typing of a render target action.
  11222. */
  11223. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11224. /**
  11225. * Strong typing of a pointer move action.
  11226. */
  11227. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11228. /**
  11229. * Strong typing of a pointer up/down action.
  11230. */
  11231. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11232. /**
  11233. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11234. * @hidden
  11235. */
  11236. export class Stage<T extends Function> extends Array<{
  11237. index: number;
  11238. component: ISceneComponent;
  11239. action: T;
  11240. }> {
  11241. /**
  11242. * Hide ctor from the rest of the world.
  11243. * @param items The items to add.
  11244. */
  11245. private constructor();
  11246. /**
  11247. * Creates a new Stage.
  11248. * @returns A new instance of a Stage
  11249. */
  11250. static Create<T extends Function>(): Stage<T>;
  11251. /**
  11252. * Registers a step in an ordered way in the targeted stage.
  11253. * @param index Defines the position to register the step in
  11254. * @param component Defines the component attached to the step
  11255. * @param action Defines the action to launch during the step
  11256. */
  11257. registerStep(index: number, component: ISceneComponent, action: T): void;
  11258. /**
  11259. * Clears all the steps from the stage.
  11260. */
  11261. clear(): void;
  11262. }
  11263. }
  11264. declare module BABYLON {
  11265. interface Scene {
  11266. /** @hidden */ private _pointerOverSprite: Nullable<Sprite>;
  11267. /** @hidden */ private _pickedDownSprite: Nullable<Sprite>;
  11268. /** @hidden */ private _tempSpritePickingRay: Nullable<Ray>;
  11269. /**
  11270. * All of the sprite managers added to this scene
  11271. * @see http://doc.babylonjs.com/babylon101/sprites
  11272. */
  11273. spriteManagers: Array<ISpriteManager>;
  11274. /**
  11275. * An event triggered when sprites rendering is about to start
  11276. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11277. */
  11278. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11279. /**
  11280. * An event triggered when sprites rendering is done
  11281. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11282. */
  11283. onAfterSpritesRenderingObservable: Observable<Scene>;
  11284. /** @hidden */ private _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11285. /** Launch a ray to try to pick a sprite in the scene
  11286. * @param x position on screen
  11287. * @param y position on screen
  11288. * @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
  11289. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11290. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11291. * @returns a PickingInfo
  11292. */
  11293. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11294. /** Use the given ray to pick a sprite in the scene
  11295. * @param ray The ray (in world space) to use to pick meshes
  11296. * @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
  11297. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11298. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11299. * @returns a PickingInfo
  11300. */
  11301. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11302. /** @hidden */ private _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11303. /** Launch a ray to try to pick sprites in the scene
  11304. * @param x position on screen
  11305. * @param y position on screen
  11306. * @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
  11307. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11308. * @returns a PickingInfo array
  11309. */
  11310. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11311. /** Use the given ray to pick sprites in the scene
  11312. * @param ray The ray (in world space) to use to pick meshes
  11313. * @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
  11314. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11315. * @returns a PickingInfo array
  11316. */
  11317. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11318. /**
  11319. * Force the sprite under the pointer
  11320. * @param sprite defines the sprite to use
  11321. */
  11322. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11323. /**
  11324. * Gets the sprite under the pointer
  11325. * @returns a Sprite or null if no sprite is under the pointer
  11326. */
  11327. getPointerOverSprite(): Nullable<Sprite>;
  11328. }
  11329. /**
  11330. * Defines the sprite scene component responsible to manage sprites
  11331. * in a given scene.
  11332. */
  11333. export class SpriteSceneComponent implements ISceneComponent {
  11334. /**
  11335. * The component name helpfull to identify the component in the list of scene components.
  11336. */
  11337. readonly name: string;
  11338. /**
  11339. * The scene the component belongs to.
  11340. */
  11341. scene: Scene;
  11342. /** @hidden */
  11343. private _spritePredicate;
  11344. /**
  11345. * Creates a new instance of the component for the given scene
  11346. * @param scene Defines the scene to register the component in
  11347. */
  11348. constructor(scene: Scene);
  11349. /**
  11350. * Registers the component in a given scene
  11351. */
  11352. register(): void;
  11353. /**
  11354. * Rebuilds the elements related to this component in case of
  11355. * context lost for instance.
  11356. */
  11357. rebuild(): void;
  11358. /**
  11359. * Disposes the component and the associated ressources.
  11360. */
  11361. dispose(): void;
  11362. private _pickSpriteButKeepRay;
  11363. private _pointerMove;
  11364. private _pointerDown;
  11365. private _pointerUp;
  11366. }
  11367. }
  11368. declare module BABYLON {
  11369. /** @hidden */
  11370. export var fogFragmentDeclaration: {
  11371. name: string;
  11372. shader: string;
  11373. };
  11374. }
  11375. declare module BABYLON {
  11376. /** @hidden */
  11377. export var fogFragment: {
  11378. name: string;
  11379. shader: string;
  11380. };
  11381. }
  11382. declare module BABYLON {
  11383. /** @hidden */
  11384. export var spritesPixelShader: {
  11385. name: string;
  11386. shader: string;
  11387. };
  11388. }
  11389. declare module BABYLON {
  11390. /** @hidden */
  11391. export var fogVertexDeclaration: {
  11392. name: string;
  11393. shader: string;
  11394. };
  11395. }
  11396. declare module BABYLON {
  11397. /** @hidden */
  11398. export var spritesVertexShader: {
  11399. name: string;
  11400. shader: string;
  11401. };
  11402. }
  11403. declare module BABYLON {
  11404. /**
  11405. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11406. */
  11407. export interface ISpriteManager extends IDisposable {
  11408. /**
  11409. * Restricts the camera to viewing objects with the same layerMask.
  11410. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11411. */
  11412. layerMask: number;
  11413. /**
  11414. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11415. */
  11416. isPickable: boolean;
  11417. /**
  11418. * Specifies the rendering group id for this mesh (0 by default)
  11419. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11420. */
  11421. renderingGroupId: number;
  11422. /**
  11423. * Defines the list of sprites managed by the manager.
  11424. */
  11425. sprites: Array<Sprite>;
  11426. /**
  11427. * Tests the intersection of a sprite with a specific ray.
  11428. * @param ray The ray we are sending to test the collision
  11429. * @param camera The camera space we are sending rays in
  11430. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11431. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11432. * @returns picking info or null.
  11433. */
  11434. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11435. /**
  11436. * Intersects the sprites with a ray
  11437. * @param ray defines the ray to intersect with
  11438. * @param camera defines the current active camera
  11439. * @param predicate defines a predicate used to select candidate sprites
  11440. * @returns null if no hit or a PickingInfo array
  11441. */
  11442. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11443. /**
  11444. * Renders the list of sprites on screen.
  11445. */
  11446. render(): void;
  11447. }
  11448. /**
  11449. * Class used to manage multiple sprites on the same spritesheet
  11450. * @see http://doc.babylonjs.com/babylon101/sprites
  11451. */
  11452. export class SpriteManager implements ISpriteManager {
  11453. /** defines the manager's name */
  11454. name: string;
  11455. /** Gets the list of sprites */
  11456. sprites: Sprite[];
  11457. /** Gets or sets the rendering group id (0 by default) */
  11458. renderingGroupId: number;
  11459. /** Gets or sets camera layer mask */
  11460. layerMask: number;
  11461. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11462. fogEnabled: boolean;
  11463. /** Gets or sets a boolean indicating if the sprites are pickable */
  11464. isPickable: boolean;
  11465. /** Defines the default width of a cell in the spritesheet */
  11466. cellWidth: number;
  11467. /** Defines the default height of a cell in the spritesheet */
  11468. cellHeight: number;
  11469. /** Associative array from JSON sprite data file */
  11470. private _cellData;
  11471. /** Array of sprite names from JSON sprite data file */
  11472. private _spriteMap;
  11473. /** True when packed cell data from JSON file is ready*/
  11474. private _packedAndReady;
  11475. /**
  11476. * An event triggered when the manager is disposed.
  11477. */
  11478. onDisposeObservable: Observable<SpriteManager>;
  11479. private _onDisposeObserver;
  11480. /**
  11481. * Callback called when the manager is disposed
  11482. */
  11483. onDispose: () => void;
  11484. private _capacity;
  11485. private _fromPacked;
  11486. private _spriteTexture;
  11487. private _epsilon;
  11488. private _scene;
  11489. private _vertexData;
  11490. private _buffer;
  11491. private _vertexBuffers;
  11492. private _indexBuffer;
  11493. private _effectBase;
  11494. private _effectFog;
  11495. /**
  11496. * Gets or sets the spritesheet texture
  11497. */
  11498. texture: Texture;
  11499. /**
  11500. * Creates a new sprite manager
  11501. * @param name defines the manager's name
  11502. * @param imgUrl defines the sprite sheet url
  11503. * @param capacity defines the maximum allowed number of sprites
  11504. * @param cellSize defines the size of a sprite cell
  11505. * @param scene defines the hosting scene
  11506. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11507. * @param samplingMode defines the smapling mode to use with spritesheet
  11508. * @param fromPacked set to false; do not alter
  11509. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11510. */
  11511. constructor(
  11512. /** defines the manager's name */
  11513. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11514. private _makePacked;
  11515. private _appendSpriteVertex;
  11516. /**
  11517. * Intersects the sprites with a ray
  11518. * @param ray defines the ray to intersect with
  11519. * @param camera defines the current active camera
  11520. * @param predicate defines a predicate used to select candidate sprites
  11521. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11522. * @returns null if no hit or a PickingInfo
  11523. */
  11524. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11525. /**
  11526. * Intersects the sprites with a ray
  11527. * @param ray defines the ray to intersect with
  11528. * @param camera defines the current active camera
  11529. * @param predicate defines a predicate used to select candidate sprites
  11530. * @returns null if no hit or a PickingInfo array
  11531. */
  11532. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11533. /**
  11534. * Render all child sprites
  11535. */
  11536. render(): void;
  11537. /**
  11538. * Release associated resources
  11539. */
  11540. dispose(): void;
  11541. }
  11542. }
  11543. declare module BABYLON {
  11544. /**
  11545. * Class used to represent a sprite
  11546. * @see http://doc.babylonjs.com/babylon101/sprites
  11547. */
  11548. export class Sprite {
  11549. /** defines the name */
  11550. name: string;
  11551. /** Gets or sets the current world position */
  11552. position: Vector3;
  11553. /** Gets or sets the main color */
  11554. color: Color4;
  11555. /** Gets or sets the width */
  11556. width: number;
  11557. /** Gets or sets the height */
  11558. height: number;
  11559. /** Gets or sets rotation angle */
  11560. angle: number;
  11561. /** Gets or sets the cell index in the sprite sheet */
  11562. cellIndex: number;
  11563. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11564. cellRef: string;
  11565. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11566. invertU: number;
  11567. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11568. invertV: number;
  11569. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11570. disposeWhenFinishedAnimating: boolean;
  11571. /** Gets the list of attached animations */
  11572. animations: Animation[];
  11573. /** Gets or sets a boolean indicating if the sprite can be picked */
  11574. isPickable: boolean;
  11575. /**
  11576. * Gets or sets the associated action manager
  11577. */
  11578. actionManager: Nullable<ActionManager>;
  11579. private _animationStarted;
  11580. private _loopAnimation;
  11581. private _fromIndex;
  11582. private _toIndex;
  11583. private _delay;
  11584. private _direction;
  11585. private _manager;
  11586. private _time;
  11587. private _onAnimationEnd;
  11588. /**
  11589. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11590. */
  11591. isVisible: boolean;
  11592. /**
  11593. * Gets or sets the sprite size
  11594. */
  11595. size: number;
  11596. /**
  11597. * Creates a new Sprite
  11598. * @param name defines the name
  11599. * @param manager defines the manager
  11600. */
  11601. constructor(
  11602. /** defines the name */
  11603. name: string, manager: ISpriteManager);
  11604. /**
  11605. * Starts an animation
  11606. * @param from defines the initial key
  11607. * @param to defines the end key
  11608. * @param loop defines if the animation must loop
  11609. * @param delay defines the start delay (in ms)
  11610. * @param onAnimationEnd defines a callback to call when animation ends
  11611. */
  11612. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11613. /** Stops current animation (if any) */
  11614. stopAnimation(): void;
  11615. /** @hidden */ private _animate(deltaTime: number): void;
  11616. /** Release associated resources */
  11617. dispose(): void;
  11618. }
  11619. }
  11620. declare module BABYLON {
  11621. /**
  11622. * Information about the result of picking within a scene
  11623. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11624. */
  11625. export class PickingInfo {
  11626. /** @hidden */ private _pickingUnavailable: boolean;
  11627. /**
  11628. * If the pick collided with an object
  11629. */
  11630. hit: boolean;
  11631. /**
  11632. * Distance away where the pick collided
  11633. */
  11634. distance: number;
  11635. /**
  11636. * The location of pick collision
  11637. */
  11638. pickedPoint: Nullable<Vector3>;
  11639. /**
  11640. * The mesh corresponding the the pick collision
  11641. */
  11642. pickedMesh: Nullable<AbstractMesh>;
  11643. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11644. bu: number;
  11645. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11646. bv: number;
  11647. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11648. faceId: number;
  11649. /** Id of the the submesh that was picked */
  11650. subMeshId: number;
  11651. /** If a sprite was picked, this will be the sprite the pick collided with */
  11652. pickedSprite: Nullable<Sprite>;
  11653. /**
  11654. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11655. */
  11656. originMesh: Nullable<AbstractMesh>;
  11657. /**
  11658. * The ray that was used to perform the picking.
  11659. */
  11660. ray: Nullable<Ray>;
  11661. /**
  11662. * Gets the normal correspodning to the face the pick collided with
  11663. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11664. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11665. * @returns The normal correspodning to the face the pick collided with
  11666. */
  11667. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11668. /**
  11669. * Gets the texture coordinates of where the pick occured
  11670. * @returns the vector containing the coordnates of the texture
  11671. */
  11672. getTextureCoordinates(): Nullable<Vector2>;
  11673. }
  11674. }
  11675. declare module BABYLON {
  11676. /**
  11677. * Gather the list of pointer event types as constants.
  11678. */
  11679. export class PointerEventTypes {
  11680. /**
  11681. * 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.
  11682. */
  11683. static readonly POINTERDOWN: number;
  11684. /**
  11685. * The pointerup event is fired when a pointer is no longer active.
  11686. */
  11687. static readonly POINTERUP: number;
  11688. /**
  11689. * The pointermove event is fired when a pointer changes coordinates.
  11690. */
  11691. static readonly POINTERMOVE: number;
  11692. /**
  11693. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11694. */
  11695. static readonly POINTERWHEEL: number;
  11696. /**
  11697. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11698. */
  11699. static readonly POINTERPICK: number;
  11700. /**
  11701. * The pointertap event is fired when a the object has been touched and released without drag.
  11702. */
  11703. static readonly POINTERTAP: number;
  11704. /**
  11705. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11706. */
  11707. static readonly POINTERDOUBLETAP: number;
  11708. }
  11709. /**
  11710. * Base class of pointer info types.
  11711. */
  11712. export class PointerInfoBase {
  11713. /**
  11714. * Defines the type of event (PointerEventTypes)
  11715. */
  11716. type: number;
  11717. /**
  11718. * Defines the related dom event
  11719. */
  11720. event: PointerEvent | MouseWheelEvent;
  11721. /**
  11722. * Instantiates the base class of pointers info.
  11723. * @param type Defines the type of event (PointerEventTypes)
  11724. * @param event Defines the related dom event
  11725. */
  11726. constructor(
  11727. /**
  11728. * Defines the type of event (PointerEventTypes)
  11729. */
  11730. type: number,
  11731. /**
  11732. * Defines the related dom event
  11733. */
  11734. event: PointerEvent | MouseWheelEvent);
  11735. }
  11736. /**
  11737. * This class is used to store pointer related info for the onPrePointerObservable event.
  11738. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11739. */
  11740. export class PointerInfoPre extends PointerInfoBase {
  11741. /**
  11742. * Ray from a pointer if availible (eg. 6dof controller)
  11743. */
  11744. ray: Nullable<Ray>;
  11745. /**
  11746. * Defines the local position of the pointer on the canvas.
  11747. */
  11748. localPosition: Vector2;
  11749. /**
  11750. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11751. */
  11752. skipOnPointerObservable: boolean;
  11753. /**
  11754. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11755. * @param type Defines the type of event (PointerEventTypes)
  11756. * @param event Defines the related dom event
  11757. * @param localX Defines the local x coordinates of the pointer when the event occured
  11758. * @param localY Defines the local y coordinates of the pointer when the event occured
  11759. */
  11760. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11761. }
  11762. /**
  11763. * This type contains all the data related to a pointer event in Babylon.js.
  11764. * 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.
  11765. */
  11766. export class PointerInfo extends PointerInfoBase {
  11767. /**
  11768. * Defines the picking info associated to the info (if any)\
  11769. */
  11770. pickInfo: Nullable<PickingInfo>;
  11771. /**
  11772. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11773. * @param type Defines the type of event (PointerEventTypes)
  11774. * @param event Defines the related dom event
  11775. * @param pickInfo Defines the picking info associated to the info (if any)\
  11776. */
  11777. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11778. /**
  11779. * Defines the picking info associated to the info (if any)\
  11780. */
  11781. pickInfo: Nullable<PickingInfo>);
  11782. }
  11783. /**
  11784. * Data relating to a touch event on the screen.
  11785. */
  11786. export interface PointerTouch {
  11787. /**
  11788. * X coordinate of touch.
  11789. */
  11790. x: number;
  11791. /**
  11792. * Y coordinate of touch.
  11793. */
  11794. y: number;
  11795. /**
  11796. * Id of touch. Unique for each finger.
  11797. */
  11798. pointerId: number;
  11799. /**
  11800. * Event type passed from DOM.
  11801. */
  11802. type: any;
  11803. }
  11804. }
  11805. declare module BABYLON {
  11806. /**
  11807. * Manage the mouse inputs to control the movement of a free camera.
  11808. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11809. */
  11810. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11811. /**
  11812. * Define if touch is enabled in the mouse input
  11813. */
  11814. touchEnabled: boolean;
  11815. /**
  11816. * Defines the camera the input is attached to.
  11817. */
  11818. camera: FreeCamera;
  11819. /**
  11820. * Defines the buttons associated with the input to handle camera move.
  11821. */
  11822. buttons: number[];
  11823. /**
  11824. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11825. */
  11826. angularSensibility: number;
  11827. private _pointerInput;
  11828. private _onMouseMove;
  11829. private _observer;
  11830. private previousPosition;
  11831. /**
  11832. * Observable for when a pointer move event occurs containing the move offset
  11833. */
  11834. onPointerMovedObservable: Observable<{
  11835. offsetX: number;
  11836. offsetY: number;
  11837. }>;
  11838. /**
  11839. * @hidden
  11840. * If the camera should be rotated automatically based on pointer movement
  11841. */ private _allowCameraRotation: boolean;
  11842. /**
  11843. * Manage the mouse inputs to control the movement of a free camera.
  11844. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11845. * @param touchEnabled Defines if touch is enabled or not
  11846. */
  11847. constructor(
  11848. /**
  11849. * Define if touch is enabled in the mouse input
  11850. */
  11851. touchEnabled?: boolean);
  11852. /**
  11853. * Attach the input controls to a specific dom element to get the input from.
  11854. * @param element Defines the element the controls should be listened from
  11855. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11856. */
  11857. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11858. /**
  11859. * Called on JS contextmenu event.
  11860. * Override this method to provide functionality.
  11861. */
  11862. protected onContextMenu(evt: PointerEvent): void;
  11863. /**
  11864. * Detach the current controls from the specified dom element.
  11865. * @param element Defines the element to stop listening the inputs from
  11866. */
  11867. detachControl(element: Nullable<HTMLElement>): void;
  11868. /**
  11869. * Gets the class name of the current intput.
  11870. * @returns the class name
  11871. */
  11872. getClassName(): string;
  11873. /**
  11874. * Get the friendly name associated with the input class.
  11875. * @returns the input friendly name
  11876. */
  11877. getSimpleName(): string;
  11878. }
  11879. }
  11880. declare module BABYLON {
  11881. /**
  11882. * Manage the touch inputs to control the movement of a free camera.
  11883. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11884. */
  11885. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11886. /**
  11887. * Defines the camera the input is attached to.
  11888. */
  11889. camera: FreeCamera;
  11890. /**
  11891. * Defines the touch sensibility for rotation.
  11892. * The higher the faster.
  11893. */
  11894. touchAngularSensibility: number;
  11895. /**
  11896. * Defines the touch sensibility for move.
  11897. * The higher the faster.
  11898. */
  11899. touchMoveSensibility: number;
  11900. private _offsetX;
  11901. private _offsetY;
  11902. private _pointerPressed;
  11903. private _pointerInput;
  11904. private _observer;
  11905. private _onLostFocus;
  11906. /**
  11907. * Attach the input controls to a specific dom element to get the input from.
  11908. * @param element Defines the element the controls should be listened from
  11909. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11910. */
  11911. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11912. /**
  11913. * Detach the current controls from the specified dom element.
  11914. * @param element Defines the element to stop listening the inputs from
  11915. */
  11916. detachControl(element: Nullable<HTMLElement>): void;
  11917. /**
  11918. * Update the current camera state depending on the inputs that have been used this frame.
  11919. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11920. */
  11921. checkInputs(): void;
  11922. /**
  11923. * Gets the class name of the current intput.
  11924. * @returns the class name
  11925. */
  11926. getClassName(): string;
  11927. /**
  11928. * Get the friendly name associated with the input class.
  11929. * @returns the input friendly name
  11930. */
  11931. getSimpleName(): string;
  11932. }
  11933. }
  11934. declare module BABYLON {
  11935. /**
  11936. * Default Inputs manager for the FreeCamera.
  11937. * It groups all the default supported inputs for ease of use.
  11938. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11939. */
  11940. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11941. /**
  11942. * @hidden
  11943. */ private _mouseInput: Nullable<FreeCameraMouseInput>;
  11944. /**
  11945. * Instantiates a new FreeCameraInputsManager.
  11946. * @param camera Defines the camera the inputs belong to
  11947. */
  11948. constructor(camera: FreeCamera);
  11949. /**
  11950. * Add keyboard input support to the input manager.
  11951. * @returns the current input manager
  11952. */
  11953. addKeyboard(): FreeCameraInputsManager;
  11954. /**
  11955. * Add mouse input support to the input manager.
  11956. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11957. * @returns the current input manager
  11958. */
  11959. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11960. /**
  11961. * Removes the mouse input support from the manager
  11962. * @returns the current input manager
  11963. */
  11964. removeMouse(): FreeCameraInputsManager;
  11965. /**
  11966. * Add touch input support to the input manager.
  11967. * @returns the current input manager
  11968. */
  11969. addTouch(): FreeCameraInputsManager;
  11970. /**
  11971. * Remove all attached input methods from a camera
  11972. */
  11973. clear(): void;
  11974. }
  11975. }
  11976. declare module BABYLON {
  11977. /**
  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 the gamepad.
  11980. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11981. */
  11982. export class FreeCamera extends TargetCamera {
  11983. /**
  11984. * Define the collision ellipsoid of the camera.
  11985. * This is helpful to simulate a camera body like the player body around the camera
  11986. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11987. */
  11988. ellipsoid: Vector3;
  11989. /**
  11990. * Define an offset for the position of the ellipsoid around the camera.
  11991. * This can be helpful to determine the center of the body near the gravity center of the body
  11992. * instead of its head.
  11993. */
  11994. ellipsoidOffset: Vector3;
  11995. /**
  11996. * Enable or disable collisions of the camera with the rest of the scene objects.
  11997. */
  11998. checkCollisions: boolean;
  11999. /**
  12000. * Enable or disable gravity on the camera.
  12001. */
  12002. applyGravity: boolean;
  12003. /**
  12004. * Define the input manager associated to the camera.
  12005. */
  12006. inputs: FreeCameraInputsManager;
  12007. /**
  12008. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12009. * Higher values reduce sensitivity.
  12010. */
  12011. /**
  12012. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12013. * Higher values reduce sensitivity.
  12014. */
  12015. angularSensibility: number;
  12016. /**
  12017. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12018. */
  12019. keysUp: number[];
  12020. /**
  12021. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12022. */
  12023. keysDown: number[];
  12024. /**
  12025. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12026. */
  12027. keysLeft: number[];
  12028. /**
  12029. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12030. */
  12031. keysRight: number[];
  12032. /**
  12033. * Event raised when the camera collide with a mesh in the scene.
  12034. */
  12035. onCollide: (collidedMesh: AbstractMesh) => void;
  12036. private _collider;
  12037. private _needMoveForGravity;
  12038. private _oldPosition;
  12039. private _diffPosition;
  12040. private _newPosition;
  12041. /** @hidden */ private _localDirection: Vector3;
  12042. /** @hidden */ private _transformedDirection: Vector3;
  12043. /**
  12044. * Instantiates a Free Camera.
  12045. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12046. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12047. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12048. * @param name Define the name of the camera in the scene
  12049. * @param position Define the start position of the camera in the scene
  12050. * @param scene Define the scene the camera belongs to
  12051. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12052. */
  12053. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12054. /**
  12055. * Attached controls to the current camera.
  12056. * @param element Defines the element the controls should be listened from
  12057. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12058. */
  12059. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12060. /**
  12061. * Detach the current controls from the camera.
  12062. * The camera will stop reacting to inputs.
  12063. * @param element Defines the element to stop listening the inputs from
  12064. */
  12065. detachControl(element: HTMLElement): void;
  12066. private _collisionMask;
  12067. /**
  12068. * Define a collision mask to limit the list of object the camera can collide with
  12069. */
  12070. collisionMask: number;
  12071. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  12072. private _onCollisionPositionChange;
  12073. /** @hidden */ private _checkInputs(): void;
  12074. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  12075. /** @hidden */ private _updatePosition(): void;
  12076. /**
  12077. * Destroy the camera and release the current resources hold by it.
  12078. */
  12079. dispose(): void;
  12080. /**
  12081. * Gets the current object class name.
  12082. * @return the class name
  12083. */
  12084. getClassName(): string;
  12085. }
  12086. }
  12087. declare module BABYLON {
  12088. /**
  12089. * Represents a gamepad control stick position
  12090. */
  12091. export class StickValues {
  12092. /**
  12093. * The x component of the control stick
  12094. */
  12095. x: number;
  12096. /**
  12097. * The y component of the control stick
  12098. */
  12099. y: number;
  12100. /**
  12101. * Initializes the gamepad x and y control stick values
  12102. * @param x The x component of the gamepad control stick value
  12103. * @param y The y component of the gamepad control stick value
  12104. */
  12105. constructor(
  12106. /**
  12107. * The x component of the control stick
  12108. */
  12109. x: number,
  12110. /**
  12111. * The y component of the control stick
  12112. */
  12113. y: number);
  12114. }
  12115. /**
  12116. * An interface which manages callbacks for gamepad button changes
  12117. */
  12118. export interface GamepadButtonChanges {
  12119. /**
  12120. * Called when a gamepad has been changed
  12121. */
  12122. changed: boolean;
  12123. /**
  12124. * Called when a gamepad press event has been triggered
  12125. */
  12126. pressChanged: boolean;
  12127. /**
  12128. * Called when a touch event has been triggered
  12129. */
  12130. touchChanged: boolean;
  12131. /**
  12132. * Called when a value has changed
  12133. */
  12134. valueChanged: boolean;
  12135. }
  12136. /**
  12137. * Represents a gamepad
  12138. */
  12139. export class Gamepad {
  12140. /**
  12141. * The id of the gamepad
  12142. */
  12143. id: string;
  12144. /**
  12145. * The index of the gamepad
  12146. */
  12147. index: number;
  12148. /**
  12149. * The browser gamepad
  12150. */
  12151. browserGamepad: any;
  12152. /**
  12153. * Specifies what type of gamepad this represents
  12154. */
  12155. type: number;
  12156. private _leftStick;
  12157. private _rightStick;
  12158. /** @hidden */ private _isConnected: boolean;
  12159. private _leftStickAxisX;
  12160. private _leftStickAxisY;
  12161. private _rightStickAxisX;
  12162. private _rightStickAxisY;
  12163. /**
  12164. * Triggered when the left control stick has been changed
  12165. */
  12166. private _onleftstickchanged;
  12167. /**
  12168. * Triggered when the right control stick has been changed
  12169. */
  12170. private _onrightstickchanged;
  12171. /**
  12172. * Represents a gamepad controller
  12173. */
  12174. static GAMEPAD: number;
  12175. /**
  12176. * Represents a generic controller
  12177. */
  12178. static GENERIC: number;
  12179. /**
  12180. * Represents an XBox controller
  12181. */
  12182. static XBOX: number;
  12183. /**
  12184. * Represents a pose-enabled controller
  12185. */
  12186. static POSE_ENABLED: number;
  12187. /**
  12188. * Represents an Dual Shock controller
  12189. */
  12190. static DUALSHOCK: number;
  12191. /**
  12192. * Specifies whether the left control stick should be Y-inverted
  12193. */
  12194. protected _invertLeftStickY: boolean;
  12195. /**
  12196. * Specifies if the gamepad has been connected
  12197. */
  12198. readonly isConnected: boolean;
  12199. /**
  12200. * Initializes the gamepad
  12201. * @param id The id of the gamepad
  12202. * @param index The index of the gamepad
  12203. * @param browserGamepad The browser gamepad
  12204. * @param leftStickX The x component of the left joystick
  12205. * @param leftStickY The y component of the left joystick
  12206. * @param rightStickX The x component of the right joystick
  12207. * @param rightStickY The y component of the right joystick
  12208. */
  12209. constructor(
  12210. /**
  12211. * The id of the gamepad
  12212. */
  12213. id: string,
  12214. /**
  12215. * The index of the gamepad
  12216. */
  12217. index: number,
  12218. /**
  12219. * The browser gamepad
  12220. */
  12221. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12222. /**
  12223. * Callback triggered when the left joystick has changed
  12224. * @param callback
  12225. */
  12226. onleftstickchanged(callback: (values: StickValues) => void): void;
  12227. /**
  12228. * Callback triggered when the right joystick has changed
  12229. * @param callback
  12230. */
  12231. onrightstickchanged(callback: (values: StickValues) => void): void;
  12232. /**
  12233. * Gets the left joystick
  12234. */
  12235. /**
  12236. * Sets the left joystick values
  12237. */
  12238. leftStick: StickValues;
  12239. /**
  12240. * Gets the right joystick
  12241. */
  12242. /**
  12243. * Sets the right joystick value
  12244. */
  12245. rightStick: StickValues;
  12246. /**
  12247. * Updates the gamepad joystick positions
  12248. */
  12249. update(): void;
  12250. /**
  12251. * Disposes the gamepad
  12252. */
  12253. dispose(): void;
  12254. }
  12255. /**
  12256. * Represents a generic gamepad
  12257. */
  12258. export class GenericPad extends Gamepad {
  12259. private _buttons;
  12260. private _onbuttondown;
  12261. private _onbuttonup;
  12262. /**
  12263. * Observable triggered when a button has been pressed
  12264. */
  12265. onButtonDownObservable: Observable<number>;
  12266. /**
  12267. * Observable triggered when a button has been released
  12268. */
  12269. onButtonUpObservable: Observable<number>;
  12270. /**
  12271. * Callback triggered when a button has been pressed
  12272. * @param callback Called when a button has been pressed
  12273. */
  12274. onbuttondown(callback: (buttonPressed: number) => void): void;
  12275. /**
  12276. * Callback triggered when a button has been released
  12277. * @param callback Called when a button has been released
  12278. */
  12279. onbuttonup(callback: (buttonReleased: number) => void): void;
  12280. /**
  12281. * Initializes the generic gamepad
  12282. * @param id The id of the generic gamepad
  12283. * @param index The index of the generic gamepad
  12284. * @param browserGamepad The browser gamepad
  12285. */
  12286. constructor(id: string, index: number, browserGamepad: any);
  12287. private _setButtonValue;
  12288. /**
  12289. * Updates the generic gamepad
  12290. */
  12291. update(): void;
  12292. /**
  12293. * Disposes the generic gamepad
  12294. */
  12295. dispose(): void;
  12296. }
  12297. }
  12298. declare module BABYLON {
  12299. interface Engine {
  12300. /**
  12301. * Creates a raw texture
  12302. * @param data defines the data to store in the texture
  12303. * @param width defines the width of the texture
  12304. * @param height defines the height of the texture
  12305. * @param format defines the format of the data
  12306. * @param generateMipMaps defines if the engine should generate the mip levels
  12307. * @param invertY defines if data must be stored with Y axis inverted
  12308. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12309. * @param compression defines the compression used (null by default)
  12310. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12311. * @returns the raw texture inside an InternalTexture
  12312. */
  12313. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12314. /**
  12315. * Update a raw texture
  12316. * @param texture defines the texture to update
  12317. * @param data defines the data to store in the texture
  12318. * @param format defines the format of the data
  12319. * @param invertY defines if data must be stored with Y axis inverted
  12320. */
  12321. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12322. /**
  12323. * Update a raw texture
  12324. * @param texture defines the texture to update
  12325. * @param data defines the data to store in the texture
  12326. * @param format defines the format of the data
  12327. * @param invertY defines if data must be stored with Y axis inverted
  12328. * @param compression defines the compression used (null by default)
  12329. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12330. */
  12331. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12332. /**
  12333. * Creates a new raw cube texture
  12334. * @param data defines the array of data to use to create each face
  12335. * @param size defines the size of the textures
  12336. * @param format defines the format of the data
  12337. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12338. * @param generateMipMaps defines if the engine should generate the mip levels
  12339. * @param invertY defines if data must be stored with Y axis inverted
  12340. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12341. * @param compression defines the compression used (null by default)
  12342. * @returns the cube texture as an InternalTexture
  12343. */
  12344. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12345. /**
  12346. * Update a raw cube texture
  12347. * @param texture defines the texture to udpdate
  12348. * @param data defines the data to store
  12349. * @param format defines the data format
  12350. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12351. * @param invertY defines if data must be stored with Y axis inverted
  12352. */
  12353. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12354. /**
  12355. * Update a raw cube texture
  12356. * @param texture defines the texture to udpdate
  12357. * @param data defines the data to store
  12358. * @param format defines the data format
  12359. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12360. * @param invertY defines if data must be stored with Y axis inverted
  12361. * @param compression defines the compression used (null by default)
  12362. */
  12363. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12364. /**
  12365. * Update a raw cube texture
  12366. * @param texture defines the texture to udpdate
  12367. * @param data defines the data to store
  12368. * @param format defines the data format
  12369. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12370. * @param invertY defines if data must be stored with Y axis inverted
  12371. * @param compression defines the compression used (null by default)
  12372. * @param level defines which level of the texture to update
  12373. */
  12374. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12375. /**
  12376. * Creates a new raw cube texture from a specified url
  12377. * @param url defines the url where the data is located
  12378. * @param scene defines the current scene
  12379. * @param size defines the size of the textures
  12380. * @param format defines the format of the data
  12381. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12382. * @param noMipmap defines if the engine should avoid generating the mip levels
  12383. * @param callback defines a callback used to extract texture data from loaded data
  12384. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12385. * @param onLoad defines a callback called when texture is loaded
  12386. * @param onError defines a callback called if there is an error
  12387. * @returns the cube texture as an InternalTexture
  12388. */
  12389. 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;
  12390. /**
  12391. * Creates a new raw cube texture from a specified url
  12392. * @param url defines the url where the data is located
  12393. * @param scene defines the current scene
  12394. * @param size defines the size of the textures
  12395. * @param format defines the format of the data
  12396. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12397. * @param noMipmap defines if the engine should avoid generating the mip levels
  12398. * @param callback defines a callback used to extract texture data from loaded data
  12399. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12400. * @param onLoad defines a callback called when texture is loaded
  12401. * @param onError defines a callback called if there is an error
  12402. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12403. * @param invertY defines if data must be stored with Y axis inverted
  12404. * @returns the cube texture as an InternalTexture
  12405. */
  12406. 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;
  12407. /**
  12408. * Creates a new raw 3D texture
  12409. * @param data defines the data used to create the texture
  12410. * @param width defines the width of the texture
  12411. * @param height defines the height of the texture
  12412. * @param depth defines the depth of the texture
  12413. * @param format defines the format of the texture
  12414. * @param generateMipMaps defines if the engine must generate mip levels
  12415. * @param invertY defines if data must be stored with Y axis inverted
  12416. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12417. * @param compression defines the compressed used (can be null)
  12418. * @param textureType defines the compressed used (can be null)
  12419. * @returns a new raw 3D texture (stored in an InternalTexture)
  12420. */
  12421. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12422. /**
  12423. * Update a raw 3D texture
  12424. * @param texture defines the texture to update
  12425. * @param data defines the data to store
  12426. * @param format defines the data format
  12427. * @param invertY defines if data must be stored with Y axis inverted
  12428. */
  12429. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12430. /**
  12431. * Update a raw 3D texture
  12432. * @param texture defines the texture to update
  12433. * @param data defines the data to store
  12434. * @param format defines the data format
  12435. * @param invertY defines if data must be stored with Y axis inverted
  12436. * @param compression defines the used compression (can be null)
  12437. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12438. */
  12439. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12440. }
  12441. }
  12442. declare module BABYLON {
  12443. /**
  12444. * Raw texture can help creating a texture directly from an array of data.
  12445. * This can be super useful if you either get the data from an uncompressed source or
  12446. * if you wish to create your texture pixel by pixel.
  12447. */
  12448. export class RawTexture extends Texture {
  12449. /**
  12450. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12451. */
  12452. format: number;
  12453. private _engine;
  12454. /**
  12455. * Instantiates a new RawTexture.
  12456. * Raw texture can help creating a texture directly from an array of data.
  12457. * This can be super useful if you either get the data from an uncompressed source or
  12458. * if you wish to create your texture pixel by pixel.
  12459. * @param data define the array of data to use to create the texture
  12460. * @param width define the width of the texture
  12461. * @param height define the height of the texture
  12462. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12463. * @param scene define the scene the texture belongs to
  12464. * @param generateMipMaps define whether mip maps should be generated or not
  12465. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12466. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12467. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12468. */
  12469. constructor(data: ArrayBufferView, width: number, height: number,
  12470. /**
  12471. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12472. */
  12473. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12474. /**
  12475. * Updates the texture underlying data.
  12476. * @param data Define the new data of the texture
  12477. */
  12478. update(data: ArrayBufferView): void;
  12479. /**
  12480. * Creates a luminance texture from some data.
  12481. * @param data Define the texture data
  12482. * @param width Define the width of the texture
  12483. * @param height Define the height of the texture
  12484. * @param scene Define the scene the texture belongs to
  12485. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12486. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12487. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12488. * @returns the luminance texture
  12489. */
  12490. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12491. /**
  12492. * Creates a luminance alpha texture from some data.
  12493. * @param data Define the texture data
  12494. * @param width Define the width of the texture
  12495. * @param height Define the height of the texture
  12496. * @param scene Define the scene the texture belongs to
  12497. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12498. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12499. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12500. * @returns the luminance alpha texture
  12501. */
  12502. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12503. /**
  12504. * Creates an alpha texture from some data.
  12505. * @param data Define the texture data
  12506. * @param width Define the width of the texture
  12507. * @param height Define the height of the texture
  12508. * @param scene Define the scene the texture belongs to
  12509. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12510. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12511. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12512. * @returns the alpha texture
  12513. */
  12514. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12515. /**
  12516. * Creates a RGB texture from some data.
  12517. * @param data Define the texture data
  12518. * @param width Define the width of the texture
  12519. * @param height Define the height of the texture
  12520. * @param scene Define the scene the texture belongs to
  12521. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12522. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12523. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12524. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12525. * @returns the RGB alpha texture
  12526. */
  12527. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12528. /**
  12529. * Creates a RGBA texture from some data.
  12530. * @param data Define the texture data
  12531. * @param width Define the width of the texture
  12532. * @param height Define the height of the texture
  12533. * @param scene Define the scene the texture belongs to
  12534. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12535. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12536. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12537. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12538. * @returns the RGBA texture
  12539. */
  12540. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12541. /**
  12542. * Creates a R texture from some data.
  12543. * @param data Define the texture data
  12544. * @param width Define the width of the texture
  12545. * @param height Define the height of the texture
  12546. * @param scene Define the scene the texture belongs to
  12547. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12548. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12549. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12550. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12551. * @returns the R texture
  12552. */
  12553. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12554. }
  12555. }
  12556. declare module BABYLON {
  12557. /**
  12558. * Interface for the size containing width and height
  12559. */
  12560. export interface ISize {
  12561. /**
  12562. * Width
  12563. */
  12564. width: number;
  12565. /**
  12566. * Heighht
  12567. */
  12568. height: number;
  12569. }
  12570. /**
  12571. * Size containing widht and height
  12572. */
  12573. export class Size implements ISize {
  12574. /**
  12575. * Width
  12576. */
  12577. width: number;
  12578. /**
  12579. * Height
  12580. */
  12581. height: number;
  12582. /**
  12583. * Creates a Size object from the given width and height (floats).
  12584. * @param width width of the new size
  12585. * @param height height of the new size
  12586. */
  12587. constructor(width: number, height: number);
  12588. /**
  12589. * Returns a string with the Size width and height
  12590. * @returns a string with the Size width and height
  12591. */
  12592. toString(): string;
  12593. /**
  12594. * "Size"
  12595. * @returns the string "Size"
  12596. */
  12597. getClassName(): string;
  12598. /**
  12599. * Returns the Size hash code.
  12600. * @returns a hash code for a unique width and height
  12601. */
  12602. getHashCode(): number;
  12603. /**
  12604. * Updates the current size from the given one.
  12605. * @param src the given size
  12606. */
  12607. copyFrom(src: Size): void;
  12608. /**
  12609. * Updates in place the current Size from the given floats.
  12610. * @param width width of the new size
  12611. * @param height height of the new size
  12612. * @returns the updated Size.
  12613. */
  12614. copyFromFloats(width: number, height: number): Size;
  12615. /**
  12616. * Updates in place the current Size from the given floats.
  12617. * @param width width to set
  12618. * @param height height to set
  12619. * @returns the updated Size.
  12620. */
  12621. set(width: number, height: number): Size;
  12622. /**
  12623. * Multiplies the width and height by numbers
  12624. * @param w factor to multiple the width by
  12625. * @param h factor to multiple the height by
  12626. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12627. */
  12628. multiplyByFloats(w: number, h: number): Size;
  12629. /**
  12630. * Clones the size
  12631. * @returns a new Size copied from the given one.
  12632. */
  12633. clone(): Size;
  12634. /**
  12635. * True if the current Size and the given one width and height are strictly equal.
  12636. * @param other the other size to compare against
  12637. * @returns True if the current Size and the given one width and height are strictly equal.
  12638. */
  12639. equals(other: Size): boolean;
  12640. /**
  12641. * The surface of the Size : width * height (float).
  12642. */
  12643. readonly surface: number;
  12644. /**
  12645. * Create a new size of zero
  12646. * @returns a new Size set to (0.0, 0.0)
  12647. */
  12648. static Zero(): Size;
  12649. /**
  12650. * Sums the width and height of two sizes
  12651. * @param otherSize size to add to this size
  12652. * @returns a new Size set as the addition result of the current Size and the given one.
  12653. */
  12654. add(otherSize: Size): Size;
  12655. /**
  12656. * Subtracts the width and height of two
  12657. * @param otherSize size to subtract to this size
  12658. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12659. */
  12660. subtract(otherSize: Size): Size;
  12661. /**
  12662. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12663. * @param start starting size to lerp between
  12664. * @param end end size to lerp between
  12665. * @param amount amount to lerp between the start and end values
  12666. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12667. */
  12668. static Lerp(start: Size, end: Size, amount: number): Size;
  12669. }
  12670. }
  12671. declare module BABYLON {
  12672. /**
  12673. * Defines a runtime animation
  12674. */
  12675. export class RuntimeAnimation {
  12676. private _events;
  12677. /**
  12678. * The current frame of the runtime animation
  12679. */
  12680. private _currentFrame;
  12681. /**
  12682. * The animation used by the runtime animation
  12683. */
  12684. private _animation;
  12685. /**
  12686. * The target of the runtime animation
  12687. */
  12688. private _target;
  12689. /**
  12690. * The initiating animatable
  12691. */
  12692. private _host;
  12693. /**
  12694. * The original value of the runtime animation
  12695. */
  12696. private _originalValue;
  12697. /**
  12698. * The original blend value of the runtime animation
  12699. */
  12700. private _originalBlendValue;
  12701. /**
  12702. * The offsets cache of the runtime animation
  12703. */
  12704. private _offsetsCache;
  12705. /**
  12706. * The high limits cache of the runtime animation
  12707. */
  12708. private _highLimitsCache;
  12709. /**
  12710. * Specifies if the runtime animation has been stopped
  12711. */
  12712. private _stopped;
  12713. /**
  12714. * The blending factor of the runtime animation
  12715. */
  12716. private _blendingFactor;
  12717. /**
  12718. * The BabylonJS scene
  12719. */
  12720. private _scene;
  12721. /**
  12722. * The current value of the runtime animation
  12723. */
  12724. private _currentValue;
  12725. /** @hidden */ private _animationState: _IAnimationState;
  12726. /**
  12727. * The active target of the runtime animation
  12728. */
  12729. private _activeTargets;
  12730. private _currentActiveTarget;
  12731. private _directTarget;
  12732. /**
  12733. * The target path of the runtime animation
  12734. */
  12735. private _targetPath;
  12736. /**
  12737. * The weight of the runtime animation
  12738. */
  12739. private _weight;
  12740. /**
  12741. * The ratio offset of the runtime animation
  12742. */
  12743. private _ratioOffset;
  12744. /**
  12745. * The previous delay of the runtime animation
  12746. */
  12747. private _previousDelay;
  12748. /**
  12749. * The previous ratio of the runtime animation
  12750. */
  12751. private _previousRatio;
  12752. private _enableBlending;
  12753. private _keys;
  12754. private _minFrame;
  12755. private _maxFrame;
  12756. private _minValue;
  12757. private _maxValue;
  12758. private _targetIsArray;
  12759. /**
  12760. * Gets the current frame of the runtime animation
  12761. */
  12762. readonly currentFrame: number;
  12763. /**
  12764. * Gets the weight of the runtime animation
  12765. */
  12766. readonly weight: number;
  12767. /**
  12768. * Gets the current value of the runtime animation
  12769. */
  12770. readonly currentValue: any;
  12771. /**
  12772. * Gets the target path of the runtime animation
  12773. */
  12774. readonly targetPath: string;
  12775. /**
  12776. * Gets the actual target of the runtime animation
  12777. */
  12778. readonly target: any;
  12779. /** @hidden */ private _onLoop: () => void;
  12780. /**
  12781. * Create a new RuntimeAnimation object
  12782. * @param target defines the target of the animation
  12783. * @param animation defines the source animation object
  12784. * @param scene defines the hosting scene
  12785. * @param host defines the initiating Animatable
  12786. */
  12787. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12788. private _preparePath;
  12789. /**
  12790. * Gets the animation from the runtime animation
  12791. */
  12792. readonly animation: Animation;
  12793. /**
  12794. * Resets the runtime animation to the beginning
  12795. * @param restoreOriginal defines whether to restore the target property to the original value
  12796. */
  12797. reset(restoreOriginal?: boolean): void;
  12798. /**
  12799. * Specifies if the runtime animation is stopped
  12800. * @returns Boolean specifying if the runtime animation is stopped
  12801. */
  12802. isStopped(): boolean;
  12803. /**
  12804. * Disposes of the runtime animation
  12805. */
  12806. dispose(): void;
  12807. /**
  12808. * Apply the interpolated value to the target
  12809. * @param currentValue defines the value computed by the animation
  12810. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12811. */
  12812. setValue(currentValue: any, weight: number): void;
  12813. private _getOriginalValues;
  12814. private _setValue;
  12815. /**
  12816. * Gets the loop pmode of the runtime animation
  12817. * @returns Loop Mode
  12818. */
  12819. private _getCorrectLoopMode;
  12820. /**
  12821. * Move the current animation to a given frame
  12822. * @param frame defines the frame to move to
  12823. */
  12824. goToFrame(frame: number): void;
  12825. /**
  12826. * @hidden Internal use only
  12827. */ private _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12828. /**
  12829. * Execute the current animation
  12830. * @param delay defines the delay to add to the current frame
  12831. * @param from defines the lower bound of the animation range
  12832. * @param to defines the upper bound of the animation range
  12833. * @param loop defines if the current animation must loop
  12834. * @param speedRatio defines the current speed ratio
  12835. * @param weight defines the weight of the animation (default is -1 so no weight)
  12836. * @param onLoop optional callback called when animation loops
  12837. * @returns a boolean indicating if the animation is running
  12838. */
  12839. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12840. }
  12841. }
  12842. declare module BABYLON {
  12843. /**
  12844. * Class used to store an actual running animation
  12845. */
  12846. export class Animatable {
  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;
  12855. /** defines a callback to call when animation ends if it is not looping */
  12856. onAnimationEnd?: (() => void) | null | undefined;
  12857. /** defines a callback to call when animation loops */
  12858. onAnimationLoop?: (() => void) | null | undefined;
  12859. private _localDelayOffset;
  12860. private _pausedDelay;
  12861. private _runtimeAnimations;
  12862. private _paused;
  12863. private _scene;
  12864. private _speedRatio;
  12865. private _weight;
  12866. private _syncRoot;
  12867. /**
  12868. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12869. * This will only apply for non looping animation (default is true)
  12870. */
  12871. disposeOnEnd: boolean;
  12872. /**
  12873. * Gets a boolean indicating if the animation has started
  12874. */
  12875. animationStarted: boolean;
  12876. /**
  12877. * Observer raised when the animation ends
  12878. */
  12879. onAnimationEndObservable: Observable<Animatable>;
  12880. /**
  12881. * Observer raised when the animation loops
  12882. */
  12883. onAnimationLoopObservable: Observable<Animatable>;
  12884. /**
  12885. * Gets the root Animatable used to synchronize and normalize animations
  12886. */
  12887. readonly syncRoot: Nullable<Animatable>;
  12888. /**
  12889. * Gets the current frame of the first RuntimeAnimation
  12890. * Used to synchronize Animatables
  12891. */
  12892. readonly masterFrame: number;
  12893. /**
  12894. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12895. */
  12896. weight: number;
  12897. /**
  12898. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12899. */
  12900. speedRatio: number;
  12901. /**
  12902. * Creates a new Animatable
  12903. * @param scene defines the hosting scene
  12904. * @param target defines the target object
  12905. * @param fromFrame defines the starting frame number (default is 0)
  12906. * @param toFrame defines the ending frame number (default is 100)
  12907. * @param loopAnimation defines if the animation must loop (default is false)
  12908. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12909. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12910. * @param animations defines a group of animation to add to the new Animatable
  12911. * @param onAnimationLoop defines a callback to call when animation loops
  12912. */
  12913. constructor(scene: Scene,
  12914. /** defines the target object */
  12915. target: any,
  12916. /** defines the starting frame number (default is 0) */
  12917. fromFrame?: number,
  12918. /** defines the ending frame number (default is 100) */
  12919. toFrame?: number,
  12920. /** defines if the animation must loop (default is false) */
  12921. loopAnimation?: boolean, speedRatio?: number,
  12922. /** defines a callback to call when animation ends if it is not looping */
  12923. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12924. /** defines a callback to call when animation loops */
  12925. onAnimationLoop?: (() => void) | null | undefined);
  12926. /**
  12927. * Synchronize and normalize current Animatable with a source Animatable
  12928. * This is useful when using animation weights and when animations are not of the same length
  12929. * @param root defines the root Animatable to synchronize with
  12930. * @returns the current Animatable
  12931. */
  12932. syncWith(root: Animatable): Animatable;
  12933. /**
  12934. * Gets the list of runtime animations
  12935. * @returns an array of RuntimeAnimation
  12936. */
  12937. getAnimations(): RuntimeAnimation[];
  12938. /**
  12939. * Adds more animations to the current animatable
  12940. * @param target defines the target of the animations
  12941. * @param animations defines the new animations to add
  12942. */
  12943. appendAnimations(target: any, animations: Animation[]): void;
  12944. /**
  12945. * Gets the source animation for a specific property
  12946. * @param property defines the propertyu to look for
  12947. * @returns null or the source animation for the given property
  12948. */
  12949. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12950. /**
  12951. * Gets the runtime animation for a specific property
  12952. * @param property defines the propertyu to look for
  12953. * @returns null or the runtime animation for the given property
  12954. */
  12955. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12956. /**
  12957. * Resets the animatable to its original state
  12958. */
  12959. reset(): void;
  12960. /**
  12961. * Allows the animatable to blend with current running animations
  12962. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12963. * @param blendingSpeed defines the blending speed to use
  12964. */
  12965. enableBlending(blendingSpeed: number): void;
  12966. /**
  12967. * Disable animation blending
  12968. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12969. */
  12970. disableBlending(): void;
  12971. /**
  12972. * Jump directly to a given frame
  12973. * @param frame defines the frame to jump to
  12974. */
  12975. goToFrame(frame: number): void;
  12976. /**
  12977. * Pause the animation
  12978. */
  12979. pause(): void;
  12980. /**
  12981. * Restart the animation
  12982. */
  12983. restart(): void;
  12984. private _raiseOnAnimationEnd;
  12985. /**
  12986. * Stop and delete the current animation
  12987. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12988. * @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)
  12989. */
  12990. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12991. /**
  12992. * Wait asynchronously for the animation to end
  12993. * @returns a promise which will be fullfilled when the animation ends
  12994. */
  12995. waitAsync(): Promise<Animatable>;
  12996. /** @hidden */ private _animate(delay: number): boolean;
  12997. }
  12998. interface Scene {
  12999. /** @hidden */ private _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13000. /** @hidden */ private _processLateAnimationBindingsForMatrices(holder: {
  13001. totalWeight: number;
  13002. animations: RuntimeAnimation[];
  13003. originalValue: Matrix;
  13004. }): any;
  13005. /** @hidden */ private _processLateAnimationBindingsForQuaternions(holder: {
  13006. totalWeight: number;
  13007. animations: RuntimeAnimation[];
  13008. originalValue: Quaternion;
  13009. }, refQuaternion: Quaternion): Quaternion;
  13010. /** @hidden */ private _processLateAnimationBindings(): void;
  13011. /**
  13012. * Will start the animation sequence of a given target
  13013. * @param target defines the target
  13014. * @param from defines from which frame should animation start
  13015. * @param to defines until which frame should animation run.
  13016. * @param weight defines the weight to apply to the animation (1.0 by default)
  13017. * @param loop defines if the animation loops
  13018. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13019. * @param onAnimationEnd defines the function to be executed when the animation ends
  13020. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13021. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13022. * @param onAnimationLoop defines the callback to call when an animation loops
  13023. * @returns the animatable object created for this animation
  13024. */
  13025. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13026. /**
  13027. * Will start the animation sequence of a given target
  13028. * @param target defines the target
  13029. * @param from defines from which frame should animation start
  13030. * @param to defines until which frame should animation run.
  13031. * @param loop defines if the animation loops
  13032. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13033. * @param onAnimationEnd defines the function to be executed when the animation ends
  13034. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13035. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13036. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13037. * @param onAnimationLoop defines the callback to call when an animation loops
  13038. * @returns the animatable object created for this animation
  13039. */
  13040. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13041. /**
  13042. * Will start the animation sequence of a given target and its hierarchy
  13043. * @param target defines the target
  13044. * @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.
  13045. * @param from defines from which frame should animation start
  13046. * @param to defines until which frame should animation run.
  13047. * @param loop defines if the animation loops
  13048. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13049. * @param onAnimationEnd defines the function to be executed when the animation ends
  13050. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13051. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13052. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13053. * @param onAnimationLoop defines the callback to call when an animation loops
  13054. * @returns the list of created animatables
  13055. */
  13056. 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[];
  13057. /**
  13058. * Begin a new animation on a given node
  13059. * @param target defines the target where the animation will take place
  13060. * @param animations defines the list of animations to start
  13061. * @param from defines the initial value
  13062. * @param to defines the final value
  13063. * @param loop defines if you want animation to loop (off by default)
  13064. * @param speedRatio defines the speed ratio to apply to all animations
  13065. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13066. * @param onAnimationLoop defines the callback to call when an animation loops
  13067. * @returns the list of created animatables
  13068. */
  13069. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13070. /**
  13071. * Begin a new animation on a given node and its hierarchy
  13072. * @param target defines the root node where the animation will take place
  13073. * @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.
  13074. * @param animations defines the list of animations to start
  13075. * @param from defines the initial value
  13076. * @param to defines the final value
  13077. * @param loop defines if you want animation to loop (off by default)
  13078. * @param speedRatio defines the speed ratio to apply to all animations
  13079. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13080. * @param onAnimationLoop defines the callback to call when an animation loops
  13081. * @returns the list of animatables created for all nodes
  13082. */
  13083. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13084. /**
  13085. * Gets the animatable associated with a specific target
  13086. * @param target defines the target of the animatable
  13087. * @returns the required animatable if found
  13088. */
  13089. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13090. /**
  13091. * Gets all animatables associated with a given target
  13092. * @param target defines the target to look animatables for
  13093. * @returns an array of Animatables
  13094. */
  13095. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13096. /**
  13097. * Stops and removes all animations that have been applied to the scene
  13098. */
  13099. stopAllAnimations(): void;
  13100. /**
  13101. * Gets the current delta time used by animation engine
  13102. */
  13103. deltaTime: number;
  13104. }
  13105. interface Bone {
  13106. /**
  13107. * Copy an animation range from another bone
  13108. * @param source defines the source bone
  13109. * @param rangeName defines the range name to copy
  13110. * @param frameOffset defines the frame offset
  13111. * @param rescaleAsRequired defines if rescaling must be applied if required
  13112. * @param skelDimensionsRatio defines the scaling ratio
  13113. * @returns true if operation was successful
  13114. */
  13115. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13116. }
  13117. }
  13118. declare module BABYLON {
  13119. /**
  13120. * Class used to override all child animations of a given target
  13121. */
  13122. export class AnimationPropertiesOverride {
  13123. /**
  13124. * Gets or sets a value indicating if animation blending must be used
  13125. */
  13126. enableBlending: boolean;
  13127. /**
  13128. * Gets or sets the blending speed to use when enableBlending is true
  13129. */
  13130. blendingSpeed: number;
  13131. /**
  13132. * Gets or sets the default loop mode to use
  13133. */
  13134. loopMode: number;
  13135. }
  13136. }
  13137. declare module BABYLON {
  13138. /**
  13139. * Class used to handle skinning animations
  13140. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13141. */
  13142. export class Skeleton implements IAnimatable {
  13143. /** defines the skeleton name */
  13144. name: string;
  13145. /** defines the skeleton Id */
  13146. id: string;
  13147. /**
  13148. * Defines the list of child bones
  13149. */
  13150. bones: Bone[];
  13151. /**
  13152. * Defines an estimate of the dimension of the skeleton at rest
  13153. */
  13154. dimensionsAtRest: Vector3;
  13155. /**
  13156. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13157. */
  13158. needInitialSkinMatrix: boolean;
  13159. /**
  13160. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13161. */
  13162. overrideMesh: Nullable<AbstractMesh>;
  13163. /**
  13164. * Gets the list of animations attached to this skeleton
  13165. */
  13166. animations: Array<Animation>;
  13167. private _scene;
  13168. private _isDirty;
  13169. private _transformMatrices;
  13170. private _transformMatrixTexture;
  13171. private _meshesWithPoseMatrix;
  13172. private _animatables;
  13173. private _identity;
  13174. private _synchronizedWithMesh;
  13175. private _ranges;
  13176. private _lastAbsoluteTransformsUpdateId;
  13177. private _canUseTextureForBones;
  13178. private _uniqueId;
  13179. /** @hidden */ private _numBonesWithLinkedTransformNode: number;
  13180. /** @hidden */ private _hasWaitingData: Nullable<boolean>;
  13181. /**
  13182. * Specifies if the skeleton should be serialized
  13183. */
  13184. doNotSerialize: boolean;
  13185. private _useTextureToStoreBoneMatrices;
  13186. /**
  13187. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13188. * Please note that this option is not available if the hardware does not support it
  13189. */
  13190. useTextureToStoreBoneMatrices: boolean;
  13191. private _animationPropertiesOverride;
  13192. /**
  13193. * Gets or sets the animation properties override
  13194. */
  13195. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13196. /**
  13197. * List of inspectable custom properties (used by the Inspector)
  13198. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13199. */
  13200. inspectableCustomProperties: IInspectable[];
  13201. /**
  13202. * An observable triggered before computing the skeleton's matrices
  13203. */
  13204. onBeforeComputeObservable: Observable<Skeleton>;
  13205. /**
  13206. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13207. */
  13208. readonly isUsingTextureForMatrices: boolean;
  13209. /**
  13210. * Gets the unique ID of this skeleton
  13211. */
  13212. readonly uniqueId: number;
  13213. /**
  13214. * Creates a new skeleton
  13215. * @param name defines the skeleton name
  13216. * @param id defines the skeleton Id
  13217. * @param scene defines the hosting scene
  13218. */
  13219. constructor(
  13220. /** defines the skeleton name */
  13221. name: string,
  13222. /** defines the skeleton Id */
  13223. id: string, scene: Scene);
  13224. /**
  13225. * Gets the current object class name.
  13226. * @return the class name
  13227. */
  13228. getClassName(): string;
  13229. /**
  13230. * Returns an array containing the root bones
  13231. * @returns an array containing the root bones
  13232. */
  13233. getChildren(): Array<Bone>;
  13234. /**
  13235. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13236. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13237. * @returns a Float32Array containing matrices data
  13238. */
  13239. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13240. /**
  13241. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13242. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13243. * @returns a raw texture containing the data
  13244. */
  13245. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13246. /**
  13247. * Gets the current hosting scene
  13248. * @returns a scene object
  13249. */
  13250. getScene(): Scene;
  13251. /**
  13252. * Gets a string representing the current skeleton data
  13253. * @param fullDetails defines a boolean indicating if we want a verbose version
  13254. * @returns a string representing the current skeleton data
  13255. */
  13256. toString(fullDetails?: boolean): string;
  13257. /**
  13258. * Get bone's index searching by name
  13259. * @param name defines bone's name to search for
  13260. * @return the indice of the bone. Returns -1 if not found
  13261. */
  13262. getBoneIndexByName(name: string): number;
  13263. /**
  13264. * Creater a new animation range
  13265. * @param name defines the name of the range
  13266. * @param from defines the start key
  13267. * @param to defines the end key
  13268. */
  13269. createAnimationRange(name: string, from: number, to: number): void;
  13270. /**
  13271. * Delete a specific animation range
  13272. * @param name defines the name of the range
  13273. * @param deleteFrames defines if frames must be removed as well
  13274. */
  13275. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13276. /**
  13277. * Gets a specific animation range
  13278. * @param name defines the name of the range to look for
  13279. * @returns the requested animation range or null if not found
  13280. */
  13281. getAnimationRange(name: string): Nullable<AnimationRange>;
  13282. /**
  13283. * Gets the list of all animation ranges defined on this skeleton
  13284. * @returns an array
  13285. */
  13286. getAnimationRanges(): Nullable<AnimationRange>[];
  13287. /**
  13288. * Copy animation range from a source skeleton.
  13289. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13290. * @param source defines the source skeleton
  13291. * @param name defines the name of the range to copy
  13292. * @param rescaleAsRequired defines if rescaling must be applied if required
  13293. * @returns true if operation was successful
  13294. */
  13295. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13296. /**
  13297. * Forces the skeleton to go to rest pose
  13298. */
  13299. returnToRest(): void;
  13300. private _getHighestAnimationFrame;
  13301. /**
  13302. * Begin a specific animation range
  13303. * @param name defines the name of the range to start
  13304. * @param loop defines if looping must be turned on (false by default)
  13305. * @param speedRatio defines the speed ratio to apply (1 by default)
  13306. * @param onAnimationEnd defines a callback which will be called when animation will end
  13307. * @returns a new animatable
  13308. */
  13309. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13310. /** @hidden */ private _markAsDirty(): void;
  13311. /** @hidden */ private _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13312. /** @hidden */ private _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13313. private _computeTransformMatrices;
  13314. /**
  13315. * Build all resources required to render a skeleton
  13316. */
  13317. prepare(): void;
  13318. /**
  13319. * Gets the list of animatables currently running for this skeleton
  13320. * @returns an array of animatables
  13321. */
  13322. getAnimatables(): IAnimatable[];
  13323. /**
  13324. * Clone the current skeleton
  13325. * @param name defines the name of the new skeleton
  13326. * @param id defines the id of the new skeleton
  13327. * @returns the new skeleton
  13328. */
  13329. clone(name: string, id: string): Skeleton;
  13330. /**
  13331. * Enable animation blending for this skeleton
  13332. * @param blendingSpeed defines the blending speed to apply
  13333. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13334. */
  13335. enableBlending(blendingSpeed?: number): void;
  13336. /**
  13337. * Releases all resources associated with the current skeleton
  13338. */
  13339. dispose(): void;
  13340. /**
  13341. * Serialize the skeleton in a JSON object
  13342. * @returns a JSON object
  13343. */
  13344. serialize(): any;
  13345. /**
  13346. * Creates a new skeleton from serialized data
  13347. * @param parsedSkeleton defines the serialized data
  13348. * @param scene defines the hosting scene
  13349. * @returns a new skeleton
  13350. */
  13351. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13352. /**
  13353. * Compute all node absolute transforms
  13354. * @param forceUpdate defines if computation must be done even if cache is up to date
  13355. */
  13356. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13357. /**
  13358. * Gets the root pose matrix
  13359. * @returns a matrix
  13360. */
  13361. getPoseMatrix(): Nullable<Matrix>;
  13362. /**
  13363. * Sorts bones per internal index
  13364. */
  13365. sortBones(): void;
  13366. private _sortBones;
  13367. }
  13368. }
  13369. declare module BABYLON {
  13370. /**
  13371. * Class used to store bone information
  13372. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13373. */
  13374. export class Bone extends Node {
  13375. /**
  13376. * defines the bone name
  13377. */
  13378. name: string;
  13379. private static _tmpVecs;
  13380. private static _tmpQuat;
  13381. private static _tmpMats;
  13382. /**
  13383. * Gets the list of child bones
  13384. */
  13385. children: Bone[];
  13386. /** Gets the animations associated with this bone */
  13387. animations: Animation[];
  13388. /**
  13389. * Gets or sets bone length
  13390. */
  13391. length: number;
  13392. /**
  13393. * @hidden Internal only
  13394. * Set this value to map this bone to a different index in the transform matrices
  13395. * Set this value to -1 to exclude the bone from the transform matrices
  13396. */ private _index: Nullable<number>;
  13397. private _skeleton;
  13398. private _localMatrix;
  13399. private _restPose;
  13400. private _baseMatrix;
  13401. private _absoluteTransform;
  13402. private _invertedAbsoluteTransform;
  13403. private _parent;
  13404. private _scalingDeterminant;
  13405. private _worldTransform;
  13406. private _localScaling;
  13407. private _localRotation;
  13408. private _localPosition;
  13409. private _needToDecompose;
  13410. private _needToCompose;
  13411. /** @hidden */ private _linkedTransformNode: Nullable<TransformNode>;
  13412. /** @hidden */ private _waitingTransformNodeId: Nullable<string>;
  13413. /** @hidden */
  13414. /** @hidden */ private _matrix: Matrix;
  13415. /**
  13416. * Create a new bone
  13417. * @param name defines the bone name
  13418. * @param skeleton defines the parent skeleton
  13419. * @param parentBone defines the parent (can be null if the bone is the root)
  13420. * @param localMatrix defines the local matrix
  13421. * @param restPose defines the rest pose matrix
  13422. * @param baseMatrix defines the base matrix
  13423. * @param index defines index of the bone in the hiearchy
  13424. */
  13425. constructor(
  13426. /**
  13427. * defines the bone name
  13428. */
  13429. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13430. /**
  13431. * Gets the current object class name.
  13432. * @return the class name
  13433. */
  13434. getClassName(): string;
  13435. /**
  13436. * Gets the parent skeleton
  13437. * @returns a skeleton
  13438. */
  13439. getSkeleton(): Skeleton;
  13440. /**
  13441. * Gets parent bone
  13442. * @returns a bone or null if the bone is the root of the bone hierarchy
  13443. */
  13444. getParent(): Nullable<Bone>;
  13445. /**
  13446. * Returns an array containing the root bones
  13447. * @returns an array containing the root bones
  13448. */
  13449. getChildren(): Array<Bone>;
  13450. /**
  13451. * Sets the parent bone
  13452. * @param parent defines the parent (can be null if the bone is the root)
  13453. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13454. */
  13455. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13456. /**
  13457. * Gets the local matrix
  13458. * @returns a matrix
  13459. */
  13460. getLocalMatrix(): Matrix;
  13461. /**
  13462. * Gets the base matrix (initial matrix which remains unchanged)
  13463. * @returns a matrix
  13464. */
  13465. getBaseMatrix(): Matrix;
  13466. /**
  13467. * Gets the rest pose matrix
  13468. * @returns a matrix
  13469. */
  13470. getRestPose(): Matrix;
  13471. /**
  13472. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13473. */
  13474. getWorldMatrix(): Matrix;
  13475. /**
  13476. * Sets the local matrix to rest pose matrix
  13477. */
  13478. returnToRest(): void;
  13479. /**
  13480. * Gets the inverse of the absolute transform matrix.
  13481. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13482. * @returns a matrix
  13483. */
  13484. getInvertedAbsoluteTransform(): Matrix;
  13485. /**
  13486. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13487. * @returns a matrix
  13488. */
  13489. getAbsoluteTransform(): Matrix;
  13490. /**
  13491. * Links with the given transform node.
  13492. * The local matrix of this bone is copied from the transform node every frame.
  13493. * @param transformNode defines the transform node to link to
  13494. */
  13495. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13496. /**
  13497. * Gets the node used to drive the bone's transformation
  13498. * @returns a transform node or null
  13499. */
  13500. getTransformNode(): Nullable<TransformNode>;
  13501. /** Gets or sets current position (in local space) */
  13502. position: Vector3;
  13503. /** Gets or sets current rotation (in local space) */
  13504. rotation: Vector3;
  13505. /** Gets or sets current rotation quaternion (in local space) */
  13506. rotationQuaternion: Quaternion;
  13507. /** Gets or sets current scaling (in local space) */
  13508. scaling: Vector3;
  13509. /**
  13510. * Gets the animation properties override
  13511. */
  13512. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13513. private _decompose;
  13514. private _compose;
  13515. /**
  13516. * Update the base and local matrices
  13517. * @param matrix defines the new base or local matrix
  13518. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13519. * @param updateLocalMatrix defines if the local matrix should be updated
  13520. */
  13521. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13522. /** @hidden */ private _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13523. /**
  13524. * Flag the bone as dirty (Forcing it to update everything)
  13525. */
  13526. markAsDirty(): void;
  13527. /** @hidden */ private _markAsDirtyAndCompose(): void;
  13528. private _markAsDirtyAndDecompose;
  13529. /**
  13530. * Translate the bone in local or world space
  13531. * @param vec The amount to translate the bone
  13532. * @param space The space that the translation is in
  13533. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13534. */
  13535. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13536. /**
  13537. * Set the postion of the bone in local or world space
  13538. * @param position The position to set the bone
  13539. * @param space The space that the position is in
  13540. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13541. */
  13542. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13543. /**
  13544. * Set the absolute position of the bone (world space)
  13545. * @param position The position to set the bone
  13546. * @param mesh The mesh that this bone is attached to
  13547. */
  13548. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13549. /**
  13550. * Scale the bone on the x, y and z axes (in local space)
  13551. * @param x The amount to scale the bone on the x axis
  13552. * @param y The amount to scale the bone on the y axis
  13553. * @param z The amount to scale the bone on the z axis
  13554. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13555. */
  13556. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13557. /**
  13558. * Set the bone scaling in local space
  13559. * @param scale defines the scaling vector
  13560. */
  13561. setScale(scale: Vector3): void;
  13562. /**
  13563. * Gets the current scaling in local space
  13564. * @returns the current scaling vector
  13565. */
  13566. getScale(): Vector3;
  13567. /**
  13568. * Gets the current scaling in local space and stores it in a target vector
  13569. * @param result defines the target vector
  13570. */
  13571. getScaleToRef(result: Vector3): void;
  13572. /**
  13573. * Set the yaw, pitch, and roll of the bone in local or world space
  13574. * @param yaw The rotation of the bone on the y axis
  13575. * @param pitch The rotation of the bone on the x axis
  13576. * @param roll The rotation of the bone on the z axis
  13577. * @param space The space that the axes of rotation are in
  13578. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13579. */
  13580. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13581. /**
  13582. * Add a rotation to the bone on an axis in local or world space
  13583. * @param axis The axis to rotate the bone on
  13584. * @param amount The amount to rotate the bone
  13585. * @param space The space that the axis is in
  13586. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13587. */
  13588. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13589. /**
  13590. * Set the rotation of the bone to a particular axis angle in local or world space
  13591. * @param axis The axis to rotate the bone on
  13592. * @param angle The angle that the bone should be rotated to
  13593. * @param space The space that the axis is in
  13594. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13595. */
  13596. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13597. /**
  13598. * Set the euler rotation of the bone in local of world space
  13599. * @param rotation The euler rotation that the bone should be set to
  13600. * @param space The space that the rotation is in
  13601. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13602. */
  13603. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13604. /**
  13605. * Set the quaternion rotation of the bone in local of world space
  13606. * @param quat The quaternion rotation that the bone should be set to
  13607. * @param space The space that the rotation is in
  13608. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13609. */
  13610. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13611. /**
  13612. * Set the rotation matrix of the bone in local of world space
  13613. * @param rotMat The rotation matrix that the bone should be set to
  13614. * @param space The space that the rotation is in
  13615. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13616. */
  13617. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13618. private _rotateWithMatrix;
  13619. private _getNegativeRotationToRef;
  13620. /**
  13621. * Get the position of the bone in local or world space
  13622. * @param space The space that the returned position is in
  13623. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13624. * @returns The position of the bone
  13625. */
  13626. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13627. /**
  13628. * Copy the position of the bone to a vector3 in local or world space
  13629. * @param space The space that the returned position is in
  13630. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13631. * @param result The vector3 to copy the position to
  13632. */
  13633. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13634. /**
  13635. * Get the absolute position of the bone (world space)
  13636. * @param mesh The mesh that this bone is attached to
  13637. * @returns The absolute position of the bone
  13638. */
  13639. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13640. /**
  13641. * Copy the absolute position of the bone (world space) to the result param
  13642. * @param mesh The mesh that this bone is attached to
  13643. * @param result The vector3 to copy the absolute position to
  13644. */
  13645. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13646. /**
  13647. * Compute the absolute transforms of this bone and its children
  13648. */
  13649. computeAbsoluteTransforms(): void;
  13650. /**
  13651. * Get the world direction from an axis that is in the local space of the bone
  13652. * @param localAxis The local direction that is used to compute the world direction
  13653. * @param mesh The mesh that this bone is attached to
  13654. * @returns The world direction
  13655. */
  13656. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13657. /**
  13658. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13659. * @param localAxis The local direction that is used to compute the world direction
  13660. * @param mesh The mesh that this bone is attached to
  13661. * @param result The vector3 that the world direction will be copied to
  13662. */
  13663. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13664. /**
  13665. * Get the euler rotation of the bone in local or world space
  13666. * @param space The space that the rotation should be in
  13667. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13668. * @returns The euler rotation
  13669. */
  13670. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13671. /**
  13672. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13673. * @param space The space that the rotation should be in
  13674. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13675. * @param result The vector3 that the rotation should be copied to
  13676. */
  13677. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13678. /**
  13679. * Get the quaternion rotation of the bone in either local or world space
  13680. * @param space The space that the rotation should be in
  13681. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13682. * @returns The quaternion rotation
  13683. */
  13684. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13685. /**
  13686. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13687. * @param space The space that the rotation should be in
  13688. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13689. * @param result The quaternion that the rotation should be copied to
  13690. */
  13691. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13692. /**
  13693. * Get the rotation matrix of the bone in local or world space
  13694. * @param space The space that the rotation should be in
  13695. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13696. * @returns The rotation matrix
  13697. */
  13698. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13699. /**
  13700. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13701. * @param space The space that the rotation should be in
  13702. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13703. * @param result The quaternion that the rotation should be copied to
  13704. */
  13705. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13706. /**
  13707. * Get the world position of a point that is in the local space of the bone
  13708. * @param position The local position
  13709. * @param mesh The mesh that this bone is attached to
  13710. * @returns The world position
  13711. */
  13712. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13713. /**
  13714. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13715. * @param position The local position
  13716. * @param mesh The mesh that this bone is attached to
  13717. * @param result The vector3 that the world position should be copied to
  13718. */
  13719. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13720. /**
  13721. * Get the local position of a point that is in world space
  13722. * @param position The world position
  13723. * @param mesh The mesh that this bone is attached to
  13724. * @returns The local position
  13725. */
  13726. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13727. /**
  13728. * Get the local position of a point that is in world space and copy it to the result param
  13729. * @param position The world position
  13730. * @param mesh The mesh that this bone is attached to
  13731. * @param result The vector3 that the local position should be copied to
  13732. */
  13733. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13734. }
  13735. }
  13736. declare module BABYLON {
  13737. /**
  13738. * 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.
  13739. * @see https://doc.babylonjs.com/how_to/transformnode
  13740. */
  13741. export class TransformNode extends Node {
  13742. /**
  13743. * Object will not rotate to face the camera
  13744. */
  13745. static BILLBOARDMODE_NONE: number;
  13746. /**
  13747. * Object will rotate to face the camera but only on the x axis
  13748. */
  13749. static BILLBOARDMODE_X: number;
  13750. /**
  13751. * Object will rotate to face the camera but only on the y axis
  13752. */
  13753. static BILLBOARDMODE_Y: number;
  13754. /**
  13755. * Object will rotate to face the camera but only on the z axis
  13756. */
  13757. static BILLBOARDMODE_Z: number;
  13758. /**
  13759. * Object will rotate to face the camera
  13760. */
  13761. static BILLBOARDMODE_ALL: number;
  13762. /**
  13763. * Object will rotate to face the camera's position instead of orientation
  13764. */
  13765. static BILLBOARDMODE_USE_POSITION: number;
  13766. private _forward;
  13767. private _forwardInverted;
  13768. private _up;
  13769. private _right;
  13770. private _rightInverted;
  13771. private _position;
  13772. private _rotation;
  13773. private _rotationQuaternion;
  13774. protected _scaling: Vector3;
  13775. protected _isDirty: boolean;
  13776. private _transformToBoneReferal;
  13777. private _isAbsoluteSynced;
  13778. private _billboardMode;
  13779. /**
  13780. * Gets or sets the billboard mode. Default is 0.
  13781. *
  13782. * | Value | Type | Description |
  13783. * | --- | --- | --- |
  13784. * | 0 | BILLBOARDMODE_NONE | |
  13785. * | 1 | BILLBOARDMODE_X | |
  13786. * | 2 | BILLBOARDMODE_Y | |
  13787. * | 4 | BILLBOARDMODE_Z | |
  13788. * | 7 | BILLBOARDMODE_ALL | |
  13789. *
  13790. */
  13791. billboardMode: number;
  13792. private _preserveParentRotationForBillboard;
  13793. /**
  13794. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13795. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13796. */
  13797. preserveParentRotationForBillboard: boolean;
  13798. /**
  13799. * 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
  13800. */
  13801. scalingDeterminant: number;
  13802. private _infiniteDistance;
  13803. /**
  13804. * Gets or sets the distance of the object to max, often used by skybox
  13805. */
  13806. infiniteDistance: boolean;
  13807. /**
  13808. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13809. * By default the system will update normals to compensate
  13810. */
  13811. ignoreNonUniformScaling: boolean;
  13812. /**
  13813. * 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
  13814. */
  13815. reIntegrateRotationIntoRotationQuaternion: boolean;
  13816. /** @hidden */ private _poseMatrix: Nullable<Matrix>;
  13817. /** @hidden */ private _localMatrix: Matrix;
  13818. private _usePivotMatrix;
  13819. private _absolutePosition;
  13820. private _absoluteScaling;
  13821. private _absoluteRotationQuaternion;
  13822. private _pivotMatrix;
  13823. private _pivotMatrixInverse;
  13824. protected _postMultiplyPivotMatrix: boolean;
  13825. protected _isWorldMatrixFrozen: boolean;
  13826. /** @hidden */ private _indexInSceneTransformNodesArray: number;
  13827. /**
  13828. * An event triggered after the world matrix is updated
  13829. */
  13830. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13831. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13832. /**
  13833. * Gets a string identifying the name of the class
  13834. * @returns "TransformNode" string
  13835. */
  13836. getClassName(): string;
  13837. /**
  13838. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13839. */
  13840. position: Vector3;
  13841. /**
  13842. * 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)).
  13843. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13844. */
  13845. rotation: Vector3;
  13846. /**
  13847. * 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)).
  13848. */
  13849. scaling: Vector3;
  13850. /**
  13851. * 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).
  13852. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13853. */
  13854. rotationQuaternion: Nullable<Quaternion>;
  13855. /**
  13856. * The forward direction of that transform in world space.
  13857. */
  13858. readonly forward: Vector3;
  13859. /**
  13860. * The up direction of that transform in world space.
  13861. */
  13862. readonly up: Vector3;
  13863. /**
  13864. * The right direction of that transform in world space.
  13865. */
  13866. readonly right: Vector3;
  13867. /**
  13868. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13869. * @param matrix the matrix to copy the pose from
  13870. * @returns this TransformNode.
  13871. */
  13872. updatePoseMatrix(matrix: Matrix): TransformNode;
  13873. /**
  13874. * Returns the mesh Pose matrix.
  13875. * @returns the pose matrix
  13876. */
  13877. getPoseMatrix(): Matrix;
  13878. /** @hidden */ private _isSynchronized(): boolean;
  13879. /** @hidden */ private _initCache(): void;
  13880. /**
  13881. * Flag the transform node as dirty (Forcing it to update everything)
  13882. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13883. * @returns this transform node
  13884. */
  13885. markAsDirty(property: string): TransformNode;
  13886. /**
  13887. * Returns the current mesh absolute position.
  13888. * Returns a Vector3.
  13889. */
  13890. readonly absolutePosition: Vector3;
  13891. /**
  13892. * Returns the current mesh absolute scaling.
  13893. * Returns a Vector3.
  13894. */
  13895. readonly absoluteScaling: Vector3;
  13896. /**
  13897. * Returns the current mesh absolute rotation.
  13898. * Returns a Quaternion.
  13899. */
  13900. readonly absoluteRotationQuaternion: Quaternion;
  13901. /**
  13902. * Sets a new matrix to apply before all other transformation
  13903. * @param matrix defines the transform matrix
  13904. * @returns the current TransformNode
  13905. */
  13906. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13907. /**
  13908. * Sets a new pivot matrix to the current node
  13909. * @param matrix defines the new pivot matrix to use
  13910. * @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
  13911. * @returns the current TransformNode
  13912. */
  13913. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13914. /**
  13915. * Returns the mesh pivot matrix.
  13916. * Default : Identity.
  13917. * @returns the matrix
  13918. */
  13919. getPivotMatrix(): Matrix;
  13920. /**
  13921. * Instantiate (when possible) or clone that node with its hierarchy
  13922. * @param newParent defines the new parent to use for the instance (or clone)
  13923. * @returns an instance (or a clone) of the current node with its hiearchy
  13924. */
  13925. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13926. /**
  13927. * Prevents the World matrix to be computed any longer
  13928. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13929. * @returns the TransformNode.
  13930. */
  13931. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13932. /**
  13933. * Allows back the World matrix computation.
  13934. * @returns the TransformNode.
  13935. */
  13936. unfreezeWorldMatrix(): this;
  13937. /**
  13938. * True if the World matrix has been frozen.
  13939. */
  13940. readonly isWorldMatrixFrozen: boolean;
  13941. /**
  13942. * Retuns the mesh absolute position in the World.
  13943. * @returns a Vector3.
  13944. */
  13945. getAbsolutePosition(): Vector3;
  13946. /**
  13947. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13948. * @param absolutePosition the absolute position to set
  13949. * @returns the TransformNode.
  13950. */
  13951. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13952. /**
  13953. * Sets the mesh position in its local space.
  13954. * @param vector3 the position to set in localspace
  13955. * @returns the TransformNode.
  13956. */
  13957. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13958. /**
  13959. * Returns the mesh position in the local space from the current World matrix values.
  13960. * @returns a new Vector3.
  13961. */
  13962. getPositionExpressedInLocalSpace(): Vector3;
  13963. /**
  13964. * Translates the mesh along the passed Vector3 in its local space.
  13965. * @param vector3 the distance to translate in localspace
  13966. * @returns the TransformNode.
  13967. */
  13968. locallyTranslate(vector3: Vector3): TransformNode;
  13969. private static _lookAtVectorCache;
  13970. /**
  13971. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13972. * @param targetPoint the position (must be in same space as current mesh) to look at
  13973. * @param yawCor optional yaw (y-axis) correction in radians
  13974. * @param pitchCor optional pitch (x-axis) correction in radians
  13975. * @param rollCor optional roll (z-axis) correction in radians
  13976. * @param space the choosen space of the target
  13977. * @returns the TransformNode.
  13978. */
  13979. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13980. /**
  13981. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13982. * This Vector3 is expressed in the World space.
  13983. * @param localAxis axis to rotate
  13984. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13985. */
  13986. getDirection(localAxis: Vector3): Vector3;
  13987. /**
  13988. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13989. * localAxis is expressed in the mesh local space.
  13990. * result is computed in the Wordl space from the mesh World matrix.
  13991. * @param localAxis axis to rotate
  13992. * @param result the resulting transformnode
  13993. * @returns this TransformNode.
  13994. */
  13995. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13996. /**
  13997. * Sets this transform node rotation to the given local axis.
  13998. * @param localAxis the axis in local space
  13999. * @param yawCor optional yaw (y-axis) correction in radians
  14000. * @param pitchCor optional pitch (x-axis) correction in radians
  14001. * @param rollCor optional roll (z-axis) correction in radians
  14002. * @returns this TransformNode
  14003. */
  14004. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14005. /**
  14006. * Sets a new pivot point to the current node
  14007. * @param point defines the new pivot point to use
  14008. * @param space defines if the point is in world or local space (local by default)
  14009. * @returns the current TransformNode
  14010. */
  14011. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14012. /**
  14013. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14014. * @returns the pivot point
  14015. */
  14016. getPivotPoint(): Vector3;
  14017. /**
  14018. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14019. * @param result the vector3 to store the result
  14020. * @returns this TransformNode.
  14021. */
  14022. getPivotPointToRef(result: Vector3): TransformNode;
  14023. /**
  14024. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14025. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14026. */
  14027. getAbsolutePivotPoint(): Vector3;
  14028. /**
  14029. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14030. * @param result vector3 to store the result
  14031. * @returns this TransformNode.
  14032. */
  14033. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14034. /**
  14035. * Defines the passed node as the parent of the current node.
  14036. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14037. * @see https://doc.babylonjs.com/how_to/parenting
  14038. * @param node the node ot set as the parent
  14039. * @returns this TransformNode.
  14040. */
  14041. setParent(node: Nullable<Node>): TransformNode;
  14042. private _nonUniformScaling;
  14043. /**
  14044. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14045. */
  14046. readonly nonUniformScaling: boolean;
  14047. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  14048. /**
  14049. * Attach the current TransformNode to another TransformNode associated with a bone
  14050. * @param bone Bone affecting the TransformNode
  14051. * @param affectedTransformNode TransformNode associated with the bone
  14052. * @returns this object
  14053. */
  14054. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14055. /**
  14056. * Detach the transform node if its associated with a bone
  14057. * @returns this object
  14058. */
  14059. detachFromBone(): TransformNode;
  14060. private static _rotationAxisCache;
  14061. /**
  14062. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14063. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14064. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14065. * The passed axis is also normalized.
  14066. * @param axis the axis to rotate around
  14067. * @param amount the amount to rotate in radians
  14068. * @param space Space to rotate in (Default: local)
  14069. * @returns the TransformNode.
  14070. */
  14071. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14072. /**
  14073. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14074. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14075. * The passed axis is also normalized. .
  14076. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14077. * @param point the point to rotate around
  14078. * @param axis the axis to rotate around
  14079. * @param amount the amount to rotate in radians
  14080. * @returns the TransformNode
  14081. */
  14082. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14083. /**
  14084. * Translates the mesh along the axis vector for the passed distance in the given space.
  14085. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14086. * @param axis the axis to translate in
  14087. * @param distance the distance to translate
  14088. * @param space Space to rotate in (Default: local)
  14089. * @returns the TransformNode.
  14090. */
  14091. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14092. /**
  14093. * Adds a rotation step to the mesh current rotation.
  14094. * x, y, z are Euler angles expressed in radians.
  14095. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14096. * This means this rotation is made in the mesh local space only.
  14097. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14098. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14099. * ```javascript
  14100. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14101. * ```
  14102. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14103. * 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.
  14104. * @param x Rotation to add
  14105. * @param y Rotation to add
  14106. * @param z Rotation to add
  14107. * @returns the TransformNode.
  14108. */
  14109. addRotation(x: number, y: number, z: number): TransformNode;
  14110. /**
  14111. * @hidden
  14112. */
  14113. protected _getEffectiveParent(): Nullable<Node>;
  14114. /**
  14115. * Computes the world matrix of the node
  14116. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14117. * @returns the world matrix
  14118. */
  14119. computeWorldMatrix(force?: boolean): Matrix;
  14120. protected _afterComputeWorldMatrix(): void;
  14121. /**
  14122. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14123. * @param func callback function to add
  14124. *
  14125. * @returns the TransformNode.
  14126. */
  14127. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14128. /**
  14129. * Removes a registered callback function.
  14130. * @param func callback function to remove
  14131. * @returns the TransformNode.
  14132. */
  14133. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14134. /**
  14135. * Gets the position of the current mesh in camera space
  14136. * @param camera defines the camera to use
  14137. * @returns a position
  14138. */
  14139. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14140. /**
  14141. * Returns the distance from the mesh to the active camera
  14142. * @param camera defines the camera to use
  14143. * @returns the distance
  14144. */
  14145. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14146. /**
  14147. * Clone the current transform node
  14148. * @param name Name of the new clone
  14149. * @param newParent New parent for the clone
  14150. * @param doNotCloneChildren Do not clone children hierarchy
  14151. * @returns the new transform node
  14152. */
  14153. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14154. /**
  14155. * Serializes the objects information.
  14156. * @param currentSerializationObject defines the object to serialize in
  14157. * @returns the serialized object
  14158. */
  14159. serialize(currentSerializationObject?: any): any;
  14160. /**
  14161. * Returns a new TransformNode object parsed from the source provided.
  14162. * @param parsedTransformNode is the source.
  14163. * @param scene the scne the object belongs to
  14164. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14165. * @returns a new TransformNode object parsed from the source provided.
  14166. */
  14167. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14168. /**
  14169. * Get all child-transformNodes of this node
  14170. * @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
  14171. * @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
  14172. * @returns an array of TransformNode
  14173. */
  14174. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14175. /**
  14176. * Releases resources associated with this transform node.
  14177. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14178. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14179. */
  14180. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14181. /**
  14182. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14183. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14184. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14185. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14186. * @returns the current mesh
  14187. */
  14188. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14189. private _syncAbsoluteScalingAndRotation;
  14190. }
  14191. }
  14192. declare module BABYLON {
  14193. /**
  14194. * Defines the types of pose enabled controllers that are supported
  14195. */
  14196. export enum PoseEnabledControllerType {
  14197. /**
  14198. * HTC Vive
  14199. */
  14200. VIVE = 0,
  14201. /**
  14202. * Oculus Rift
  14203. */
  14204. OCULUS = 1,
  14205. /**
  14206. * Windows mixed reality
  14207. */
  14208. WINDOWS = 2,
  14209. /**
  14210. * Samsung gear VR
  14211. */
  14212. GEAR_VR = 3,
  14213. /**
  14214. * Google Daydream
  14215. */
  14216. DAYDREAM = 4,
  14217. /**
  14218. * Generic
  14219. */
  14220. GENERIC = 5
  14221. }
  14222. /**
  14223. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14224. */
  14225. export interface MutableGamepadButton {
  14226. /**
  14227. * Value of the button/trigger
  14228. */
  14229. value: number;
  14230. /**
  14231. * If the button/trigger is currently touched
  14232. */
  14233. touched: boolean;
  14234. /**
  14235. * If the button/trigger is currently pressed
  14236. */
  14237. pressed: boolean;
  14238. }
  14239. /**
  14240. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14241. * @hidden
  14242. */
  14243. export interface ExtendedGamepadButton extends GamepadButton {
  14244. /**
  14245. * If the button/trigger is currently pressed
  14246. */
  14247. readonly pressed: boolean;
  14248. /**
  14249. * If the button/trigger is currently touched
  14250. */
  14251. readonly touched: boolean;
  14252. /**
  14253. * Value of the button/trigger
  14254. */
  14255. readonly value: number;
  14256. }
  14257. /** @hidden */
  14258. export interface _GamePadFactory {
  14259. /**
  14260. * Returns wether or not the current gamepad can be created for this type of controller.
  14261. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14262. * @returns true if it can be created, otherwise false
  14263. */
  14264. canCreate(gamepadInfo: any): boolean;
  14265. /**
  14266. * Creates a new instance of the Gamepad.
  14267. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14268. * @returns the new gamepad instance
  14269. */
  14270. create(gamepadInfo: any): Gamepad;
  14271. }
  14272. /**
  14273. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14274. */
  14275. export class PoseEnabledControllerHelper {
  14276. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  14277. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14278. /**
  14279. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14280. * @param vrGamepad the gamepad to initialized
  14281. * @returns a vr controller of the type the gamepad identified as
  14282. */
  14283. static InitiateController(vrGamepad: any): Gamepad;
  14284. }
  14285. /**
  14286. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14287. */
  14288. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14289. /**
  14290. * If the controller is used in a webXR session
  14291. */
  14292. isXR: boolean;
  14293. private _deviceRoomPosition;
  14294. private _deviceRoomRotationQuaternion;
  14295. /**
  14296. * The device position in babylon space
  14297. */
  14298. devicePosition: Vector3;
  14299. /**
  14300. * The device rotation in babylon space
  14301. */
  14302. deviceRotationQuaternion: Quaternion;
  14303. /**
  14304. * The scale factor of the device in babylon space
  14305. */
  14306. deviceScaleFactor: number;
  14307. /**
  14308. * (Likely devicePosition should be used instead) The device position in its room space
  14309. */
  14310. position: Vector3;
  14311. /**
  14312. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14313. */
  14314. rotationQuaternion: Quaternion;
  14315. /**
  14316. * The type of controller (Eg. Windows mixed reality)
  14317. */
  14318. controllerType: PoseEnabledControllerType;
  14319. protected _calculatedPosition: Vector3;
  14320. private _calculatedRotation;
  14321. /**
  14322. * The raw pose from the device
  14323. */
  14324. rawPose: DevicePose;
  14325. private _trackPosition;
  14326. private _maxRotationDistFromHeadset;
  14327. private _draggedRoomRotation;
  14328. /**
  14329. * @hidden
  14330. */ private _disableTrackPosition(fixedPosition: Vector3): void;
  14331. /**
  14332. * Internal, the mesh attached to the controller
  14333. * @hidden
  14334. */ private _mesh: Nullable<AbstractMesh>;
  14335. private _poseControlledCamera;
  14336. private _leftHandSystemQuaternion;
  14337. /**
  14338. * Internal, matrix used to convert room space to babylon space
  14339. * @hidden
  14340. */ private _deviceToWorld: Matrix;
  14341. /**
  14342. * Node to be used when casting a ray from the controller
  14343. * @hidden
  14344. */ private _pointingPoseNode: Nullable<TransformNode>;
  14345. /**
  14346. * Name of the child mesh that can be used to cast a ray from the controller
  14347. */
  14348. static readonly POINTING_POSE: string;
  14349. /**
  14350. * Creates a new PoseEnabledController from a gamepad
  14351. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14352. */
  14353. constructor(browserGamepad: any);
  14354. private _workingMatrix;
  14355. /**
  14356. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14357. */
  14358. update(): void;
  14359. /**
  14360. * Updates only the pose device and mesh without doing any button event checking
  14361. */
  14362. protected _updatePoseAndMesh(): void;
  14363. /**
  14364. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14365. * @param poseData raw pose fromthe device
  14366. */
  14367. updateFromDevice(poseData: DevicePose): void;
  14368. /**
  14369. * @hidden
  14370. */ private _meshAttachedObservable: Observable<AbstractMesh>;
  14371. /**
  14372. * Attaches a mesh to the controller
  14373. * @param mesh the mesh to be attached
  14374. */
  14375. attachToMesh(mesh: AbstractMesh): void;
  14376. /**
  14377. * Attaches the controllers mesh to a camera
  14378. * @param camera the camera the mesh should be attached to
  14379. */
  14380. attachToPoseControlledCamera(camera: TargetCamera): void;
  14381. /**
  14382. * Disposes of the controller
  14383. */
  14384. dispose(): void;
  14385. /**
  14386. * The mesh that is attached to the controller
  14387. */
  14388. readonly mesh: Nullable<AbstractMesh>;
  14389. /**
  14390. * Gets the ray of the controller in the direction the controller is pointing
  14391. * @param length the length the resulting ray should be
  14392. * @returns a ray in the direction the controller is pointing
  14393. */
  14394. getForwardRay(length?: number): Ray;
  14395. }
  14396. }
  14397. declare module BABYLON {
  14398. /**
  14399. * Defines the WebVRController object that represents controllers tracked in 3D space
  14400. */
  14401. export abstract class WebVRController extends PoseEnabledController {
  14402. /**
  14403. * Internal, the default controller model for the controller
  14404. */
  14405. protected _defaultModel: Nullable<AbstractMesh>;
  14406. /**
  14407. * Fired when the trigger state has changed
  14408. */
  14409. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14410. /**
  14411. * Fired when the main button state has changed
  14412. */
  14413. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14414. /**
  14415. * Fired when the secondary button state has changed
  14416. */
  14417. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14418. /**
  14419. * Fired when the pad state has changed
  14420. */
  14421. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14422. /**
  14423. * Fired when controllers stick values have changed
  14424. */
  14425. onPadValuesChangedObservable: Observable<StickValues>;
  14426. /**
  14427. * Array of button availible on the controller
  14428. */
  14429. protected _buttons: Array<MutableGamepadButton>;
  14430. private _onButtonStateChange;
  14431. /**
  14432. * Fired when a controller button's state has changed
  14433. * @param callback the callback containing the button that was modified
  14434. */
  14435. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14436. /**
  14437. * X and Y axis corresponding to the controllers joystick
  14438. */
  14439. pad: StickValues;
  14440. /**
  14441. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14442. */
  14443. hand: string;
  14444. /**
  14445. * The default controller model for the controller
  14446. */
  14447. readonly defaultModel: Nullable<AbstractMesh>;
  14448. /**
  14449. * Creates a new WebVRController from a gamepad
  14450. * @param vrGamepad the gamepad that the WebVRController should be created from
  14451. */
  14452. constructor(vrGamepad: any);
  14453. /**
  14454. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14455. */
  14456. update(): void;
  14457. /**
  14458. * Function to be called when a button is modified
  14459. */
  14460. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14461. /**
  14462. * Loads a mesh and attaches it to the controller
  14463. * @param scene the scene the mesh should be added to
  14464. * @param meshLoaded callback for when the mesh has been loaded
  14465. */
  14466. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14467. private _setButtonValue;
  14468. private _changes;
  14469. private _checkChanges;
  14470. /**
  14471. * Disposes of th webVRCOntroller
  14472. */
  14473. dispose(): void;
  14474. }
  14475. }
  14476. declare module BABYLON {
  14477. /**
  14478. * The HemisphericLight simulates the ambient environment light,
  14479. * so the passed direction is the light reflection direction, not the incoming direction.
  14480. */
  14481. export class HemisphericLight extends Light {
  14482. /**
  14483. * The groundColor is the light in the opposite direction to the one specified during creation.
  14484. * 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.
  14485. */
  14486. groundColor: Color3;
  14487. /**
  14488. * The light reflection direction, not the incoming direction.
  14489. */
  14490. direction: Vector3;
  14491. /**
  14492. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14493. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14494. * The HemisphericLight can't cast shadows.
  14495. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14496. * @param name The friendly name of the light
  14497. * @param direction The direction of the light reflection
  14498. * @param scene The scene the light belongs to
  14499. */
  14500. constructor(name: string, direction: Vector3, scene: Scene);
  14501. protected _buildUniformLayout(): void;
  14502. /**
  14503. * Returns the string "HemisphericLight".
  14504. * @return The class name
  14505. */
  14506. getClassName(): string;
  14507. /**
  14508. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14509. * Returns the updated direction.
  14510. * @param target The target the direction should point to
  14511. * @return The computed direction
  14512. */
  14513. setDirectionToTarget(target: Vector3): Vector3;
  14514. /**
  14515. * Returns the shadow generator associated to the light.
  14516. * @returns Always null for hemispheric lights because it does not support shadows.
  14517. */
  14518. getShadowGenerator(): Nullable<IShadowGenerator>;
  14519. /**
  14520. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14521. * @param effect The effect to update
  14522. * @param lightIndex The index of the light in the effect to update
  14523. * @returns The hemispheric light
  14524. */
  14525. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14526. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14527. /**
  14528. * Computes the world matrix of the node
  14529. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14530. * @param useWasUpdatedFlag defines a reserved property
  14531. * @returns the world matrix
  14532. */
  14533. computeWorldMatrix(): Matrix;
  14534. /**
  14535. * Returns the integer 3.
  14536. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14537. */
  14538. getTypeID(): number;
  14539. /**
  14540. * Prepares the list of defines specific to the light type.
  14541. * @param defines the list of defines
  14542. * @param lightIndex defines the index of the light for the effect
  14543. */
  14544. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14545. }
  14546. }
  14547. declare module BABYLON {
  14548. /** @hidden */
  14549. export var vrMultiviewToSingleviewPixelShader: {
  14550. name: string;
  14551. shader: string;
  14552. };
  14553. }
  14554. declare module BABYLON {
  14555. /**
  14556. * Renders to multiple views with a single draw call
  14557. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14558. */
  14559. export class MultiviewRenderTarget extends RenderTargetTexture {
  14560. /**
  14561. * Creates a multiview render target
  14562. * @param scene scene used with the render target
  14563. * @param size the size of the render target (used for each view)
  14564. */
  14565. constructor(scene: Scene, size?: number | {
  14566. width: number;
  14567. height: number;
  14568. } | {
  14569. ratio: number;
  14570. });
  14571. /**
  14572. * @hidden
  14573. * @param faceIndex the face index, if its a cube texture
  14574. */ private _bindFrameBuffer(faceIndex?: number): void;
  14575. /**
  14576. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14577. * @returns the view count
  14578. */
  14579. getViewCount(): number;
  14580. }
  14581. }
  14582. declare module BABYLON {
  14583. /**
  14584. * Represents a camera frustum
  14585. */
  14586. export class Frustum {
  14587. /**
  14588. * Gets the planes representing the frustum
  14589. * @param transform matrix to be applied to the returned planes
  14590. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14591. */
  14592. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14593. /**
  14594. * Gets the near frustum plane transformed by the transform matrix
  14595. * @param transform transformation matrix to be applied to the resulting frustum plane
  14596. * @param frustumPlane the resuling frustum plane
  14597. */
  14598. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14599. /**
  14600. * Gets the far frustum plane transformed by the transform matrix
  14601. * @param transform transformation matrix to be applied to the resulting frustum plane
  14602. * @param frustumPlane the resuling frustum plane
  14603. */
  14604. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14605. /**
  14606. * Gets the left frustum plane transformed by the transform matrix
  14607. * @param transform transformation matrix to be applied to the resulting frustum plane
  14608. * @param frustumPlane the resuling frustum plane
  14609. */
  14610. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14611. /**
  14612. * Gets the right frustum plane transformed by the transform matrix
  14613. * @param transform transformation matrix to be applied to the resulting frustum plane
  14614. * @param frustumPlane the resuling frustum plane
  14615. */
  14616. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14617. /**
  14618. * Gets the top frustum plane transformed by the transform matrix
  14619. * @param transform transformation matrix to be applied to the resulting frustum plane
  14620. * @param frustumPlane the resuling frustum plane
  14621. */
  14622. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14623. /**
  14624. * Gets the bottom frustum plane transformed by the transform matrix
  14625. * @param transform transformation matrix to be applied to the resulting frustum plane
  14626. * @param frustumPlane the resuling frustum plane
  14627. */
  14628. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14629. /**
  14630. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14631. * @param transform transformation matrix to be applied to the resulting frustum planes
  14632. * @param frustumPlanes the resuling frustum planes
  14633. */
  14634. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14635. }
  14636. }
  14637. declare module BABYLON {
  14638. interface Engine {
  14639. /**
  14640. * Creates a new multiview render target
  14641. * @param width defines the width of the texture
  14642. * @param height defines the height of the texture
  14643. * @returns the created multiview texture
  14644. */
  14645. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14646. /**
  14647. * Binds a multiview framebuffer to be drawn to
  14648. * @param multiviewTexture texture to bind
  14649. */
  14650. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14651. }
  14652. interface Camera {
  14653. /**
  14654. * @hidden
  14655. * 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)
  14656. */ private _useMultiviewToSingleView: boolean;
  14657. /**
  14658. * @hidden
  14659. * 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)
  14660. */ private _multiviewTexture: Nullable<RenderTargetTexture>;
  14661. /**
  14662. * @hidden
  14663. * ensures the multiview texture of the camera exists and has the specified width/height
  14664. * @param width height to set on the multiview texture
  14665. * @param height width to set on the multiview texture
  14666. */ private _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14667. }
  14668. interface Scene {
  14669. /** @hidden */ private _transformMatrixR: Matrix;
  14670. /** @hidden */ private _multiviewSceneUbo: Nullable<UniformBuffer>;
  14671. /** @hidden */ private _createMultiviewUbo(): void;
  14672. /** @hidden */ private _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14673. /** @hidden */ private _renderMultiviewToSingleView(camera: Camera): void;
  14674. }
  14675. }
  14676. declare module BABYLON {
  14677. /**
  14678. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14679. * This will not be used for webXR as it supports displaying texture arrays directly
  14680. */
  14681. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14682. /**
  14683. * Initializes a VRMultiviewToSingleview
  14684. * @param name name of the post process
  14685. * @param camera camera to be applied to
  14686. * @param scaleFactor scaling factor to the size of the output texture
  14687. */
  14688. constructor(name: string, camera: Camera, scaleFactor: number);
  14689. }
  14690. }
  14691. declare module BABYLON {
  14692. interface Engine {
  14693. /** @hidden */ private _vrDisplay: any;
  14694. /** @hidden */ private _vrSupported: boolean;
  14695. /** @hidden */ private _oldSize: Size;
  14696. /** @hidden */ private _oldHardwareScaleFactor: number;
  14697. /** @hidden */ private _vrExclusivePointerMode: boolean;
  14698. /** @hidden */ private _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14699. /** @hidden */ private _onVRDisplayPointerRestricted: () => void;
  14700. /** @hidden */ private _onVRDisplayPointerUnrestricted: () => void;
  14701. /** @hidden */ private _onVrDisplayConnect: Nullable<(display: any) => void>;
  14702. /** @hidden */ private _onVrDisplayDisconnect: Nullable<() => void>;
  14703. /** @hidden */ private _onVrDisplayPresentChange: Nullable<() => void>;
  14704. /**
  14705. * Observable signaled when VR display mode changes
  14706. */
  14707. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14708. /**
  14709. * Observable signaled when VR request present is complete
  14710. */
  14711. onVRRequestPresentComplete: Observable<boolean>;
  14712. /**
  14713. * Observable signaled when VR request present starts
  14714. */
  14715. onVRRequestPresentStart: Observable<Engine>;
  14716. /**
  14717. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14718. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14719. */
  14720. isInVRExclusivePointerMode: boolean;
  14721. /**
  14722. * Gets a boolean indicating if a webVR device was detected
  14723. * @returns true if a webVR device was detected
  14724. */
  14725. isVRDevicePresent(): boolean;
  14726. /**
  14727. * Gets the current webVR device
  14728. * @returns the current webVR device (or null)
  14729. */
  14730. getVRDevice(): any;
  14731. /**
  14732. * Initializes a webVR display and starts listening to display change events
  14733. * The onVRDisplayChangedObservable will be notified upon these changes
  14734. * @returns A promise containing a VRDisplay and if vr is supported
  14735. */
  14736. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14737. /** @hidden */ private _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14738. /**
  14739. * Call this function to switch to webVR mode
  14740. * Will do nothing if webVR is not supported or if there is no webVR device
  14741. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14742. */
  14743. enableVR(): void;
  14744. /** @hidden */ private _onVRFullScreenTriggered(): void;
  14745. }
  14746. }
  14747. declare module BABYLON {
  14748. /**
  14749. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14750. * IMPORTANT!! The data is right-hand data.
  14751. * @export
  14752. * @interface DevicePose
  14753. */
  14754. export interface DevicePose {
  14755. /**
  14756. * The position of the device, values in array are [x,y,z].
  14757. */
  14758. readonly position: Nullable<Float32Array>;
  14759. /**
  14760. * The linearVelocity of the device, values in array are [x,y,z].
  14761. */
  14762. readonly linearVelocity: Nullable<Float32Array>;
  14763. /**
  14764. * The linearAcceleration of the device, values in array are [x,y,z].
  14765. */
  14766. readonly linearAcceleration: Nullable<Float32Array>;
  14767. /**
  14768. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14769. */
  14770. readonly orientation: Nullable<Float32Array>;
  14771. /**
  14772. * The angularVelocity of the device, values in array are [x,y,z].
  14773. */
  14774. readonly angularVelocity: Nullable<Float32Array>;
  14775. /**
  14776. * The angularAcceleration of the device, values in array are [x,y,z].
  14777. */
  14778. readonly angularAcceleration: Nullable<Float32Array>;
  14779. }
  14780. /**
  14781. * Interface representing a pose controlled object in Babylon.
  14782. * A pose controlled object has both regular pose values as well as pose values
  14783. * from an external device such as a VR head mounted display
  14784. */
  14785. export interface PoseControlled {
  14786. /**
  14787. * The position of the object in babylon space.
  14788. */
  14789. position: Vector3;
  14790. /**
  14791. * The rotation quaternion of the object in babylon space.
  14792. */
  14793. rotationQuaternion: Quaternion;
  14794. /**
  14795. * The position of the device in babylon space.
  14796. */
  14797. devicePosition?: Vector3;
  14798. /**
  14799. * The rotation quaternion of the device in babylon space.
  14800. */
  14801. deviceRotationQuaternion: Quaternion;
  14802. /**
  14803. * The raw pose coming from the device.
  14804. */
  14805. rawPose: Nullable<DevicePose>;
  14806. /**
  14807. * The scale of the device to be used when translating from device space to babylon space.
  14808. */
  14809. deviceScaleFactor: number;
  14810. /**
  14811. * Updates the poseControlled values based on the input device pose.
  14812. * @param poseData the pose data to update the object with
  14813. */
  14814. updateFromDevice(poseData: DevicePose): void;
  14815. }
  14816. /**
  14817. * Set of options to customize the webVRCamera
  14818. */
  14819. export interface WebVROptions {
  14820. /**
  14821. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14822. */
  14823. trackPosition?: boolean;
  14824. /**
  14825. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14826. */
  14827. positionScale?: number;
  14828. /**
  14829. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14830. */
  14831. displayName?: string;
  14832. /**
  14833. * Should the native controller meshes be initialized. (default: true)
  14834. */
  14835. controllerMeshes?: boolean;
  14836. /**
  14837. * Creating a default HemiLight only on controllers. (default: true)
  14838. */
  14839. defaultLightingOnControllers?: boolean;
  14840. /**
  14841. * If you don't want to use the default VR button of the helper. (default: false)
  14842. */
  14843. useCustomVRButton?: boolean;
  14844. /**
  14845. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14846. */
  14847. customVRButton?: HTMLButtonElement;
  14848. /**
  14849. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14850. */
  14851. rayLength?: number;
  14852. /**
  14853. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14854. */
  14855. defaultHeight?: number;
  14856. /**
  14857. * If multiview should be used if availible (default: false)
  14858. */
  14859. useMultiview?: boolean;
  14860. }
  14861. /**
  14862. * This represents a WebVR camera.
  14863. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14864. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14865. */
  14866. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14867. private webVROptions;
  14868. /**
  14869. * @hidden
  14870. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14871. */ private _vrDevice: any;
  14872. /**
  14873. * The rawPose of the vrDevice.
  14874. */
  14875. rawPose: Nullable<DevicePose>;
  14876. private _onVREnabled;
  14877. private _specsVersion;
  14878. private _attached;
  14879. private _frameData;
  14880. protected _descendants: Array<Node>;
  14881. private _deviceRoomPosition;
  14882. /** @hidden */ private _deviceRoomRotationQuaternion: Quaternion;
  14883. private _standingMatrix;
  14884. /**
  14885. * Represents device position in babylon space.
  14886. */
  14887. devicePosition: Vector3;
  14888. /**
  14889. * Represents device rotation in babylon space.
  14890. */
  14891. deviceRotationQuaternion: Quaternion;
  14892. /**
  14893. * The scale of the device to be used when translating from device space to babylon space.
  14894. */
  14895. deviceScaleFactor: number;
  14896. private _deviceToWorld;
  14897. private _worldToDevice;
  14898. /**
  14899. * References to the webVR controllers for the vrDevice.
  14900. */
  14901. controllers: Array<WebVRController>;
  14902. /**
  14903. * Emits an event when a controller is attached.
  14904. */
  14905. onControllersAttachedObservable: Observable<WebVRController[]>;
  14906. /**
  14907. * Emits an event when a controller's mesh has been loaded;
  14908. */
  14909. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14910. /**
  14911. * Emits an event when the HMD's pose has been updated.
  14912. */
  14913. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14914. private _poseSet;
  14915. /**
  14916. * If the rig cameras be used as parent instead of this camera.
  14917. */
  14918. rigParenting: boolean;
  14919. private _lightOnControllers;
  14920. private _defaultHeight?;
  14921. /**
  14922. * Instantiates a WebVRFreeCamera.
  14923. * @param name The name of the WebVRFreeCamera
  14924. * @param position The starting anchor position for the camera
  14925. * @param scene The scene the camera belongs to
  14926. * @param webVROptions a set of customizable options for the webVRCamera
  14927. */
  14928. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14929. /**
  14930. * Gets the device distance from the ground in meters.
  14931. * @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.
  14932. */
  14933. deviceDistanceToRoomGround(): number;
  14934. /**
  14935. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14936. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14937. */
  14938. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14939. /**
  14940. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14941. * @returns A promise with a boolean set to if the standing matrix is supported.
  14942. */
  14943. useStandingMatrixAsync(): Promise<boolean>;
  14944. /**
  14945. * Disposes the camera
  14946. */
  14947. dispose(): void;
  14948. /**
  14949. * Gets a vrController by name.
  14950. * @param name The name of the controller to retreive
  14951. * @returns the controller matching the name specified or null if not found
  14952. */
  14953. getControllerByName(name: string): Nullable<WebVRController>;
  14954. private _leftController;
  14955. /**
  14956. * The controller corresponding to the users left hand.
  14957. */
  14958. readonly leftController: Nullable<WebVRController>;
  14959. private _rightController;
  14960. /**
  14961. * The controller corresponding to the users right hand.
  14962. */
  14963. readonly rightController: Nullable<WebVRController>;
  14964. /**
  14965. * Casts a ray forward from the vrCamera's gaze.
  14966. * @param length Length of the ray (default: 100)
  14967. * @returns the ray corresponding to the gaze
  14968. */
  14969. getForwardRay(length?: number): Ray;
  14970. /**
  14971. * @hidden
  14972. * Updates the camera based on device's frame data
  14973. */ private _checkInputs(): void;
  14974. /**
  14975. * Updates the poseControlled values based on the input device pose.
  14976. * @param poseData Pose coming from the device
  14977. */
  14978. updateFromDevice(poseData: DevicePose): void;
  14979. private _htmlElementAttached;
  14980. private _detachIfAttached;
  14981. /**
  14982. * WebVR's attach control will start broadcasting frames to the device.
  14983. * Note that in certain browsers (chrome for example) this function must be called
  14984. * within a user-interaction callback. Example:
  14985. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14986. *
  14987. * @param element html element to attach the vrDevice to
  14988. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14989. */
  14990. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14991. /**
  14992. * Detaches the camera from the html element and disables VR
  14993. *
  14994. * @param element html element to detach from
  14995. */
  14996. detachControl(element: HTMLElement): void;
  14997. /**
  14998. * @returns the name of this class
  14999. */
  15000. getClassName(): string;
  15001. /**
  15002. * Calls resetPose on the vrDisplay
  15003. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15004. */
  15005. resetToCurrentRotation(): void;
  15006. /**
  15007. * @hidden
  15008. * Updates the rig cameras (left and right eye)
  15009. */ private _updateRigCameras(): void;
  15010. private _workingVector;
  15011. private _oneVector;
  15012. private _workingMatrix;
  15013. private updateCacheCalled;
  15014. private _correctPositionIfNotTrackPosition;
  15015. /**
  15016. * @hidden
  15017. * Updates the cached values of the camera
  15018. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15019. */ private _updateCache(ignoreParentClass?: boolean): void;
  15020. /**
  15021. * @hidden
  15022. * Get current device position in babylon world
  15023. */ private _computeDevicePosition(): void;
  15024. /**
  15025. * Updates the current device position and rotation in the babylon world
  15026. */
  15027. update(): void;
  15028. /**
  15029. * @hidden
  15030. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15031. * @returns an identity matrix
  15032. */ private _getViewMatrix(): Matrix;
  15033. private _tmpMatrix;
  15034. /**
  15035. * This function is called by the two RIG cameras.
  15036. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15037. * @hidden
  15038. */ private _getWebVRViewMatrix(): Matrix;
  15039. /** @hidden */ private _getWebVRProjectionMatrix(): Matrix;
  15040. private _onGamepadConnectedObserver;
  15041. private _onGamepadDisconnectedObserver;
  15042. private _updateCacheWhenTrackingDisabledObserver;
  15043. /**
  15044. * Initializes the controllers and their meshes
  15045. */
  15046. initControllers(): void;
  15047. }
  15048. }
  15049. declare module BABYLON {
  15050. /**
  15051. * Size options for a post process
  15052. */
  15053. export type PostProcessOptions = {
  15054. width: number;
  15055. height: number;
  15056. };
  15057. /**
  15058. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15059. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15060. */
  15061. export class PostProcess {
  15062. /** Name of the PostProcess. */
  15063. name: string;
  15064. /**
  15065. * Gets or sets the unique id of the post process
  15066. */
  15067. uniqueId: number;
  15068. /**
  15069. * Width of the texture to apply the post process on
  15070. */
  15071. width: number;
  15072. /**
  15073. * Height of the texture to apply the post process on
  15074. */
  15075. height: number;
  15076. /**
  15077. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15078. * @hidden
  15079. */ private _outputTexture: Nullable<InternalTexture>;
  15080. /**
  15081. * Sampling mode used by the shader
  15082. * See https://doc.babylonjs.com/classes/3.1/texture
  15083. */
  15084. renderTargetSamplingMode: number;
  15085. /**
  15086. * Clear color to use when screen clearing
  15087. */
  15088. clearColor: Color4;
  15089. /**
  15090. * If the buffer needs to be cleared before applying the post process. (default: true)
  15091. * Should be set to false if shader will overwrite all previous pixels.
  15092. */
  15093. autoClear: boolean;
  15094. /**
  15095. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15096. */
  15097. alphaMode: number;
  15098. /**
  15099. * Sets the setAlphaBlendConstants of the babylon engine
  15100. */
  15101. alphaConstants: Color4;
  15102. /**
  15103. * Animations to be used for the post processing
  15104. */
  15105. animations: Animation[];
  15106. /**
  15107. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15108. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15109. */
  15110. enablePixelPerfectMode: boolean;
  15111. /**
  15112. * Force the postprocess to be applied without taking in account viewport
  15113. */
  15114. forceFullscreenViewport: boolean;
  15115. /**
  15116. * List of inspectable custom properties (used by the Inspector)
  15117. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15118. */
  15119. inspectableCustomProperties: IInspectable[];
  15120. /**
  15121. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15122. *
  15123. * | Value | Type | Description |
  15124. * | ----- | ----------------------------------- | ----------- |
  15125. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15126. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15127. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15128. *
  15129. */
  15130. scaleMode: number;
  15131. /**
  15132. * Force textures to be a power of two (default: false)
  15133. */
  15134. alwaysForcePOT: boolean;
  15135. private _samples;
  15136. /**
  15137. * Number of sample textures (default: 1)
  15138. */
  15139. samples: number;
  15140. /**
  15141. * Modify the scale of the post process to be the same as the viewport (default: false)
  15142. */
  15143. adaptScaleToCurrentViewport: boolean;
  15144. private _camera;
  15145. private _scene;
  15146. private _engine;
  15147. private _options;
  15148. private _reusable;
  15149. private _textureType;
  15150. /**
  15151. * Smart array of input and output textures for the post process.
  15152. * @hidden
  15153. */ private _textures: SmartArray<InternalTexture>;
  15154. /**
  15155. * The index in _textures that corresponds to the output texture.
  15156. * @hidden
  15157. */ private _currentRenderTextureInd: number;
  15158. private _effect;
  15159. private _samplers;
  15160. private _fragmentUrl;
  15161. private _vertexUrl;
  15162. private _parameters;
  15163. private _scaleRatio;
  15164. protected _indexParameters: any;
  15165. private _shareOutputWithPostProcess;
  15166. private _texelSize;
  15167. private _forcedOutputTexture;
  15168. /**
  15169. * Returns the fragment url or shader name used in the post process.
  15170. * @returns the fragment url or name in the shader store.
  15171. */
  15172. getEffectName(): string;
  15173. /**
  15174. * An event triggered when the postprocess is activated.
  15175. */
  15176. onActivateObservable: Observable<Camera>;
  15177. private _onActivateObserver;
  15178. /**
  15179. * A function that is added to the onActivateObservable
  15180. */
  15181. onActivate: Nullable<(camera: Camera) => void>;
  15182. /**
  15183. * An event triggered when the postprocess changes its size.
  15184. */
  15185. onSizeChangedObservable: Observable<PostProcess>;
  15186. private _onSizeChangedObserver;
  15187. /**
  15188. * A function that is added to the onSizeChangedObservable
  15189. */
  15190. onSizeChanged: (postProcess: PostProcess) => void;
  15191. /**
  15192. * An event triggered when the postprocess applies its effect.
  15193. */
  15194. onApplyObservable: Observable<Effect>;
  15195. private _onApplyObserver;
  15196. /**
  15197. * A function that is added to the onApplyObservable
  15198. */
  15199. onApply: (effect: Effect) => void;
  15200. /**
  15201. * An event triggered before rendering the postprocess
  15202. */
  15203. onBeforeRenderObservable: Observable<Effect>;
  15204. private _onBeforeRenderObserver;
  15205. /**
  15206. * A function that is added to the onBeforeRenderObservable
  15207. */
  15208. onBeforeRender: (effect: Effect) => void;
  15209. /**
  15210. * An event triggered after rendering the postprocess
  15211. */
  15212. onAfterRenderObservable: Observable<Effect>;
  15213. private _onAfterRenderObserver;
  15214. /**
  15215. * A function that is added to the onAfterRenderObservable
  15216. */
  15217. onAfterRender: (efect: Effect) => void;
  15218. /**
  15219. * 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
  15220. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15221. */
  15222. inputTexture: InternalTexture;
  15223. /**
  15224. * Gets the camera which post process is applied to.
  15225. * @returns The camera the post process is applied to.
  15226. */
  15227. getCamera(): Camera;
  15228. /**
  15229. * Gets the texel size of the postprocess.
  15230. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15231. */
  15232. readonly texelSize: Vector2;
  15233. /**
  15234. * Creates a new instance PostProcess
  15235. * @param name The name of the PostProcess.
  15236. * @param fragmentUrl The url of the fragment shader to be used.
  15237. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15238. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15239. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15240. * @param camera The camera to apply the render pass to.
  15241. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15242. * @param engine The engine which the post process will be applied. (default: current engine)
  15243. * @param reusable If the post process can be reused on the same frame. (default: false)
  15244. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15245. * @param textureType Type of textures used when performing the post process. (default: 0)
  15246. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15247. * @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
  15248. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15249. */
  15250. constructor(
  15251. /** Name of the PostProcess. */
  15252. 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);
  15253. /**
  15254. * Gets a string idenfifying the name of the class
  15255. * @returns "PostProcess" string
  15256. */
  15257. getClassName(): string;
  15258. /**
  15259. * Gets the engine which this post process belongs to.
  15260. * @returns The engine the post process was enabled with.
  15261. */
  15262. getEngine(): Engine;
  15263. /**
  15264. * The effect that is created when initializing the post process.
  15265. * @returns The created effect corresponding the the postprocess.
  15266. */
  15267. getEffect(): Effect;
  15268. /**
  15269. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15270. * @param postProcess The post process to share the output with.
  15271. * @returns This post process.
  15272. */
  15273. shareOutputWith(postProcess: PostProcess): PostProcess;
  15274. /**
  15275. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15276. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15277. */
  15278. useOwnOutput(): void;
  15279. /**
  15280. * Updates the effect with the current post process compile time values and recompiles the shader.
  15281. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15282. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15283. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15284. * @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
  15285. * @param onCompiled Called when the shader has been compiled.
  15286. * @param onError Called if there is an error when compiling a shader.
  15287. */
  15288. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15289. /**
  15290. * The post process is reusable if it can be used multiple times within one frame.
  15291. * @returns If the post process is reusable
  15292. */
  15293. isReusable(): boolean;
  15294. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15295. markTextureDirty(): void;
  15296. /**
  15297. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15298. * 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.
  15299. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15300. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15301. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15302. * @returns The target texture that was bound to be written to.
  15303. */
  15304. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15305. /**
  15306. * If the post process is supported.
  15307. */
  15308. readonly isSupported: boolean;
  15309. /**
  15310. * The aspect ratio of the output texture.
  15311. */
  15312. readonly aspectRatio: number;
  15313. /**
  15314. * Get a value indicating if the post-process is ready to be used
  15315. * @returns true if the post-process is ready (shader is compiled)
  15316. */
  15317. isReady(): boolean;
  15318. /**
  15319. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15320. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15321. */
  15322. apply(): Nullable<Effect>;
  15323. private _disposeTextures;
  15324. /**
  15325. * Disposes the post process.
  15326. * @param camera The camera to dispose the post process on.
  15327. */
  15328. dispose(camera?: Camera): void;
  15329. }
  15330. }
  15331. declare module BABYLON {
  15332. /** @hidden */
  15333. export var kernelBlurVaryingDeclaration: {
  15334. name: string;
  15335. shader: string;
  15336. };
  15337. }
  15338. declare module BABYLON {
  15339. /** @hidden */
  15340. export var kernelBlurFragment: {
  15341. name: string;
  15342. shader: string;
  15343. };
  15344. }
  15345. declare module BABYLON {
  15346. /** @hidden */
  15347. export var kernelBlurFragment2: {
  15348. name: string;
  15349. shader: string;
  15350. };
  15351. }
  15352. declare module BABYLON {
  15353. /** @hidden */
  15354. export var kernelBlurPixelShader: {
  15355. name: string;
  15356. shader: string;
  15357. };
  15358. }
  15359. declare module BABYLON {
  15360. /** @hidden */
  15361. export var kernelBlurVertex: {
  15362. name: string;
  15363. shader: string;
  15364. };
  15365. }
  15366. declare module BABYLON {
  15367. /** @hidden */
  15368. export var kernelBlurVertexShader: {
  15369. name: string;
  15370. shader: string;
  15371. };
  15372. }
  15373. declare module BABYLON {
  15374. /**
  15375. * The Blur Post Process which blurs an image based on a kernel and direction.
  15376. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15377. */
  15378. export class BlurPostProcess extends PostProcess {
  15379. /** The direction in which to blur the image. */
  15380. direction: Vector2;
  15381. private blockCompilation;
  15382. protected _kernel: number;
  15383. protected _idealKernel: number;
  15384. protected _packedFloat: boolean;
  15385. private _staticDefines;
  15386. /**
  15387. * Sets the length in pixels of the blur sample region
  15388. */
  15389. /**
  15390. * Gets the length in pixels of the blur sample region
  15391. */
  15392. kernel: number;
  15393. /**
  15394. * Sets wether or not the blur needs to unpack/repack floats
  15395. */
  15396. /**
  15397. * Gets wether or not the blur is unpacking/repacking floats
  15398. */
  15399. packedFloat: boolean;
  15400. /**
  15401. * Creates a new instance BlurPostProcess
  15402. * @param name The name of the effect.
  15403. * @param direction The direction in which to blur the image.
  15404. * @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.
  15405. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15406. * @param camera The camera to apply the render pass to.
  15407. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15408. * @param engine The engine which the post process will be applied. (default: current engine)
  15409. * @param reusable If the post process can be reused on the same frame. (default: false)
  15410. * @param textureType Type of textures used when performing the post process. (default: 0)
  15411. * @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)
  15412. */
  15413. constructor(name: string,
  15414. /** The direction in which to blur the image. */
  15415. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15416. /**
  15417. * Updates the effect with the current post process compile time values and recompiles the shader.
  15418. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15419. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15420. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15421. * @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
  15422. * @param onCompiled Called when the shader has been compiled.
  15423. * @param onError Called if there is an error when compiling a shader.
  15424. */
  15425. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15426. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15427. /**
  15428. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15429. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15430. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15431. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15432. * The gaps between physical kernels are compensated for in the weighting of the samples
  15433. * @param idealKernel Ideal blur kernel.
  15434. * @return Nearest best kernel.
  15435. */
  15436. protected _nearestBestKernel(idealKernel: number): number;
  15437. /**
  15438. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15439. * @param x The point on the Gaussian distribution to sample.
  15440. * @return the value of the Gaussian function at x.
  15441. */
  15442. protected _gaussianWeight(x: number): number;
  15443. /**
  15444. * Generates a string that can be used as a floating point number in GLSL.
  15445. * @param x Value to print.
  15446. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15447. * @return GLSL float string.
  15448. */
  15449. protected _glslFloat(x: number, decimalFigures?: number): string;
  15450. }
  15451. }
  15452. declare module BABYLON {
  15453. /**
  15454. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15455. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15456. * You can then easily use it as a reflectionTexture on a flat surface.
  15457. * In case the surface is not a plane, please consider relying on reflection probes.
  15458. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15459. */
  15460. export class MirrorTexture extends RenderTargetTexture {
  15461. private scene;
  15462. /**
  15463. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15464. * 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.
  15465. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15466. */
  15467. mirrorPlane: Plane;
  15468. /**
  15469. * Define the blur ratio used to blur the reflection if needed.
  15470. */
  15471. blurRatio: number;
  15472. /**
  15473. * Define the adaptive blur kernel used to blur the reflection if needed.
  15474. * This will autocompute the closest best match for the `blurKernel`
  15475. */
  15476. adaptiveBlurKernel: number;
  15477. /**
  15478. * Define the blur kernel used to blur the reflection if needed.
  15479. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15480. */
  15481. blurKernel: number;
  15482. /**
  15483. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15484. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15485. */
  15486. blurKernelX: number;
  15487. /**
  15488. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15489. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15490. */
  15491. blurKernelY: number;
  15492. private _autoComputeBlurKernel;
  15493. protected _onRatioRescale(): void;
  15494. private _updateGammaSpace;
  15495. private _imageProcessingConfigChangeObserver;
  15496. private _transformMatrix;
  15497. private _mirrorMatrix;
  15498. private _savedViewMatrix;
  15499. private _blurX;
  15500. private _blurY;
  15501. private _adaptiveBlurKernel;
  15502. private _blurKernelX;
  15503. private _blurKernelY;
  15504. private _blurRatio;
  15505. /**
  15506. * Instantiates a Mirror Texture.
  15507. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15508. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15509. * You can then easily use it as a reflectionTexture on a flat surface.
  15510. * In case the surface is not a plane, please consider relying on reflection probes.
  15511. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15512. * @param name
  15513. * @param size
  15514. * @param scene
  15515. * @param generateMipMaps
  15516. * @param type
  15517. * @param samplingMode
  15518. * @param generateDepthBuffer
  15519. */
  15520. constructor(name: string, size: number | {
  15521. width: number;
  15522. height: number;
  15523. } | {
  15524. ratio: number;
  15525. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15526. private _preparePostProcesses;
  15527. /**
  15528. * Clone the mirror texture.
  15529. * @returns the cloned texture
  15530. */
  15531. clone(): MirrorTexture;
  15532. /**
  15533. * Serialize the texture to a JSON representation you could use in Parse later on
  15534. * @returns the serialized JSON representation
  15535. */
  15536. serialize(): any;
  15537. /**
  15538. * Dispose the texture and release its associated resources.
  15539. */
  15540. dispose(): void;
  15541. }
  15542. }
  15543. declare module BABYLON {
  15544. /**
  15545. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15546. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15547. */
  15548. export class Texture extends BaseTexture {
  15549. /**
  15550. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15551. */
  15552. static SerializeBuffers: boolean;
  15553. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15554. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15555. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15556. /** nearest is mag = nearest and min = nearest and mip = linear */
  15557. static readonly NEAREST_SAMPLINGMODE: number;
  15558. /** nearest is mag = nearest and min = nearest and mip = linear */
  15559. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15560. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15561. static readonly BILINEAR_SAMPLINGMODE: number;
  15562. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15563. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15564. /** Trilinear is mag = linear and min = linear and mip = linear */
  15565. static readonly TRILINEAR_SAMPLINGMODE: number;
  15566. /** Trilinear is mag = linear and min = linear and mip = linear */
  15567. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15568. /** mag = nearest and min = nearest and mip = nearest */
  15569. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15570. /** mag = nearest and min = linear and mip = nearest */
  15571. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15572. /** mag = nearest and min = linear and mip = linear */
  15573. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15574. /** mag = nearest and min = linear and mip = none */
  15575. static readonly NEAREST_LINEAR: number;
  15576. /** mag = nearest and min = nearest and mip = none */
  15577. static readonly NEAREST_NEAREST: number;
  15578. /** mag = linear and min = nearest and mip = nearest */
  15579. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15580. /** mag = linear and min = nearest and mip = linear */
  15581. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15582. /** mag = linear and min = linear and mip = none */
  15583. static readonly LINEAR_LINEAR: number;
  15584. /** mag = linear and min = nearest and mip = none */
  15585. static readonly LINEAR_NEAREST: number;
  15586. /** Explicit coordinates mode */
  15587. static readonly EXPLICIT_MODE: number;
  15588. /** Spherical coordinates mode */
  15589. static readonly SPHERICAL_MODE: number;
  15590. /** Planar coordinates mode */
  15591. static readonly PLANAR_MODE: number;
  15592. /** Cubic coordinates mode */
  15593. static readonly CUBIC_MODE: number;
  15594. /** Projection coordinates mode */
  15595. static readonly PROJECTION_MODE: number;
  15596. /** Inverse Cubic coordinates mode */
  15597. static readonly SKYBOX_MODE: number;
  15598. /** Inverse Cubic coordinates mode */
  15599. static readonly INVCUBIC_MODE: number;
  15600. /** Equirectangular coordinates mode */
  15601. static readonly EQUIRECTANGULAR_MODE: number;
  15602. /** Equirectangular Fixed coordinates mode */
  15603. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15604. /** Equirectangular Fixed Mirrored coordinates mode */
  15605. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15606. /** Texture is not repeating outside of 0..1 UVs */
  15607. static readonly CLAMP_ADDRESSMODE: number;
  15608. /** Texture is repeating outside of 0..1 UVs */
  15609. static readonly WRAP_ADDRESSMODE: number;
  15610. /** Texture is repeating and mirrored */
  15611. static readonly MIRROR_ADDRESSMODE: number;
  15612. /**
  15613. * 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
  15614. */
  15615. static UseSerializedUrlIfAny: boolean;
  15616. /**
  15617. * Define the url of the texture.
  15618. */
  15619. url: Nullable<string>;
  15620. /**
  15621. * Define an offset on the texture to offset the u coordinates of the UVs
  15622. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15623. */
  15624. uOffset: number;
  15625. /**
  15626. * Define an offset on the texture to offset the v coordinates of the UVs
  15627. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15628. */
  15629. vOffset: number;
  15630. /**
  15631. * Define an offset on the texture to scale the u coordinates of the UVs
  15632. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15633. */
  15634. uScale: number;
  15635. /**
  15636. * Define an offset on the texture to scale the v coordinates of the UVs
  15637. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15638. */
  15639. vScale: number;
  15640. /**
  15641. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15642. * @see http://doc.babylonjs.com/how_to/more_materials
  15643. */
  15644. uAng: number;
  15645. /**
  15646. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15647. * @see http://doc.babylonjs.com/how_to/more_materials
  15648. */
  15649. vAng: number;
  15650. /**
  15651. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15652. * @see http://doc.babylonjs.com/how_to/more_materials
  15653. */
  15654. wAng: number;
  15655. /**
  15656. * Defines the center of rotation (U)
  15657. */
  15658. uRotationCenter: number;
  15659. /**
  15660. * Defines the center of rotation (V)
  15661. */
  15662. vRotationCenter: number;
  15663. /**
  15664. * Defines the center of rotation (W)
  15665. */
  15666. wRotationCenter: number;
  15667. /**
  15668. * Are mip maps generated for this texture or not.
  15669. */
  15670. readonly noMipmap: boolean;
  15671. /**
  15672. * List of inspectable custom properties (used by the Inspector)
  15673. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15674. */
  15675. inspectableCustomProperties: Nullable<IInspectable[]>;
  15676. private _noMipmap;
  15677. /** @hidden */ private _invertY: boolean;
  15678. private _rowGenerationMatrix;
  15679. private _cachedTextureMatrix;
  15680. private _projectionModeMatrix;
  15681. private _t0;
  15682. private _t1;
  15683. private _t2;
  15684. private _cachedUOffset;
  15685. private _cachedVOffset;
  15686. private _cachedUScale;
  15687. private _cachedVScale;
  15688. private _cachedUAng;
  15689. private _cachedVAng;
  15690. private _cachedWAng;
  15691. private _cachedProjectionMatrixId;
  15692. private _cachedCoordinatesMode;
  15693. /** @hidden */
  15694. protected _initialSamplingMode: number;
  15695. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  15696. private _deleteBuffer;
  15697. protected _format: Nullable<number>;
  15698. private _delayedOnLoad;
  15699. private _delayedOnError;
  15700. /**
  15701. * Observable triggered once the texture has been loaded.
  15702. */
  15703. onLoadObservable: Observable<Texture>;
  15704. protected _isBlocking: boolean;
  15705. /**
  15706. * Is the texture preventing material to render while loading.
  15707. * If false, a default texture will be used instead of the loading one during the preparation step.
  15708. */
  15709. isBlocking: boolean;
  15710. /**
  15711. * Get the current sampling mode associated with the texture.
  15712. */
  15713. readonly samplingMode: number;
  15714. /**
  15715. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15716. */
  15717. readonly invertY: boolean;
  15718. /**
  15719. * Instantiates a new texture.
  15720. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15721. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15722. * @param url define the url of the picture to load as a texture
  15723. * @param scene define the scene or engine the texture will belong to
  15724. * @param noMipmap define if the texture will require mip maps or not
  15725. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15726. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15727. * @param onLoad define a callback triggered when the texture has been loaded
  15728. * @param onError define a callback triggered when an error occurred during the loading session
  15729. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15730. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15731. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15732. */
  15733. 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);
  15734. /**
  15735. * Update the url (and optional buffer) of this texture if url was null during construction.
  15736. * @param url the url of the texture
  15737. * @param buffer the buffer of the texture (defaults to null)
  15738. * @param onLoad callback called when the texture is loaded (defaults to null)
  15739. */
  15740. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15741. /**
  15742. * Finish the loading sequence of a texture flagged as delayed load.
  15743. * @hidden
  15744. */
  15745. delayLoad(): void;
  15746. private _prepareRowForTextureGeneration;
  15747. /**
  15748. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15749. * @returns the transform matrix of the texture.
  15750. */
  15751. getTextureMatrix(): Matrix;
  15752. /**
  15753. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15754. * @returns The reflection texture transform
  15755. */
  15756. getReflectionTextureMatrix(): Matrix;
  15757. /**
  15758. * Clones the texture.
  15759. * @returns the cloned texture
  15760. */
  15761. clone(): Texture;
  15762. /**
  15763. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15764. * @returns The JSON representation of the texture
  15765. */
  15766. serialize(): any;
  15767. /**
  15768. * Get the current class name of the texture useful for serialization or dynamic coding.
  15769. * @returns "Texture"
  15770. */
  15771. getClassName(): string;
  15772. /**
  15773. * Dispose the texture and release its associated resources.
  15774. */
  15775. dispose(): void;
  15776. /**
  15777. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15778. * @param parsedTexture Define the JSON representation of the texture
  15779. * @param scene Define the scene the parsed texture should be instantiated in
  15780. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15781. * @returns The parsed texture if successful
  15782. */
  15783. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15784. /**
  15785. * Creates a texture from its base 64 representation.
  15786. * @param data Define the base64 payload without the data: prefix
  15787. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15788. * @param scene Define the scene the texture should belong to
  15789. * @param noMipmap Forces the texture to not create mip map information if true
  15790. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15791. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15792. * @param onLoad define a callback triggered when the texture has been loaded
  15793. * @param onError define a callback triggered when an error occurred during the loading session
  15794. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15795. * @returns the created texture
  15796. */
  15797. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15798. /**
  15799. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15800. * @param data Define the base64 payload without the data: prefix
  15801. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15802. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15803. * @param scene Define the scene the texture should belong to
  15804. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15805. * @param noMipmap Forces the texture to not create mip map information if true
  15806. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15807. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15808. * @param onLoad define a callback triggered when the texture has been loaded
  15809. * @param onError define a callback triggered when an error occurred during the loading session
  15810. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15811. * @returns the created texture
  15812. */
  15813. 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;
  15814. }
  15815. }
  15816. declare module BABYLON {
  15817. /**
  15818. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15819. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15820. */
  15821. export class PostProcessManager {
  15822. private _scene;
  15823. private _indexBuffer;
  15824. private _vertexBuffers;
  15825. /**
  15826. * Creates a new instance PostProcess
  15827. * @param scene The scene that the post process is associated with.
  15828. */
  15829. constructor(scene: Scene);
  15830. private _prepareBuffers;
  15831. private _buildIndexBuffer;
  15832. /**
  15833. * Rebuilds the vertex buffers of the manager.
  15834. * @hidden
  15835. */ private _rebuild(): void;
  15836. /**
  15837. * Prepares a frame to be run through a post process.
  15838. * @param sourceTexture The input texture to the post procesess. (default: null)
  15839. * @param postProcesses An array of post processes to be run. (default: null)
  15840. * @returns True if the post processes were able to be run.
  15841. * @hidden
  15842. */ private _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15843. /**
  15844. * Manually render a set of post processes to a texture.
  15845. * @param postProcesses An array of post processes to be run.
  15846. * @param targetTexture The target texture to render to.
  15847. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15848. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15849. * @param lodLevel defines which lod of the texture to render to
  15850. */
  15851. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15852. /**
  15853. * Finalize the result of the output of the postprocesses.
  15854. * @param doNotPresent If true the result will not be displayed to the screen.
  15855. * @param targetTexture The target texture to render to.
  15856. * @param faceIndex The index of the face to bind the target texture to.
  15857. * @param postProcesses The array of post processes to render.
  15858. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15859. * @hidden
  15860. */ private _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15861. /**
  15862. * Disposes of the post process manager.
  15863. */
  15864. dispose(): void;
  15865. }
  15866. }
  15867. declare module BABYLON {
  15868. /** Interface used by value gradients (color, factor, ...) */
  15869. export interface IValueGradient {
  15870. /**
  15871. * Gets or sets the gradient value (between 0 and 1)
  15872. */
  15873. gradient: number;
  15874. }
  15875. /** Class used to store color4 gradient */
  15876. export class ColorGradient implements IValueGradient {
  15877. /**
  15878. * Gets or sets the gradient value (between 0 and 1)
  15879. */
  15880. gradient: number;
  15881. /**
  15882. * Gets or sets first associated color
  15883. */
  15884. color1: Color4;
  15885. /**
  15886. * Gets or sets second associated color
  15887. */
  15888. color2?: Color4;
  15889. /**
  15890. * Will get a color picked randomly between color1 and color2.
  15891. * If color2 is undefined then color1 will be used
  15892. * @param result defines the target Color4 to store the result in
  15893. */
  15894. getColorToRef(result: Color4): void;
  15895. }
  15896. /** Class used to store color 3 gradient */
  15897. export class Color3Gradient implements IValueGradient {
  15898. /**
  15899. * Gets or sets the gradient value (between 0 and 1)
  15900. */
  15901. gradient: number;
  15902. /**
  15903. * Gets or sets the associated color
  15904. */
  15905. color: Color3;
  15906. }
  15907. /** Class used to store factor gradient */
  15908. export class FactorGradient implements IValueGradient {
  15909. /**
  15910. * Gets or sets the gradient value (between 0 and 1)
  15911. */
  15912. gradient: number;
  15913. /**
  15914. * Gets or sets first associated factor
  15915. */
  15916. factor1: number;
  15917. /**
  15918. * Gets or sets second associated factor
  15919. */
  15920. factor2?: number;
  15921. /**
  15922. * Will get a number picked randomly between factor1 and factor2.
  15923. * If factor2 is undefined then factor1 will be used
  15924. * @returns the picked number
  15925. */
  15926. getFactor(): number;
  15927. }
  15928. /**
  15929. * Helper used to simplify some generic gradient tasks
  15930. */
  15931. export class GradientHelper {
  15932. /**
  15933. * Gets the current gradient from an array of IValueGradient
  15934. * @param ratio defines the current ratio to get
  15935. * @param gradients defines the array of IValueGradient
  15936. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15937. */
  15938. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15939. }
  15940. }
  15941. declare module BABYLON {
  15942. interface ThinEngine {
  15943. /**
  15944. * Creates a dynamic texture
  15945. * @param width defines the width of the texture
  15946. * @param height defines the height of the texture
  15947. * @param generateMipMaps defines if the engine should generate the mip levels
  15948. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  15949. * @returns the dynamic texture inside an InternalTexture
  15950. */
  15951. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  15952. /**
  15953. * Update the content of a dynamic texture
  15954. * @param texture defines the texture to update
  15955. * @param canvas defines the canvas containing the source
  15956. * @param invertY defines if data must be stored with Y axis inverted
  15957. * @param premulAlpha defines if alpha is stored as premultiplied
  15958. * @param format defines the format of the data
  15959. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  15960. */
  15961. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  15962. }
  15963. }
  15964. declare module BABYLON {
  15965. /**
  15966. * A class extending Texture allowing drawing on a texture
  15967. * @see http://doc.babylonjs.com/how_to/dynamictexture
  15968. */
  15969. export class DynamicTexture extends Texture {
  15970. private _generateMipMaps;
  15971. private _canvas;
  15972. private _context;
  15973. private _engine;
  15974. /**
  15975. * Creates a DynamicTexture
  15976. * @param name defines the name of the texture
  15977. * @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
  15978. * @param scene defines the scene where you want the texture
  15979. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  15980. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  15981. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  15982. */
  15983. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  15984. /**
  15985. * Get the current class name of the texture useful for serialization or dynamic coding.
  15986. * @returns "DynamicTexture"
  15987. */
  15988. getClassName(): string;
  15989. /**
  15990. * Gets the current state of canRescale
  15991. */
  15992. readonly canRescale: boolean;
  15993. private _recreate;
  15994. /**
  15995. * Scales the texture
  15996. * @param ratio the scale factor to apply to both width and height
  15997. */
  15998. scale(ratio: number): void;
  15999. /**
  16000. * Resizes the texture
  16001. * @param width the new width
  16002. * @param height the new height
  16003. */
  16004. scaleTo(width: number, height: number): void;
  16005. /**
  16006. * Gets the context of the canvas used by the texture
  16007. * @returns the canvas context of the dynamic texture
  16008. */
  16009. getContext(): CanvasRenderingContext2D;
  16010. /**
  16011. * Clears the texture
  16012. */
  16013. clear(): void;
  16014. /**
  16015. * Updates the texture
  16016. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16017. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16018. */
  16019. update(invertY?: boolean, premulAlpha?: boolean): void;
  16020. /**
  16021. * Draws text onto the texture
  16022. * @param text defines the text to be drawn
  16023. * @param x defines the placement of the text from the left
  16024. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16025. * @param font defines the font to be used with font-style, font-size, font-name
  16026. * @param color defines the color used for the text
  16027. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16028. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16029. * @param update defines whether texture is immediately update (default is true)
  16030. */
  16031. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16032. /**
  16033. * Clones the texture
  16034. * @returns the clone of the texture.
  16035. */
  16036. clone(): DynamicTexture;
  16037. /**
  16038. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16039. * @returns a serialized dynamic texture object
  16040. */
  16041. serialize(): any;
  16042. /** @hidden */ private _rebuild(): void;
  16043. }
  16044. }
  16045. declare module BABYLON {
  16046. interface AbstractScene {
  16047. /**
  16048. * The list of procedural textures added to the scene
  16049. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16050. */
  16051. proceduralTextures: Array<ProceduralTexture>;
  16052. }
  16053. /**
  16054. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16055. * in a given scene.
  16056. */
  16057. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16058. /**
  16059. * The component name helpfull to identify the component in the list of scene components.
  16060. */
  16061. readonly name: string;
  16062. /**
  16063. * The scene the component belongs to.
  16064. */
  16065. scene: Scene;
  16066. /**
  16067. * Creates a new instance of the component for the given scene
  16068. * @param scene Defines the scene to register the component in
  16069. */
  16070. constructor(scene: Scene);
  16071. /**
  16072. * Registers the component in a given scene
  16073. */
  16074. register(): void;
  16075. /**
  16076. * Rebuilds the elements related to this component in case of
  16077. * context lost for instance.
  16078. */
  16079. rebuild(): void;
  16080. /**
  16081. * Disposes the component and the associated ressources.
  16082. */
  16083. dispose(): void;
  16084. private _beforeClear;
  16085. }
  16086. }
  16087. declare module BABYLON {
  16088. interface ThinEngine {
  16089. /**
  16090. * Creates a new render target cube texture
  16091. * @param size defines the size of the texture
  16092. * @param options defines the options used to create the texture
  16093. * @returns a new render target cube texture stored in an InternalTexture
  16094. */
  16095. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16096. }
  16097. }
  16098. declare module BABYLON {
  16099. /** @hidden */
  16100. export var proceduralVertexShader: {
  16101. name: string;
  16102. shader: string;
  16103. };
  16104. }
  16105. declare module BABYLON {
  16106. /**
  16107. * 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.
  16108. * This is the base class of any Procedural texture and contains most of the shareable code.
  16109. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16110. */
  16111. export class ProceduralTexture extends Texture {
  16112. isCube: boolean;
  16113. /**
  16114. * Define if the texture is enabled or not (disabled texture will not render)
  16115. */
  16116. isEnabled: boolean;
  16117. /**
  16118. * Define if the texture must be cleared before rendering (default is true)
  16119. */
  16120. autoClear: boolean;
  16121. /**
  16122. * Callback called when the texture is generated
  16123. */
  16124. onGenerated: () => void;
  16125. /**
  16126. * Event raised when the texture is generated
  16127. */
  16128. onGeneratedObservable: Observable<ProceduralTexture>;
  16129. /** @hidden */ private _generateMipMaps: boolean;
  16130. /** @hidden **/ private _effect: Effect;
  16131. /** @hidden */ private _textures: {
  16132. [key: string]: Texture;
  16133. };
  16134. private _size;
  16135. private _currentRefreshId;
  16136. private _refreshRate;
  16137. private _vertexBuffers;
  16138. private _indexBuffer;
  16139. private _uniforms;
  16140. private _samplers;
  16141. private _fragment;
  16142. private _floats;
  16143. private _ints;
  16144. private _floatsArrays;
  16145. private _colors3;
  16146. private _colors4;
  16147. private _vectors2;
  16148. private _vectors3;
  16149. private _matrices;
  16150. private _fallbackTexture;
  16151. private _fallbackTextureUsed;
  16152. private _engine;
  16153. private _cachedDefines;
  16154. private _contentUpdateId;
  16155. private _contentData;
  16156. /**
  16157. * Instantiates a new procedural texture.
  16158. * 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.
  16159. * This is the base class of any Procedural texture and contains most of the shareable code.
  16160. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16161. * @param name Define the name of the texture
  16162. * @param size Define the size of the texture to create
  16163. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16164. * @param scene Define the scene the texture belongs to
  16165. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16166. * @param generateMipMaps Define if the texture should creates mip maps or not
  16167. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16168. */
  16169. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16170. /**
  16171. * The effect that is created when initializing the post process.
  16172. * @returns The created effect corresponding the the postprocess.
  16173. */
  16174. getEffect(): Effect;
  16175. /**
  16176. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16177. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16178. */
  16179. getContent(): Nullable<ArrayBufferView>;
  16180. private _createIndexBuffer;
  16181. /** @hidden */ private _rebuild(): void;
  16182. /**
  16183. * Resets the texture in order to recreate its associated resources.
  16184. * This can be called in case of context loss
  16185. */
  16186. reset(): void;
  16187. protected _getDefines(): string;
  16188. /**
  16189. * Is the texture ready to be used ? (rendered at least once)
  16190. * @returns true if ready, otherwise, false.
  16191. */
  16192. isReady(): boolean;
  16193. /**
  16194. * Resets the refresh counter of the texture and start bak from scratch.
  16195. * Could be useful to regenerate the texture if it is setup to render only once.
  16196. */
  16197. resetRefreshCounter(): void;
  16198. /**
  16199. * Set the fragment shader to use in order to render the texture.
  16200. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16201. */
  16202. setFragment(fragment: any): void;
  16203. /**
  16204. * Define the refresh rate of the texture or the rendering frequency.
  16205. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16206. */
  16207. refreshRate: number;
  16208. /** @hidden */ private _shouldRender(): boolean;
  16209. /**
  16210. * Get the size the texture is rendering at.
  16211. * @returns the size (texture is always squared)
  16212. */
  16213. getRenderSize(): number;
  16214. /**
  16215. * Resize the texture to new value.
  16216. * @param size Define the new size the texture should have
  16217. * @param generateMipMaps Define whether the new texture should create mip maps
  16218. */
  16219. resize(size: number, generateMipMaps: boolean): void;
  16220. private _checkUniform;
  16221. /**
  16222. * Set a texture in the shader program used to render.
  16223. * @param name Define the name of the uniform samplers as defined in the shader
  16224. * @param texture Define the texture to bind to this sampler
  16225. * @return the texture itself allowing "fluent" like uniform updates
  16226. */
  16227. setTexture(name: string, texture: Texture): ProceduralTexture;
  16228. /**
  16229. * Set a float in the shader.
  16230. * @param name Define the name of the uniform as defined in the shader
  16231. * @param value Define the value to give to the uniform
  16232. * @return the texture itself allowing "fluent" like uniform updates
  16233. */
  16234. setFloat(name: string, value: number): ProceduralTexture;
  16235. /**
  16236. * Set a int in the shader.
  16237. * @param name Define the name of the uniform as defined in the shader
  16238. * @param value Define the value to give to the uniform
  16239. * @return the texture itself allowing "fluent" like uniform updates
  16240. */
  16241. setInt(name: string, value: number): ProceduralTexture;
  16242. /**
  16243. * Set an array of floats in the shader.
  16244. * @param name Define the name of the uniform as defined in the shader
  16245. * @param value Define the value to give to the uniform
  16246. * @return the texture itself allowing "fluent" like uniform updates
  16247. */
  16248. setFloats(name: string, value: number[]): ProceduralTexture;
  16249. /**
  16250. * Set a vec3 in the shader from a Color3.
  16251. * @param name Define the name of the uniform as defined in the shader
  16252. * @param value Define the value to give to the uniform
  16253. * @return the texture itself allowing "fluent" like uniform updates
  16254. */
  16255. setColor3(name: string, value: Color3): ProceduralTexture;
  16256. /**
  16257. * Set a vec4 in the shader from a Color4.
  16258. * @param name Define the name of the uniform as defined in the shader
  16259. * @param value Define the value to give to the uniform
  16260. * @return the texture itself allowing "fluent" like uniform updates
  16261. */
  16262. setColor4(name: string, value: Color4): ProceduralTexture;
  16263. /**
  16264. * Set a vec2 in the shader from a Vector2.
  16265. * @param name Define the name of the uniform as defined in the shader
  16266. * @param value Define the value to give to the uniform
  16267. * @return the texture itself allowing "fluent" like uniform updates
  16268. */
  16269. setVector2(name: string, value: Vector2): ProceduralTexture;
  16270. /**
  16271. * Set a vec3 in the shader from a Vector3.
  16272. * @param name Define the name of the uniform as defined in the shader
  16273. * @param value Define the value to give to the uniform
  16274. * @return the texture itself allowing "fluent" like uniform updates
  16275. */
  16276. setVector3(name: string, value: Vector3): ProceduralTexture;
  16277. /**
  16278. * Set a mat4 in the shader from a MAtrix.
  16279. * @param name Define the name of the uniform as defined in the shader
  16280. * @param value Define the value to give to the uniform
  16281. * @return the texture itself allowing "fluent" like uniform updates
  16282. */
  16283. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16284. /**
  16285. * Render the texture to its associated render target.
  16286. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16287. */
  16288. render(useCameraPostProcess?: boolean): void;
  16289. /**
  16290. * Clone the texture.
  16291. * @returns the cloned texture
  16292. */
  16293. clone(): ProceduralTexture;
  16294. /**
  16295. * Dispose the texture and release its asoociated resources.
  16296. */
  16297. dispose(): void;
  16298. }
  16299. }
  16300. declare module BABYLON {
  16301. /**
  16302. * This represents the base class for particle system in Babylon.
  16303. * 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.
  16304. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16305. * @example https://doc.babylonjs.com/babylon101/particles
  16306. */
  16307. export class BaseParticleSystem {
  16308. /**
  16309. * Source color is added to the destination color without alpha affecting the result
  16310. */
  16311. static BLENDMODE_ONEONE: number;
  16312. /**
  16313. * Blend current color and particle color using particle’s alpha
  16314. */
  16315. static BLENDMODE_STANDARD: number;
  16316. /**
  16317. * Add current color and particle color multiplied by particle’s alpha
  16318. */
  16319. static BLENDMODE_ADD: number;
  16320. /**
  16321. * Multiply current color with particle color
  16322. */
  16323. static BLENDMODE_MULTIPLY: number;
  16324. /**
  16325. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16326. */
  16327. static BLENDMODE_MULTIPLYADD: number;
  16328. /**
  16329. * List of animations used by the particle system.
  16330. */
  16331. animations: Animation[];
  16332. /**
  16333. * The id of the Particle system.
  16334. */
  16335. id: string;
  16336. /**
  16337. * The friendly name of the Particle system.
  16338. */
  16339. name: string;
  16340. /**
  16341. * The rendering group used by the Particle system to chose when to render.
  16342. */
  16343. renderingGroupId: number;
  16344. /**
  16345. * The emitter represents the Mesh or position we are attaching the particle system to.
  16346. */
  16347. emitter: Nullable<AbstractMesh | Vector3>;
  16348. /**
  16349. * The maximum number of particles to emit per frame
  16350. */
  16351. emitRate: number;
  16352. /**
  16353. * If you want to launch only a few particles at once, that can be done, as well.
  16354. */
  16355. manualEmitCount: number;
  16356. /**
  16357. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16358. */
  16359. updateSpeed: number;
  16360. /**
  16361. * The amount of time the particle system is running (depends of the overall update speed).
  16362. */
  16363. targetStopDuration: number;
  16364. /**
  16365. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16366. */
  16367. disposeOnStop: boolean;
  16368. /**
  16369. * Minimum power of emitting particles.
  16370. */
  16371. minEmitPower: number;
  16372. /**
  16373. * Maximum power of emitting particles.
  16374. */
  16375. maxEmitPower: number;
  16376. /**
  16377. * Minimum life time of emitting particles.
  16378. */
  16379. minLifeTime: number;
  16380. /**
  16381. * Maximum life time of emitting particles.
  16382. */
  16383. maxLifeTime: number;
  16384. /**
  16385. * Minimum Size of emitting particles.
  16386. */
  16387. minSize: number;
  16388. /**
  16389. * Maximum Size of emitting particles.
  16390. */
  16391. maxSize: number;
  16392. /**
  16393. * Minimum scale of emitting particles on X axis.
  16394. */
  16395. minScaleX: number;
  16396. /**
  16397. * Maximum scale of emitting particles on X axis.
  16398. */
  16399. maxScaleX: number;
  16400. /**
  16401. * Minimum scale of emitting particles on Y axis.
  16402. */
  16403. minScaleY: number;
  16404. /**
  16405. * Maximum scale of emitting particles on Y axis.
  16406. */
  16407. maxScaleY: number;
  16408. /**
  16409. * Gets or sets the minimal initial rotation in radians.
  16410. */
  16411. minInitialRotation: number;
  16412. /**
  16413. * Gets or sets the maximal initial rotation in radians.
  16414. */
  16415. maxInitialRotation: number;
  16416. /**
  16417. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16418. */
  16419. minAngularSpeed: number;
  16420. /**
  16421. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16422. */
  16423. maxAngularSpeed: number;
  16424. /**
  16425. * The texture used to render each particle. (this can be a spritesheet)
  16426. */
  16427. particleTexture: Nullable<Texture>;
  16428. /**
  16429. * The layer mask we are rendering the particles through.
  16430. */
  16431. layerMask: number;
  16432. /**
  16433. * This can help using your own shader to render the particle system.
  16434. * The according effect will be created
  16435. */
  16436. customShader: any;
  16437. /**
  16438. * By default particle system starts as soon as they are created. This prevents the
  16439. * automatic start to happen and let you decide when to start emitting particles.
  16440. */
  16441. preventAutoStart: boolean;
  16442. private _noiseTexture;
  16443. /**
  16444. * Gets or sets a texture used to add random noise to particle positions
  16445. */
  16446. noiseTexture: Nullable<ProceduralTexture>;
  16447. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16448. noiseStrength: Vector3;
  16449. /**
  16450. * Callback triggered when the particle animation is ending.
  16451. */
  16452. onAnimationEnd: Nullable<() => void>;
  16453. /**
  16454. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16455. */
  16456. blendMode: number;
  16457. /**
  16458. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16459. * to override the particles.
  16460. */
  16461. forceDepthWrite: boolean;
  16462. /** 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 */
  16463. preWarmCycles: number;
  16464. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16465. preWarmStepOffset: number;
  16466. /**
  16467. * 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)
  16468. */
  16469. spriteCellChangeSpeed: number;
  16470. /**
  16471. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16472. */
  16473. startSpriteCellID: number;
  16474. /**
  16475. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16476. */
  16477. endSpriteCellID: number;
  16478. /**
  16479. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16480. */
  16481. spriteCellWidth: number;
  16482. /**
  16483. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16484. */
  16485. spriteCellHeight: number;
  16486. /**
  16487. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16488. */
  16489. spriteRandomStartCell: boolean;
  16490. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16491. translationPivot: Vector2;
  16492. /** @hidden */
  16493. protected _isAnimationSheetEnabled: boolean;
  16494. /**
  16495. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16496. */
  16497. beginAnimationOnStart: boolean;
  16498. /**
  16499. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16500. */
  16501. beginAnimationFrom: number;
  16502. /**
  16503. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16504. */
  16505. beginAnimationTo: number;
  16506. /**
  16507. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16508. */
  16509. beginAnimationLoop: boolean;
  16510. /**
  16511. * Gets or sets a world offset applied to all particles
  16512. */
  16513. worldOffset: Vector3;
  16514. /**
  16515. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16516. */
  16517. isAnimationSheetEnabled: boolean;
  16518. /**
  16519. * Get hosting scene
  16520. * @returns the scene
  16521. */
  16522. getScene(): Scene;
  16523. /**
  16524. * You can use gravity if you want to give an orientation to your particles.
  16525. */
  16526. gravity: Vector3;
  16527. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16528. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16529. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16530. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16531. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16532. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16533. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16534. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16535. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16536. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16537. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16538. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16539. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16540. /**
  16541. * Defines the delay in milliseconds before starting the system (0 by default)
  16542. */
  16543. startDelay: number;
  16544. /**
  16545. * Gets the current list of drag gradients.
  16546. * You must use addDragGradient and removeDragGradient to udpate this list
  16547. * @returns the list of drag gradients
  16548. */
  16549. getDragGradients(): Nullable<Array<FactorGradient>>;
  16550. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16551. limitVelocityDamping: number;
  16552. /**
  16553. * Gets the current list of limit velocity gradients.
  16554. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16555. * @returns the list of limit velocity gradients
  16556. */
  16557. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16558. /**
  16559. * Gets the current list of color gradients.
  16560. * You must use addColorGradient and removeColorGradient to udpate this list
  16561. * @returns the list of color gradients
  16562. */
  16563. getColorGradients(): Nullable<Array<ColorGradient>>;
  16564. /**
  16565. * Gets the current list of size gradients.
  16566. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16567. * @returns the list of size gradients
  16568. */
  16569. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16570. /**
  16571. * Gets the current list of color remap gradients.
  16572. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16573. * @returns the list of color remap gradients
  16574. */
  16575. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16576. /**
  16577. * Gets the current list of alpha remap gradients.
  16578. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16579. * @returns the list of alpha remap gradients
  16580. */
  16581. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16582. /**
  16583. * Gets the current list of life time gradients.
  16584. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16585. * @returns the list of life time gradients
  16586. */
  16587. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16588. /**
  16589. * Gets the current list of angular speed gradients.
  16590. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16591. * @returns the list of angular speed gradients
  16592. */
  16593. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16594. /**
  16595. * Gets the current list of velocity gradients.
  16596. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16597. * @returns the list of velocity gradients
  16598. */
  16599. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16600. /**
  16601. * Gets the current list of start size gradients.
  16602. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16603. * @returns the list of start size gradients
  16604. */
  16605. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16606. /**
  16607. * Gets the current list of emit rate gradients.
  16608. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16609. * @returns the list of emit rate gradients
  16610. */
  16611. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16612. /**
  16613. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16614. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16615. */
  16616. direction1: Vector3;
  16617. /**
  16618. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16619. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16620. */
  16621. direction2: Vector3;
  16622. /**
  16623. * 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.
  16624. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16625. */
  16626. minEmitBox: Vector3;
  16627. /**
  16628. * 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.
  16629. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16630. */
  16631. maxEmitBox: Vector3;
  16632. /**
  16633. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16634. */
  16635. color1: Color4;
  16636. /**
  16637. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16638. */
  16639. color2: Color4;
  16640. /**
  16641. * Color the particle will have at the end of its lifetime
  16642. */
  16643. colorDead: Color4;
  16644. /**
  16645. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16646. */
  16647. textureMask: Color4;
  16648. /**
  16649. * The particle emitter type defines the emitter used by the particle system.
  16650. * It can be for example box, sphere, or cone...
  16651. */
  16652. particleEmitterType: IParticleEmitterType;
  16653. /** @hidden */ private _isSubEmitter: boolean;
  16654. /**
  16655. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16656. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16657. */
  16658. billboardMode: number;
  16659. protected _isBillboardBased: boolean;
  16660. /**
  16661. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16662. */
  16663. isBillboardBased: boolean;
  16664. /**
  16665. * The scene the particle system belongs to.
  16666. */
  16667. protected _scene: Scene;
  16668. /**
  16669. * Local cache of defines for image processing.
  16670. */
  16671. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16672. /**
  16673. * Default configuration related to image processing available in the standard Material.
  16674. */
  16675. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16676. /**
  16677. * Gets the image processing configuration used either in this material.
  16678. */
  16679. /**
  16680. * Sets the Default image processing configuration used either in the this material.
  16681. *
  16682. * If sets to null, the scene one is in use.
  16683. */
  16684. imageProcessingConfiguration: ImageProcessingConfiguration;
  16685. /**
  16686. * Attaches a new image processing configuration to the Standard Material.
  16687. * @param configuration
  16688. */
  16689. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16690. /** @hidden */
  16691. protected _reset(): void;
  16692. /** @hidden */
  16693. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16694. /**
  16695. * Instantiates a particle system.
  16696. * 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.
  16697. * @param name The name of the particle system
  16698. */
  16699. constructor(name: string);
  16700. /**
  16701. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16702. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16703. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16704. * @returns the emitter
  16705. */
  16706. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16707. /**
  16708. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16709. * @param radius The radius of the hemisphere to emit from
  16710. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16711. * @returns the emitter
  16712. */
  16713. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16714. /**
  16715. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16716. * @param radius The radius of the sphere to emit from
  16717. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16718. * @returns the emitter
  16719. */
  16720. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16721. /**
  16722. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16723. * @param radius The radius of the sphere to emit from
  16724. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16725. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16726. * @returns the emitter
  16727. */
  16728. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16729. /**
  16730. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16731. * @param radius The radius of the emission cylinder
  16732. * @param height The height of the emission cylinder
  16733. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16734. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16735. * @returns the emitter
  16736. */
  16737. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16738. /**
  16739. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16740. * @param radius The radius of the cylinder to emit from
  16741. * @param height The height of the emission cylinder
  16742. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16743. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16744. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16745. * @returns the emitter
  16746. */
  16747. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16748. /**
  16749. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16750. * @param radius The radius of the cone to emit from
  16751. * @param angle The base angle of the cone
  16752. * @returns the emitter
  16753. */
  16754. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16755. /**
  16756. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16757. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16758. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16759. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16760. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16761. * @returns the emitter
  16762. */
  16763. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16764. }
  16765. }
  16766. declare module BABYLON {
  16767. /**
  16768. * Type of sub emitter
  16769. */
  16770. export enum SubEmitterType {
  16771. /**
  16772. * Attached to the particle over it's lifetime
  16773. */
  16774. ATTACHED = 0,
  16775. /**
  16776. * Created when the particle dies
  16777. */
  16778. END = 1
  16779. }
  16780. /**
  16781. * Sub emitter class used to emit particles from an existing particle
  16782. */
  16783. export class SubEmitter {
  16784. /**
  16785. * the particle system to be used by the sub emitter
  16786. */
  16787. particleSystem: ParticleSystem;
  16788. /**
  16789. * Type of the submitter (Default: END)
  16790. */
  16791. type: SubEmitterType;
  16792. /**
  16793. * 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)
  16794. * Note: This only is supported when using an emitter of type Mesh
  16795. */
  16796. inheritDirection: boolean;
  16797. /**
  16798. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16799. */
  16800. inheritedVelocityAmount: number;
  16801. /**
  16802. * Creates a sub emitter
  16803. * @param particleSystem the particle system to be used by the sub emitter
  16804. */
  16805. constructor(
  16806. /**
  16807. * the particle system to be used by the sub emitter
  16808. */
  16809. particleSystem: ParticleSystem);
  16810. /**
  16811. * Clones the sub emitter
  16812. * @returns the cloned sub emitter
  16813. */
  16814. clone(): SubEmitter;
  16815. /**
  16816. * Serialize current object to a JSON object
  16817. * @returns the serialized object
  16818. */
  16819. serialize(): any;
  16820. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16821. /**
  16822. * Creates a new SubEmitter from a serialized JSON version
  16823. * @param serializationObject defines the JSON object to read from
  16824. * @param scene defines the hosting scene
  16825. * @param rootUrl defines the rootUrl for data loading
  16826. * @returns a new SubEmitter
  16827. */
  16828. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16829. /** Release associated resources */
  16830. dispose(): void;
  16831. }
  16832. }
  16833. declare module BABYLON {
  16834. /** @hidden */
  16835. export var clipPlaneFragmentDeclaration: {
  16836. name: string;
  16837. shader: string;
  16838. };
  16839. }
  16840. declare module BABYLON {
  16841. /** @hidden */
  16842. export var imageProcessingDeclaration: {
  16843. name: string;
  16844. shader: string;
  16845. };
  16846. }
  16847. declare module BABYLON {
  16848. /** @hidden */
  16849. export var imageProcessingFunctions: {
  16850. name: string;
  16851. shader: string;
  16852. };
  16853. }
  16854. declare module BABYLON {
  16855. /** @hidden */
  16856. export var clipPlaneFragment: {
  16857. name: string;
  16858. shader: string;
  16859. };
  16860. }
  16861. declare module BABYLON {
  16862. /** @hidden */
  16863. export var particlesPixelShader: {
  16864. name: string;
  16865. shader: string;
  16866. };
  16867. }
  16868. declare module BABYLON {
  16869. /** @hidden */
  16870. export var clipPlaneVertexDeclaration: {
  16871. name: string;
  16872. shader: string;
  16873. };
  16874. }
  16875. declare module BABYLON {
  16876. /** @hidden */
  16877. export var clipPlaneVertex: {
  16878. name: string;
  16879. shader: string;
  16880. };
  16881. }
  16882. declare module BABYLON {
  16883. /** @hidden */
  16884. export var particlesVertexShader: {
  16885. name: string;
  16886. shader: string;
  16887. };
  16888. }
  16889. declare module BABYLON {
  16890. /**
  16891. * This represents a particle system in Babylon.
  16892. * 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.
  16893. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16894. * @example https://doc.babylonjs.com/babylon101/particles
  16895. */
  16896. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16897. /**
  16898. * Billboard mode will only apply to Y axis
  16899. */
  16900. static readonly BILLBOARDMODE_Y: number;
  16901. /**
  16902. * Billboard mode will apply to all axes
  16903. */
  16904. static readonly BILLBOARDMODE_ALL: number;
  16905. /**
  16906. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16907. */
  16908. static readonly BILLBOARDMODE_STRETCHED: number;
  16909. /**
  16910. * This function can be defined to provide custom update for active particles.
  16911. * This function will be called instead of regular update (age, position, color, etc.).
  16912. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16913. */
  16914. updateFunction: (particles: Particle[]) => void;
  16915. private _emitterWorldMatrix;
  16916. /**
  16917. * This function can be defined to specify initial direction for every new particle.
  16918. * It by default use the emitterType defined function
  16919. */
  16920. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16921. /**
  16922. * This function can be defined to specify initial position for every new particle.
  16923. * It by default use the emitterType defined function
  16924. */
  16925. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16926. /**
  16927. * @hidden
  16928. */ private _inheritedVelocityOffset: Vector3;
  16929. /**
  16930. * An event triggered when the system is disposed
  16931. */
  16932. onDisposeObservable: Observable<ParticleSystem>;
  16933. private _onDisposeObserver;
  16934. /**
  16935. * Sets a callback that will be triggered when the system is disposed
  16936. */
  16937. onDispose: () => void;
  16938. private _particles;
  16939. private _epsilon;
  16940. private _capacity;
  16941. private _stockParticles;
  16942. private _newPartsExcess;
  16943. private _vertexData;
  16944. private _vertexBuffer;
  16945. private _vertexBuffers;
  16946. private _spriteBuffer;
  16947. private _indexBuffer;
  16948. private _effect;
  16949. private _customEffect;
  16950. private _cachedDefines;
  16951. private _scaledColorStep;
  16952. private _colorDiff;
  16953. private _scaledDirection;
  16954. private _scaledGravity;
  16955. private _currentRenderId;
  16956. private _alive;
  16957. private _useInstancing;
  16958. private _started;
  16959. private _stopped;
  16960. private _actualFrame;
  16961. private _scaledUpdateSpeed;
  16962. private _vertexBufferSize;
  16963. /** @hidden */ private _currentEmitRateGradient: Nullable<FactorGradient>;
  16964. /** @hidden */ private _currentEmitRate1: number;
  16965. /** @hidden */ private _currentEmitRate2: number;
  16966. /** @hidden */ private _currentStartSizeGradient: Nullable<FactorGradient>;
  16967. /** @hidden */ private _currentStartSize1: number;
  16968. /** @hidden */ private _currentStartSize2: number;
  16969. private readonly _rawTextureWidth;
  16970. private _rampGradientsTexture;
  16971. private _useRampGradients;
  16972. /** Gets or sets a boolean indicating that ramp gradients must be used
  16973. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16974. */
  16975. useRampGradients: boolean;
  16976. /**
  16977. * 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.
  16978. * 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: [])
  16979. */
  16980. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16981. private _subEmitters;
  16982. /**
  16983. * @hidden
  16984. * If the particle systems emitter should be disposed when the particle system is disposed
  16985. */ private _disposeEmitterOnDispose: boolean;
  16986. /**
  16987. * The current active Sub-systems, this property is used by the root particle system only.
  16988. */
  16989. activeSubSystems: Array<ParticleSystem>;
  16990. private _rootParticleSystem;
  16991. /**
  16992. * Gets the current list of active particles
  16993. */
  16994. readonly particles: Particle[];
  16995. /**
  16996. * Returns the string "ParticleSystem"
  16997. * @returns a string containing the class name
  16998. */
  16999. getClassName(): string;
  17000. /**
  17001. * Instantiates a particle system.
  17002. * 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.
  17003. * @param name The name of the particle system
  17004. * @param capacity The max number of particles alive at the same time
  17005. * @param scene The scene the particle system belongs to
  17006. * @param customEffect a custom effect used to change the way particles are rendered by default
  17007. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17008. * @param epsilon Offset used to render the particles
  17009. */
  17010. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17011. private _addFactorGradient;
  17012. private _removeFactorGradient;
  17013. /**
  17014. * Adds a new life time gradient
  17015. * @param gradient defines the gradient to use (between 0 and 1)
  17016. * @param factor defines the life time factor to affect to the specified gradient
  17017. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17018. * @returns the current particle system
  17019. */
  17020. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17021. /**
  17022. * Remove a specific life time gradient
  17023. * @param gradient defines the gradient to remove
  17024. * @returns the current particle system
  17025. */
  17026. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17027. /**
  17028. * Adds a new size gradient
  17029. * @param gradient defines the gradient to use (between 0 and 1)
  17030. * @param factor defines the size factor to affect to the specified gradient
  17031. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17032. * @returns the current particle system
  17033. */
  17034. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17035. /**
  17036. * Remove a specific size gradient
  17037. * @param gradient defines the gradient to remove
  17038. * @returns the current particle system
  17039. */
  17040. removeSizeGradient(gradient: number): IParticleSystem;
  17041. /**
  17042. * Adds a new color remap gradient
  17043. * @param gradient defines the gradient to use (between 0 and 1)
  17044. * @param min defines the color remap minimal range
  17045. * @param max defines the color remap maximal range
  17046. * @returns the current particle system
  17047. */
  17048. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17049. /**
  17050. * Remove a specific color remap gradient
  17051. * @param gradient defines the gradient to remove
  17052. * @returns the current particle system
  17053. */
  17054. removeColorRemapGradient(gradient: number): IParticleSystem;
  17055. /**
  17056. * Adds a new alpha remap gradient
  17057. * @param gradient defines the gradient to use (between 0 and 1)
  17058. * @param min defines the alpha remap minimal range
  17059. * @param max defines the alpha remap maximal range
  17060. * @returns the current particle system
  17061. */
  17062. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17063. /**
  17064. * Remove a specific alpha remap gradient
  17065. * @param gradient defines the gradient to remove
  17066. * @returns the current particle system
  17067. */
  17068. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17069. /**
  17070. * Adds a new angular speed gradient
  17071. * @param gradient defines the gradient to use (between 0 and 1)
  17072. * @param factor defines the angular speed to affect to the specified gradient
  17073. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17074. * @returns the current particle system
  17075. */
  17076. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17077. /**
  17078. * Remove a specific angular speed gradient
  17079. * @param gradient defines the gradient to remove
  17080. * @returns the current particle system
  17081. */
  17082. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17083. /**
  17084. * Adds a new velocity gradient
  17085. * @param gradient defines the gradient to use (between 0 and 1)
  17086. * @param factor defines the velocity to affect to the specified gradient
  17087. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17088. * @returns the current particle system
  17089. */
  17090. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17091. /**
  17092. * Remove a specific velocity gradient
  17093. * @param gradient defines the gradient to remove
  17094. * @returns the current particle system
  17095. */
  17096. removeVelocityGradient(gradient: number): IParticleSystem;
  17097. /**
  17098. * Adds a new limit velocity gradient
  17099. * @param gradient defines the gradient to use (between 0 and 1)
  17100. * @param factor defines the limit velocity value to affect to the specified gradient
  17101. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17102. * @returns the current particle system
  17103. */
  17104. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17105. /**
  17106. * Remove a specific limit velocity gradient
  17107. * @param gradient defines the gradient to remove
  17108. * @returns the current particle system
  17109. */
  17110. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17111. /**
  17112. * Adds a new drag gradient
  17113. * @param gradient defines the gradient to use (between 0 and 1)
  17114. * @param factor defines the drag value to affect to the specified gradient
  17115. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17116. * @returns the current particle system
  17117. */
  17118. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17119. /**
  17120. * Remove a specific drag gradient
  17121. * @param gradient defines the gradient to remove
  17122. * @returns the current particle system
  17123. */
  17124. removeDragGradient(gradient: number): IParticleSystem;
  17125. /**
  17126. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17127. * @param gradient defines the gradient to use (between 0 and 1)
  17128. * @param factor defines the emit rate value to affect to the specified gradient
  17129. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17130. * @returns the current particle system
  17131. */
  17132. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17133. /**
  17134. * Remove a specific emit rate gradient
  17135. * @param gradient defines the gradient to remove
  17136. * @returns the current particle system
  17137. */
  17138. removeEmitRateGradient(gradient: number): IParticleSystem;
  17139. /**
  17140. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17141. * @param gradient defines the gradient to use (between 0 and 1)
  17142. * @param factor defines the start size value to affect to the specified gradient
  17143. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17144. * @returns the current particle system
  17145. */
  17146. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17147. /**
  17148. * Remove a specific start size gradient
  17149. * @param gradient defines the gradient to remove
  17150. * @returns the current particle system
  17151. */
  17152. removeStartSizeGradient(gradient: number): IParticleSystem;
  17153. private _createRampGradientTexture;
  17154. /**
  17155. * Gets the current list of ramp gradients.
  17156. * You must use addRampGradient and removeRampGradient to udpate this list
  17157. * @returns the list of ramp gradients
  17158. */
  17159. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17160. /**
  17161. * Adds a new ramp gradient used to remap particle colors
  17162. * @param gradient defines the gradient to use (between 0 and 1)
  17163. * @param color defines the color to affect to the specified gradient
  17164. * @returns the current particle system
  17165. */
  17166. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17167. /**
  17168. * Remove a specific ramp gradient
  17169. * @param gradient defines the gradient to remove
  17170. * @returns the current particle system
  17171. */
  17172. removeRampGradient(gradient: number): ParticleSystem;
  17173. /**
  17174. * Adds a new color gradient
  17175. * @param gradient defines the gradient to use (between 0 and 1)
  17176. * @param color1 defines the color to affect to the specified gradient
  17177. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17178. * @returns this particle system
  17179. */
  17180. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17181. /**
  17182. * Remove a specific color gradient
  17183. * @param gradient defines the gradient to remove
  17184. * @returns this particle system
  17185. */
  17186. removeColorGradient(gradient: number): IParticleSystem;
  17187. private _fetchR;
  17188. protected _reset(): void;
  17189. private _resetEffect;
  17190. private _createVertexBuffers;
  17191. private _createIndexBuffer;
  17192. /**
  17193. * Gets the maximum number of particles active at the same time.
  17194. * @returns The max number of active particles.
  17195. */
  17196. getCapacity(): number;
  17197. /**
  17198. * Gets whether there are still active particles in the system.
  17199. * @returns True if it is alive, otherwise false.
  17200. */
  17201. isAlive(): boolean;
  17202. /**
  17203. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17204. * @returns True if it has been started, otherwise false.
  17205. */
  17206. isStarted(): boolean;
  17207. private _prepareSubEmitterInternalArray;
  17208. /**
  17209. * Starts the particle system and begins to emit
  17210. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17211. */
  17212. start(delay?: number): void;
  17213. /**
  17214. * Stops the particle system.
  17215. * @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.
  17216. */
  17217. stop(stopSubEmitters?: boolean): void;
  17218. /**
  17219. * Remove all active particles
  17220. */
  17221. reset(): void;
  17222. /**
  17223. * @hidden (for internal use only)
  17224. */ private _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17225. /**
  17226. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17227. * Its lifetime will start back at 0.
  17228. */
  17229. recycleParticle: (particle: Particle) => void;
  17230. private _stopSubEmitters;
  17231. private _createParticle;
  17232. private _removeFromRoot;
  17233. private _emitFromParticle;
  17234. private _update;
  17235. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17236. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17237. /** @hidden */
  17238. private _getEffect;
  17239. /**
  17240. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17241. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17242. */
  17243. animate(preWarmOnly?: boolean): void;
  17244. private _appendParticleVertices;
  17245. /**
  17246. * Rebuilds the particle system.
  17247. */
  17248. rebuild(): void;
  17249. /**
  17250. * Is this system ready to be used/rendered
  17251. * @return true if the system is ready
  17252. */
  17253. isReady(): boolean;
  17254. private _render;
  17255. /**
  17256. * Renders the particle system in its current state.
  17257. * @returns the current number of particles
  17258. */
  17259. render(): number;
  17260. /**
  17261. * Disposes the particle system and free the associated resources
  17262. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17263. */
  17264. dispose(disposeTexture?: boolean): void;
  17265. /**
  17266. * Clones the particle system.
  17267. * @param name The name of the cloned object
  17268. * @param newEmitter The new emitter to use
  17269. * @returns the cloned particle system
  17270. */
  17271. clone(name: string, newEmitter: any): ParticleSystem;
  17272. /**
  17273. * Serializes the particle system to a JSON object.
  17274. * @returns the JSON object
  17275. */
  17276. serialize(): any;
  17277. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17278. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17279. /**
  17280. * Parses a JSON object to create a particle system.
  17281. * @param parsedParticleSystem The JSON object to parse
  17282. * @param scene The scene to create the particle system in
  17283. * @param rootUrl The root url to use to load external dependencies like texture
  17284. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17285. * @returns the Parsed particle system
  17286. */
  17287. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17288. }
  17289. }
  17290. declare module BABYLON {
  17291. /**
  17292. * A particle represents one of the element emitted by a particle system.
  17293. * This is mainly define by its coordinates, direction, velocity and age.
  17294. */
  17295. export class Particle {
  17296. /**
  17297. * The particle system the particle belongs to.
  17298. */
  17299. particleSystem: ParticleSystem;
  17300. private static _Count;
  17301. /**
  17302. * Unique ID of the particle
  17303. */
  17304. id: number;
  17305. /**
  17306. * The world position of the particle in the scene.
  17307. */
  17308. position: Vector3;
  17309. /**
  17310. * The world direction of the particle in the scene.
  17311. */
  17312. direction: Vector3;
  17313. /**
  17314. * The color of the particle.
  17315. */
  17316. color: Color4;
  17317. /**
  17318. * The color change of the particle per step.
  17319. */
  17320. colorStep: Color4;
  17321. /**
  17322. * Defines how long will the life of the particle be.
  17323. */
  17324. lifeTime: number;
  17325. /**
  17326. * The current age of the particle.
  17327. */
  17328. age: number;
  17329. /**
  17330. * The current size of the particle.
  17331. */
  17332. size: number;
  17333. /**
  17334. * The current scale of the particle.
  17335. */
  17336. scale: Vector2;
  17337. /**
  17338. * The current angle of the particle.
  17339. */
  17340. angle: number;
  17341. /**
  17342. * Defines how fast is the angle changing.
  17343. */
  17344. angularSpeed: number;
  17345. /**
  17346. * Defines the cell index used by the particle to be rendered from a sprite.
  17347. */
  17348. cellIndex: number;
  17349. /**
  17350. * The information required to support color remapping
  17351. */
  17352. remapData: Vector4;
  17353. /** @hidden */ private _randomCellOffset?: number;
  17354. /** @hidden */ private _initialDirection: Nullable<Vector3>;
  17355. /** @hidden */ private _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17356. /** @hidden */ private _initialStartSpriteCellID: number;
  17357. /** @hidden */ private _initialEndSpriteCellID: number;
  17358. /** @hidden */ private _currentColorGradient: Nullable<ColorGradient>;
  17359. /** @hidden */ private _currentColor1: Color4;
  17360. /** @hidden */ private _currentColor2: Color4;
  17361. /** @hidden */ private _currentSizeGradient: Nullable<FactorGradient>;
  17362. /** @hidden */ private _currentSize1: number;
  17363. /** @hidden */ private _currentSize2: number;
  17364. /** @hidden */ private _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17365. /** @hidden */ private _currentAngularSpeed1: number;
  17366. /** @hidden */ private _currentAngularSpeed2: number;
  17367. /** @hidden */ private _currentVelocityGradient: Nullable<FactorGradient>;
  17368. /** @hidden */ private _currentVelocity1: number;
  17369. /** @hidden */ private _currentVelocity2: number;
  17370. /** @hidden */ private _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17371. /** @hidden */ private _currentLimitVelocity1: number;
  17372. /** @hidden */ private _currentLimitVelocity2: number;
  17373. /** @hidden */ private _currentDragGradient: Nullable<FactorGradient>;
  17374. /** @hidden */ private _currentDrag1: number;
  17375. /** @hidden */ private _currentDrag2: number;
  17376. /** @hidden */ private _randomNoiseCoordinates1: Vector3;
  17377. /** @hidden */ private _randomNoiseCoordinates2: Vector3;
  17378. /**
  17379. * Creates a new instance Particle
  17380. * @param particleSystem the particle system the particle belongs to
  17381. */
  17382. constructor(
  17383. /**
  17384. * The particle system the particle belongs to.
  17385. */
  17386. particleSystem: ParticleSystem);
  17387. private updateCellInfoFromSystem;
  17388. /**
  17389. * Defines how the sprite cell index is updated for the particle
  17390. */
  17391. updateCellIndex(): void;
  17392. /** @hidden */ private _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17393. /** @hidden */ private _inheritParticleInfoToSubEmitters(): void;
  17394. /** @hidden */ private _reset(): void;
  17395. /**
  17396. * Copy the properties of particle to another one.
  17397. * @param other the particle to copy the information to.
  17398. */
  17399. copyTo(other: Particle): void;
  17400. }
  17401. }
  17402. declare module BABYLON {
  17403. /**
  17404. * Particle emitter represents a volume emitting particles.
  17405. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17406. */
  17407. export interface IParticleEmitterType {
  17408. /**
  17409. * Called by the particle System when the direction is computed for the created particle.
  17410. * @param worldMatrix is the world matrix of the particle system
  17411. * @param directionToUpdate is the direction vector to update with the result
  17412. * @param particle is the particle we are computed the direction for
  17413. */
  17414. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17415. /**
  17416. * Called by the particle System when the position is computed for the created particle.
  17417. * @param worldMatrix is the world matrix of the particle system
  17418. * @param positionToUpdate is the position vector to update with the result
  17419. * @param particle is the particle we are computed the position for
  17420. */
  17421. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17422. /**
  17423. * Clones the current emitter and returns a copy of it
  17424. * @returns the new emitter
  17425. */
  17426. clone(): IParticleEmitterType;
  17427. /**
  17428. * Called by the GPUParticleSystem to setup the update shader
  17429. * @param effect defines the update shader
  17430. */
  17431. applyToShader(effect: Effect): void;
  17432. /**
  17433. * Returns a string to use to update the GPU particles update shader
  17434. * @returns the effect defines string
  17435. */
  17436. getEffectDefines(): string;
  17437. /**
  17438. * Returns a string representing the class name
  17439. * @returns a string containing the class name
  17440. */
  17441. getClassName(): string;
  17442. /**
  17443. * Serializes the particle system to a JSON object.
  17444. * @returns the JSON object
  17445. */
  17446. serialize(): any;
  17447. /**
  17448. * Parse properties from a JSON object
  17449. * @param serializationObject defines the JSON object
  17450. */
  17451. parse(serializationObject: any): void;
  17452. }
  17453. }
  17454. declare module BABYLON {
  17455. /**
  17456. * Particle emitter emitting particles from the inside of a box.
  17457. * It emits the particles randomly between 2 given directions.
  17458. */
  17459. export class BoxParticleEmitter implements IParticleEmitterType {
  17460. /**
  17461. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17462. */
  17463. direction1: Vector3;
  17464. /**
  17465. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17466. */
  17467. direction2: Vector3;
  17468. /**
  17469. * 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.
  17470. */
  17471. minEmitBox: Vector3;
  17472. /**
  17473. * 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.
  17474. */
  17475. maxEmitBox: Vector3;
  17476. /**
  17477. * Creates a new instance BoxParticleEmitter
  17478. */
  17479. constructor();
  17480. /**
  17481. * Called by the particle System when the direction is computed for the created particle.
  17482. * @param worldMatrix is the world matrix of the particle system
  17483. * @param directionToUpdate is the direction vector to update with the result
  17484. * @param particle is the particle we are computed the direction for
  17485. */
  17486. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17487. /**
  17488. * Called by the particle System when the position is computed for the created particle.
  17489. * @param worldMatrix is the world matrix of the particle system
  17490. * @param positionToUpdate is the position vector to update with the result
  17491. * @param particle is the particle we are computed the position for
  17492. */
  17493. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17494. /**
  17495. * Clones the current emitter and returns a copy of it
  17496. * @returns the new emitter
  17497. */
  17498. clone(): BoxParticleEmitter;
  17499. /**
  17500. * Called by the GPUParticleSystem to setup the update shader
  17501. * @param effect defines the update shader
  17502. */
  17503. applyToShader(effect: Effect): void;
  17504. /**
  17505. * Returns a string to use to update the GPU particles update shader
  17506. * @returns a string containng the defines string
  17507. */
  17508. getEffectDefines(): string;
  17509. /**
  17510. * Returns the string "BoxParticleEmitter"
  17511. * @returns a string containing the class name
  17512. */
  17513. getClassName(): string;
  17514. /**
  17515. * Serializes the particle system to a JSON object.
  17516. * @returns the JSON object
  17517. */
  17518. serialize(): any;
  17519. /**
  17520. * Parse properties from a JSON object
  17521. * @param serializationObject defines the JSON object
  17522. */
  17523. parse(serializationObject: any): void;
  17524. }
  17525. }
  17526. declare module BABYLON {
  17527. /**
  17528. * Particle emitter emitting particles from the inside of a cone.
  17529. * It emits the particles alongside the cone volume from the base to the particle.
  17530. * The emission direction might be randomized.
  17531. */
  17532. export class ConeParticleEmitter implements IParticleEmitterType {
  17533. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17534. directionRandomizer: number;
  17535. private _radius;
  17536. private _angle;
  17537. private _height;
  17538. /**
  17539. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17540. */
  17541. radiusRange: number;
  17542. /**
  17543. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17544. */
  17545. heightRange: number;
  17546. /**
  17547. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17548. */
  17549. emitFromSpawnPointOnly: boolean;
  17550. /**
  17551. * Gets or sets the radius of the emission cone
  17552. */
  17553. radius: number;
  17554. /**
  17555. * Gets or sets the angle of the emission cone
  17556. */
  17557. angle: number;
  17558. private _buildHeight;
  17559. /**
  17560. * Creates a new instance ConeParticleEmitter
  17561. * @param radius the radius of the emission cone (1 by default)
  17562. * @param angle the cone base angle (PI by default)
  17563. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17564. */
  17565. constructor(radius?: number, angle?: number,
  17566. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17567. directionRandomizer?: number);
  17568. /**
  17569. * Called by the particle System when the direction is computed for the created particle.
  17570. * @param worldMatrix is the world matrix of the particle system
  17571. * @param directionToUpdate is the direction vector to update with the result
  17572. * @param particle is the particle we are computed the direction for
  17573. */
  17574. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17575. /**
  17576. * Called by the particle System when the position is computed for the created particle.
  17577. * @param worldMatrix is the world matrix of the particle system
  17578. * @param positionToUpdate is the position vector to update with the result
  17579. * @param particle is the particle we are computed the position for
  17580. */
  17581. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17582. /**
  17583. * Clones the current emitter and returns a copy of it
  17584. * @returns the new emitter
  17585. */
  17586. clone(): ConeParticleEmitter;
  17587. /**
  17588. * Called by the GPUParticleSystem to setup the update shader
  17589. * @param effect defines the update shader
  17590. */
  17591. applyToShader(effect: Effect): void;
  17592. /**
  17593. * Returns a string to use to update the GPU particles update shader
  17594. * @returns a string containng the defines string
  17595. */
  17596. getEffectDefines(): string;
  17597. /**
  17598. * Returns the string "ConeParticleEmitter"
  17599. * @returns a string containing the class name
  17600. */
  17601. getClassName(): string;
  17602. /**
  17603. * Serializes the particle system to a JSON object.
  17604. * @returns the JSON object
  17605. */
  17606. serialize(): any;
  17607. /**
  17608. * Parse properties from a JSON object
  17609. * @param serializationObject defines the JSON object
  17610. */
  17611. parse(serializationObject: any): void;
  17612. }
  17613. }
  17614. declare module BABYLON {
  17615. /**
  17616. * Particle emitter emitting particles from the inside of a cylinder.
  17617. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17618. */
  17619. export class CylinderParticleEmitter implements IParticleEmitterType {
  17620. /**
  17621. * The radius of the emission cylinder.
  17622. */
  17623. radius: number;
  17624. /**
  17625. * The height of the emission cylinder.
  17626. */
  17627. height: number;
  17628. /**
  17629. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17630. */
  17631. radiusRange: number;
  17632. /**
  17633. * How much to randomize the particle direction [0-1].
  17634. */
  17635. directionRandomizer: number;
  17636. /**
  17637. * Creates a new instance CylinderParticleEmitter
  17638. * @param radius the radius of the emission cylinder (1 by default)
  17639. * @param height the height of the emission cylinder (1 by default)
  17640. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17641. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17642. */
  17643. constructor(
  17644. /**
  17645. * The radius of the emission cylinder.
  17646. */
  17647. radius?: number,
  17648. /**
  17649. * The height of the emission cylinder.
  17650. */
  17651. height?: number,
  17652. /**
  17653. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17654. */
  17655. radiusRange?: number,
  17656. /**
  17657. * How much to randomize the particle direction [0-1].
  17658. */
  17659. directionRandomizer?: number);
  17660. /**
  17661. * Called by the particle System when the direction is computed for the created particle.
  17662. * @param worldMatrix is the world matrix of the particle system
  17663. * @param directionToUpdate is the direction vector to update with the result
  17664. * @param particle is the particle we are computed the direction for
  17665. */
  17666. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17667. /**
  17668. * Called by the particle System when the position is computed for the created particle.
  17669. * @param worldMatrix is the world matrix of the particle system
  17670. * @param positionToUpdate is the position vector to update with the result
  17671. * @param particle is the particle we are computed the position for
  17672. */
  17673. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17674. /**
  17675. * Clones the current emitter and returns a copy of it
  17676. * @returns the new emitter
  17677. */
  17678. clone(): CylinderParticleEmitter;
  17679. /**
  17680. * Called by the GPUParticleSystem to setup the update shader
  17681. * @param effect defines the update shader
  17682. */
  17683. applyToShader(effect: Effect): void;
  17684. /**
  17685. * Returns a string to use to update the GPU particles update shader
  17686. * @returns a string containng the defines string
  17687. */
  17688. getEffectDefines(): string;
  17689. /**
  17690. * Returns the string "CylinderParticleEmitter"
  17691. * @returns a string containing the class name
  17692. */
  17693. getClassName(): string;
  17694. /**
  17695. * Serializes the particle system to a JSON object.
  17696. * @returns the JSON object
  17697. */
  17698. serialize(): any;
  17699. /**
  17700. * Parse properties from a JSON object
  17701. * @param serializationObject defines the JSON object
  17702. */
  17703. parse(serializationObject: any): void;
  17704. }
  17705. /**
  17706. * Particle emitter emitting particles from the inside of a cylinder.
  17707. * It emits the particles randomly between two vectors.
  17708. */
  17709. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17710. /**
  17711. * The min limit of the emission direction.
  17712. */
  17713. direction1: Vector3;
  17714. /**
  17715. * The max limit of the emission direction.
  17716. */
  17717. direction2: Vector3;
  17718. /**
  17719. * Creates a new instance CylinderDirectedParticleEmitter
  17720. * @param radius the radius of the emission cylinder (1 by default)
  17721. * @param height the height of the emission cylinder (1 by default)
  17722. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17723. * @param direction1 the min limit of the emission direction (up vector by default)
  17724. * @param direction2 the max limit of the emission direction (up vector by default)
  17725. */
  17726. constructor(radius?: number, height?: number, radiusRange?: number,
  17727. /**
  17728. * The min limit of the emission direction.
  17729. */
  17730. direction1?: Vector3,
  17731. /**
  17732. * The max limit of the emission direction.
  17733. */
  17734. direction2?: Vector3);
  17735. /**
  17736. * Called by the particle System when the direction is computed for the created particle.
  17737. * @param worldMatrix is the world matrix of the particle system
  17738. * @param directionToUpdate is the direction vector to update with the result
  17739. * @param particle is the particle we are computed the direction for
  17740. */
  17741. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17742. /**
  17743. * Clones the current emitter and returns a copy of it
  17744. * @returns the new emitter
  17745. */
  17746. clone(): CylinderDirectedParticleEmitter;
  17747. /**
  17748. * Called by the GPUParticleSystem to setup the update shader
  17749. * @param effect defines the update shader
  17750. */
  17751. applyToShader(effect: Effect): void;
  17752. /**
  17753. * Returns a string to use to update the GPU particles update shader
  17754. * @returns a string containng the defines string
  17755. */
  17756. getEffectDefines(): string;
  17757. /**
  17758. * Returns the string "CylinderDirectedParticleEmitter"
  17759. * @returns a string containing the class name
  17760. */
  17761. getClassName(): string;
  17762. /**
  17763. * Serializes the particle system to a JSON object.
  17764. * @returns the JSON object
  17765. */
  17766. serialize(): any;
  17767. /**
  17768. * Parse properties from a JSON object
  17769. * @param serializationObject defines the JSON object
  17770. */
  17771. parse(serializationObject: any): void;
  17772. }
  17773. }
  17774. declare module BABYLON {
  17775. /**
  17776. * Particle emitter emitting particles from the inside of a hemisphere.
  17777. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17778. */
  17779. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17780. /**
  17781. * The radius of the emission hemisphere.
  17782. */
  17783. radius: number;
  17784. /**
  17785. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17786. */
  17787. radiusRange: number;
  17788. /**
  17789. * How much to randomize the particle direction [0-1].
  17790. */
  17791. directionRandomizer: number;
  17792. /**
  17793. * Creates a new instance HemisphericParticleEmitter
  17794. * @param radius the radius of the emission hemisphere (1 by default)
  17795. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17796. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17797. */
  17798. constructor(
  17799. /**
  17800. * The radius of the emission hemisphere.
  17801. */
  17802. radius?: number,
  17803. /**
  17804. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17805. */
  17806. radiusRange?: number,
  17807. /**
  17808. * How much to randomize the particle direction [0-1].
  17809. */
  17810. directionRandomizer?: number);
  17811. /**
  17812. * Called by the particle System when the direction is computed for the created particle.
  17813. * @param worldMatrix is the world matrix of the particle system
  17814. * @param directionToUpdate is the direction vector to update with the result
  17815. * @param particle is the particle we are computed the direction for
  17816. */
  17817. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17818. /**
  17819. * Called by the particle System when the position is computed for the created particle.
  17820. * @param worldMatrix is the world matrix of the particle system
  17821. * @param positionToUpdate is the position vector to update with the result
  17822. * @param particle is the particle we are computed the position for
  17823. */
  17824. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17825. /**
  17826. * Clones the current emitter and returns a copy of it
  17827. * @returns the new emitter
  17828. */
  17829. clone(): HemisphericParticleEmitter;
  17830. /**
  17831. * Called by the GPUParticleSystem to setup the update shader
  17832. * @param effect defines the update shader
  17833. */
  17834. applyToShader(effect: Effect): void;
  17835. /**
  17836. * Returns a string to use to update the GPU particles update shader
  17837. * @returns a string containng the defines string
  17838. */
  17839. getEffectDefines(): string;
  17840. /**
  17841. * Returns the string "HemisphericParticleEmitter"
  17842. * @returns a string containing the class name
  17843. */
  17844. getClassName(): string;
  17845. /**
  17846. * Serializes the particle system to a JSON object.
  17847. * @returns the JSON object
  17848. */
  17849. serialize(): any;
  17850. /**
  17851. * Parse properties from a JSON object
  17852. * @param serializationObject defines the JSON object
  17853. */
  17854. parse(serializationObject: any): void;
  17855. }
  17856. }
  17857. declare module BABYLON {
  17858. /**
  17859. * Particle emitter emitting particles from a point.
  17860. * It emits the particles randomly between 2 given directions.
  17861. */
  17862. export class PointParticleEmitter implements IParticleEmitterType {
  17863. /**
  17864. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17865. */
  17866. direction1: Vector3;
  17867. /**
  17868. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17869. */
  17870. direction2: Vector3;
  17871. /**
  17872. * Creates a new instance PointParticleEmitter
  17873. */
  17874. constructor();
  17875. /**
  17876. * Called by the particle System when the direction is computed for the created particle.
  17877. * @param worldMatrix is the world matrix of the particle system
  17878. * @param directionToUpdate is the direction vector to update with the result
  17879. * @param particle is the particle we are computed the direction for
  17880. */
  17881. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17882. /**
  17883. * Called by the particle System when the position is computed for the created particle.
  17884. * @param worldMatrix is the world matrix of the particle system
  17885. * @param positionToUpdate is the position vector to update with the result
  17886. * @param particle is the particle we are computed the position for
  17887. */
  17888. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17889. /**
  17890. * Clones the current emitter and returns a copy of it
  17891. * @returns the new emitter
  17892. */
  17893. clone(): PointParticleEmitter;
  17894. /**
  17895. * Called by the GPUParticleSystem to setup the update shader
  17896. * @param effect defines the update shader
  17897. */
  17898. applyToShader(effect: Effect): void;
  17899. /**
  17900. * Returns a string to use to update the GPU particles update shader
  17901. * @returns a string containng the defines string
  17902. */
  17903. getEffectDefines(): string;
  17904. /**
  17905. * Returns the string "PointParticleEmitter"
  17906. * @returns a string containing the class name
  17907. */
  17908. getClassName(): string;
  17909. /**
  17910. * Serializes the particle system to a JSON object.
  17911. * @returns the JSON object
  17912. */
  17913. serialize(): any;
  17914. /**
  17915. * Parse properties from a JSON object
  17916. * @param serializationObject defines the JSON object
  17917. */
  17918. parse(serializationObject: any): void;
  17919. }
  17920. }
  17921. declare module BABYLON {
  17922. /**
  17923. * Particle emitter emitting particles from the inside of a sphere.
  17924. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17925. */
  17926. export class SphereParticleEmitter implements IParticleEmitterType {
  17927. /**
  17928. * The radius of the emission sphere.
  17929. */
  17930. radius: number;
  17931. /**
  17932. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17933. */
  17934. radiusRange: number;
  17935. /**
  17936. * How much to randomize the particle direction [0-1].
  17937. */
  17938. directionRandomizer: number;
  17939. /**
  17940. * Creates a new instance SphereParticleEmitter
  17941. * @param radius the radius of the emission sphere (1 by default)
  17942. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17943. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17944. */
  17945. constructor(
  17946. /**
  17947. * The radius of the emission sphere.
  17948. */
  17949. radius?: number,
  17950. /**
  17951. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17952. */
  17953. radiusRange?: number,
  17954. /**
  17955. * How much to randomize the particle direction [0-1].
  17956. */
  17957. directionRandomizer?: number);
  17958. /**
  17959. * Called by the particle System when the direction is computed for the created particle.
  17960. * @param worldMatrix is the world matrix of the particle system
  17961. * @param directionToUpdate is the direction vector to update with the result
  17962. * @param particle is the particle we are computed the direction for
  17963. */
  17964. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17965. /**
  17966. * Called by the particle System when the position is computed for the created particle.
  17967. * @param worldMatrix is the world matrix of the particle system
  17968. * @param positionToUpdate is the position vector to update with the result
  17969. * @param particle is the particle we are computed the position for
  17970. */
  17971. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17972. /**
  17973. * Clones the current emitter and returns a copy of it
  17974. * @returns the new emitter
  17975. */
  17976. clone(): SphereParticleEmitter;
  17977. /**
  17978. * Called by the GPUParticleSystem to setup the update shader
  17979. * @param effect defines the update shader
  17980. */
  17981. applyToShader(effect: Effect): void;
  17982. /**
  17983. * Returns a string to use to update the GPU particles update shader
  17984. * @returns a string containng the defines string
  17985. */
  17986. getEffectDefines(): string;
  17987. /**
  17988. * Returns the string "SphereParticleEmitter"
  17989. * @returns a string containing the class name
  17990. */
  17991. getClassName(): string;
  17992. /**
  17993. * Serializes the particle system to a JSON object.
  17994. * @returns the JSON object
  17995. */
  17996. serialize(): any;
  17997. /**
  17998. * Parse properties from a JSON object
  17999. * @param serializationObject defines the JSON object
  18000. */
  18001. parse(serializationObject: any): void;
  18002. }
  18003. /**
  18004. * Particle emitter emitting particles from the inside of a sphere.
  18005. * It emits the particles randomly between two vectors.
  18006. */
  18007. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18008. /**
  18009. * The min limit of the emission direction.
  18010. */
  18011. direction1: Vector3;
  18012. /**
  18013. * The max limit of the emission direction.
  18014. */
  18015. direction2: Vector3;
  18016. /**
  18017. * Creates a new instance SphereDirectedParticleEmitter
  18018. * @param radius the radius of the emission sphere (1 by default)
  18019. * @param direction1 the min limit of the emission direction (up vector by default)
  18020. * @param direction2 the max limit of the emission direction (up vector by default)
  18021. */
  18022. constructor(radius?: number,
  18023. /**
  18024. * The min limit of the emission direction.
  18025. */
  18026. direction1?: Vector3,
  18027. /**
  18028. * The max limit of the emission direction.
  18029. */
  18030. direction2?: Vector3);
  18031. /**
  18032. * Called by the particle System when the direction is computed for the created particle.
  18033. * @param worldMatrix is the world matrix of the particle system
  18034. * @param directionToUpdate is the direction vector to update with the result
  18035. * @param particle is the particle we are computed the direction for
  18036. */
  18037. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18038. /**
  18039. * Clones the current emitter and returns a copy of it
  18040. * @returns the new emitter
  18041. */
  18042. clone(): SphereDirectedParticleEmitter;
  18043. /**
  18044. * Called by the GPUParticleSystem to setup the update shader
  18045. * @param effect defines the update shader
  18046. */
  18047. applyToShader(effect: Effect): void;
  18048. /**
  18049. * Returns a string to use to update the GPU particles update shader
  18050. * @returns a string containng the defines string
  18051. */
  18052. getEffectDefines(): string;
  18053. /**
  18054. * Returns the string "SphereDirectedParticleEmitter"
  18055. * @returns a string containing the class name
  18056. */
  18057. getClassName(): string;
  18058. /**
  18059. * Serializes the particle system to a JSON object.
  18060. * @returns the JSON object
  18061. */
  18062. serialize(): any;
  18063. /**
  18064. * Parse properties from a JSON object
  18065. * @param serializationObject defines the JSON object
  18066. */
  18067. parse(serializationObject: any): void;
  18068. }
  18069. }
  18070. declare module BABYLON {
  18071. /**
  18072. * Interface representing a particle system in Babylon.js.
  18073. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18074. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18075. */
  18076. export interface IParticleSystem {
  18077. /**
  18078. * List of animations used by the particle system.
  18079. */
  18080. animations: Animation[];
  18081. /**
  18082. * The id of the Particle system.
  18083. */
  18084. id: string;
  18085. /**
  18086. * The name of the Particle system.
  18087. */
  18088. name: string;
  18089. /**
  18090. * The emitter represents the Mesh or position we are attaching the particle system to.
  18091. */
  18092. emitter: Nullable<AbstractMesh | Vector3>;
  18093. /**
  18094. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18095. */
  18096. isBillboardBased: boolean;
  18097. /**
  18098. * The rendering group used by the Particle system to chose when to render.
  18099. */
  18100. renderingGroupId: number;
  18101. /**
  18102. * The layer mask we are rendering the particles through.
  18103. */
  18104. layerMask: number;
  18105. /**
  18106. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18107. */
  18108. updateSpeed: number;
  18109. /**
  18110. * The amount of time the particle system is running (depends of the overall update speed).
  18111. */
  18112. targetStopDuration: number;
  18113. /**
  18114. * The texture used to render each particle. (this can be a spritesheet)
  18115. */
  18116. particleTexture: Nullable<Texture>;
  18117. /**
  18118. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18119. */
  18120. blendMode: number;
  18121. /**
  18122. * Minimum life time of emitting particles.
  18123. */
  18124. minLifeTime: number;
  18125. /**
  18126. * Maximum life time of emitting particles.
  18127. */
  18128. maxLifeTime: number;
  18129. /**
  18130. * Minimum Size of emitting particles.
  18131. */
  18132. minSize: number;
  18133. /**
  18134. * Maximum Size of emitting particles.
  18135. */
  18136. maxSize: number;
  18137. /**
  18138. * Minimum scale of emitting particles on X axis.
  18139. */
  18140. minScaleX: number;
  18141. /**
  18142. * Maximum scale of emitting particles on X axis.
  18143. */
  18144. maxScaleX: number;
  18145. /**
  18146. * Minimum scale of emitting particles on Y axis.
  18147. */
  18148. minScaleY: number;
  18149. /**
  18150. * Maximum scale of emitting particles on Y axis.
  18151. */
  18152. maxScaleY: number;
  18153. /**
  18154. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18155. */
  18156. color1: Color4;
  18157. /**
  18158. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18159. */
  18160. color2: Color4;
  18161. /**
  18162. * Color the particle will have at the end of its lifetime.
  18163. */
  18164. colorDead: Color4;
  18165. /**
  18166. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18167. */
  18168. emitRate: number;
  18169. /**
  18170. * You can use gravity if you want to give an orientation to your particles.
  18171. */
  18172. gravity: Vector3;
  18173. /**
  18174. * Minimum power of emitting particles.
  18175. */
  18176. minEmitPower: number;
  18177. /**
  18178. * Maximum power of emitting particles.
  18179. */
  18180. maxEmitPower: number;
  18181. /**
  18182. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18183. */
  18184. minAngularSpeed: number;
  18185. /**
  18186. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18187. */
  18188. maxAngularSpeed: number;
  18189. /**
  18190. * Gets or sets the minimal initial rotation in radians.
  18191. */
  18192. minInitialRotation: number;
  18193. /**
  18194. * Gets or sets the maximal initial rotation in radians.
  18195. */
  18196. maxInitialRotation: number;
  18197. /**
  18198. * The particle emitter type defines the emitter used by the particle system.
  18199. * It can be for example box, sphere, or cone...
  18200. */
  18201. particleEmitterType: Nullable<IParticleEmitterType>;
  18202. /**
  18203. * Defines the delay in milliseconds before starting the system (0 by default)
  18204. */
  18205. startDelay: number;
  18206. /**
  18207. * 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
  18208. */
  18209. preWarmCycles: number;
  18210. /**
  18211. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18212. */
  18213. preWarmStepOffset: number;
  18214. /**
  18215. * 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)
  18216. */
  18217. spriteCellChangeSpeed: number;
  18218. /**
  18219. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18220. */
  18221. startSpriteCellID: number;
  18222. /**
  18223. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18224. */
  18225. endSpriteCellID: number;
  18226. /**
  18227. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18228. */
  18229. spriteCellWidth: number;
  18230. /**
  18231. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18232. */
  18233. spriteCellHeight: number;
  18234. /**
  18235. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18236. */
  18237. spriteRandomStartCell: boolean;
  18238. /**
  18239. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18240. */
  18241. isAnimationSheetEnabled: boolean;
  18242. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18243. translationPivot: Vector2;
  18244. /**
  18245. * Gets or sets a texture used to add random noise to particle positions
  18246. */
  18247. noiseTexture: Nullable<BaseTexture>;
  18248. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18249. noiseStrength: Vector3;
  18250. /**
  18251. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18252. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18253. */
  18254. billboardMode: number;
  18255. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18256. limitVelocityDamping: number;
  18257. /**
  18258. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18259. */
  18260. beginAnimationOnStart: boolean;
  18261. /**
  18262. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18263. */
  18264. beginAnimationFrom: number;
  18265. /**
  18266. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18267. */
  18268. beginAnimationTo: number;
  18269. /**
  18270. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18271. */
  18272. beginAnimationLoop: boolean;
  18273. /**
  18274. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18275. */
  18276. disposeOnStop: boolean;
  18277. /**
  18278. * Gets the maximum number of particles active at the same time.
  18279. * @returns The max number of active particles.
  18280. */
  18281. getCapacity(): number;
  18282. /**
  18283. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18284. * @returns True if it has been started, otherwise false.
  18285. */
  18286. isStarted(): boolean;
  18287. /**
  18288. * Animates the particle system for this frame.
  18289. */
  18290. animate(): void;
  18291. /**
  18292. * Renders the particle system in its current state.
  18293. * @returns the current number of particles
  18294. */
  18295. render(): number;
  18296. /**
  18297. * Dispose the particle system and frees its associated resources.
  18298. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18299. */
  18300. dispose(disposeTexture?: boolean): void;
  18301. /**
  18302. * Clones the particle system.
  18303. * @param name The name of the cloned object
  18304. * @param newEmitter The new emitter to use
  18305. * @returns the cloned particle system
  18306. */
  18307. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18308. /**
  18309. * Serializes the particle system to a JSON object.
  18310. * @returns the JSON object
  18311. */
  18312. serialize(): any;
  18313. /**
  18314. * Rebuild the particle system
  18315. */
  18316. rebuild(): void;
  18317. /**
  18318. * Starts the particle system and begins to emit
  18319. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18320. */
  18321. start(delay?: number): void;
  18322. /**
  18323. * Stops the particle system.
  18324. */
  18325. stop(): void;
  18326. /**
  18327. * Remove all active particles
  18328. */
  18329. reset(): void;
  18330. /**
  18331. * Is this system ready to be used/rendered
  18332. * @return true if the system is ready
  18333. */
  18334. isReady(): boolean;
  18335. /**
  18336. * Adds a new color gradient
  18337. * @param gradient defines the gradient to use (between 0 and 1)
  18338. * @param color1 defines the color to affect to the specified gradient
  18339. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18340. * @returns the current particle system
  18341. */
  18342. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18343. /**
  18344. * Remove a specific color gradient
  18345. * @param gradient defines the gradient to remove
  18346. * @returns the current particle system
  18347. */
  18348. removeColorGradient(gradient: number): IParticleSystem;
  18349. /**
  18350. * Adds a new size gradient
  18351. * @param gradient defines the gradient to use (between 0 and 1)
  18352. * @param factor defines the size factor to affect to the specified gradient
  18353. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18354. * @returns the current particle system
  18355. */
  18356. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18357. /**
  18358. * Remove a specific size gradient
  18359. * @param gradient defines the gradient to remove
  18360. * @returns the current particle system
  18361. */
  18362. removeSizeGradient(gradient: number): IParticleSystem;
  18363. /**
  18364. * Gets the current list of color gradients.
  18365. * You must use addColorGradient and removeColorGradient to udpate this list
  18366. * @returns the list of color gradients
  18367. */
  18368. getColorGradients(): Nullable<Array<ColorGradient>>;
  18369. /**
  18370. * Gets the current list of size gradients.
  18371. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18372. * @returns the list of size gradients
  18373. */
  18374. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18375. /**
  18376. * Gets the current list of angular speed gradients.
  18377. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18378. * @returns the list of angular speed gradients
  18379. */
  18380. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18381. /**
  18382. * Adds a new angular speed gradient
  18383. * @param gradient defines the gradient to use (between 0 and 1)
  18384. * @param factor defines the angular speed 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. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18389. /**
  18390. * Remove a specific angular speed gradient
  18391. * @param gradient defines the gradient to remove
  18392. * @returns the current particle system
  18393. */
  18394. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18395. /**
  18396. * Gets the current list of velocity gradients.
  18397. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18398. * @returns the list of velocity gradients
  18399. */
  18400. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18401. /**
  18402. * Adds a new velocity gradient
  18403. * @param gradient defines the gradient to use (between 0 and 1)
  18404. * @param factor defines the velocity 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. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18409. /**
  18410. * Remove a specific velocity gradient
  18411. * @param gradient defines the gradient to remove
  18412. * @returns the current particle system
  18413. */
  18414. removeVelocityGradient(gradient: number): IParticleSystem;
  18415. /**
  18416. * Gets the current list of limit velocity gradients.
  18417. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18418. * @returns the list of limit velocity gradients
  18419. */
  18420. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18421. /**
  18422. * Adds a new limit velocity gradient
  18423. * @param gradient defines the gradient to use (between 0 and 1)
  18424. * @param factor defines the limit velocity to affect to the specified gradient
  18425. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18426. * @returns the current particle system
  18427. */
  18428. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18429. /**
  18430. * Remove a specific limit velocity gradient
  18431. * @param gradient defines the gradient to remove
  18432. * @returns the current particle system
  18433. */
  18434. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18435. /**
  18436. * Adds a new drag gradient
  18437. * @param gradient defines the gradient to use (between 0 and 1)
  18438. * @param factor defines the drag to affect to the specified gradient
  18439. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18440. * @returns the current particle system
  18441. */
  18442. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18443. /**
  18444. * Remove a specific drag gradient
  18445. * @param gradient defines the gradient to remove
  18446. * @returns the current particle system
  18447. */
  18448. removeDragGradient(gradient: number): IParticleSystem;
  18449. /**
  18450. * Gets the current list of drag gradients.
  18451. * You must use addDragGradient and removeDragGradient to udpate this list
  18452. * @returns the list of drag gradients
  18453. */
  18454. getDragGradients(): Nullable<Array<FactorGradient>>;
  18455. /**
  18456. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18457. * @param gradient defines the gradient to use (between 0 and 1)
  18458. * @param factor defines the emit rate to affect to the specified gradient
  18459. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18460. * @returns the current particle system
  18461. */
  18462. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18463. /**
  18464. * Remove a specific emit rate gradient
  18465. * @param gradient defines the gradient to remove
  18466. * @returns the current particle system
  18467. */
  18468. removeEmitRateGradient(gradient: number): IParticleSystem;
  18469. /**
  18470. * Gets the current list of emit rate gradients.
  18471. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18472. * @returns the list of emit rate gradients
  18473. */
  18474. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18475. /**
  18476. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18477. * @param gradient defines the gradient to use (between 0 and 1)
  18478. * @param factor defines the start size to affect to the specified gradient
  18479. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18480. * @returns the current particle system
  18481. */
  18482. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18483. /**
  18484. * Remove a specific start size gradient
  18485. * @param gradient defines the gradient to remove
  18486. * @returns the current particle system
  18487. */
  18488. removeStartSizeGradient(gradient: number): IParticleSystem;
  18489. /**
  18490. * Gets the current list of start size gradients.
  18491. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18492. * @returns the list of start size gradients
  18493. */
  18494. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18495. /**
  18496. * Adds a new life time gradient
  18497. * @param gradient defines the gradient to use (between 0 and 1)
  18498. * @param factor defines the life time factor to affect to the specified gradient
  18499. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18500. * @returns the current particle system
  18501. */
  18502. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18503. /**
  18504. * Remove a specific life time gradient
  18505. * @param gradient defines the gradient to remove
  18506. * @returns the current particle system
  18507. */
  18508. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18509. /**
  18510. * Gets the current list of life time gradients.
  18511. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18512. * @returns the list of life time gradients
  18513. */
  18514. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18515. /**
  18516. * Gets the current list of color gradients.
  18517. * You must use addColorGradient and removeColorGradient to udpate this list
  18518. * @returns the list of color gradients
  18519. */
  18520. getColorGradients(): Nullable<Array<ColorGradient>>;
  18521. /**
  18522. * Adds a new ramp gradient used to remap particle colors
  18523. * @param gradient defines the gradient to use (between 0 and 1)
  18524. * @param color defines the color to affect to the specified gradient
  18525. * @returns the current particle system
  18526. */
  18527. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18528. /**
  18529. * Gets the current list of ramp gradients.
  18530. * You must use addRampGradient and removeRampGradient to udpate this list
  18531. * @returns the list of ramp gradients
  18532. */
  18533. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18534. /** Gets or sets a boolean indicating that ramp gradients must be used
  18535. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18536. */
  18537. useRampGradients: boolean;
  18538. /**
  18539. * Adds a new color remap gradient
  18540. * @param gradient defines the gradient to use (between 0 and 1)
  18541. * @param min defines the color remap minimal range
  18542. * @param max defines the color remap maximal range
  18543. * @returns the current particle system
  18544. */
  18545. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18546. /**
  18547. * Gets the current list of color remap gradients.
  18548. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18549. * @returns the list of color remap gradients
  18550. */
  18551. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18552. /**
  18553. * Adds a new alpha remap gradient
  18554. * @param gradient defines the gradient to use (between 0 and 1)
  18555. * @param min defines the alpha remap minimal range
  18556. * @param max defines the alpha remap maximal range
  18557. * @returns the current particle system
  18558. */
  18559. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18560. /**
  18561. * Gets the current list of alpha remap gradients.
  18562. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18563. * @returns the list of alpha remap gradients
  18564. */
  18565. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18566. /**
  18567. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18568. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18569. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18570. * @returns the emitter
  18571. */
  18572. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18573. /**
  18574. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18575. * @param radius The radius of the hemisphere to emit from
  18576. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18577. * @returns the emitter
  18578. */
  18579. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18580. /**
  18581. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18582. * @param radius The radius of the sphere to emit from
  18583. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18584. * @returns the emitter
  18585. */
  18586. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18587. /**
  18588. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18589. * @param radius The radius of the sphere to emit from
  18590. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18591. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18592. * @returns the emitter
  18593. */
  18594. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18595. /**
  18596. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18597. * @param radius The radius of the emission cylinder
  18598. * @param height The height of the emission cylinder
  18599. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18600. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18601. * @returns the emitter
  18602. */
  18603. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18604. /**
  18605. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18606. * @param radius The radius of the cylinder to emit from
  18607. * @param height The height of the emission cylinder
  18608. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18609. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18610. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18611. * @returns the emitter
  18612. */
  18613. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18614. /**
  18615. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18616. * @param radius The radius of the cone to emit from
  18617. * @param angle The base angle of the cone
  18618. * @returns the emitter
  18619. */
  18620. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18621. /**
  18622. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18623. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18624. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18625. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18626. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18627. * @returns the emitter
  18628. */
  18629. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18630. /**
  18631. * Get hosting scene
  18632. * @returns the scene
  18633. */
  18634. getScene(): Scene;
  18635. }
  18636. }
  18637. declare module BABYLON {
  18638. /**
  18639. * Creates an instance based on a source mesh.
  18640. */
  18641. export class InstancedMesh extends AbstractMesh {
  18642. private _sourceMesh;
  18643. private _currentLOD;
  18644. /** @hidden */ private _indexInSourceMeshInstanceArray: number;
  18645. constructor(name: string, source: Mesh);
  18646. /**
  18647. * Returns the string "InstancedMesh".
  18648. */
  18649. getClassName(): string;
  18650. /** Gets the list of lights affecting that mesh */
  18651. readonly lightSources: Light[]; private _resyncLightSources(): void; private _resyncLighSource(light: Light): void; private _removeLightSource(light: Light, dispose: boolean): void;
  18652. /**
  18653. * If the source mesh receives shadows
  18654. */
  18655. readonly receiveShadows: boolean;
  18656. /**
  18657. * The material of the source mesh
  18658. */
  18659. readonly material: Nullable<Material>;
  18660. /**
  18661. * Visibility of the source mesh
  18662. */
  18663. readonly visibility: number;
  18664. /**
  18665. * Skeleton of the source mesh
  18666. */
  18667. readonly skeleton: Nullable<Skeleton>;
  18668. /**
  18669. * Rendering ground id of the source mesh
  18670. */
  18671. renderingGroupId: number;
  18672. /**
  18673. * Returns the total number of vertices (integer).
  18674. */
  18675. getTotalVertices(): number;
  18676. /**
  18677. * Returns a positive integer : the total number of indices in this mesh geometry.
  18678. * @returns the numner of indices or zero if the mesh has no geometry.
  18679. */
  18680. getTotalIndices(): number;
  18681. /**
  18682. * The source mesh of the instance
  18683. */
  18684. readonly sourceMesh: Mesh;
  18685. /**
  18686. * Is this node ready to be used/rendered
  18687. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18688. * @return {boolean} is it ready
  18689. */
  18690. isReady(completeCheck?: boolean): boolean;
  18691. /**
  18692. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18693. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18694. * @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.
  18695. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18696. */
  18697. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18698. /**
  18699. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18700. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18701. * The `data` are either a numeric array either a Float32Array.
  18702. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18703. * 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).
  18704. * Note that a new underlying VertexBuffer object is created each call.
  18705. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18706. *
  18707. * Possible `kind` values :
  18708. * - VertexBuffer.PositionKind
  18709. * - VertexBuffer.UVKind
  18710. * - VertexBuffer.UV2Kind
  18711. * - VertexBuffer.UV3Kind
  18712. * - VertexBuffer.UV4Kind
  18713. * - VertexBuffer.UV5Kind
  18714. * - VertexBuffer.UV6Kind
  18715. * - VertexBuffer.ColorKind
  18716. * - VertexBuffer.MatricesIndicesKind
  18717. * - VertexBuffer.MatricesIndicesExtraKind
  18718. * - VertexBuffer.MatricesWeightsKind
  18719. * - VertexBuffer.MatricesWeightsExtraKind
  18720. *
  18721. * Returns the Mesh.
  18722. */
  18723. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18724. /**
  18725. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18726. * If the mesh has no geometry, it is simply returned as it is.
  18727. * The `data` are either a numeric array either a Float32Array.
  18728. * No new underlying VertexBuffer object is created.
  18729. * 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.
  18730. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18731. *
  18732. * Possible `kind` values :
  18733. * - VertexBuffer.PositionKind
  18734. * - VertexBuffer.UVKind
  18735. * - VertexBuffer.UV2Kind
  18736. * - VertexBuffer.UV3Kind
  18737. * - VertexBuffer.UV4Kind
  18738. * - VertexBuffer.UV5Kind
  18739. * - VertexBuffer.UV6Kind
  18740. * - VertexBuffer.ColorKind
  18741. * - VertexBuffer.MatricesIndicesKind
  18742. * - VertexBuffer.MatricesIndicesExtraKind
  18743. * - VertexBuffer.MatricesWeightsKind
  18744. * - VertexBuffer.MatricesWeightsExtraKind
  18745. *
  18746. * Returns the Mesh.
  18747. */
  18748. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18749. /**
  18750. * Sets the mesh indices.
  18751. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18752. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18753. * This method creates a new index buffer each call.
  18754. * Returns the Mesh.
  18755. */
  18756. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18757. /**
  18758. * Boolean : True if the mesh owns the requested kind of data.
  18759. */
  18760. isVerticesDataPresent(kind: string): boolean;
  18761. /**
  18762. * Returns an array of indices (IndicesArray).
  18763. */
  18764. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  18765. /**
  18766. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18767. * This means the mesh underlying bounding box and sphere are recomputed.
  18768. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18769. * @returns the current mesh
  18770. */
  18771. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18772. /** @hidden */ private _preActivate(): InstancedMesh;
  18773. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  18774. /** @hidden */ private _postActivate(): void;
  18775. getWorldMatrix(): Matrix;
  18776. readonly isAnInstance: boolean;
  18777. /**
  18778. * Returns the current associated LOD AbstractMesh.
  18779. */
  18780. getLOD(camera: Camera): AbstractMesh;
  18781. /** @hidden */ private _syncSubMeshes(): InstancedMesh;
  18782. /** @hidden */ private _generatePointsArray(): boolean;
  18783. /**
  18784. * Creates a new InstancedMesh from the current mesh.
  18785. * - name (string) : the cloned mesh name
  18786. * - newParent (optional Node) : the optional Node to parent the clone to.
  18787. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18788. *
  18789. * Returns the clone.
  18790. */
  18791. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18792. /**
  18793. * Disposes the InstancedMesh.
  18794. * Returns nothing.
  18795. */
  18796. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18797. }
  18798. }
  18799. declare module BABYLON {
  18800. /**
  18801. * Defines the options associated with the creation of a shader material.
  18802. */
  18803. export interface IShaderMaterialOptions {
  18804. /**
  18805. * Does the material work in alpha blend mode
  18806. */
  18807. needAlphaBlending: boolean;
  18808. /**
  18809. * Does the material work in alpha test mode
  18810. */
  18811. needAlphaTesting: boolean;
  18812. /**
  18813. * The list of attribute names used in the shader
  18814. */
  18815. attributes: string[];
  18816. /**
  18817. * The list of unifrom names used in the shader
  18818. */
  18819. uniforms: string[];
  18820. /**
  18821. * The list of UBO names used in the shader
  18822. */
  18823. uniformBuffers: string[];
  18824. /**
  18825. * The list of sampler names used in the shader
  18826. */
  18827. samplers: string[];
  18828. /**
  18829. * The list of defines used in the shader
  18830. */
  18831. defines: string[];
  18832. }
  18833. /**
  18834. * 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.
  18835. *
  18836. * This returned material effects how the mesh will look based on the code in the shaders.
  18837. *
  18838. * @see http://doc.babylonjs.com/how_to/shader_material
  18839. */
  18840. export class ShaderMaterial extends Material {
  18841. private _shaderPath;
  18842. private _options;
  18843. private _textures;
  18844. private _textureArrays;
  18845. private _floats;
  18846. private _ints;
  18847. private _floatsArrays;
  18848. private _colors3;
  18849. private _colors3Arrays;
  18850. private _colors4;
  18851. private _colors4Arrays;
  18852. private _vectors2;
  18853. private _vectors3;
  18854. private _vectors4;
  18855. private _matrices;
  18856. private _matrices3x3;
  18857. private _matrices2x2;
  18858. private _vectors2Arrays;
  18859. private _vectors3Arrays;
  18860. private _vectors4Arrays;
  18861. private _cachedWorldViewMatrix;
  18862. private _cachedWorldViewProjectionMatrix;
  18863. private _renderId;
  18864. /**
  18865. * Instantiate a new shader material.
  18866. * 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.
  18867. * This returned material effects how the mesh will look based on the code in the shaders.
  18868. * @see http://doc.babylonjs.com/how_to/shader_material
  18869. * @param name Define the name of the material in the scene
  18870. * @param scene Define the scene the material belongs to
  18871. * @param shaderPath Defines the route to the shader code in one of three ways:
  18872. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18873. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  18874. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  18875. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18876. * @param options Define the options used to create the shader
  18877. */
  18878. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18879. /**
  18880. * Gets the options used to compile the shader.
  18881. * They can be modified to trigger a new compilation
  18882. */
  18883. readonly options: IShaderMaterialOptions;
  18884. /**
  18885. * Gets the current class name of the material e.g. "ShaderMaterial"
  18886. * Mainly use in serialization.
  18887. * @returns the class name
  18888. */
  18889. getClassName(): string;
  18890. /**
  18891. * Specifies if the material will require alpha blending
  18892. * @returns a boolean specifying if alpha blending is needed
  18893. */
  18894. needAlphaBlending(): boolean;
  18895. /**
  18896. * Specifies if this material should be rendered in alpha test mode
  18897. * @returns a boolean specifying if an alpha test is needed.
  18898. */
  18899. needAlphaTesting(): boolean;
  18900. private _checkUniform;
  18901. /**
  18902. * Set a texture in the shader.
  18903. * @param name Define the name of the uniform samplers as defined in the shader
  18904. * @param texture Define the texture to bind to this sampler
  18905. * @return the material itself allowing "fluent" like uniform updates
  18906. */
  18907. setTexture(name: string, texture: Texture): ShaderMaterial;
  18908. /**
  18909. * Set a texture array in the shader.
  18910. * @param name Define the name of the uniform sampler array as defined in the shader
  18911. * @param textures Define the list of textures to bind to this sampler
  18912. * @return the material itself allowing "fluent" like uniform updates
  18913. */
  18914. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18915. /**
  18916. * Set a float in the shader.
  18917. * @param name Define the name of the uniform as defined in the shader
  18918. * @param value Define the value to give to the uniform
  18919. * @return the material itself allowing "fluent" like uniform updates
  18920. */
  18921. setFloat(name: string, value: number): ShaderMaterial;
  18922. /**
  18923. * Set a int in the shader.
  18924. * @param name Define the name of the uniform as defined in the shader
  18925. * @param value Define the value to give to the uniform
  18926. * @return the material itself allowing "fluent" like uniform updates
  18927. */
  18928. setInt(name: string, value: number): ShaderMaterial;
  18929. /**
  18930. * Set an array of floats in the shader.
  18931. * @param name Define the name of the uniform as defined in the shader
  18932. * @param value Define the value to give to the uniform
  18933. * @return the material itself allowing "fluent" like uniform updates
  18934. */
  18935. setFloats(name: string, value: number[]): ShaderMaterial;
  18936. /**
  18937. * Set a vec3 in the shader from a Color3.
  18938. * @param name Define the name of the uniform as defined in the shader
  18939. * @param value Define the value to give to the uniform
  18940. * @return the material itself allowing "fluent" like uniform updates
  18941. */
  18942. setColor3(name: string, value: Color3): ShaderMaterial;
  18943. /**
  18944. * Set a vec3 array in the shader from a Color3 array.
  18945. * @param name Define the name of the uniform as defined in the shader
  18946. * @param value Define the value to give to the uniform
  18947. * @return the material itself allowing "fluent" like uniform updates
  18948. */
  18949. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18950. /**
  18951. * Set a vec4 in the shader from a Color4.
  18952. * @param name Define the name of the uniform as defined in the shader
  18953. * @param value Define the value to give to the uniform
  18954. * @return the material itself allowing "fluent" like uniform updates
  18955. */
  18956. setColor4(name: string, value: Color4): ShaderMaterial;
  18957. /**
  18958. * Set a vec4 array in the shader from a Color4 array.
  18959. * @param name Define the name of the uniform as defined in the shader
  18960. * @param value Define the value to give to the uniform
  18961. * @return the material itself allowing "fluent" like uniform updates
  18962. */
  18963. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18964. /**
  18965. * Set a vec2 in the shader from a Vector2.
  18966. * @param name Define the name of the uniform as defined in the shader
  18967. * @param value Define the value to give to the uniform
  18968. * @return the material itself allowing "fluent" like uniform updates
  18969. */
  18970. setVector2(name: string, value: Vector2): ShaderMaterial;
  18971. /**
  18972. * Set a vec3 in the shader from a Vector3.
  18973. * @param name Define the name of the uniform as defined in the shader
  18974. * @param value Define the value to give to the uniform
  18975. * @return the material itself allowing "fluent" like uniform updates
  18976. */
  18977. setVector3(name: string, value: Vector3): ShaderMaterial;
  18978. /**
  18979. * Set a vec4 in the shader from a Vector4.
  18980. * @param name Define the name of the uniform as defined in the shader
  18981. * @param value Define the value to give to the uniform
  18982. * @return the material itself allowing "fluent" like uniform updates
  18983. */
  18984. setVector4(name: string, value: Vector4): ShaderMaterial;
  18985. /**
  18986. * Set a mat4 in the shader from a Matrix.
  18987. * @param name Define the name of the uniform as defined in the shader
  18988. * @param value Define the value to give to the uniform
  18989. * @return the material itself allowing "fluent" like uniform updates
  18990. */
  18991. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18992. /**
  18993. * Set a mat3 in the shader from a Float32Array.
  18994. * @param name Define the name of the uniform as defined in the shader
  18995. * @param value Define the value to give to the uniform
  18996. * @return the material itself allowing "fluent" like uniform updates
  18997. */
  18998. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18999. /**
  19000. * Set a mat2 in the shader from a Float32Array.
  19001. * @param name Define the name of the uniform as defined in the shader
  19002. * @param value Define the value to give to the uniform
  19003. * @return the material itself allowing "fluent" like uniform updates
  19004. */
  19005. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19006. /**
  19007. * Set a vec2 array in the shader from a number array.
  19008. * @param name Define the name of the uniform as defined in the shader
  19009. * @param value Define the value to give to the uniform
  19010. * @return the material itself allowing "fluent" like uniform updates
  19011. */
  19012. setArray2(name: string, value: number[]): ShaderMaterial;
  19013. /**
  19014. * Set a vec3 array in the shader from a number array.
  19015. * @param name Define the name of the uniform as defined in the shader
  19016. * @param value Define the value to give to the uniform
  19017. * @return the material itself allowing "fluent" like uniform updates
  19018. */
  19019. setArray3(name: string, value: number[]): ShaderMaterial;
  19020. /**
  19021. * Set a vec4 array in the shader from a number array.
  19022. * @param name Define the name of the uniform as defined in the shader
  19023. * @param value Define the value to give to the uniform
  19024. * @return the material itself allowing "fluent" like uniform updates
  19025. */
  19026. setArray4(name: string, value: number[]): ShaderMaterial;
  19027. private _checkCache;
  19028. /**
  19029. * Specifies that the submesh is ready to be used
  19030. * @param mesh defines the mesh to check
  19031. * @param subMesh defines which submesh to check
  19032. * @param useInstances specifies that instances should be used
  19033. * @returns a boolean indicating that the submesh is ready or not
  19034. */
  19035. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19036. /**
  19037. * Checks if the material is ready to render the requested mesh
  19038. * @param mesh Define the mesh to render
  19039. * @param useInstances Define whether or not the material is used with instances
  19040. * @returns true if ready, otherwise false
  19041. */
  19042. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19043. /**
  19044. * Binds the world matrix to the material
  19045. * @param world defines the world transformation matrix
  19046. */
  19047. bindOnlyWorldMatrix(world: Matrix): void;
  19048. /**
  19049. * Binds the material to the mesh
  19050. * @param world defines the world transformation matrix
  19051. * @param mesh defines the mesh to bind the material to
  19052. */
  19053. bind(world: Matrix, mesh?: Mesh): void;
  19054. /**
  19055. * Gets the active textures from the material
  19056. * @returns an array of textures
  19057. */
  19058. getActiveTextures(): BaseTexture[];
  19059. /**
  19060. * Specifies if the material uses a texture
  19061. * @param texture defines the texture to check against the material
  19062. * @returns a boolean specifying if the material uses the texture
  19063. */
  19064. hasTexture(texture: BaseTexture): boolean;
  19065. /**
  19066. * Makes a duplicate of the material, and gives it a new name
  19067. * @param name defines the new name for the duplicated material
  19068. * @returns the cloned material
  19069. */
  19070. clone(name: string): ShaderMaterial;
  19071. /**
  19072. * Disposes the material
  19073. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19074. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19075. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19076. */
  19077. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19078. /**
  19079. * Serializes this material in a JSON representation
  19080. * @returns the serialized material object
  19081. */
  19082. serialize(): any;
  19083. /**
  19084. * Creates a shader material from parsed shader material data
  19085. * @param source defines the JSON represnetation of the material
  19086. * @param scene defines the hosting scene
  19087. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19088. * @returns a new material
  19089. */
  19090. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19091. }
  19092. }
  19093. declare module BABYLON {
  19094. /** @hidden */
  19095. export var colorPixelShader: {
  19096. name: string;
  19097. shader: string;
  19098. };
  19099. }
  19100. declare module BABYLON {
  19101. /** @hidden */
  19102. export var colorVertexShader: {
  19103. name: string;
  19104. shader: string;
  19105. };
  19106. }
  19107. declare module BABYLON {
  19108. /**
  19109. * Line mesh
  19110. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19111. */
  19112. export class LinesMesh extends Mesh {
  19113. /**
  19114. * If vertex color should be applied to the mesh
  19115. */
  19116. readonly useVertexColor?: boolean | undefined;
  19117. /**
  19118. * If vertex alpha should be applied to the mesh
  19119. */
  19120. readonly useVertexAlpha?: boolean | undefined;
  19121. /**
  19122. * Color of the line (Default: White)
  19123. */
  19124. color: Color3;
  19125. /**
  19126. * Alpha of the line (Default: 1)
  19127. */
  19128. alpha: number;
  19129. /**
  19130. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19131. * This margin is expressed in world space coordinates, so its value may vary.
  19132. * Default value is 0.1
  19133. */
  19134. intersectionThreshold: number;
  19135. private _colorShader;
  19136. private color4;
  19137. /**
  19138. * Creates a new LinesMesh
  19139. * @param name defines the name
  19140. * @param scene defines the hosting scene
  19141. * @param parent defines the parent mesh if any
  19142. * @param source defines the optional source LinesMesh used to clone data from
  19143. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19144. * When false, achieved by calling a clone(), also passing False.
  19145. * This will make creation of children, recursive.
  19146. * @param useVertexColor defines if this LinesMesh supports vertex color
  19147. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19148. */
  19149. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19150. /**
  19151. * If vertex color should be applied to the mesh
  19152. */
  19153. useVertexColor?: boolean | undefined,
  19154. /**
  19155. * If vertex alpha should be applied to the mesh
  19156. */
  19157. useVertexAlpha?: boolean | undefined);
  19158. private _addClipPlaneDefine;
  19159. private _removeClipPlaneDefine;
  19160. isReady(): boolean;
  19161. /**
  19162. * Returns the string "LineMesh"
  19163. */
  19164. getClassName(): string;
  19165. /**
  19166. * @hidden
  19167. */
  19168. /**
  19169. * @hidden
  19170. */
  19171. material: Material;
  19172. /**
  19173. * @hidden
  19174. */
  19175. readonly checkCollisions: boolean;
  19176. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19177. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19178. /**
  19179. * Disposes of the line mesh
  19180. * @param doNotRecurse If children should be disposed
  19181. */
  19182. dispose(doNotRecurse?: boolean): void;
  19183. /**
  19184. * Returns a new LineMesh object cloned from the current one.
  19185. */
  19186. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19187. /**
  19188. * Creates a new InstancedLinesMesh object from the mesh model.
  19189. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19190. * @param name defines the name of the new instance
  19191. * @returns a new InstancedLinesMesh
  19192. */
  19193. createInstance(name: string): InstancedLinesMesh;
  19194. }
  19195. /**
  19196. * Creates an instance based on a source LinesMesh
  19197. */
  19198. export class InstancedLinesMesh extends InstancedMesh {
  19199. /**
  19200. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19201. * This margin is expressed in world space coordinates, so its value may vary.
  19202. * Initilized with the intersectionThreshold value of the source LinesMesh
  19203. */
  19204. intersectionThreshold: number;
  19205. constructor(name: string, source: LinesMesh);
  19206. /**
  19207. * Returns the string "InstancedLinesMesh".
  19208. */
  19209. getClassName(): string;
  19210. }
  19211. }
  19212. declare module BABYLON {
  19213. /** @hidden */
  19214. export var linePixelShader: {
  19215. name: string;
  19216. shader: string;
  19217. };
  19218. }
  19219. declare module BABYLON {
  19220. /** @hidden */
  19221. export var lineVertexShader: {
  19222. name: string;
  19223. shader: string;
  19224. };
  19225. }
  19226. declare module BABYLON {
  19227. interface AbstractMesh {
  19228. /**
  19229. * Gets the edgesRenderer associated with the mesh
  19230. */
  19231. edgesRenderer: Nullable<EdgesRenderer>;
  19232. }
  19233. interface LinesMesh {
  19234. /**
  19235. * Enables the edge rendering mode on the mesh.
  19236. * This mode makes the mesh edges visible
  19237. * @param epsilon defines the maximal distance between two angles to detect a face
  19238. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19239. * @returns the currentAbstractMesh
  19240. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19241. */
  19242. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19243. }
  19244. interface InstancedLinesMesh {
  19245. /**
  19246. * Enables the edge rendering mode on the mesh.
  19247. * This mode makes the mesh edges visible
  19248. * @param epsilon defines the maximal distance between two angles to detect a face
  19249. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19250. * @returns the current InstancedLinesMesh
  19251. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19252. */
  19253. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19254. }
  19255. /**
  19256. * Defines the minimum contract an Edges renderer should follow.
  19257. */
  19258. export interface IEdgesRenderer extends IDisposable {
  19259. /**
  19260. * Gets or sets a boolean indicating if the edgesRenderer is active
  19261. */
  19262. isEnabled: boolean;
  19263. /**
  19264. * Renders the edges of the attached mesh,
  19265. */
  19266. render(): void;
  19267. /**
  19268. * Checks wether or not the edges renderer is ready to render.
  19269. * @return true if ready, otherwise false.
  19270. */
  19271. isReady(): boolean;
  19272. }
  19273. /**
  19274. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19275. */
  19276. export class EdgesRenderer implements IEdgesRenderer {
  19277. /**
  19278. * Define the size of the edges with an orthographic camera
  19279. */
  19280. edgesWidthScalerForOrthographic: number;
  19281. /**
  19282. * Define the size of the edges with a perspective camera
  19283. */
  19284. edgesWidthScalerForPerspective: number;
  19285. protected _source: AbstractMesh;
  19286. protected _linesPositions: number[];
  19287. protected _linesNormals: number[];
  19288. protected _linesIndices: number[];
  19289. protected _epsilon: number;
  19290. protected _indicesCount: number;
  19291. protected _lineShader: ShaderMaterial;
  19292. protected _ib: DataBuffer;
  19293. protected _buffers: {
  19294. [key: string]: Nullable<VertexBuffer>;
  19295. };
  19296. protected _checkVerticesInsteadOfIndices: boolean;
  19297. private _meshRebuildObserver;
  19298. private _meshDisposeObserver;
  19299. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19300. isEnabled: boolean;
  19301. /**
  19302. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19303. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19304. * @param source Mesh used to create edges
  19305. * @param epsilon sum of angles in adjacency to check for edge
  19306. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19307. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19308. */
  19309. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19310. protected _prepareRessources(): void;
  19311. /** @hidden */ private _rebuild(): void;
  19312. /**
  19313. * Releases the required resources for the edges renderer
  19314. */
  19315. dispose(): void;
  19316. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19317. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19318. /**
  19319. * Checks if the pair of p0 and p1 is en edge
  19320. * @param faceIndex
  19321. * @param edge
  19322. * @param faceNormals
  19323. * @param p0
  19324. * @param p1
  19325. * @private
  19326. */
  19327. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19328. /**
  19329. * push line into the position, normal and index buffer
  19330. * @protected
  19331. */
  19332. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19333. /**
  19334. * Generates lines edges from adjacencjes
  19335. * @private
  19336. */ private _generateEdgesLines(): void;
  19337. /**
  19338. * Checks wether or not the edges renderer is ready to render.
  19339. * @return true if ready, otherwise false.
  19340. */
  19341. isReady(): boolean;
  19342. /**
  19343. * Renders the edges of the attached mesh,
  19344. */
  19345. render(): void;
  19346. }
  19347. /**
  19348. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19349. */
  19350. export class LineEdgesRenderer extends EdgesRenderer {
  19351. /**
  19352. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19353. * @param source LineMesh used to generate edges
  19354. * @param epsilon not important (specified angle for edge detection)
  19355. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19356. */
  19357. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19358. /**
  19359. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19360. */ private _generateEdgesLines(): void;
  19361. }
  19362. }
  19363. declare module BABYLON {
  19364. /**
  19365. * This represents the object necessary to create a rendering group.
  19366. * This is exclusively used and created by the rendering manager.
  19367. * To modify the behavior, you use the available helpers in your scene or meshes.
  19368. * @hidden
  19369. */
  19370. export class RenderingGroup {
  19371. index: number;
  19372. private static _zeroVector;
  19373. private _scene;
  19374. private _opaqueSubMeshes;
  19375. private _transparentSubMeshes;
  19376. private _alphaTestSubMeshes;
  19377. private _depthOnlySubMeshes;
  19378. private _particleSystems;
  19379. private _spriteManagers;
  19380. private _opaqueSortCompareFn;
  19381. private _alphaTestSortCompareFn;
  19382. private _transparentSortCompareFn;
  19383. private _renderOpaque;
  19384. private _renderAlphaTest;
  19385. private _renderTransparent;
  19386. /** @hidden */ private _edgesRenderers: SmartArray<IEdgesRenderer>;
  19387. onBeforeTransparentRendering: () => void;
  19388. /**
  19389. * Set the opaque sort comparison function.
  19390. * If null the sub meshes will be render in the order they were created
  19391. */
  19392. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19393. /**
  19394. * Set the alpha test sort comparison function.
  19395. * If null the sub meshes will be render in the order they were created
  19396. */
  19397. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19398. /**
  19399. * Set the transparent sort comparison function.
  19400. * If null the sub meshes will be render in the order they were created
  19401. */
  19402. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19403. /**
  19404. * Creates a new rendering group.
  19405. * @param index The rendering group index
  19406. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19407. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19408. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19409. */
  19410. 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>);
  19411. /**
  19412. * Render all the sub meshes contained in the group.
  19413. * @param customRenderFunction Used to override the default render behaviour of the group.
  19414. * @returns true if rendered some submeshes.
  19415. */
  19416. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19417. /**
  19418. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19419. * @param subMeshes The submeshes to render
  19420. */
  19421. private renderOpaqueSorted;
  19422. /**
  19423. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19424. * @param subMeshes The submeshes to render
  19425. */
  19426. private renderAlphaTestSorted;
  19427. /**
  19428. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19429. * @param subMeshes The submeshes to render
  19430. */
  19431. private renderTransparentSorted;
  19432. /**
  19433. * Renders the submeshes in a specified order.
  19434. * @param subMeshes The submeshes to sort before render
  19435. * @param sortCompareFn The comparison function use to sort
  19436. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19437. * @param transparent Specifies to activate blending if true
  19438. */
  19439. private static renderSorted;
  19440. /**
  19441. * Renders the submeshes in the order they were dispatched (no sort applied).
  19442. * @param subMeshes The submeshes to render
  19443. */
  19444. private static renderUnsorted;
  19445. /**
  19446. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19447. * are rendered back to front if in the same alpha index.
  19448. *
  19449. * @param a The first submesh
  19450. * @param b The second submesh
  19451. * @returns The result of the comparison
  19452. */
  19453. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19454. /**
  19455. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19456. * are rendered back to front.
  19457. *
  19458. * @param a The first submesh
  19459. * @param b The second submesh
  19460. * @returns The result of the comparison
  19461. */
  19462. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19463. /**
  19464. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19465. * are rendered front to back (prevent overdraw).
  19466. *
  19467. * @param a The first submesh
  19468. * @param b The second submesh
  19469. * @returns The result of the comparison
  19470. */
  19471. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19472. /**
  19473. * Resets the different lists of submeshes to prepare a new frame.
  19474. */
  19475. prepare(): void;
  19476. dispose(): void;
  19477. /**
  19478. * Inserts the submesh in its correct queue depending on its material.
  19479. * @param subMesh The submesh to dispatch
  19480. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19481. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19482. */
  19483. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19484. dispatchSprites(spriteManager: ISpriteManager): void;
  19485. dispatchParticles(particleSystem: IParticleSystem): void;
  19486. private _renderParticles;
  19487. private _renderSprites;
  19488. }
  19489. }
  19490. declare module BABYLON {
  19491. /**
  19492. * Interface describing the different options available in the rendering manager
  19493. * regarding Auto Clear between groups.
  19494. */
  19495. export interface IRenderingManagerAutoClearSetup {
  19496. /**
  19497. * Defines whether or not autoclear is enable.
  19498. */
  19499. autoClear: boolean;
  19500. /**
  19501. * Defines whether or not to autoclear the depth buffer.
  19502. */
  19503. depth: boolean;
  19504. /**
  19505. * Defines whether or not to autoclear the stencil buffer.
  19506. */
  19507. stencil: boolean;
  19508. }
  19509. /**
  19510. * This class is used by the onRenderingGroupObservable
  19511. */
  19512. export class RenderingGroupInfo {
  19513. /**
  19514. * The Scene that being rendered
  19515. */
  19516. scene: Scene;
  19517. /**
  19518. * The camera currently used for the rendering pass
  19519. */
  19520. camera: Nullable<Camera>;
  19521. /**
  19522. * The ID of the renderingGroup being processed
  19523. */
  19524. renderingGroupId: number;
  19525. }
  19526. /**
  19527. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19528. * It is enable to manage the different groups as well as the different necessary sort functions.
  19529. * This should not be used directly aside of the few static configurations
  19530. */
  19531. export class RenderingManager {
  19532. /**
  19533. * The max id used for rendering groups (not included)
  19534. */
  19535. static MAX_RENDERINGGROUPS: number;
  19536. /**
  19537. * The min id used for rendering groups (included)
  19538. */
  19539. static MIN_RENDERINGGROUPS: number;
  19540. /**
  19541. * Used to globally prevent autoclearing scenes.
  19542. */
  19543. static AUTOCLEAR: boolean;
  19544. /**
  19545. * @hidden
  19546. */ private _useSceneAutoClearSetup: boolean;
  19547. private _scene;
  19548. private _renderingGroups;
  19549. private _depthStencilBufferAlreadyCleaned;
  19550. private _autoClearDepthStencil;
  19551. private _customOpaqueSortCompareFn;
  19552. private _customAlphaTestSortCompareFn;
  19553. private _customTransparentSortCompareFn;
  19554. private _renderingGroupInfo;
  19555. /**
  19556. * Instantiates a new rendering group for a particular scene
  19557. * @param scene Defines the scene the groups belongs to
  19558. */
  19559. constructor(scene: Scene);
  19560. private _clearDepthStencilBuffer;
  19561. /**
  19562. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19563. * @hidden
  19564. */
  19565. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19566. /**
  19567. * Resets the different information of the group to prepare a new frame
  19568. * @hidden
  19569. */
  19570. reset(): void;
  19571. /**
  19572. * Dispose and release the group and its associated resources.
  19573. * @hidden
  19574. */
  19575. dispose(): void;
  19576. /**
  19577. * Clear the info related to rendering groups preventing retention points during dispose.
  19578. */
  19579. freeRenderingGroups(): void;
  19580. private _prepareRenderingGroup;
  19581. /**
  19582. * Add a sprite manager to the rendering manager in order to render it this frame.
  19583. * @param spriteManager Define the sprite manager to render
  19584. */
  19585. dispatchSprites(spriteManager: ISpriteManager): void;
  19586. /**
  19587. * Add a particle system to the rendering manager in order to render it this frame.
  19588. * @param particleSystem Define the particle system to render
  19589. */
  19590. dispatchParticles(particleSystem: IParticleSystem): void;
  19591. /**
  19592. * Add a submesh to the manager in order to render it this frame
  19593. * @param subMesh The submesh to dispatch
  19594. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19595. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19596. */
  19597. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19598. /**
  19599. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19600. * This allowed control for front to back rendering or reversly depending of the special needs.
  19601. *
  19602. * @param renderingGroupId The rendering group id corresponding to its index
  19603. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19604. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19605. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19606. */
  19607. 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;
  19608. /**
  19609. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19610. *
  19611. * @param renderingGroupId The rendering group id corresponding to its index
  19612. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19613. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19614. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19615. */
  19616. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19617. /**
  19618. * Gets the current auto clear configuration for one rendering group of the rendering
  19619. * manager.
  19620. * @param index the rendering group index to get the information for
  19621. * @returns The auto clear setup for the requested rendering group
  19622. */
  19623. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19624. }
  19625. }
  19626. declare module BABYLON {
  19627. /**
  19628. * This Helps creating a texture that will be created from a camera in your scene.
  19629. * It is basically a dynamic texture that could be used to create special effects for instance.
  19630. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19631. */
  19632. export class RenderTargetTexture extends Texture {
  19633. isCube: boolean;
  19634. /**
  19635. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19636. */
  19637. static readonly REFRESHRATE_RENDER_ONCE: number;
  19638. /**
  19639. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19640. */
  19641. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19642. /**
  19643. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19644. * the central point of your effect and can save a lot of performances.
  19645. */
  19646. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19647. /**
  19648. * Use this predicate to dynamically define the list of mesh you want to render.
  19649. * If set, the renderList property will be overwritten.
  19650. */
  19651. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19652. private _renderList;
  19653. /**
  19654. * Use this list to define the list of mesh you want to render.
  19655. */
  19656. renderList: Nullable<Array<AbstractMesh>>;
  19657. private _hookArray;
  19658. /**
  19659. * Define if particles should be rendered in your texture.
  19660. */
  19661. renderParticles: boolean;
  19662. /**
  19663. * Define if sprites should be rendered in your texture.
  19664. */
  19665. renderSprites: boolean;
  19666. /**
  19667. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19668. */
  19669. coordinatesMode: number;
  19670. /**
  19671. * Define the camera used to render the texture.
  19672. */
  19673. activeCamera: Nullable<Camera>;
  19674. /**
  19675. * Override the render function of the texture with your own one.
  19676. */
  19677. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19678. /**
  19679. * Define if camera post processes should be use while rendering the texture.
  19680. */
  19681. useCameraPostProcesses: boolean;
  19682. /**
  19683. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19684. */
  19685. ignoreCameraViewport: boolean;
  19686. private _postProcessManager;
  19687. private _postProcesses;
  19688. private _resizeObserver;
  19689. /**
  19690. * An event triggered when the texture is unbind.
  19691. */
  19692. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19693. /**
  19694. * An event triggered when the texture is unbind.
  19695. */
  19696. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19697. private _onAfterUnbindObserver;
  19698. /**
  19699. * Set a after unbind callback in the texture.
  19700. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19701. */
  19702. onAfterUnbind: () => void;
  19703. /**
  19704. * An event triggered before rendering the texture
  19705. */
  19706. onBeforeRenderObservable: Observable<number>;
  19707. private _onBeforeRenderObserver;
  19708. /**
  19709. * Set a before render callback in the texture.
  19710. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19711. */
  19712. onBeforeRender: (faceIndex: number) => void;
  19713. /**
  19714. * An event triggered after rendering the texture
  19715. */
  19716. onAfterRenderObservable: Observable<number>;
  19717. private _onAfterRenderObserver;
  19718. /**
  19719. * Set a after render callback in the texture.
  19720. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19721. */
  19722. onAfterRender: (faceIndex: number) => void;
  19723. /**
  19724. * An event triggered after the texture clear
  19725. */
  19726. onClearObservable: Observable<Engine>;
  19727. private _onClearObserver;
  19728. /**
  19729. * Set a clear callback in the texture.
  19730. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19731. */
  19732. onClear: (Engine: Engine) => void;
  19733. /**
  19734. * An event triggered when the texture is resized.
  19735. */
  19736. onResizeObservable: Observable<RenderTargetTexture>;
  19737. /**
  19738. * Define the clear color of the Render Target if it should be different from the scene.
  19739. */
  19740. clearColor: Color4;
  19741. protected _size: number | {
  19742. width: number;
  19743. height: number;
  19744. };
  19745. protected _initialSizeParameter: number | {
  19746. width: number;
  19747. height: number;
  19748. } | {
  19749. ratio: number;
  19750. };
  19751. protected _sizeRatio: Nullable<number>;
  19752. /** @hidden */ private _generateMipMaps: boolean;
  19753. protected _renderingManager: RenderingManager;
  19754. /** @hidden */ private _waitingRenderList: string[];
  19755. protected _doNotChangeAspectRatio: boolean;
  19756. protected _currentRefreshId: number;
  19757. protected _refreshRate: number;
  19758. protected _textureMatrix: Matrix;
  19759. protected _samples: number;
  19760. protected _renderTargetOptions: RenderTargetCreationOptions;
  19761. /**
  19762. * Gets render target creation options that were used.
  19763. */
  19764. readonly renderTargetOptions: RenderTargetCreationOptions;
  19765. protected _engine: Engine;
  19766. protected _onRatioRescale(): void;
  19767. /**
  19768. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19769. * It must define where the camera used to render the texture is set
  19770. */
  19771. boundingBoxPosition: Vector3;
  19772. private _boundingBoxSize;
  19773. /**
  19774. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19775. * When defined, the cubemap will switch to local mode
  19776. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19777. * @example https://www.babylonjs-playground.com/#RNASML
  19778. */
  19779. boundingBoxSize: Vector3;
  19780. /**
  19781. * In case the RTT has been created with a depth texture, get the associated
  19782. * depth texture.
  19783. * Otherwise, return null.
  19784. */
  19785. depthStencilTexture: Nullable<InternalTexture>;
  19786. /**
  19787. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19788. * or used a shadow, depth texture...
  19789. * @param name The friendly name of the texture
  19790. * @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)
  19791. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19792. * @param generateMipMaps True if mip maps need to be generated after render.
  19793. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19794. * @param type The type of the buffer in the RTT (int, half float, float...)
  19795. * @param isCube True if a cube texture needs to be created
  19796. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19797. * @param generateDepthBuffer True to generate a depth buffer
  19798. * @param generateStencilBuffer True to generate a stencil buffer
  19799. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19800. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19801. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19802. */
  19803. constructor(name: string, size: number | {
  19804. width: number;
  19805. height: number;
  19806. } | {
  19807. ratio: number;
  19808. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19809. /**
  19810. * Creates a depth stencil texture.
  19811. * This is only available in WebGL 2 or with the depth texture extension available.
  19812. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19813. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19814. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19815. */
  19816. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19817. private _processSizeParameter;
  19818. /**
  19819. * Define the number of samples to use in case of MSAA.
  19820. * It defaults to one meaning no MSAA has been enabled.
  19821. */
  19822. samples: number;
  19823. /**
  19824. * Resets the refresh counter of the texture and start bak from scratch.
  19825. * Could be useful to regenerate the texture if it is setup to render only once.
  19826. */
  19827. resetRefreshCounter(): void;
  19828. /**
  19829. * Define the refresh rate of the texture or the rendering frequency.
  19830. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19831. */
  19832. refreshRate: number;
  19833. /**
  19834. * Adds a post process to the render target rendering passes.
  19835. * @param postProcess define the post process to add
  19836. */
  19837. addPostProcess(postProcess: PostProcess): void;
  19838. /**
  19839. * Clear all the post processes attached to the render target
  19840. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19841. */
  19842. clearPostProcesses(dispose?: boolean): void;
  19843. /**
  19844. * Remove one of the post process from the list of attached post processes to the texture
  19845. * @param postProcess define the post process to remove from the list
  19846. */
  19847. removePostProcess(postProcess: PostProcess): void;
  19848. /** @hidden */ private _shouldRender(): boolean;
  19849. /**
  19850. * Gets the actual render size of the texture.
  19851. * @returns the width of the render size
  19852. */
  19853. getRenderSize(): number;
  19854. /**
  19855. * Gets the actual render width of the texture.
  19856. * @returns the width of the render size
  19857. */
  19858. getRenderWidth(): number;
  19859. /**
  19860. * Gets the actual render height of the texture.
  19861. * @returns the height of the render size
  19862. */
  19863. getRenderHeight(): number;
  19864. /**
  19865. * Get if the texture can be rescaled or not.
  19866. */
  19867. readonly canRescale: boolean;
  19868. /**
  19869. * Resize the texture using a ratio.
  19870. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19871. */
  19872. scale(ratio: number): void;
  19873. /**
  19874. * Get the texture reflection matrix used to rotate/transform the reflection.
  19875. * @returns the reflection matrix
  19876. */
  19877. getReflectionTextureMatrix(): Matrix;
  19878. /**
  19879. * Resize the texture to a new desired size.
  19880. * Be carrefull as it will recreate all the data in the new texture.
  19881. * @param size Define the new size. It can be:
  19882. * - a number for squared texture,
  19883. * - an object containing { width: number, height: number }
  19884. * - or an object containing a ratio { ratio: number }
  19885. */
  19886. resize(size: number | {
  19887. width: number;
  19888. height: number;
  19889. } | {
  19890. ratio: number;
  19891. }): void;
  19892. /**
  19893. * Renders all the objects from the render list into the texture.
  19894. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19895. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19896. */
  19897. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19898. private _bestReflectionRenderTargetDimension;
  19899. /**
  19900. * @hidden
  19901. * @param faceIndex face index to bind to if this is a cubetexture
  19902. */ private _bindFrameBuffer(faceIndex?: number): void;
  19903. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19904. private renderToTarget;
  19905. /**
  19906. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19907. * This allowed control for front to back rendering or reversly depending of the special needs.
  19908. *
  19909. * @param renderingGroupId The rendering group id corresponding to its index
  19910. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19911. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19912. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19913. */
  19914. 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;
  19915. /**
  19916. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19917. *
  19918. * @param renderingGroupId The rendering group id corresponding to its index
  19919. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19920. */
  19921. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19922. /**
  19923. * Clones the texture.
  19924. * @returns the cloned texture
  19925. */
  19926. clone(): RenderTargetTexture;
  19927. /**
  19928. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19929. * @returns The JSON representation of the texture
  19930. */
  19931. serialize(): any;
  19932. /**
  19933. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19934. */
  19935. disposeFramebufferObjects(): void;
  19936. /**
  19937. * Dispose the texture and release its associated resources.
  19938. */
  19939. dispose(): void;
  19940. /** @hidden */ private _rebuild(): void;
  19941. /**
  19942. * Clear the info related to rendering groups preventing retention point in material dispose.
  19943. */
  19944. freeRenderingGroups(): void;
  19945. /**
  19946. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19947. * @returns the view count
  19948. */
  19949. getViewCount(): number;
  19950. }
  19951. }
  19952. declare module BABYLON {
  19953. /**
  19954. * Base class for the main features of a material in Babylon.js
  19955. */
  19956. export class Material implements IAnimatable {
  19957. /**
  19958. * Returns the triangle fill mode
  19959. */
  19960. static readonly TriangleFillMode: number;
  19961. /**
  19962. * Returns the wireframe mode
  19963. */
  19964. static readonly WireFrameFillMode: number;
  19965. /**
  19966. * Returns the point fill mode
  19967. */
  19968. static readonly PointFillMode: number;
  19969. /**
  19970. * Returns the point list draw mode
  19971. */
  19972. static readonly PointListDrawMode: number;
  19973. /**
  19974. * Returns the line list draw mode
  19975. */
  19976. static readonly LineListDrawMode: number;
  19977. /**
  19978. * Returns the line loop draw mode
  19979. */
  19980. static readonly LineLoopDrawMode: number;
  19981. /**
  19982. * Returns the line strip draw mode
  19983. */
  19984. static readonly LineStripDrawMode: number;
  19985. /**
  19986. * Returns the triangle strip draw mode
  19987. */
  19988. static readonly TriangleStripDrawMode: number;
  19989. /**
  19990. * Returns the triangle fan draw mode
  19991. */
  19992. static readonly TriangleFanDrawMode: number;
  19993. /**
  19994. * Stores the clock-wise side orientation
  19995. */
  19996. static readonly ClockWiseSideOrientation: number;
  19997. /**
  19998. * Stores the counter clock-wise side orientation
  19999. */
  20000. static readonly CounterClockWiseSideOrientation: number;
  20001. /**
  20002. * The dirty texture flag value
  20003. */
  20004. static readonly TextureDirtyFlag: number;
  20005. /**
  20006. * The dirty light flag value
  20007. */
  20008. static readonly LightDirtyFlag: number;
  20009. /**
  20010. * The dirty fresnel flag value
  20011. */
  20012. static readonly FresnelDirtyFlag: number;
  20013. /**
  20014. * The dirty attribute flag value
  20015. */
  20016. static readonly AttributesDirtyFlag: number;
  20017. /**
  20018. * The dirty misc flag value
  20019. */
  20020. static readonly MiscDirtyFlag: number;
  20021. /**
  20022. * The all dirty flag value
  20023. */
  20024. static readonly AllDirtyFlag: number;
  20025. /**
  20026. * The ID of the material
  20027. */
  20028. id: string;
  20029. /**
  20030. * Gets or sets the unique id of the material
  20031. */
  20032. uniqueId: number;
  20033. /**
  20034. * The name of the material
  20035. */
  20036. name: string;
  20037. /**
  20038. * Gets or sets user defined metadata
  20039. */
  20040. metadata: any;
  20041. /**
  20042. * For internal use only. Please do not use.
  20043. */
  20044. reservedDataStore: any;
  20045. /**
  20046. * Specifies if the ready state should be checked on each call
  20047. */
  20048. checkReadyOnEveryCall: boolean;
  20049. /**
  20050. * Specifies if the ready state should be checked once
  20051. */
  20052. checkReadyOnlyOnce: boolean;
  20053. /**
  20054. * The state of the material
  20055. */
  20056. state: string;
  20057. /**
  20058. * The alpha value of the material
  20059. */
  20060. protected _alpha: number;
  20061. /**
  20062. * List of inspectable custom properties (used by the Inspector)
  20063. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20064. */
  20065. inspectableCustomProperties: IInspectable[];
  20066. /**
  20067. * Sets the alpha value of the material
  20068. */
  20069. /**
  20070. * Gets the alpha value of the material
  20071. */
  20072. alpha: number;
  20073. /**
  20074. * Specifies if back face culling is enabled
  20075. */
  20076. protected _backFaceCulling: boolean;
  20077. /**
  20078. * Sets the back-face culling state
  20079. */
  20080. /**
  20081. * Gets the back-face culling state
  20082. */
  20083. backFaceCulling: boolean;
  20084. /**
  20085. * Stores the value for side orientation
  20086. */
  20087. sideOrientation: number;
  20088. /**
  20089. * Callback triggered when the material is compiled
  20090. */
  20091. onCompiled: Nullable<(effect: Effect) => void>;
  20092. /**
  20093. * Callback triggered when an error occurs
  20094. */
  20095. onError: Nullable<(effect: Effect, errors: string) => void>;
  20096. /**
  20097. * Callback triggered to get the render target textures
  20098. */
  20099. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20100. /**
  20101. * Gets a boolean indicating that current material needs to register RTT
  20102. */
  20103. readonly hasRenderTargetTextures: boolean;
  20104. /**
  20105. * Specifies if the material should be serialized
  20106. */
  20107. doNotSerialize: boolean;
  20108. /**
  20109. * @hidden
  20110. */ private _storeEffectOnSubMeshes: boolean;
  20111. /**
  20112. * Stores the animations for the material
  20113. */
  20114. animations: Nullable<Array<Animation>>;
  20115. /**
  20116. * An event triggered when the material is disposed
  20117. */
  20118. onDisposeObservable: Observable<Material>;
  20119. /**
  20120. * An observer which watches for dispose events
  20121. */
  20122. private _onDisposeObserver;
  20123. private _onUnBindObservable;
  20124. /**
  20125. * Called during a dispose event
  20126. */
  20127. onDispose: () => void;
  20128. private _onBindObservable;
  20129. /**
  20130. * An event triggered when the material is bound
  20131. */
  20132. readonly onBindObservable: Observable<AbstractMesh>;
  20133. /**
  20134. * An observer which watches for bind events
  20135. */
  20136. private _onBindObserver;
  20137. /**
  20138. * Called during a bind event
  20139. */
  20140. onBind: (Mesh: AbstractMesh) => void;
  20141. /**
  20142. * An event triggered when the material is unbound
  20143. */
  20144. readonly onUnBindObservable: Observable<Material>;
  20145. /**
  20146. * Stores the value of the alpha mode
  20147. */
  20148. private _alphaMode;
  20149. /**
  20150. * Sets the value of the alpha mode.
  20151. *
  20152. * | Value | Type | Description |
  20153. * | --- | --- | --- |
  20154. * | 0 | ALPHA_DISABLE | |
  20155. * | 1 | ALPHA_ADD | |
  20156. * | 2 | ALPHA_COMBINE | |
  20157. * | 3 | ALPHA_SUBTRACT | |
  20158. * | 4 | ALPHA_MULTIPLY | |
  20159. * | 5 | ALPHA_MAXIMIZED | |
  20160. * | 6 | ALPHA_ONEONE | |
  20161. * | 7 | ALPHA_PREMULTIPLIED | |
  20162. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20163. * | 9 | ALPHA_INTERPOLATE | |
  20164. * | 10 | ALPHA_SCREENMODE | |
  20165. *
  20166. */
  20167. /**
  20168. * Gets the value of the alpha mode
  20169. */
  20170. alphaMode: number;
  20171. /**
  20172. * Stores the state of the need depth pre-pass value
  20173. */
  20174. private _needDepthPrePass;
  20175. /**
  20176. * Sets the need depth pre-pass value
  20177. */
  20178. /**
  20179. * Gets the depth pre-pass value
  20180. */
  20181. needDepthPrePass: boolean;
  20182. /**
  20183. * Specifies if depth writing should be disabled
  20184. */
  20185. disableDepthWrite: boolean;
  20186. /**
  20187. * Specifies if depth writing should be forced
  20188. */
  20189. forceDepthWrite: boolean;
  20190. /**
  20191. * Specifies if there should be a separate pass for culling
  20192. */
  20193. separateCullingPass: boolean;
  20194. /**
  20195. * Stores the state specifing if fog should be enabled
  20196. */
  20197. private _fogEnabled;
  20198. /**
  20199. * Sets the state for enabling fog
  20200. */
  20201. /**
  20202. * Gets the value of the fog enabled state
  20203. */
  20204. fogEnabled: boolean;
  20205. /**
  20206. * Stores the size of points
  20207. */
  20208. pointSize: number;
  20209. /**
  20210. * Stores the z offset value
  20211. */
  20212. zOffset: number;
  20213. /**
  20214. * Gets a value specifying if wireframe mode is enabled
  20215. */
  20216. /**
  20217. * Sets the state of wireframe mode
  20218. */
  20219. wireframe: boolean;
  20220. /**
  20221. * Gets the value specifying if point clouds are enabled
  20222. */
  20223. /**
  20224. * Sets the state of point cloud mode
  20225. */
  20226. pointsCloud: boolean;
  20227. /**
  20228. * Gets the material fill mode
  20229. */
  20230. /**
  20231. * Sets the material fill mode
  20232. */
  20233. fillMode: number;
  20234. /**
  20235. * @hidden
  20236. * Stores the effects for the material
  20237. */ private _effect: Nullable<Effect>;
  20238. /**
  20239. * @hidden
  20240. * Specifies if the material was previously ready
  20241. */ private _wasPreviouslyReady: boolean;
  20242. /**
  20243. * Specifies if uniform buffers should be used
  20244. */
  20245. private _useUBO;
  20246. /**
  20247. * Stores a reference to the scene
  20248. */
  20249. private _scene;
  20250. /**
  20251. * Stores the fill mode state
  20252. */
  20253. private _fillMode;
  20254. /**
  20255. * Specifies if the depth write state should be cached
  20256. */
  20257. private _cachedDepthWriteState;
  20258. /**
  20259. * Stores the uniform buffer
  20260. */
  20261. protected _uniformBuffer: UniformBuffer;
  20262. /** @hidden */ private _indexInSceneMaterialArray: number;
  20263. /** @hidden */
  20264. meshMap: Nullable<{
  20265. [id: string]: AbstractMesh | undefined;
  20266. }>;
  20267. /**
  20268. * Creates a material instance
  20269. * @param name defines the name of the material
  20270. * @param scene defines the scene to reference
  20271. * @param doNotAdd specifies if the material should be added to the scene
  20272. */
  20273. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20274. /**
  20275. * Returns a string representation of the current material
  20276. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20277. * @returns a string with material information
  20278. */
  20279. toString(fullDetails?: boolean): string;
  20280. /**
  20281. * Gets the class name of the material
  20282. * @returns a string with the class name of the material
  20283. */
  20284. getClassName(): string;
  20285. /**
  20286. * Specifies if updates for the material been locked
  20287. */
  20288. readonly isFrozen: boolean;
  20289. /**
  20290. * Locks updates for the material
  20291. */
  20292. freeze(): void;
  20293. /**
  20294. * Unlocks updates for the material
  20295. */
  20296. unfreeze(): void;
  20297. /**
  20298. * Specifies if the material is ready to be used
  20299. * @param mesh defines the mesh to check
  20300. * @param useInstances specifies if instances should be used
  20301. * @returns a boolean indicating if the material is ready to be used
  20302. */
  20303. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20304. /**
  20305. * Specifies that the submesh is ready to be used
  20306. * @param mesh defines the mesh to check
  20307. * @param subMesh defines which submesh to check
  20308. * @param useInstances specifies that instances should be used
  20309. * @returns a boolean indicating that the submesh is ready or not
  20310. */
  20311. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20312. /**
  20313. * Returns the material effect
  20314. * @returns the effect associated with the material
  20315. */
  20316. getEffect(): Nullable<Effect>;
  20317. /**
  20318. * Returns the current scene
  20319. * @returns a Scene
  20320. */
  20321. getScene(): Scene;
  20322. /**
  20323. * Specifies if the material will require alpha blending
  20324. * @returns a boolean specifying if alpha blending is needed
  20325. */
  20326. needAlphaBlending(): boolean;
  20327. /**
  20328. * Specifies if the mesh will require alpha blending
  20329. * @param mesh defines the mesh to check
  20330. * @returns a boolean specifying if alpha blending is needed for the mesh
  20331. */
  20332. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20333. /**
  20334. * Specifies if this material should be rendered in alpha test mode
  20335. * @returns a boolean specifying if an alpha test is needed.
  20336. */
  20337. needAlphaTesting(): boolean;
  20338. /**
  20339. * Gets the texture used for the alpha test
  20340. * @returns the texture to use for alpha testing
  20341. */
  20342. getAlphaTestTexture(): Nullable<BaseTexture>;
  20343. /**
  20344. * Marks the material to indicate that it needs to be re-calculated
  20345. */
  20346. markDirty(): void;
  20347. /** @hidden */ private _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20348. /**
  20349. * Binds the material to the mesh
  20350. * @param world defines the world transformation matrix
  20351. * @param mesh defines the mesh to bind the material to
  20352. */
  20353. bind(world: Matrix, mesh?: Mesh): void;
  20354. /**
  20355. * Binds the submesh to the material
  20356. * @param world defines the world transformation matrix
  20357. * @param mesh defines the mesh containing the submesh
  20358. * @param subMesh defines the submesh to bind the material to
  20359. */
  20360. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20361. /**
  20362. * Binds the world matrix to the material
  20363. * @param world defines the world transformation matrix
  20364. */
  20365. bindOnlyWorldMatrix(world: Matrix): void;
  20366. /**
  20367. * Binds the scene's uniform buffer to the effect.
  20368. * @param effect defines the effect to bind to the scene uniform buffer
  20369. * @param sceneUbo defines the uniform buffer storing scene data
  20370. */
  20371. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20372. /**
  20373. * Binds the view matrix to the effect
  20374. * @param effect defines the effect to bind the view matrix to
  20375. */
  20376. bindView(effect: Effect): void;
  20377. /**
  20378. * Binds the view projection matrix to the effect
  20379. * @param effect defines the effect to bind the view projection matrix to
  20380. */
  20381. bindViewProjection(effect: Effect): void;
  20382. /**
  20383. * Specifies if material alpha testing should be turned on for the mesh
  20384. * @param mesh defines the mesh to check
  20385. */
  20386. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20387. /**
  20388. * Processes to execute after binding the material to a mesh
  20389. * @param mesh defines the rendered mesh
  20390. */
  20391. protected _afterBind(mesh?: Mesh): void;
  20392. /**
  20393. * Unbinds the material from the mesh
  20394. */
  20395. unbind(): void;
  20396. /**
  20397. * Gets the active textures from the material
  20398. * @returns an array of textures
  20399. */
  20400. getActiveTextures(): BaseTexture[];
  20401. /**
  20402. * Specifies if the material uses a texture
  20403. * @param texture defines the texture to check against the material
  20404. * @returns a boolean specifying if the material uses the texture
  20405. */
  20406. hasTexture(texture: BaseTexture): boolean;
  20407. /**
  20408. * Makes a duplicate of the material, and gives it a new name
  20409. * @param name defines the new name for the duplicated material
  20410. * @returns the cloned material
  20411. */
  20412. clone(name: string): Nullable<Material>;
  20413. /**
  20414. * Gets the meshes bound to the material
  20415. * @returns an array of meshes bound to the material
  20416. */
  20417. getBindedMeshes(): AbstractMesh[];
  20418. /**
  20419. * Force shader compilation
  20420. * @param mesh defines the mesh associated with this material
  20421. * @param onCompiled defines a function to execute once the material is compiled
  20422. * @param options defines the options to configure the compilation
  20423. */
  20424. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20425. clipPlane: boolean;
  20426. }>): void;
  20427. /**
  20428. * Force shader compilation
  20429. * @param mesh defines the mesh that will use this material
  20430. * @param options defines additional options for compiling the shaders
  20431. * @returns a promise that resolves when the compilation completes
  20432. */
  20433. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20434. clipPlane: boolean;
  20435. }>): Promise<void>;
  20436. private static readonly _AllDirtyCallBack;
  20437. private static readonly _ImageProcessingDirtyCallBack;
  20438. private static readonly _TextureDirtyCallBack;
  20439. private static readonly _FresnelDirtyCallBack;
  20440. private static readonly _MiscDirtyCallBack;
  20441. private static readonly _LightsDirtyCallBack;
  20442. private static readonly _AttributeDirtyCallBack;
  20443. private static _FresnelAndMiscDirtyCallBack;
  20444. private static _TextureAndMiscDirtyCallBack;
  20445. private static readonly _DirtyCallbackArray;
  20446. private static readonly _RunDirtyCallBacks;
  20447. /**
  20448. * Marks a define in the material to indicate that it needs to be re-computed
  20449. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20450. */
  20451. markAsDirty(flag: number): void;
  20452. /**
  20453. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20454. * @param func defines a function which checks material defines against the submeshes
  20455. */
  20456. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20457. /**
  20458. * Indicates that we need to re-calculated for all submeshes
  20459. */
  20460. protected _markAllSubMeshesAsAllDirty(): void;
  20461. /**
  20462. * Indicates that image processing needs to be re-calculated for all submeshes
  20463. */
  20464. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20465. /**
  20466. * Indicates that textures need to be re-calculated for all submeshes
  20467. */
  20468. protected _markAllSubMeshesAsTexturesDirty(): void;
  20469. /**
  20470. * Indicates that fresnel needs to be re-calculated for all submeshes
  20471. */
  20472. protected _markAllSubMeshesAsFresnelDirty(): void;
  20473. /**
  20474. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20475. */
  20476. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20477. /**
  20478. * Indicates that lights need to be re-calculated for all submeshes
  20479. */
  20480. protected _markAllSubMeshesAsLightsDirty(): void;
  20481. /**
  20482. * Indicates that attributes need to be re-calculated for all submeshes
  20483. */
  20484. protected _markAllSubMeshesAsAttributesDirty(): void;
  20485. /**
  20486. * Indicates that misc needs to be re-calculated for all submeshes
  20487. */
  20488. protected _markAllSubMeshesAsMiscDirty(): void;
  20489. /**
  20490. * Indicates that textures and misc need to be re-calculated for all submeshes
  20491. */
  20492. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20493. /**
  20494. * Disposes the material
  20495. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20496. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20497. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20498. */
  20499. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20500. /** @hidden */
  20501. private releaseVertexArrayObject;
  20502. /**
  20503. * Serializes this material
  20504. * @returns the serialized material object
  20505. */
  20506. serialize(): any;
  20507. /**
  20508. * Creates a material from parsed material data
  20509. * @param parsedMaterial defines parsed material data
  20510. * @param scene defines the hosting scene
  20511. * @param rootUrl defines the root URL to use to load textures
  20512. * @returns a new material
  20513. */
  20514. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20515. }
  20516. }
  20517. declare module BABYLON {
  20518. /**
  20519. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20520. * separate meshes. This can be use to improve performances.
  20521. * @see http://doc.babylonjs.com/how_to/multi_materials
  20522. */
  20523. export class MultiMaterial extends Material {
  20524. private _subMaterials;
  20525. /**
  20526. * Gets or Sets the list of Materials used within the multi material.
  20527. * They need to be ordered according to the submeshes order in the associated mesh
  20528. */
  20529. subMaterials: Nullable<Material>[];
  20530. /**
  20531. * Function used to align with Node.getChildren()
  20532. * @returns the list of Materials used within the multi material
  20533. */
  20534. getChildren(): Nullable<Material>[];
  20535. /**
  20536. * Instantiates a new Multi Material
  20537. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20538. * separate meshes. This can be use to improve performances.
  20539. * @see http://doc.babylonjs.com/how_to/multi_materials
  20540. * @param name Define the name in the scene
  20541. * @param scene Define the scene the material belongs to
  20542. */
  20543. constructor(name: string, scene: Scene);
  20544. private _hookArray;
  20545. /**
  20546. * Get one of the submaterial by its index in the submaterials array
  20547. * @param index The index to look the sub material at
  20548. * @returns The Material if the index has been defined
  20549. */
  20550. getSubMaterial(index: number): Nullable<Material>;
  20551. /**
  20552. * Get the list of active textures for the whole sub materials list.
  20553. * @returns All the textures that will be used during the rendering
  20554. */
  20555. getActiveTextures(): BaseTexture[];
  20556. /**
  20557. * Gets the current class name of the material e.g. "MultiMaterial"
  20558. * Mainly use in serialization.
  20559. * @returns the class name
  20560. */
  20561. getClassName(): string;
  20562. /**
  20563. * Checks if the material is ready to render the requested sub mesh
  20564. * @param mesh Define the mesh the submesh belongs to
  20565. * @param subMesh Define the sub mesh to look readyness for
  20566. * @param useInstances Define whether or not the material is used with instances
  20567. * @returns true if ready, otherwise false
  20568. */
  20569. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20570. /**
  20571. * Clones the current material and its related sub materials
  20572. * @param name Define the name of the newly cloned material
  20573. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20574. * @returns the cloned material
  20575. */
  20576. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20577. /**
  20578. * Serializes the materials into a JSON representation.
  20579. * @returns the JSON representation
  20580. */
  20581. serialize(): any;
  20582. /**
  20583. * Dispose the material and release its associated resources
  20584. * @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)
  20585. * @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)
  20586. * @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)
  20587. */
  20588. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20589. /**
  20590. * Creates a MultiMaterial from parsed MultiMaterial data.
  20591. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20592. * @param scene defines the hosting scene
  20593. * @returns a new MultiMaterial
  20594. */
  20595. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20596. }
  20597. }
  20598. declare module BABYLON {
  20599. /**
  20600. * Base class for submeshes
  20601. */
  20602. export class BaseSubMesh {
  20603. /** @hidden */ private _materialDefines: Nullable<MaterialDefines>;
  20604. /** @hidden */ private _materialEffect: Nullable<Effect>;
  20605. /**
  20606. * Gets associated effect
  20607. */
  20608. readonly effect: Nullable<Effect>;
  20609. /**
  20610. * Sets associated effect (effect used to render this submesh)
  20611. * @param effect defines the effect to associate with
  20612. * @param defines defines the set of defines used to compile this effect
  20613. */
  20614. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20615. }
  20616. /**
  20617. * Defines a subdivision inside a mesh
  20618. */
  20619. export class SubMesh extends BaseSubMesh implements ICullable {
  20620. /** the material index to use */
  20621. materialIndex: number;
  20622. /** vertex index start */
  20623. verticesStart: number;
  20624. /** vertices count */
  20625. verticesCount: number;
  20626. /** index start */
  20627. indexStart: number;
  20628. /** indices count */
  20629. indexCount: number;
  20630. /** @hidden */ private _linesIndexCount: number;
  20631. private _mesh;
  20632. private _renderingMesh;
  20633. private _boundingInfo;
  20634. private _linesIndexBuffer;
  20635. /** @hidden */ private _lastColliderWorldVertices: Nullable<Vector3[]>;
  20636. /** @hidden */ private _trianglePlanes: Plane[];
  20637. /** @hidden */ private _lastColliderTransformMatrix: Nullable<Matrix>;
  20638. /** @hidden */ private _renderId: number;
  20639. /** @hidden */ private _alphaIndex: number;
  20640. /** @hidden */ private _distanceToCamera: number;
  20641. /** @hidden */ private _id: number;
  20642. private _currentMaterial;
  20643. /**
  20644. * Add a new submesh to a mesh
  20645. * @param materialIndex defines the material index to use
  20646. * @param verticesStart defines vertex index start
  20647. * @param verticesCount defines vertices count
  20648. * @param indexStart defines index start
  20649. * @param indexCount defines indices count
  20650. * @param mesh defines the parent mesh
  20651. * @param renderingMesh defines an optional rendering mesh
  20652. * @param createBoundingBox defines if bounding box should be created for this submesh
  20653. * @returns the new submesh
  20654. */
  20655. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20656. /**
  20657. * Creates a new submesh
  20658. * @param materialIndex defines the material index to use
  20659. * @param verticesStart defines vertex index start
  20660. * @param verticesCount defines vertices count
  20661. * @param indexStart defines index start
  20662. * @param indexCount defines indices count
  20663. * @param mesh defines the parent mesh
  20664. * @param renderingMesh defines an optional rendering mesh
  20665. * @param createBoundingBox defines if bounding box should be created for this submesh
  20666. */
  20667. constructor(
  20668. /** the material index to use */
  20669. materialIndex: number,
  20670. /** vertex index start */
  20671. verticesStart: number,
  20672. /** vertices count */
  20673. verticesCount: number,
  20674. /** index start */
  20675. indexStart: number,
  20676. /** indices count */
  20677. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20678. /**
  20679. * Returns true if this submesh covers the entire parent mesh
  20680. * @ignorenaming
  20681. */
  20682. readonly IsGlobal: boolean;
  20683. /**
  20684. * Returns the submesh BoudingInfo object
  20685. * @returns current bounding info (or mesh's one if the submesh is global)
  20686. */
  20687. getBoundingInfo(): BoundingInfo;
  20688. /**
  20689. * Sets the submesh BoundingInfo
  20690. * @param boundingInfo defines the new bounding info to use
  20691. * @returns the SubMesh
  20692. */
  20693. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20694. /**
  20695. * Returns the mesh of the current submesh
  20696. * @return the parent mesh
  20697. */
  20698. getMesh(): AbstractMesh;
  20699. /**
  20700. * Returns the rendering mesh of the submesh
  20701. * @returns the rendering mesh (could be different from parent mesh)
  20702. */
  20703. getRenderingMesh(): Mesh;
  20704. /**
  20705. * Returns the submesh material
  20706. * @returns null or the current material
  20707. */
  20708. getMaterial(): Nullable<Material>;
  20709. /**
  20710. * Sets a new updated BoundingInfo object to the submesh
  20711. * @param data defines an optional position array to use to determine the bounding info
  20712. * @returns the SubMesh
  20713. */
  20714. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20715. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  20716. /**
  20717. * Updates the submesh BoundingInfo
  20718. * @param world defines the world matrix to use to update the bounding info
  20719. * @returns the submesh
  20720. */
  20721. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20722. /**
  20723. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20724. * @param frustumPlanes defines the frustum planes
  20725. * @returns true if the submesh is intersecting with the frustum
  20726. */
  20727. isInFrustum(frustumPlanes: Plane[]): boolean;
  20728. /**
  20729. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20730. * @param frustumPlanes defines the frustum planes
  20731. * @returns true if the submesh is inside the frustum
  20732. */
  20733. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20734. /**
  20735. * Renders the submesh
  20736. * @param enableAlphaMode defines if alpha needs to be used
  20737. * @returns the submesh
  20738. */
  20739. render(enableAlphaMode: boolean): SubMesh;
  20740. /**
  20741. * @hidden
  20742. */ private _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20743. /**
  20744. * Checks if the submesh intersects with a ray
  20745. * @param ray defines the ray to test
  20746. * @returns true is the passed ray intersects the submesh bounding box
  20747. */
  20748. canIntersects(ray: Ray): boolean;
  20749. /**
  20750. * Intersects current submesh with a ray
  20751. * @param ray defines the ray to test
  20752. * @param positions defines mesh's positions array
  20753. * @param indices defines mesh's indices array
  20754. * @param fastCheck defines if only bounding info should be used
  20755. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20756. * @returns intersection info or null if no intersection
  20757. */
  20758. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20759. /** @hidden */
  20760. private _intersectLines;
  20761. /** @hidden */
  20762. private _intersectUnIndexedLines;
  20763. /** @hidden */
  20764. private _intersectTriangles;
  20765. /** @hidden */
  20766. private _intersectUnIndexedTriangles;
  20767. /** @hidden */ private _rebuild(): void;
  20768. /**
  20769. * Creates a new submesh from the passed mesh
  20770. * @param newMesh defines the new hosting mesh
  20771. * @param newRenderingMesh defines an optional rendering mesh
  20772. * @returns the new submesh
  20773. */
  20774. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20775. /**
  20776. * Release associated resources
  20777. */
  20778. dispose(): void;
  20779. /**
  20780. * Gets the class name
  20781. * @returns the string "SubMesh".
  20782. */
  20783. getClassName(): string;
  20784. /**
  20785. * Creates a new submesh from indices data
  20786. * @param materialIndex the index of the main mesh material
  20787. * @param startIndex the index where to start the copy in the mesh indices array
  20788. * @param indexCount the number of indices to copy then from the startIndex
  20789. * @param mesh the main mesh to create the submesh from
  20790. * @param renderingMesh the optional rendering mesh
  20791. * @returns a new submesh
  20792. */
  20793. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20794. }
  20795. }
  20796. declare module BABYLON {
  20797. /**
  20798. * Class used to represent data loading progression
  20799. */
  20800. export class SceneLoaderFlags {
  20801. private static _ForceFullSceneLoadingForIncremental;
  20802. private static _ShowLoadingScreen;
  20803. private static _CleanBoneMatrixWeights;
  20804. private static _loggingLevel;
  20805. /**
  20806. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20807. */
  20808. static ForceFullSceneLoadingForIncremental: boolean;
  20809. /**
  20810. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20811. */
  20812. static ShowLoadingScreen: boolean;
  20813. /**
  20814. * Defines the current logging level (while loading the scene)
  20815. * @ignorenaming
  20816. */
  20817. static loggingLevel: number;
  20818. /**
  20819. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20820. */
  20821. static CleanBoneMatrixWeights: boolean;
  20822. }
  20823. }
  20824. declare module BABYLON {
  20825. /**
  20826. * Class used to store geometry data (vertex buffers + index buffer)
  20827. */
  20828. export class Geometry implements IGetSetVerticesData {
  20829. /**
  20830. * Gets or sets the ID of the geometry
  20831. */
  20832. id: string;
  20833. /**
  20834. * Gets or sets the unique ID of the geometry
  20835. */
  20836. uniqueId: number;
  20837. /**
  20838. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20839. */
  20840. delayLoadState: number;
  20841. /**
  20842. * Gets the file containing the data to load when running in delay load state
  20843. */
  20844. delayLoadingFile: Nullable<string>;
  20845. /**
  20846. * Callback called when the geometry is updated
  20847. */
  20848. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20849. private _scene;
  20850. private _engine;
  20851. private _meshes;
  20852. private _totalVertices;
  20853. /** @hidden */ private _indices: IndicesArray;
  20854. /** @hidden */ private _vertexBuffers: {
  20855. [key: string]: VertexBuffer;
  20856. };
  20857. private _isDisposed;
  20858. private _extend;
  20859. private _boundingBias;
  20860. /** @hidden */ private _delayInfo: Array<string>;
  20861. private _indexBuffer;
  20862. private _indexBufferIsUpdatable;
  20863. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  20864. /** @hidden */ private _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20865. /** @hidden */ private _softwareSkinningFrameId: number;
  20866. private _vertexArrayObjects;
  20867. private _updatable;
  20868. /** @hidden */ private _positions: Nullable<Vector3[]>;
  20869. /**
  20870. * 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
  20871. */
  20872. /**
  20873. * 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
  20874. */
  20875. boundingBias: Vector2;
  20876. /**
  20877. * Static function used to attach a new empty geometry to a mesh
  20878. * @param mesh defines the mesh to attach the geometry to
  20879. * @returns the new Geometry
  20880. */
  20881. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20882. /**
  20883. * Creates a new geometry
  20884. * @param id defines the unique ID
  20885. * @param scene defines the hosting scene
  20886. * @param vertexData defines the VertexData used to get geometry data
  20887. * @param updatable defines if geometry must be updatable (false by default)
  20888. * @param mesh defines the mesh that will be associated with the geometry
  20889. */
  20890. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20891. /**
  20892. * Gets the current extend of the geometry
  20893. */
  20894. readonly extend: {
  20895. minimum: Vector3;
  20896. maximum: Vector3;
  20897. };
  20898. /**
  20899. * Gets the hosting scene
  20900. * @returns the hosting Scene
  20901. */
  20902. getScene(): Scene;
  20903. /**
  20904. * Gets the hosting engine
  20905. * @returns the hosting Engine
  20906. */
  20907. getEngine(): Engine;
  20908. /**
  20909. * Defines if the geometry is ready to use
  20910. * @returns true if the geometry is ready to be used
  20911. */
  20912. isReady(): boolean;
  20913. /**
  20914. * Gets a value indicating that the geometry should not be serialized
  20915. */
  20916. readonly doNotSerialize: boolean;
  20917. /** @hidden */ private _rebuild(): void;
  20918. /**
  20919. * Affects all geometry data in one call
  20920. * @param vertexData defines the geometry data
  20921. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20922. */
  20923. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20924. /**
  20925. * Set specific vertex data
  20926. * @param kind defines the data kind (Position, normal, etc...)
  20927. * @param data defines the vertex data to use
  20928. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20929. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20930. */
  20931. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20932. /**
  20933. * Removes a specific vertex data
  20934. * @param kind defines the data kind (Position, normal, etc...)
  20935. */
  20936. removeVerticesData(kind: string): void;
  20937. /**
  20938. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20939. * @param buffer defines the vertex buffer to use
  20940. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20941. */
  20942. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20943. /**
  20944. * Update a specific vertex buffer
  20945. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20946. * It will do nothing if the buffer is not updatable
  20947. * @param kind defines the data kind (Position, normal, etc...)
  20948. * @param data defines the data to use
  20949. * @param offset defines the offset in the target buffer where to store the data
  20950. * @param useBytes set to true if the offset is in bytes
  20951. */
  20952. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20953. /**
  20954. * Update a specific vertex buffer
  20955. * This function will create a new buffer if the current one is not updatable
  20956. * @param kind defines the data kind (Position, normal, etc...)
  20957. * @param data defines the data to use
  20958. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20959. */
  20960. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20961. private _updateBoundingInfo;
  20962. /** @hidden */ private _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20963. /**
  20964. * Gets total number of vertices
  20965. * @returns the total number of vertices
  20966. */
  20967. getTotalVertices(): number;
  20968. /**
  20969. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20970. * @param kind defines the data kind (Position, normal, etc...)
  20971. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20972. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20973. * @returns a float array containing vertex data
  20974. */
  20975. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20976. /**
  20977. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20978. * @param kind defines the data kind (Position, normal, etc...)
  20979. * @returns true if the vertex buffer with the specified kind is updatable
  20980. */
  20981. isVertexBufferUpdatable(kind: string): boolean;
  20982. /**
  20983. * Gets a specific vertex buffer
  20984. * @param kind defines the data kind (Position, normal, etc...)
  20985. * @returns a VertexBuffer
  20986. */
  20987. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20988. /**
  20989. * Returns all vertex buffers
  20990. * @return an object holding all vertex buffers indexed by kind
  20991. */
  20992. getVertexBuffers(): Nullable<{
  20993. [key: string]: VertexBuffer;
  20994. }>;
  20995. /**
  20996. * Gets a boolean indicating if specific vertex buffer is present
  20997. * @param kind defines the data kind (Position, normal, etc...)
  20998. * @returns true if data is present
  20999. */
  21000. isVerticesDataPresent(kind: string): boolean;
  21001. /**
  21002. * Gets a list of all attached data kinds (Position, normal, etc...)
  21003. * @returns a list of string containing all kinds
  21004. */
  21005. getVerticesDataKinds(): string[];
  21006. /**
  21007. * Update index buffer
  21008. * @param indices defines the indices to store in the index buffer
  21009. * @param offset defines the offset in the target buffer where to store the data
  21010. * @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)
  21011. */
  21012. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21013. /**
  21014. * Creates a new index buffer
  21015. * @param indices defines the indices to store in the index buffer
  21016. * @param totalVertices defines the total number of vertices (could be null)
  21017. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21018. */
  21019. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21020. /**
  21021. * Return the total number of indices
  21022. * @returns the total number of indices
  21023. */
  21024. getTotalIndices(): number;
  21025. /**
  21026. * Gets the index buffer array
  21027. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21028. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21029. * @returns the index buffer array
  21030. */
  21031. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21032. /**
  21033. * Gets the index buffer
  21034. * @return the index buffer
  21035. */
  21036. getIndexBuffer(): Nullable<DataBuffer>;
  21037. /** @hidden */ private _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21038. /**
  21039. * Release the associated resources for a specific mesh
  21040. * @param mesh defines the source mesh
  21041. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21042. */
  21043. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21044. /**
  21045. * Apply current geometry to a given mesh
  21046. * @param mesh defines the mesh to apply geometry to
  21047. */
  21048. applyToMesh(mesh: Mesh): void;
  21049. private _updateExtend;
  21050. private _applyToMesh;
  21051. private notifyUpdate;
  21052. /**
  21053. * Load the geometry if it was flagged as delay loaded
  21054. * @param scene defines the hosting scene
  21055. * @param onLoaded defines a callback called when the geometry is loaded
  21056. */
  21057. load(scene: Scene, onLoaded?: () => void): void;
  21058. private _queueLoad;
  21059. /**
  21060. * Invert the geometry to move from a right handed system to a left handed one.
  21061. */
  21062. toLeftHanded(): void;
  21063. /** @hidden */ private _resetPointsArrayCache(): void;
  21064. /** @hidden */ private _generatePointsArray(): boolean;
  21065. /**
  21066. * Gets a value indicating if the geometry is disposed
  21067. * @returns true if the geometry was disposed
  21068. */
  21069. isDisposed(): boolean;
  21070. private _disposeVertexArrayObjects;
  21071. /**
  21072. * Free all associated resources
  21073. */
  21074. dispose(): void;
  21075. /**
  21076. * Clone the current geometry into a new geometry
  21077. * @param id defines the unique ID of the new geometry
  21078. * @returns a new geometry object
  21079. */
  21080. copy(id: string): Geometry;
  21081. /**
  21082. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21083. * @return a JSON representation of the current geometry data (without the vertices data)
  21084. */
  21085. serialize(): any;
  21086. private toNumberArray;
  21087. /**
  21088. * Serialize all vertices data into a JSON oject
  21089. * @returns a JSON representation of the current geometry data
  21090. */
  21091. serializeVerticeData(): any;
  21092. /**
  21093. * Extracts a clone of a mesh geometry
  21094. * @param mesh defines the source mesh
  21095. * @param id defines the unique ID of the new geometry object
  21096. * @returns the new geometry object
  21097. */
  21098. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21099. /**
  21100. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21101. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21102. * Be aware Math.random() could cause collisions, but:
  21103. * "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"
  21104. * @returns a string containing a new GUID
  21105. */
  21106. static RandomId(): string;
  21107. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21108. private static _CleanMatricesWeights;
  21109. /**
  21110. * Create a new geometry from persisted data (Using .babylon file format)
  21111. * @param parsedVertexData defines the persisted data
  21112. * @param scene defines the hosting scene
  21113. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21114. * @returns the new geometry object
  21115. */
  21116. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21117. }
  21118. }
  21119. declare module BABYLON {
  21120. /**
  21121. * Define an interface for all classes that will get and set the data on vertices
  21122. */
  21123. export interface IGetSetVerticesData {
  21124. /**
  21125. * Gets a boolean indicating if specific vertex data is present
  21126. * @param kind defines the vertex data kind to use
  21127. * @returns true is data kind is present
  21128. */
  21129. isVerticesDataPresent(kind: string): boolean;
  21130. /**
  21131. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21132. * @param kind defines the data kind (Position, normal, etc...)
  21133. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21134. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21135. * @returns a float array containing vertex data
  21136. */
  21137. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21138. /**
  21139. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21140. * @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.
  21141. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21142. * @returns the indices array or an empty array if the mesh has no geometry
  21143. */
  21144. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21145. /**
  21146. * Set specific vertex data
  21147. * @param kind defines the data kind (Position, normal, etc...)
  21148. * @param data defines the vertex data to use
  21149. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21150. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21151. */
  21152. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21153. /**
  21154. * Update a specific associated vertex buffer
  21155. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21156. * - VertexBuffer.PositionKind
  21157. * - VertexBuffer.UVKind
  21158. * - VertexBuffer.UV2Kind
  21159. * - VertexBuffer.UV3Kind
  21160. * - VertexBuffer.UV4Kind
  21161. * - VertexBuffer.UV5Kind
  21162. * - VertexBuffer.UV6Kind
  21163. * - VertexBuffer.ColorKind
  21164. * - VertexBuffer.MatricesIndicesKind
  21165. * - VertexBuffer.MatricesIndicesExtraKind
  21166. * - VertexBuffer.MatricesWeightsKind
  21167. * - VertexBuffer.MatricesWeightsExtraKind
  21168. * @param data defines the data source
  21169. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21170. * @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)
  21171. */
  21172. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21173. /**
  21174. * Creates a new index buffer
  21175. * @param indices defines the indices to store in the index buffer
  21176. * @param totalVertices defines the total number of vertices (could be null)
  21177. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21178. */
  21179. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21180. }
  21181. /**
  21182. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21183. */
  21184. export class VertexData {
  21185. /**
  21186. * Mesh side orientation : usually the external or front surface
  21187. */
  21188. static readonly FRONTSIDE: number;
  21189. /**
  21190. * Mesh side orientation : usually the internal or back surface
  21191. */
  21192. static readonly BACKSIDE: number;
  21193. /**
  21194. * Mesh side orientation : both internal and external or front and back surfaces
  21195. */
  21196. static readonly DOUBLESIDE: number;
  21197. /**
  21198. * Mesh side orientation : by default, `FRONTSIDE`
  21199. */
  21200. static readonly DEFAULTSIDE: number;
  21201. /**
  21202. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21203. */
  21204. positions: Nullable<FloatArray>;
  21205. /**
  21206. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21207. */
  21208. normals: Nullable<FloatArray>;
  21209. /**
  21210. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21211. */
  21212. tangents: Nullable<FloatArray>;
  21213. /**
  21214. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21215. */
  21216. uvs: Nullable<FloatArray>;
  21217. /**
  21218. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21219. */
  21220. uvs2: Nullable<FloatArray>;
  21221. /**
  21222. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21223. */
  21224. uvs3: Nullable<FloatArray>;
  21225. /**
  21226. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21227. */
  21228. uvs4: Nullable<FloatArray>;
  21229. /**
  21230. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21231. */
  21232. uvs5: Nullable<FloatArray>;
  21233. /**
  21234. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21235. */
  21236. uvs6: Nullable<FloatArray>;
  21237. /**
  21238. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21239. */
  21240. colors: Nullable<FloatArray>;
  21241. /**
  21242. * 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).
  21243. */
  21244. matricesIndices: Nullable<FloatArray>;
  21245. /**
  21246. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21247. */
  21248. matricesWeights: Nullable<FloatArray>;
  21249. /**
  21250. * An array extending the number of possible indices
  21251. */
  21252. matricesIndicesExtra: Nullable<FloatArray>;
  21253. /**
  21254. * An array extending the number of possible weights when the number of indices is extended
  21255. */
  21256. matricesWeightsExtra: Nullable<FloatArray>;
  21257. /**
  21258. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21259. */
  21260. indices: Nullable<IndicesArray>;
  21261. /**
  21262. * Uses the passed data array to set the set the values for the specified kind of data
  21263. * @param data a linear array of floating numbers
  21264. * @param kind the type of data that is being set, eg positions, colors etc
  21265. */
  21266. set(data: FloatArray, kind: string): void;
  21267. /**
  21268. * Associates the vertexData to the passed Mesh.
  21269. * Sets it as updatable or not (default `false`)
  21270. * @param mesh the mesh the vertexData is applied to
  21271. * @param updatable when used and having the value true allows new data to update the vertexData
  21272. * @returns the VertexData
  21273. */
  21274. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21275. /**
  21276. * Associates the vertexData to the passed Geometry.
  21277. * Sets it as updatable or not (default `false`)
  21278. * @param geometry the geometry the vertexData is applied to
  21279. * @param updatable when used and having the value true allows new data to update the vertexData
  21280. * @returns VertexData
  21281. */
  21282. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21283. /**
  21284. * Updates the associated mesh
  21285. * @param mesh the mesh to be updated
  21286. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21287. * @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
  21288. * @returns VertexData
  21289. */
  21290. updateMesh(mesh: Mesh): VertexData;
  21291. /**
  21292. * Updates the associated geometry
  21293. * @param geometry the geometry to be updated
  21294. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21295. * @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
  21296. * @returns VertexData.
  21297. */
  21298. updateGeometry(geometry: Geometry): VertexData;
  21299. private _applyTo;
  21300. private _update;
  21301. /**
  21302. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21303. * @param matrix the transforming matrix
  21304. * @returns the VertexData
  21305. */
  21306. transform(matrix: Matrix): VertexData;
  21307. /**
  21308. * Merges the passed VertexData into the current one
  21309. * @param other the VertexData to be merged into the current one
  21310. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21311. * @returns the modified VertexData
  21312. */
  21313. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21314. private _mergeElement;
  21315. private _validate;
  21316. /**
  21317. * Serializes the VertexData
  21318. * @returns a serialized object
  21319. */
  21320. serialize(): any;
  21321. /**
  21322. * Extracts the vertexData from a mesh
  21323. * @param mesh the mesh from which to extract the VertexData
  21324. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21325. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21326. * @returns the object VertexData associated to the passed mesh
  21327. */
  21328. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21329. /**
  21330. * Extracts the vertexData from the geometry
  21331. * @param geometry the geometry from which to extract the VertexData
  21332. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21333. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21334. * @returns the object VertexData associated to the passed mesh
  21335. */
  21336. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21337. private static _ExtractFrom;
  21338. /**
  21339. * Creates the VertexData for a Ribbon
  21340. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21341. * * pathArray array of paths, each of which an array of successive Vector3
  21342. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21343. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21344. * * 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
  21345. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21346. * * 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)
  21347. * * 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)
  21348. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21349. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21350. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21351. * @returns the VertexData of the ribbon
  21352. */
  21353. static CreateRibbon(options: {
  21354. pathArray: Vector3[][];
  21355. closeArray?: boolean;
  21356. closePath?: boolean;
  21357. offset?: number;
  21358. sideOrientation?: number;
  21359. frontUVs?: Vector4;
  21360. backUVs?: Vector4;
  21361. invertUV?: boolean;
  21362. uvs?: Vector2[];
  21363. colors?: Color4[];
  21364. }): VertexData;
  21365. /**
  21366. * Creates the VertexData for a box
  21367. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21368. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21369. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21370. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21371. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21372. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21373. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21374. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21375. * * 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)
  21376. * * 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)
  21377. * @returns the VertexData of the box
  21378. */
  21379. static CreateBox(options: {
  21380. size?: number;
  21381. width?: number;
  21382. height?: number;
  21383. depth?: number;
  21384. faceUV?: Vector4[];
  21385. faceColors?: Color4[];
  21386. sideOrientation?: number;
  21387. frontUVs?: Vector4;
  21388. backUVs?: Vector4;
  21389. }): VertexData;
  21390. /**
  21391. * Creates the VertexData for a tiled box
  21392. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21393. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21394. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21395. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21396. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21397. * @returns the VertexData of the box
  21398. */
  21399. static CreateTiledBox(options: {
  21400. pattern?: number;
  21401. width?: number;
  21402. height?: number;
  21403. depth?: number;
  21404. tileSize?: number;
  21405. tileWidth?: number;
  21406. tileHeight?: number;
  21407. alignHorizontal?: number;
  21408. alignVertical?: number;
  21409. faceUV?: Vector4[];
  21410. faceColors?: Color4[];
  21411. sideOrientation?: number;
  21412. }): VertexData;
  21413. /**
  21414. * Creates the VertexData for a tiled plane
  21415. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21416. * * pattern a limited pattern arrangement depending on the number
  21417. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21418. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21419. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21420. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21421. * * 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)
  21422. * * 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)
  21423. * @returns the VertexData of the tiled plane
  21424. */
  21425. static CreateTiledPlane(options: {
  21426. pattern?: number;
  21427. tileSize?: number;
  21428. tileWidth?: number;
  21429. tileHeight?: number;
  21430. size?: number;
  21431. width?: number;
  21432. height?: number;
  21433. alignHorizontal?: number;
  21434. alignVertical?: number;
  21435. sideOrientation?: number;
  21436. frontUVs?: Vector4;
  21437. backUVs?: Vector4;
  21438. }): VertexData;
  21439. /**
  21440. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21441. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21442. * * segments sets the number of horizontal strips optional, default 32
  21443. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21444. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21445. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21446. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21447. * * 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
  21448. * * 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
  21449. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21450. * * 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)
  21451. * * 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)
  21452. * @returns the VertexData of the ellipsoid
  21453. */
  21454. static CreateSphere(options: {
  21455. segments?: number;
  21456. diameter?: number;
  21457. diameterX?: number;
  21458. diameterY?: number;
  21459. diameterZ?: number;
  21460. arc?: number;
  21461. slice?: number;
  21462. sideOrientation?: number;
  21463. frontUVs?: Vector4;
  21464. backUVs?: Vector4;
  21465. }): VertexData;
  21466. /**
  21467. * Creates the VertexData for a cylinder, cone or prism
  21468. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21469. * * height sets the height (y direction) of the cylinder, optional, default 2
  21470. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21471. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21472. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21473. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21474. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21475. * * 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
  21476. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21477. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21478. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21479. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21480. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21481. * * 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)
  21482. * * 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)
  21483. * @returns the VertexData of the cylinder, cone or prism
  21484. */
  21485. static CreateCylinder(options: {
  21486. height?: number;
  21487. diameterTop?: number;
  21488. diameterBottom?: number;
  21489. diameter?: number;
  21490. tessellation?: number;
  21491. subdivisions?: number;
  21492. arc?: number;
  21493. faceColors?: Color4[];
  21494. faceUV?: Vector4[];
  21495. hasRings?: boolean;
  21496. enclose?: boolean;
  21497. sideOrientation?: number;
  21498. frontUVs?: Vector4;
  21499. backUVs?: Vector4;
  21500. }): VertexData;
  21501. /**
  21502. * Creates the VertexData for a torus
  21503. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21504. * * diameter the diameter of the torus, optional default 1
  21505. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21506. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21507. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21508. * * 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)
  21509. * * 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)
  21510. * @returns the VertexData of the torus
  21511. */
  21512. static CreateTorus(options: {
  21513. diameter?: number;
  21514. thickness?: number;
  21515. tessellation?: number;
  21516. sideOrientation?: number;
  21517. frontUVs?: Vector4;
  21518. backUVs?: Vector4;
  21519. }): VertexData;
  21520. /**
  21521. * Creates the VertexData of the LineSystem
  21522. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21523. * - lines an array of lines, each line being an array of successive Vector3
  21524. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21525. * @returns the VertexData of the LineSystem
  21526. */
  21527. static CreateLineSystem(options: {
  21528. lines: Vector3[][];
  21529. colors?: Nullable<Color4[][]>;
  21530. }): VertexData;
  21531. /**
  21532. * Create the VertexData for a DashedLines
  21533. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21534. * - points an array successive Vector3
  21535. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21536. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21537. * - dashNb the intended total number of dashes, optional, default 200
  21538. * @returns the VertexData for the DashedLines
  21539. */
  21540. static CreateDashedLines(options: {
  21541. points: Vector3[];
  21542. dashSize?: number;
  21543. gapSize?: number;
  21544. dashNb?: number;
  21545. }): VertexData;
  21546. /**
  21547. * Creates the VertexData for a Ground
  21548. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21549. * - width the width (x direction) of the ground, optional, default 1
  21550. * - height the height (z direction) of the ground, optional, default 1
  21551. * - subdivisions the number of subdivisions per side, optional, default 1
  21552. * @returns the VertexData of the Ground
  21553. */
  21554. static CreateGround(options: {
  21555. width?: number;
  21556. height?: number;
  21557. subdivisions?: number;
  21558. subdivisionsX?: number;
  21559. subdivisionsY?: number;
  21560. }): VertexData;
  21561. /**
  21562. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21563. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21564. * * xmin the ground minimum X coordinate, optional, default -1
  21565. * * zmin the ground minimum Z coordinate, optional, default -1
  21566. * * xmax the ground maximum X coordinate, optional, default 1
  21567. * * zmax the ground maximum Z coordinate, optional, default 1
  21568. * * 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}
  21569. * * 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}
  21570. * @returns the VertexData of the TiledGround
  21571. */
  21572. static CreateTiledGround(options: {
  21573. xmin: number;
  21574. zmin: number;
  21575. xmax: number;
  21576. zmax: number;
  21577. subdivisions?: {
  21578. w: number;
  21579. h: number;
  21580. };
  21581. precision?: {
  21582. w: number;
  21583. h: number;
  21584. };
  21585. }): VertexData;
  21586. /**
  21587. * Creates the VertexData of the Ground designed from a heightmap
  21588. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21589. * * width the width (x direction) of the ground
  21590. * * height the height (z direction) of the ground
  21591. * * subdivisions the number of subdivisions per side
  21592. * * minHeight the minimum altitude on the ground, optional, default 0
  21593. * * maxHeight the maximum altitude on the ground, optional default 1
  21594. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21595. * * buffer the array holding the image color data
  21596. * * bufferWidth the width of image
  21597. * * bufferHeight the height of image
  21598. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21599. * @returns the VertexData of the Ground designed from a heightmap
  21600. */
  21601. static CreateGroundFromHeightMap(options: {
  21602. width: number;
  21603. height: number;
  21604. subdivisions: number;
  21605. minHeight: number;
  21606. maxHeight: number;
  21607. colorFilter: Color3;
  21608. buffer: Uint8Array;
  21609. bufferWidth: number;
  21610. bufferHeight: number;
  21611. alphaFilter: number;
  21612. }): VertexData;
  21613. /**
  21614. * Creates the VertexData for a Plane
  21615. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21616. * * size sets the width and height of the plane to the value of size, optional default 1
  21617. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21618. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21619. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21620. * * 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)
  21621. * * 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)
  21622. * @returns the VertexData of the box
  21623. */
  21624. static CreatePlane(options: {
  21625. size?: number;
  21626. width?: number;
  21627. height?: number;
  21628. sideOrientation?: number;
  21629. frontUVs?: Vector4;
  21630. backUVs?: Vector4;
  21631. }): VertexData;
  21632. /**
  21633. * Creates the VertexData of the Disc or regular Polygon
  21634. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21635. * * radius the radius of the disc, optional default 0.5
  21636. * * tessellation the number of polygon sides, optional, default 64
  21637. * * 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
  21638. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21639. * * 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)
  21640. * * 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)
  21641. * @returns the VertexData of the box
  21642. */
  21643. static CreateDisc(options: {
  21644. radius?: number;
  21645. tessellation?: number;
  21646. arc?: number;
  21647. sideOrientation?: number;
  21648. frontUVs?: Vector4;
  21649. backUVs?: Vector4;
  21650. }): VertexData;
  21651. /**
  21652. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21653. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21654. * @param polygon a mesh built from polygonTriangulation.build()
  21655. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21656. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21657. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21658. * @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)
  21659. * @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)
  21660. * @returns the VertexData of the Polygon
  21661. */
  21662. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21663. /**
  21664. * Creates the VertexData of the IcoSphere
  21665. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21666. * * radius the radius of the IcoSphere, optional default 1
  21667. * * radiusX allows stretching in the x direction, optional, default radius
  21668. * * radiusY allows stretching in the y direction, optional, default radius
  21669. * * radiusZ allows stretching in the z direction, optional, default radius
  21670. * * flat when true creates a flat shaded mesh, optional, default true
  21671. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21672. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21673. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21674. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21675. * @returns the VertexData of the IcoSphere
  21676. */
  21677. static CreateIcoSphere(options: {
  21678. radius?: number;
  21679. radiusX?: number;
  21680. radiusY?: number;
  21681. radiusZ?: number;
  21682. flat?: boolean;
  21683. subdivisions?: number;
  21684. sideOrientation?: number;
  21685. frontUVs?: Vector4;
  21686. backUVs?: Vector4;
  21687. }): VertexData;
  21688. /**
  21689. * Creates the VertexData for a Polyhedron
  21690. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21691. * * type provided types are:
  21692. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21693. * * 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)
  21694. * * size the size of the IcoSphere, optional default 1
  21695. * * sizeX allows stretching in the x direction, optional, default size
  21696. * * sizeY allows stretching in the y direction, optional, default size
  21697. * * sizeZ allows stretching in the z direction, optional, default size
  21698. * * 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
  21699. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21700. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21701. * * flat when true creates a flat shaded mesh, optional, default true
  21702. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21703. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21704. * * 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)
  21705. * * 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)
  21706. * @returns the VertexData of the Polyhedron
  21707. */
  21708. static CreatePolyhedron(options: {
  21709. type?: number;
  21710. size?: number;
  21711. sizeX?: number;
  21712. sizeY?: number;
  21713. sizeZ?: number;
  21714. custom?: any;
  21715. faceUV?: Vector4[];
  21716. faceColors?: Color4[];
  21717. flat?: boolean;
  21718. sideOrientation?: number;
  21719. frontUVs?: Vector4;
  21720. backUVs?: Vector4;
  21721. }): VertexData;
  21722. /**
  21723. * Creates the VertexData for a TorusKnot
  21724. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21725. * * radius the radius of the torus knot, optional, default 2
  21726. * * tube the thickness of the tube, optional, default 0.5
  21727. * * radialSegments the number of sides on each tube segments, optional, default 32
  21728. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21729. * * p the number of windings around the z axis, optional, default 2
  21730. * * q the number of windings around the x axis, optional, default 3
  21731. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21732. * * 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)
  21733. * * 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)
  21734. * @returns the VertexData of the Torus Knot
  21735. */
  21736. static CreateTorusKnot(options: {
  21737. radius?: number;
  21738. tube?: number;
  21739. radialSegments?: number;
  21740. tubularSegments?: number;
  21741. p?: number;
  21742. q?: number;
  21743. sideOrientation?: number;
  21744. frontUVs?: Vector4;
  21745. backUVs?: Vector4;
  21746. }): VertexData;
  21747. /**
  21748. * Compute normals for given positions and indices
  21749. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21750. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21751. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21752. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21753. * * facetNormals : optional array of facet normals (vector3)
  21754. * * facetPositions : optional array of facet positions (vector3)
  21755. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21756. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21757. * * bInfo : optional bounding info, required for facetPartitioning computation
  21758. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21759. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21760. * * useRightHandedSystem: optional boolean to for right handed system computation
  21761. * * depthSort : optional boolean to enable the facet depth sort computation
  21762. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21763. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21764. */
  21765. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21766. facetNormals?: any;
  21767. facetPositions?: any;
  21768. facetPartitioning?: any;
  21769. ratio?: number;
  21770. bInfo?: any;
  21771. bbSize?: Vector3;
  21772. subDiv?: any;
  21773. useRightHandedSystem?: boolean;
  21774. depthSort?: boolean;
  21775. distanceTo?: Vector3;
  21776. depthSortedFacets?: any;
  21777. }): void;
  21778. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21779. /**
  21780. * Applies VertexData created from the imported parameters to the geometry
  21781. * @param parsedVertexData the parsed data from an imported file
  21782. * @param geometry the geometry to apply the VertexData to
  21783. */
  21784. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21785. }
  21786. }
  21787. declare module BABYLON {
  21788. /**
  21789. * Defines a target to use with MorphTargetManager
  21790. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21791. */
  21792. export class MorphTarget implements IAnimatable {
  21793. /** defines the name of the target */
  21794. name: string;
  21795. /**
  21796. * Gets or sets the list of animations
  21797. */
  21798. animations: Animation[];
  21799. private _scene;
  21800. private _positions;
  21801. private _normals;
  21802. private _tangents;
  21803. private _uvs;
  21804. private _influence;
  21805. /**
  21806. * Observable raised when the influence changes
  21807. */
  21808. onInfluenceChanged: Observable<boolean>;
  21809. /** @hidden */ private _onDataLayoutChanged: Observable<void>;
  21810. /**
  21811. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21812. */
  21813. influence: number;
  21814. /**
  21815. * Gets or sets the id of the morph Target
  21816. */
  21817. id: string;
  21818. private _animationPropertiesOverride;
  21819. /**
  21820. * Gets or sets the animation properties override
  21821. */
  21822. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21823. /**
  21824. * Creates a new MorphTarget
  21825. * @param name defines the name of the target
  21826. * @param influence defines the influence to use
  21827. * @param scene defines the scene the morphtarget belongs to
  21828. */
  21829. constructor(
  21830. /** defines the name of the target */
  21831. name: string, influence?: number, scene?: Nullable<Scene>);
  21832. /**
  21833. * Gets a boolean defining if the target contains position data
  21834. */
  21835. readonly hasPositions: boolean;
  21836. /**
  21837. * Gets a boolean defining if the target contains normal data
  21838. */
  21839. readonly hasNormals: boolean;
  21840. /**
  21841. * Gets a boolean defining if the target contains tangent data
  21842. */
  21843. readonly hasTangents: boolean;
  21844. /**
  21845. * Gets a boolean defining if the target contains texture coordinates data
  21846. */
  21847. readonly hasUVs: boolean;
  21848. /**
  21849. * Affects position data to this target
  21850. * @param data defines the position data to use
  21851. */
  21852. setPositions(data: Nullable<FloatArray>): void;
  21853. /**
  21854. * Gets the position data stored in this target
  21855. * @returns a FloatArray containing the position data (or null if not present)
  21856. */
  21857. getPositions(): Nullable<FloatArray>;
  21858. /**
  21859. * Affects normal data to this target
  21860. * @param data defines the normal data to use
  21861. */
  21862. setNormals(data: Nullable<FloatArray>): void;
  21863. /**
  21864. * Gets the normal data stored in this target
  21865. * @returns a FloatArray containing the normal data (or null if not present)
  21866. */
  21867. getNormals(): Nullable<FloatArray>;
  21868. /**
  21869. * Affects tangent data to this target
  21870. * @param data defines the tangent data to use
  21871. */
  21872. setTangents(data: Nullable<FloatArray>): void;
  21873. /**
  21874. * Gets the tangent data stored in this target
  21875. * @returns a FloatArray containing the tangent data (or null if not present)
  21876. */
  21877. getTangents(): Nullable<FloatArray>;
  21878. /**
  21879. * Affects texture coordinates data to this target
  21880. * @param data defines the texture coordinates data to use
  21881. */
  21882. setUVs(data: Nullable<FloatArray>): void;
  21883. /**
  21884. * Gets the texture coordinates data stored in this target
  21885. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21886. */
  21887. getUVs(): Nullable<FloatArray>;
  21888. /**
  21889. * Serializes the current target into a Serialization object
  21890. * @returns the serialized object
  21891. */
  21892. serialize(): any;
  21893. /**
  21894. * Returns the string "MorphTarget"
  21895. * @returns "MorphTarget"
  21896. */
  21897. getClassName(): string;
  21898. /**
  21899. * Creates a new target from serialized data
  21900. * @param serializationObject defines the serialized data to use
  21901. * @returns a new MorphTarget
  21902. */
  21903. static Parse(serializationObject: any): MorphTarget;
  21904. /**
  21905. * Creates a MorphTarget from mesh data
  21906. * @param mesh defines the source mesh
  21907. * @param name defines the name to use for the new target
  21908. * @param influence defines the influence to attach to the target
  21909. * @returns a new MorphTarget
  21910. */
  21911. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21912. }
  21913. }
  21914. declare module BABYLON {
  21915. /**
  21916. * This class is used to deform meshes using morphing between different targets
  21917. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21918. */
  21919. export class MorphTargetManager {
  21920. private _targets;
  21921. private _targetInfluenceChangedObservers;
  21922. private _targetDataLayoutChangedObservers;
  21923. private _activeTargets;
  21924. private _scene;
  21925. private _influences;
  21926. private _supportsNormals;
  21927. private _supportsTangents;
  21928. private _supportsUVs;
  21929. private _vertexCount;
  21930. private _uniqueId;
  21931. private _tempInfluences;
  21932. /**
  21933. * Gets or sets a boolean indicating if normals must be morphed
  21934. */
  21935. enableNormalMorphing: boolean;
  21936. /**
  21937. * Gets or sets a boolean indicating if tangents must be morphed
  21938. */
  21939. enableTangentMorphing: boolean;
  21940. /**
  21941. * Gets or sets a boolean indicating if UV must be morphed
  21942. */
  21943. enableUVMorphing: boolean;
  21944. /**
  21945. * Creates a new MorphTargetManager
  21946. * @param scene defines the current scene
  21947. */
  21948. constructor(scene?: Nullable<Scene>);
  21949. /**
  21950. * Gets the unique ID of this manager
  21951. */
  21952. readonly uniqueId: number;
  21953. /**
  21954. * Gets the number of vertices handled by this manager
  21955. */
  21956. readonly vertexCount: number;
  21957. /**
  21958. * Gets a boolean indicating if this manager supports morphing of normals
  21959. */
  21960. readonly supportsNormals: boolean;
  21961. /**
  21962. * Gets a boolean indicating if this manager supports morphing of tangents
  21963. */
  21964. readonly supportsTangents: boolean;
  21965. /**
  21966. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21967. */
  21968. readonly supportsUVs: boolean;
  21969. /**
  21970. * Gets the number of targets stored in this manager
  21971. */
  21972. readonly numTargets: number;
  21973. /**
  21974. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21975. */
  21976. readonly numInfluencers: number;
  21977. /**
  21978. * Gets the list of influences (one per target)
  21979. */
  21980. readonly influences: Float32Array;
  21981. /**
  21982. * Gets the active target at specified index. An active target is a target with an influence > 0
  21983. * @param index defines the index to check
  21984. * @returns the requested target
  21985. */
  21986. getActiveTarget(index: number): MorphTarget;
  21987. /**
  21988. * Gets the target at specified index
  21989. * @param index defines the index to check
  21990. * @returns the requested target
  21991. */
  21992. getTarget(index: number): MorphTarget;
  21993. /**
  21994. * Add a new target to this manager
  21995. * @param target defines the target to add
  21996. */
  21997. addTarget(target: MorphTarget): void;
  21998. /**
  21999. * Removes a target from the manager
  22000. * @param target defines the target to remove
  22001. */
  22002. removeTarget(target: MorphTarget): void;
  22003. /**
  22004. * Serializes the current manager into a Serialization object
  22005. * @returns the serialized object
  22006. */
  22007. serialize(): any;
  22008. private _syncActiveTargets;
  22009. /**
  22010. * Syncrhonize the targets with all the meshes using this morph target manager
  22011. */
  22012. synchronize(): void;
  22013. /**
  22014. * Creates a new MorphTargetManager from serialized data
  22015. * @param serializationObject defines the serialized data
  22016. * @param scene defines the hosting scene
  22017. * @returns the new MorphTargetManager
  22018. */
  22019. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22020. }
  22021. }
  22022. declare module BABYLON {
  22023. /**
  22024. * Class used to represent a specific level of detail of a mesh
  22025. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22026. */
  22027. export class MeshLODLevel {
  22028. /** Defines the distance where this level should start being displayed */
  22029. distance: number;
  22030. /** Defines the mesh to use to render this level */
  22031. mesh: Nullable<Mesh>;
  22032. /**
  22033. * Creates a new LOD level
  22034. * @param distance defines the distance where this level should star being displayed
  22035. * @param mesh defines the mesh to use to render this level
  22036. */
  22037. constructor(
  22038. /** Defines the distance where this level should start being displayed */
  22039. distance: number,
  22040. /** Defines the mesh to use to render this level */
  22041. mesh: Nullable<Mesh>);
  22042. }
  22043. }
  22044. declare module BABYLON {
  22045. /**
  22046. * Mesh representing the gorund
  22047. */
  22048. export class GroundMesh extends Mesh {
  22049. /** If octree should be generated */
  22050. generateOctree: boolean;
  22051. private _heightQuads;
  22052. /** @hidden */ private _subdivisionsX: number;
  22053. /** @hidden */ private _subdivisionsY: number;
  22054. /** @hidden */ private _width: number;
  22055. /** @hidden */ private _height: number;
  22056. /** @hidden */ private _minX: number;
  22057. /** @hidden */ private _maxX: number;
  22058. /** @hidden */ private _minZ: number;
  22059. /** @hidden */ private _maxZ: number;
  22060. constructor(name: string, scene: Scene);
  22061. /**
  22062. * "GroundMesh"
  22063. * @returns "GroundMesh"
  22064. */
  22065. getClassName(): string;
  22066. /**
  22067. * The minimum of x and y subdivisions
  22068. */
  22069. readonly subdivisions: number;
  22070. /**
  22071. * X subdivisions
  22072. */
  22073. readonly subdivisionsX: number;
  22074. /**
  22075. * Y subdivisions
  22076. */
  22077. readonly subdivisionsY: number;
  22078. /**
  22079. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22080. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22081. * @param chunksCount the number of subdivisions for x and y
  22082. * @param octreeBlocksSize (Default: 32)
  22083. */
  22084. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22085. /**
  22086. * Returns a height (y) value in the Worl system :
  22087. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22088. * @param x x coordinate
  22089. * @param z z coordinate
  22090. * @returns the ground y position if (x, z) are outside the ground surface.
  22091. */
  22092. getHeightAtCoordinates(x: number, z: number): number;
  22093. /**
  22094. * Returns a normalized vector (Vector3) orthogonal to the ground
  22095. * at the ground coordinates (x, z) expressed in the World system.
  22096. * @param x x coordinate
  22097. * @param z z coordinate
  22098. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22099. */
  22100. getNormalAtCoordinates(x: number, z: number): Vector3;
  22101. /**
  22102. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22103. * at the ground coordinates (x, z) expressed in the World system.
  22104. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22105. * @param x x coordinate
  22106. * @param z z coordinate
  22107. * @param ref vector to store the result
  22108. * @returns the GroundMesh.
  22109. */
  22110. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22111. /**
  22112. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22113. * if the ground has been updated.
  22114. * This can be used in the render loop.
  22115. * @returns the GroundMesh.
  22116. */
  22117. updateCoordinateHeights(): GroundMesh;
  22118. private _getFacetAt;
  22119. private _initHeightQuads;
  22120. private _computeHeightQuads;
  22121. /**
  22122. * Serializes this ground mesh
  22123. * @param serializationObject object to write serialization to
  22124. */
  22125. serialize(serializationObject: any): void;
  22126. /**
  22127. * Parses a serialized ground mesh
  22128. * @param parsedMesh the serialized mesh
  22129. * @param scene the scene to create the ground mesh in
  22130. * @returns the created ground mesh
  22131. */
  22132. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22133. }
  22134. }
  22135. declare module BABYLON {
  22136. /**
  22137. * Interface for Physics-Joint data
  22138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22139. */
  22140. export interface PhysicsJointData {
  22141. /**
  22142. * The main pivot of the joint
  22143. */
  22144. mainPivot?: Vector3;
  22145. /**
  22146. * The connected pivot of the joint
  22147. */
  22148. connectedPivot?: Vector3;
  22149. /**
  22150. * The main axis of the joint
  22151. */
  22152. mainAxis?: Vector3;
  22153. /**
  22154. * The connected axis of the joint
  22155. */
  22156. connectedAxis?: Vector3;
  22157. /**
  22158. * The collision of the joint
  22159. */
  22160. collision?: boolean;
  22161. /**
  22162. * Native Oimo/Cannon/Energy data
  22163. */
  22164. nativeParams?: any;
  22165. }
  22166. /**
  22167. * This is a holder class for the physics joint created by the physics plugin
  22168. * It holds a set of functions to control the underlying joint
  22169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22170. */
  22171. export class PhysicsJoint {
  22172. /**
  22173. * The type of the physics joint
  22174. */
  22175. type: number;
  22176. /**
  22177. * The data for the physics joint
  22178. */
  22179. jointData: PhysicsJointData;
  22180. private _physicsJoint;
  22181. protected _physicsPlugin: IPhysicsEnginePlugin;
  22182. /**
  22183. * Initializes the physics joint
  22184. * @param type The type of the physics joint
  22185. * @param jointData The data for the physics joint
  22186. */
  22187. constructor(
  22188. /**
  22189. * The type of the physics joint
  22190. */
  22191. type: number,
  22192. /**
  22193. * The data for the physics joint
  22194. */
  22195. jointData: PhysicsJointData);
  22196. /**
  22197. * Gets the physics joint
  22198. */
  22199. /**
  22200. * Sets the physics joint
  22201. */
  22202. physicsJoint: any;
  22203. /**
  22204. * Sets the physics plugin
  22205. */
  22206. physicsPlugin: IPhysicsEnginePlugin;
  22207. /**
  22208. * Execute a function that is physics-plugin specific.
  22209. * @param {Function} func the function that will be executed.
  22210. * It accepts two parameters: the physics world and the physics joint
  22211. */
  22212. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22213. /**
  22214. * Distance-Joint type
  22215. */
  22216. static DistanceJoint: number;
  22217. /**
  22218. * Hinge-Joint type
  22219. */
  22220. static HingeJoint: number;
  22221. /**
  22222. * Ball-and-Socket joint type
  22223. */
  22224. static BallAndSocketJoint: number;
  22225. /**
  22226. * Wheel-Joint type
  22227. */
  22228. static WheelJoint: number;
  22229. /**
  22230. * Slider-Joint type
  22231. */
  22232. static SliderJoint: number;
  22233. /**
  22234. * Prismatic-Joint type
  22235. */
  22236. static PrismaticJoint: number;
  22237. /**
  22238. * Universal-Joint type
  22239. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22240. */
  22241. static UniversalJoint: number;
  22242. /**
  22243. * Hinge-Joint 2 type
  22244. */
  22245. static Hinge2Joint: number;
  22246. /**
  22247. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22248. */
  22249. static PointToPointJoint: number;
  22250. /**
  22251. * Spring-Joint type
  22252. */
  22253. static SpringJoint: number;
  22254. /**
  22255. * Lock-Joint type
  22256. */
  22257. static LockJoint: number;
  22258. }
  22259. /**
  22260. * A class representing a physics distance joint
  22261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22262. */
  22263. export class DistanceJoint extends PhysicsJoint {
  22264. /**
  22265. *
  22266. * @param jointData The data for the Distance-Joint
  22267. */
  22268. constructor(jointData: DistanceJointData);
  22269. /**
  22270. * Update the predefined distance.
  22271. * @param maxDistance The maximum preferred distance
  22272. * @param minDistance The minimum preferred distance
  22273. */
  22274. updateDistance(maxDistance: number, minDistance?: number): void;
  22275. }
  22276. /**
  22277. * Represents a Motor-Enabled Joint
  22278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22279. */
  22280. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22281. /**
  22282. * Initializes the Motor-Enabled Joint
  22283. * @param type The type of the joint
  22284. * @param jointData The physica joint data for the joint
  22285. */
  22286. constructor(type: number, jointData: PhysicsJointData);
  22287. /**
  22288. * Set the motor values.
  22289. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22290. * @param force the force to apply
  22291. * @param maxForce max force for this motor.
  22292. */
  22293. setMotor(force?: number, maxForce?: number): void;
  22294. /**
  22295. * Set the motor's limits.
  22296. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22297. * @param upperLimit The upper limit of the motor
  22298. * @param lowerLimit The lower limit of the motor
  22299. */
  22300. setLimit(upperLimit: number, lowerLimit?: number): void;
  22301. }
  22302. /**
  22303. * This class represents a single physics Hinge-Joint
  22304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22305. */
  22306. export class HingeJoint extends MotorEnabledJoint {
  22307. /**
  22308. * Initializes the Hinge-Joint
  22309. * @param jointData The joint data for the Hinge-Joint
  22310. */
  22311. constructor(jointData: PhysicsJointData);
  22312. /**
  22313. * Set the motor values.
  22314. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22315. * @param {number} force the force to apply
  22316. * @param {number} maxForce max force for this motor.
  22317. */
  22318. setMotor(force?: number, maxForce?: number): void;
  22319. /**
  22320. * Set the motor's limits.
  22321. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22322. * @param upperLimit The upper limit of the motor
  22323. * @param lowerLimit The lower limit of the motor
  22324. */
  22325. setLimit(upperLimit: number, lowerLimit?: number): void;
  22326. }
  22327. /**
  22328. * This class represents a dual hinge physics joint (same as wheel joint)
  22329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22330. */
  22331. export class Hinge2Joint extends MotorEnabledJoint {
  22332. /**
  22333. * Initializes the Hinge2-Joint
  22334. * @param jointData The joint data for the Hinge2-Joint
  22335. */
  22336. constructor(jointData: PhysicsJointData);
  22337. /**
  22338. * Set the motor values.
  22339. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22340. * @param {number} targetSpeed the speed the motor is to reach
  22341. * @param {number} maxForce max force for this motor.
  22342. * @param {motorIndex} the motor's index, 0 or 1.
  22343. */
  22344. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22345. /**
  22346. * Set the motor limits.
  22347. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22348. * @param {number} upperLimit the upper limit
  22349. * @param {number} lowerLimit lower limit
  22350. * @param {motorIndex} the motor's index, 0 or 1.
  22351. */
  22352. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22353. }
  22354. /**
  22355. * Interface for a motor enabled joint
  22356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22357. */
  22358. export interface IMotorEnabledJoint {
  22359. /**
  22360. * Physics joint
  22361. */
  22362. physicsJoint: any;
  22363. /**
  22364. * Sets the motor of the motor-enabled joint
  22365. * @param force The force of the motor
  22366. * @param maxForce The maximum force of the motor
  22367. * @param motorIndex The index of the motor
  22368. */
  22369. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22370. /**
  22371. * Sets the limit of the motor
  22372. * @param upperLimit The upper limit of the motor
  22373. * @param lowerLimit The lower limit of the motor
  22374. * @param motorIndex The index of the motor
  22375. */
  22376. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22377. }
  22378. /**
  22379. * Joint data for a Distance-Joint
  22380. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22381. */
  22382. export interface DistanceJointData extends PhysicsJointData {
  22383. /**
  22384. * Max distance the 2 joint objects can be apart
  22385. */
  22386. maxDistance: number;
  22387. }
  22388. /**
  22389. * Joint data from a spring joint
  22390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22391. */
  22392. export interface SpringJointData extends PhysicsJointData {
  22393. /**
  22394. * Length of the spring
  22395. */
  22396. length: number;
  22397. /**
  22398. * Stiffness of the spring
  22399. */
  22400. stiffness: number;
  22401. /**
  22402. * Damping of the spring
  22403. */
  22404. damping: number;
  22405. /** this callback will be called when applying the force to the impostors. */
  22406. forceApplicationCallback: () => void;
  22407. }
  22408. }
  22409. declare module BABYLON {
  22410. /**
  22411. * Holds the data for the raycast result
  22412. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22413. */
  22414. export class PhysicsRaycastResult {
  22415. private _hasHit;
  22416. private _hitDistance;
  22417. private _hitNormalWorld;
  22418. private _hitPointWorld;
  22419. private _rayFromWorld;
  22420. private _rayToWorld;
  22421. /**
  22422. * Gets if there was a hit
  22423. */
  22424. readonly hasHit: boolean;
  22425. /**
  22426. * Gets the distance from the hit
  22427. */
  22428. readonly hitDistance: number;
  22429. /**
  22430. * Gets the hit normal/direction in the world
  22431. */
  22432. readonly hitNormalWorld: Vector3;
  22433. /**
  22434. * Gets the hit point in the world
  22435. */
  22436. readonly hitPointWorld: Vector3;
  22437. /**
  22438. * Gets the ray "start point" of the ray in the world
  22439. */
  22440. readonly rayFromWorld: Vector3;
  22441. /**
  22442. * Gets the ray "end point" of the ray in the world
  22443. */
  22444. readonly rayToWorld: Vector3;
  22445. /**
  22446. * Sets the hit data (normal & point in world space)
  22447. * @param hitNormalWorld defines the normal in world space
  22448. * @param hitPointWorld defines the point in world space
  22449. */
  22450. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22451. /**
  22452. * Sets the distance from the start point to the hit point
  22453. * @param distance
  22454. */
  22455. setHitDistance(distance: number): void;
  22456. /**
  22457. * Calculates the distance manually
  22458. */
  22459. calculateHitDistance(): void;
  22460. /**
  22461. * Resets all the values to default
  22462. * @param from The from point on world space
  22463. * @param to The to point on world space
  22464. */
  22465. reset(from?: Vector3, to?: Vector3): void;
  22466. }
  22467. /**
  22468. * Interface for the size containing width and height
  22469. */
  22470. interface IXYZ {
  22471. /**
  22472. * X
  22473. */
  22474. x: number;
  22475. /**
  22476. * Y
  22477. */
  22478. y: number;
  22479. /**
  22480. * Z
  22481. */
  22482. z: number;
  22483. }
  22484. }
  22485. declare module BABYLON {
  22486. /**
  22487. * Interface used to describe a physics joint
  22488. */
  22489. export interface PhysicsImpostorJoint {
  22490. /** Defines the main impostor to which the joint is linked */
  22491. mainImpostor: PhysicsImpostor;
  22492. /** Defines the impostor that is connected to the main impostor using this joint */
  22493. connectedImpostor: PhysicsImpostor;
  22494. /** Defines the joint itself */
  22495. joint: PhysicsJoint;
  22496. }
  22497. /** @hidden */
  22498. export interface IPhysicsEnginePlugin {
  22499. world: any;
  22500. name: string;
  22501. setGravity(gravity: Vector3): void;
  22502. setTimeStep(timeStep: number): void;
  22503. getTimeStep(): number;
  22504. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22505. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22506. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22507. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22508. removePhysicsBody(impostor: PhysicsImpostor): void;
  22509. generateJoint(joint: PhysicsImpostorJoint): void;
  22510. removeJoint(joint: PhysicsImpostorJoint): void;
  22511. isSupported(): boolean;
  22512. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22513. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22514. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22515. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22516. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22517. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22518. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22519. getBodyMass(impostor: PhysicsImpostor): number;
  22520. getBodyFriction(impostor: PhysicsImpostor): number;
  22521. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22522. getBodyRestitution(impostor: PhysicsImpostor): number;
  22523. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22524. getBodyPressure?(impostor: PhysicsImpostor): number;
  22525. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22526. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22527. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22528. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22529. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22530. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22531. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22532. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22533. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22534. sleepBody(impostor: PhysicsImpostor): void;
  22535. wakeUpBody(impostor: PhysicsImpostor): void;
  22536. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22537. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22538. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22539. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22540. getRadius(impostor: PhysicsImpostor): number;
  22541. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22542. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22543. dispose(): void;
  22544. }
  22545. /**
  22546. * Interface used to define a physics engine
  22547. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22548. */
  22549. export interface IPhysicsEngine {
  22550. /**
  22551. * Gets the gravity vector used by the simulation
  22552. */
  22553. gravity: Vector3;
  22554. /**
  22555. * Sets the gravity vector used by the simulation
  22556. * @param gravity defines the gravity vector to use
  22557. */
  22558. setGravity(gravity: Vector3): void;
  22559. /**
  22560. * Set the time step of the physics engine.
  22561. * Default is 1/60.
  22562. * To slow it down, enter 1/600 for example.
  22563. * To speed it up, 1/30
  22564. * @param newTimeStep the new timestep to apply to this world.
  22565. */
  22566. setTimeStep(newTimeStep: number): void;
  22567. /**
  22568. * Get the time step of the physics engine.
  22569. * @returns the current time step
  22570. */
  22571. getTimeStep(): number;
  22572. /**
  22573. * Release all resources
  22574. */
  22575. dispose(): void;
  22576. /**
  22577. * Gets the name of the current physics plugin
  22578. * @returns the name of the plugin
  22579. */
  22580. getPhysicsPluginName(): string;
  22581. /**
  22582. * Adding a new impostor for the impostor tracking.
  22583. * This will be done by the impostor itself.
  22584. * @param impostor the impostor to add
  22585. */
  22586. addImpostor(impostor: PhysicsImpostor): void;
  22587. /**
  22588. * Remove an impostor from the engine.
  22589. * This impostor and its mesh will not longer be updated by the physics engine.
  22590. * @param impostor the impostor to remove
  22591. */
  22592. removeImpostor(impostor: PhysicsImpostor): void;
  22593. /**
  22594. * Add a joint to the physics engine
  22595. * @param mainImpostor defines the main impostor to which the joint is added.
  22596. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22597. * @param joint defines the joint that will connect both impostors.
  22598. */
  22599. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22600. /**
  22601. * Removes a joint from the simulation
  22602. * @param mainImpostor defines the impostor used with the joint
  22603. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22604. * @param joint defines the joint to remove
  22605. */
  22606. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22607. /**
  22608. * Gets the current plugin used to run the simulation
  22609. * @returns current plugin
  22610. */
  22611. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22612. /**
  22613. * Gets the list of physic impostors
  22614. * @returns an array of PhysicsImpostor
  22615. */
  22616. getImpostors(): Array<PhysicsImpostor>;
  22617. /**
  22618. * Gets the impostor for a physics enabled object
  22619. * @param object defines the object impersonated by the impostor
  22620. * @returns the PhysicsImpostor or null if not found
  22621. */
  22622. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22623. /**
  22624. * Gets the impostor for a physics body object
  22625. * @param body defines physics body used by the impostor
  22626. * @returns the PhysicsImpostor or null if not found
  22627. */
  22628. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22629. /**
  22630. * Does a raycast in the physics world
  22631. * @param from when should the ray start?
  22632. * @param to when should the ray end?
  22633. * @returns PhysicsRaycastResult
  22634. */
  22635. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22636. /**
  22637. * Called by the scene. No need to call it.
  22638. * @param delta defines the timespam between frames
  22639. */ private _step(delta: number): void;
  22640. }
  22641. }
  22642. declare module BABYLON {
  22643. /**
  22644. * The interface for the physics imposter parameters
  22645. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22646. */
  22647. export interface PhysicsImpostorParameters {
  22648. /**
  22649. * The mass of the physics imposter
  22650. */
  22651. mass: number;
  22652. /**
  22653. * The friction of the physics imposter
  22654. */
  22655. friction?: number;
  22656. /**
  22657. * The coefficient of restitution of the physics imposter
  22658. */
  22659. restitution?: number;
  22660. /**
  22661. * The native options of the physics imposter
  22662. */
  22663. nativeOptions?: any;
  22664. /**
  22665. * Specifies if the parent should be ignored
  22666. */
  22667. ignoreParent?: boolean;
  22668. /**
  22669. * Specifies if bi-directional transformations should be disabled
  22670. */
  22671. disableBidirectionalTransformation?: boolean;
  22672. /**
  22673. * The pressure inside the physics imposter, soft object only
  22674. */
  22675. pressure?: number;
  22676. /**
  22677. * The stiffness the physics imposter, soft object only
  22678. */
  22679. stiffness?: number;
  22680. /**
  22681. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22682. */
  22683. velocityIterations?: number;
  22684. /**
  22685. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22686. */
  22687. positionIterations?: number;
  22688. /**
  22689. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22690. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22691. * Add to fix multiple points
  22692. */
  22693. fixedPoints?: number;
  22694. /**
  22695. * The collision margin around a soft object
  22696. */
  22697. margin?: number;
  22698. /**
  22699. * The collision margin around a soft object
  22700. */
  22701. damping?: number;
  22702. /**
  22703. * The path for a rope based on an extrusion
  22704. */
  22705. path?: any;
  22706. /**
  22707. * The shape of an extrusion used for a rope based on an extrusion
  22708. */
  22709. shape?: any;
  22710. }
  22711. /**
  22712. * Interface for a physics-enabled object
  22713. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22714. */
  22715. export interface IPhysicsEnabledObject {
  22716. /**
  22717. * The position of the physics-enabled object
  22718. */
  22719. position: Vector3;
  22720. /**
  22721. * The rotation of the physics-enabled object
  22722. */
  22723. rotationQuaternion: Nullable<Quaternion>;
  22724. /**
  22725. * The scale of the physics-enabled object
  22726. */
  22727. scaling: Vector3;
  22728. /**
  22729. * The rotation of the physics-enabled object
  22730. */
  22731. rotation?: Vector3;
  22732. /**
  22733. * The parent of the physics-enabled object
  22734. */
  22735. parent?: any;
  22736. /**
  22737. * The bounding info of the physics-enabled object
  22738. * @returns The bounding info of the physics-enabled object
  22739. */
  22740. getBoundingInfo(): BoundingInfo;
  22741. /**
  22742. * Computes the world matrix
  22743. * @param force Specifies if the world matrix should be computed by force
  22744. * @returns A world matrix
  22745. */
  22746. computeWorldMatrix(force: boolean): Matrix;
  22747. /**
  22748. * Gets the world matrix
  22749. * @returns A world matrix
  22750. */
  22751. getWorldMatrix?(): Matrix;
  22752. /**
  22753. * Gets the child meshes
  22754. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22755. * @returns An array of abstract meshes
  22756. */
  22757. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22758. /**
  22759. * Gets the vertex data
  22760. * @param kind The type of vertex data
  22761. * @returns A nullable array of numbers, or a float32 array
  22762. */
  22763. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22764. /**
  22765. * Gets the indices from the mesh
  22766. * @returns A nullable array of index arrays
  22767. */
  22768. getIndices?(): Nullable<IndicesArray>;
  22769. /**
  22770. * Gets the scene from the mesh
  22771. * @returns the indices array or null
  22772. */
  22773. getScene?(): Scene;
  22774. /**
  22775. * Gets the absolute position from the mesh
  22776. * @returns the absolute position
  22777. */
  22778. getAbsolutePosition(): Vector3;
  22779. /**
  22780. * Gets the absolute pivot point from the mesh
  22781. * @returns the absolute pivot point
  22782. */
  22783. getAbsolutePivotPoint(): Vector3;
  22784. /**
  22785. * Rotates the mesh
  22786. * @param axis The axis of rotation
  22787. * @param amount The amount of rotation
  22788. * @param space The space of the rotation
  22789. * @returns The rotation transform node
  22790. */
  22791. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22792. /**
  22793. * Translates the mesh
  22794. * @param axis The axis of translation
  22795. * @param distance The distance of translation
  22796. * @param space The space of the translation
  22797. * @returns The transform node
  22798. */
  22799. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22800. /**
  22801. * Sets the absolute position of the mesh
  22802. * @param absolutePosition The absolute position of the mesh
  22803. * @returns The transform node
  22804. */
  22805. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22806. /**
  22807. * Gets the class name of the mesh
  22808. * @returns The class name
  22809. */
  22810. getClassName(): string;
  22811. }
  22812. /**
  22813. * Represents a physics imposter
  22814. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22815. */
  22816. export class PhysicsImpostor {
  22817. /**
  22818. * The physics-enabled object used as the physics imposter
  22819. */
  22820. object: IPhysicsEnabledObject;
  22821. /**
  22822. * The type of the physics imposter
  22823. */
  22824. type: number;
  22825. private _options;
  22826. private _scene?;
  22827. /**
  22828. * The default object size of the imposter
  22829. */
  22830. static DEFAULT_OBJECT_SIZE: Vector3;
  22831. /**
  22832. * The identity quaternion of the imposter
  22833. */
  22834. static IDENTITY_QUATERNION: Quaternion;
  22835. /** @hidden */ private _pluginData: any;
  22836. private _physicsEngine;
  22837. private _physicsBody;
  22838. private _bodyUpdateRequired;
  22839. private _onBeforePhysicsStepCallbacks;
  22840. private _onAfterPhysicsStepCallbacks;
  22841. /** @hidden */ private _onPhysicsCollideCallbacks: Array<{
  22842. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22843. otherImpostors: Array<PhysicsImpostor>;
  22844. }>;
  22845. private _deltaPosition;
  22846. private _deltaRotation;
  22847. private _deltaRotationConjugated;
  22848. /** @hidden */ private _isFromLine: boolean;
  22849. private _parent;
  22850. private _isDisposed;
  22851. private static _tmpVecs;
  22852. private static _tmpQuat;
  22853. /**
  22854. * Specifies if the physics imposter is disposed
  22855. */
  22856. readonly isDisposed: boolean;
  22857. /**
  22858. * Gets the mass of the physics imposter
  22859. */
  22860. mass: number;
  22861. /**
  22862. * Gets the coefficient of friction
  22863. */
  22864. /**
  22865. * Sets the coefficient of friction
  22866. */
  22867. friction: number;
  22868. /**
  22869. * Gets the coefficient of restitution
  22870. */
  22871. /**
  22872. * Sets the coefficient of restitution
  22873. */
  22874. restitution: number;
  22875. /**
  22876. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22877. */
  22878. /**
  22879. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22880. */
  22881. pressure: number;
  22882. /**
  22883. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22884. */
  22885. /**
  22886. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22887. */
  22888. stiffness: number;
  22889. /**
  22890. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22891. */
  22892. /**
  22893. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22894. */
  22895. velocityIterations: number;
  22896. /**
  22897. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22898. */
  22899. /**
  22900. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22901. */
  22902. positionIterations: number;
  22903. /**
  22904. * The unique id of the physics imposter
  22905. * set by the physics engine when adding this impostor to the array
  22906. */
  22907. uniqueId: number;
  22908. /**
  22909. * @hidden
  22910. */
  22911. soft: boolean;
  22912. /**
  22913. * @hidden
  22914. */
  22915. segments: number;
  22916. private _joints;
  22917. /**
  22918. * Initializes the physics imposter
  22919. * @param object The physics-enabled object used as the physics imposter
  22920. * @param type The type of the physics imposter
  22921. * @param _options The options for the physics imposter
  22922. * @param _scene The Babylon scene
  22923. */
  22924. constructor(
  22925. /**
  22926. * The physics-enabled object used as the physics imposter
  22927. */
  22928. object: IPhysicsEnabledObject,
  22929. /**
  22930. * The type of the physics imposter
  22931. */
  22932. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22933. /**
  22934. * This function will completly initialize this impostor.
  22935. * It will create a new body - but only if this mesh has no parent.
  22936. * If it has, this impostor will not be used other than to define the impostor
  22937. * of the child mesh.
  22938. * @hidden
  22939. */ private _init(): void;
  22940. private _getPhysicsParent;
  22941. /**
  22942. * Should a new body be generated.
  22943. * @returns boolean specifying if body initialization is required
  22944. */
  22945. isBodyInitRequired(): boolean;
  22946. /**
  22947. * Sets the updated scaling
  22948. * @param updated Specifies if the scaling is updated
  22949. */
  22950. setScalingUpdated(): void;
  22951. /**
  22952. * Force a regeneration of this or the parent's impostor's body.
  22953. * Use under cautious - This will remove all joints already implemented.
  22954. */
  22955. forceUpdate(): void;
  22956. /**
  22957. * Gets the body that holds this impostor. Either its own, or its parent.
  22958. */
  22959. /**
  22960. * Set the physics body. Used mainly by the physics engine/plugin
  22961. */
  22962. physicsBody: any;
  22963. /**
  22964. * Get the parent of the physics imposter
  22965. * @returns Physics imposter or null
  22966. */
  22967. /**
  22968. * Sets the parent of the physics imposter
  22969. */
  22970. parent: Nullable<PhysicsImpostor>;
  22971. /**
  22972. * Resets the update flags
  22973. */
  22974. resetUpdateFlags(): void;
  22975. /**
  22976. * Gets the object extend size
  22977. * @returns the object extend size
  22978. */
  22979. getObjectExtendSize(): Vector3;
  22980. /**
  22981. * Gets the object center
  22982. * @returns The object center
  22983. */
  22984. getObjectCenter(): Vector3;
  22985. /**
  22986. * Get a specific parametes from the options parameter
  22987. * @param paramName The object parameter name
  22988. * @returns The object parameter
  22989. */
  22990. getParam(paramName: string): any;
  22991. /**
  22992. * Sets a specific parameter in the options given to the physics plugin
  22993. * @param paramName The parameter name
  22994. * @param value The value of the parameter
  22995. */
  22996. setParam(paramName: string, value: number): void;
  22997. /**
  22998. * Specifically change the body's mass option. Won't recreate the physics body object
  22999. * @param mass The mass of the physics imposter
  23000. */
  23001. setMass(mass: number): void;
  23002. /**
  23003. * Gets the linear velocity
  23004. * @returns linear velocity or null
  23005. */
  23006. getLinearVelocity(): Nullable<Vector3>;
  23007. /**
  23008. * Sets the linear velocity
  23009. * @param velocity linear velocity or null
  23010. */
  23011. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23012. /**
  23013. * Gets the angular velocity
  23014. * @returns angular velocity or null
  23015. */
  23016. getAngularVelocity(): Nullable<Vector3>;
  23017. /**
  23018. * Sets the angular velocity
  23019. * @param velocity The velocity or null
  23020. */
  23021. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23022. /**
  23023. * Execute a function with the physics plugin native code
  23024. * Provide a function the will have two variables - the world object and the physics body object
  23025. * @param func The function to execute with the physics plugin native code
  23026. */
  23027. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23028. /**
  23029. * Register a function that will be executed before the physics world is stepping forward
  23030. * @param func The function to execute before the physics world is stepped forward
  23031. */
  23032. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23033. /**
  23034. * Unregister a function that will be executed before the physics world is stepping forward
  23035. * @param func The function to execute before the physics world is stepped forward
  23036. */
  23037. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23038. /**
  23039. * Register a function that will be executed after the physics step
  23040. * @param func The function to execute after physics step
  23041. */
  23042. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23043. /**
  23044. * Unregisters a function that will be executed after the physics step
  23045. * @param func The function to execute after physics step
  23046. */
  23047. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23048. /**
  23049. * register a function that will be executed when this impostor collides against a different body
  23050. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23051. * @param func Callback that is executed on collision
  23052. */
  23053. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23054. /**
  23055. * Unregisters the physics imposter on contact
  23056. * @param collideAgainst The physics object to collide against
  23057. * @param func Callback to execute on collision
  23058. */
  23059. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23060. private _tmpQuat;
  23061. private _tmpQuat2;
  23062. /**
  23063. * Get the parent rotation
  23064. * @returns The parent rotation
  23065. */
  23066. getParentsRotation(): Quaternion;
  23067. /**
  23068. * this function is executed by the physics engine.
  23069. */
  23070. beforeStep: () => void;
  23071. /**
  23072. * this function is executed by the physics engine
  23073. */
  23074. afterStep: () => void;
  23075. /**
  23076. * Legacy collision detection event support
  23077. */
  23078. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23079. /**
  23080. * event and body object due to cannon's event-based architecture.
  23081. */
  23082. onCollide: (e: {
  23083. body: any;
  23084. }) => void;
  23085. /**
  23086. * Apply a force
  23087. * @param force The force to apply
  23088. * @param contactPoint The contact point for the force
  23089. * @returns The physics imposter
  23090. */
  23091. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23092. /**
  23093. * Apply an impulse
  23094. * @param force The impulse force
  23095. * @param contactPoint The contact point for the impulse force
  23096. * @returns The physics imposter
  23097. */
  23098. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23099. /**
  23100. * A help function to create a joint
  23101. * @param otherImpostor A physics imposter used to create a joint
  23102. * @param jointType The type of joint
  23103. * @param jointData The data for the joint
  23104. * @returns The physics imposter
  23105. */
  23106. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23107. /**
  23108. * Add a joint to this impostor with a different impostor
  23109. * @param otherImpostor A physics imposter used to add a joint
  23110. * @param joint The joint to add
  23111. * @returns The physics imposter
  23112. */
  23113. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23114. /**
  23115. * Add an anchor to a cloth impostor
  23116. * @param otherImpostor rigid impostor to anchor to
  23117. * @param width ratio across width from 0 to 1
  23118. * @param height ratio up height from 0 to 1
  23119. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23120. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23121. * @returns impostor the soft imposter
  23122. */
  23123. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23124. /**
  23125. * Add a hook to a rope impostor
  23126. * @param otherImpostor rigid impostor to anchor to
  23127. * @param length ratio across rope from 0 to 1
  23128. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23129. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23130. * @returns impostor the rope imposter
  23131. */
  23132. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23133. /**
  23134. * Will keep this body still, in a sleep mode.
  23135. * @returns the physics imposter
  23136. */
  23137. sleep(): PhysicsImpostor;
  23138. /**
  23139. * Wake the body up.
  23140. * @returns The physics imposter
  23141. */
  23142. wakeUp(): PhysicsImpostor;
  23143. /**
  23144. * Clones the physics imposter
  23145. * @param newObject The physics imposter clones to this physics-enabled object
  23146. * @returns A nullable physics imposter
  23147. */
  23148. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23149. /**
  23150. * Disposes the physics imposter
  23151. */
  23152. dispose(): void;
  23153. /**
  23154. * Sets the delta position
  23155. * @param position The delta position amount
  23156. */
  23157. setDeltaPosition(position: Vector3): void;
  23158. /**
  23159. * Sets the delta rotation
  23160. * @param rotation The delta rotation amount
  23161. */
  23162. setDeltaRotation(rotation: Quaternion): void;
  23163. /**
  23164. * Gets the box size of the physics imposter and stores the result in the input parameter
  23165. * @param result Stores the box size
  23166. * @returns The physics imposter
  23167. */
  23168. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23169. /**
  23170. * Gets the radius of the physics imposter
  23171. * @returns Radius of the physics imposter
  23172. */
  23173. getRadius(): number;
  23174. /**
  23175. * Sync a bone with this impostor
  23176. * @param bone The bone to sync to the impostor.
  23177. * @param boneMesh The mesh that the bone is influencing.
  23178. * @param jointPivot The pivot of the joint / bone in local space.
  23179. * @param distToJoint Optional distance from the impostor to the joint.
  23180. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23181. */
  23182. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23183. /**
  23184. * Sync impostor to a bone
  23185. * @param bone The bone that the impostor will be synced to.
  23186. * @param boneMesh The mesh that the bone is influencing.
  23187. * @param jointPivot The pivot of the joint / bone in local space.
  23188. * @param distToJoint Optional distance from the impostor to the joint.
  23189. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23190. * @param boneAxis Optional vector3 axis the bone is aligned with
  23191. */
  23192. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23193. /**
  23194. * No-Imposter type
  23195. */
  23196. static NoImpostor: number;
  23197. /**
  23198. * Sphere-Imposter type
  23199. */
  23200. static SphereImpostor: number;
  23201. /**
  23202. * Box-Imposter type
  23203. */
  23204. static BoxImpostor: number;
  23205. /**
  23206. * Plane-Imposter type
  23207. */
  23208. static PlaneImpostor: number;
  23209. /**
  23210. * Mesh-imposter type
  23211. */
  23212. static MeshImpostor: number;
  23213. /**
  23214. * Capsule-Impostor type (Ammo.js plugin only)
  23215. */
  23216. static CapsuleImpostor: number;
  23217. /**
  23218. * Cylinder-Imposter type
  23219. */
  23220. static CylinderImpostor: number;
  23221. /**
  23222. * Particle-Imposter type
  23223. */
  23224. static ParticleImpostor: number;
  23225. /**
  23226. * Heightmap-Imposter type
  23227. */
  23228. static HeightmapImpostor: number;
  23229. /**
  23230. * ConvexHull-Impostor type (Ammo.js plugin only)
  23231. */
  23232. static ConvexHullImpostor: number;
  23233. /**
  23234. * Rope-Imposter type
  23235. */
  23236. static RopeImpostor: number;
  23237. /**
  23238. * Cloth-Imposter type
  23239. */
  23240. static ClothImpostor: number;
  23241. /**
  23242. * Softbody-Imposter type
  23243. */
  23244. static SoftbodyImpostor: number;
  23245. }
  23246. }
  23247. declare module BABYLON {
  23248. /**
  23249. * @hidden
  23250. **/
  23251. export class _CreationDataStorage {
  23252. closePath?: boolean;
  23253. closeArray?: boolean;
  23254. idx: number[];
  23255. dashSize: number;
  23256. gapSize: number;
  23257. path3D: Path3D;
  23258. pathArray: Vector3[][];
  23259. arc: number;
  23260. radius: number;
  23261. cap: number;
  23262. tessellation: number;
  23263. }
  23264. /**
  23265. * @hidden
  23266. **/ private class _InstanceDataStorage {
  23267. visibleInstances: any;
  23268. batchCache: _InstancesBatch;
  23269. instancesBufferSize: number;
  23270. instancesBuffer: Nullable<Buffer>;
  23271. instancesData: Float32Array;
  23272. overridenInstanceCount: number;
  23273. isFrozen: boolean;
  23274. previousBatch: Nullable<_InstancesBatch>;
  23275. hardwareInstancedRendering: boolean;
  23276. sideOrientation: number;
  23277. }
  23278. /**
  23279. * @hidden
  23280. **/
  23281. export class _InstancesBatch {
  23282. mustReturn: boolean;
  23283. visibleInstances: Nullable<InstancedMesh[]>[];
  23284. renderSelf: boolean[];
  23285. hardwareInstancedRendering: boolean[];
  23286. }
  23287. /**
  23288. * Class used to represent renderable models
  23289. */
  23290. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23291. /**
  23292. * Mesh side orientation : usually the external or front surface
  23293. */
  23294. static readonly FRONTSIDE: number;
  23295. /**
  23296. * Mesh side orientation : usually the internal or back surface
  23297. */
  23298. static readonly BACKSIDE: number;
  23299. /**
  23300. * Mesh side orientation : both internal and external or front and back surfaces
  23301. */
  23302. static readonly DOUBLESIDE: number;
  23303. /**
  23304. * Mesh side orientation : by default, `FRONTSIDE`
  23305. */
  23306. static readonly DEFAULTSIDE: number;
  23307. /**
  23308. * Mesh cap setting : no cap
  23309. */
  23310. static readonly NO_CAP: number;
  23311. /**
  23312. * Mesh cap setting : one cap at the beginning of the mesh
  23313. */
  23314. static readonly CAP_START: number;
  23315. /**
  23316. * Mesh cap setting : one cap at the end of the mesh
  23317. */
  23318. static readonly CAP_END: number;
  23319. /**
  23320. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23321. */
  23322. static readonly CAP_ALL: number;
  23323. /**
  23324. * Mesh pattern setting : no flip or rotate
  23325. */
  23326. static readonly NO_FLIP: number;
  23327. /**
  23328. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23329. */
  23330. static readonly FLIP_TILE: number;
  23331. /**
  23332. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23333. */
  23334. static readonly ROTATE_TILE: number;
  23335. /**
  23336. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23337. */
  23338. static readonly FLIP_ROW: number;
  23339. /**
  23340. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23341. */
  23342. static readonly ROTATE_ROW: number;
  23343. /**
  23344. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23345. */
  23346. static readonly FLIP_N_ROTATE_TILE: number;
  23347. /**
  23348. * Mesh pattern setting : rotate pattern and rotate
  23349. */
  23350. static readonly FLIP_N_ROTATE_ROW: number;
  23351. /**
  23352. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23353. */
  23354. static readonly CENTER: number;
  23355. /**
  23356. * Mesh tile positioning : part tiles on left
  23357. */
  23358. static readonly LEFT: number;
  23359. /**
  23360. * Mesh tile positioning : part tiles on right
  23361. */
  23362. static readonly RIGHT: number;
  23363. /**
  23364. * Mesh tile positioning : part tiles on top
  23365. */
  23366. static readonly TOP: number;
  23367. /**
  23368. * Mesh tile positioning : part tiles on bottom
  23369. */
  23370. static readonly BOTTOM: number;
  23371. /**
  23372. * Gets the default side orientation.
  23373. * @param orientation the orientation to value to attempt to get
  23374. * @returns the default orientation
  23375. * @hidden
  23376. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  23377. private _internalMeshDataInfo;
  23378. /**
  23379. * An event triggered before rendering the mesh
  23380. */
  23381. readonly onBeforeRenderObservable: Observable<Mesh>;
  23382. /**
  23383. * An event triggered before binding the mesh
  23384. */
  23385. readonly onBeforeBindObservable: Observable<Mesh>;
  23386. /**
  23387. * An event triggered after rendering the mesh
  23388. */
  23389. readonly onAfterRenderObservable: Observable<Mesh>;
  23390. /**
  23391. * An event triggered before drawing the mesh
  23392. */
  23393. readonly onBeforeDrawObservable: Observable<Mesh>;
  23394. private _onBeforeDrawObserver;
  23395. /**
  23396. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23397. */
  23398. onBeforeDraw: () => void;
  23399. readonly hasInstances: boolean;
  23400. /**
  23401. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23402. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23403. */
  23404. delayLoadState: number;
  23405. /**
  23406. * Gets the list of instances created from this mesh
  23407. * it is not supposed to be modified manually.
  23408. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23409. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23410. */
  23411. instances: InstancedMesh[];
  23412. /**
  23413. * Gets the file containing delay loading data for this mesh
  23414. */
  23415. delayLoadingFile: string;
  23416. /** @hidden */ private _binaryInfo: any;
  23417. /**
  23418. * User defined function used to change how LOD level selection is done
  23419. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23420. */
  23421. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23422. /**
  23423. * Gets or sets the morph target manager
  23424. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23425. */
  23426. morphTargetManager: Nullable<MorphTargetManager>;
  23427. /** @hidden */ private _creationDataStorage: Nullable<_CreationDataStorage>;
  23428. /** @hidden */ private _geometry: Nullable<Geometry>;
  23429. /** @hidden */ private _delayInfo: Array<string>;
  23430. /** @hidden */ private _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23431. /** @hidden */ private _instanceDataStorage: _InstanceDataStorage;
  23432. private _effectiveMaterial;
  23433. /** @hidden */ private _shouldGenerateFlatShading: boolean;
  23434. /** @hidden */ private _originalBuilderSideOrientation: number;
  23435. /**
  23436. * Use this property to change the original side orientation defined at construction time
  23437. */
  23438. overrideMaterialSideOrientation: Nullable<number>;
  23439. /**
  23440. * Gets the source mesh (the one used to clone this one from)
  23441. */
  23442. readonly source: Nullable<Mesh>;
  23443. /**
  23444. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23445. */
  23446. isUnIndexed: boolean;
  23447. /**
  23448. * @constructor
  23449. * @param name The value used by scene.getMeshByName() to do a lookup.
  23450. * @param scene The scene to add this mesh to.
  23451. * @param parent The parent of this mesh, if it has one
  23452. * @param source An optional Mesh from which geometry is shared, cloned.
  23453. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23454. * When false, achieved by calling a clone(), also passing False.
  23455. * This will make creation of children, recursive.
  23456. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23457. */
  23458. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23459. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23460. /**
  23461. * Gets the class name
  23462. * @returns the string "Mesh".
  23463. */
  23464. getClassName(): string;
  23465. /** @hidden */ protected readonly _isMesh: boolean;
  23466. /**
  23467. * Returns a description of this mesh
  23468. * @param fullDetails define if full details about this mesh must be used
  23469. * @returns a descriptive string representing this mesh
  23470. */
  23471. toString(fullDetails?: boolean): string;
  23472. /** @hidden */ private _unBindEffect(): void;
  23473. /**
  23474. * Gets a boolean indicating if this mesh has LOD
  23475. */
  23476. readonly hasLODLevels: boolean;
  23477. /**
  23478. * Gets the list of MeshLODLevel associated with the current mesh
  23479. * @returns an array of MeshLODLevel
  23480. */
  23481. getLODLevels(): MeshLODLevel[];
  23482. private _sortLODLevels;
  23483. /**
  23484. * Add a mesh as LOD level triggered at the given distance.
  23485. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23486. * @param distance The distance from the center of the object to show this level
  23487. * @param mesh The mesh to be added as LOD level (can be null)
  23488. * @return This mesh (for chaining)
  23489. */
  23490. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23491. /**
  23492. * Returns the LOD level mesh at the passed distance or null if not found.
  23493. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23494. * @param distance The distance from the center of the object to show this level
  23495. * @returns a Mesh or `null`
  23496. */
  23497. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23498. /**
  23499. * Remove a mesh from the LOD array
  23500. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23501. * @param mesh defines the mesh to be removed
  23502. * @return This mesh (for chaining)
  23503. */
  23504. removeLODLevel(mesh: Mesh): Mesh;
  23505. /**
  23506. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23507. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23508. * @param camera defines the camera to use to compute distance
  23509. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23510. * @return This mesh (for chaining)
  23511. */
  23512. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23513. /**
  23514. * Gets the mesh internal Geometry object
  23515. */
  23516. readonly geometry: Nullable<Geometry>;
  23517. /**
  23518. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23519. * @returns the total number of vertices
  23520. */
  23521. getTotalVertices(): number;
  23522. /**
  23523. * Returns the content of an associated vertex buffer
  23524. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23525. * - VertexBuffer.PositionKind
  23526. * - VertexBuffer.UVKind
  23527. * - VertexBuffer.UV2Kind
  23528. * - VertexBuffer.UV3Kind
  23529. * - VertexBuffer.UV4Kind
  23530. * - VertexBuffer.UV5Kind
  23531. * - VertexBuffer.UV6Kind
  23532. * - VertexBuffer.ColorKind
  23533. * - VertexBuffer.MatricesIndicesKind
  23534. * - VertexBuffer.MatricesIndicesExtraKind
  23535. * - VertexBuffer.MatricesWeightsKind
  23536. * - VertexBuffer.MatricesWeightsExtraKind
  23537. * @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
  23538. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23539. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23540. */
  23541. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23542. /**
  23543. * Returns the mesh VertexBuffer object from the requested `kind`
  23544. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23545. * - VertexBuffer.PositionKind
  23546. * - VertexBuffer.NormalKind
  23547. * - VertexBuffer.UVKind
  23548. * - VertexBuffer.UV2Kind
  23549. * - VertexBuffer.UV3Kind
  23550. * - VertexBuffer.UV4Kind
  23551. * - VertexBuffer.UV5Kind
  23552. * - VertexBuffer.UV6Kind
  23553. * - VertexBuffer.ColorKind
  23554. * - VertexBuffer.MatricesIndicesKind
  23555. * - VertexBuffer.MatricesIndicesExtraKind
  23556. * - VertexBuffer.MatricesWeightsKind
  23557. * - VertexBuffer.MatricesWeightsExtraKind
  23558. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23559. */
  23560. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23561. /**
  23562. * Tests if a specific vertex buffer is associated with this mesh
  23563. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23564. * - VertexBuffer.PositionKind
  23565. * - VertexBuffer.NormalKind
  23566. * - VertexBuffer.UVKind
  23567. * - VertexBuffer.UV2Kind
  23568. * - VertexBuffer.UV3Kind
  23569. * - VertexBuffer.UV4Kind
  23570. * - VertexBuffer.UV5Kind
  23571. * - VertexBuffer.UV6Kind
  23572. * - VertexBuffer.ColorKind
  23573. * - VertexBuffer.MatricesIndicesKind
  23574. * - VertexBuffer.MatricesIndicesExtraKind
  23575. * - VertexBuffer.MatricesWeightsKind
  23576. * - VertexBuffer.MatricesWeightsExtraKind
  23577. * @returns a boolean
  23578. */
  23579. isVerticesDataPresent(kind: string): boolean;
  23580. /**
  23581. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23582. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23583. * - VertexBuffer.PositionKind
  23584. * - VertexBuffer.UVKind
  23585. * - VertexBuffer.UV2Kind
  23586. * - VertexBuffer.UV3Kind
  23587. * - VertexBuffer.UV4Kind
  23588. * - VertexBuffer.UV5Kind
  23589. * - VertexBuffer.UV6Kind
  23590. * - VertexBuffer.ColorKind
  23591. * - VertexBuffer.MatricesIndicesKind
  23592. * - VertexBuffer.MatricesIndicesExtraKind
  23593. * - VertexBuffer.MatricesWeightsKind
  23594. * - VertexBuffer.MatricesWeightsExtraKind
  23595. * @returns a boolean
  23596. */
  23597. isVertexBufferUpdatable(kind: string): boolean;
  23598. /**
  23599. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23600. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23601. * - VertexBuffer.PositionKind
  23602. * - VertexBuffer.NormalKind
  23603. * - VertexBuffer.UVKind
  23604. * - VertexBuffer.UV2Kind
  23605. * - VertexBuffer.UV3Kind
  23606. * - VertexBuffer.UV4Kind
  23607. * - VertexBuffer.UV5Kind
  23608. * - VertexBuffer.UV6Kind
  23609. * - VertexBuffer.ColorKind
  23610. * - VertexBuffer.MatricesIndicesKind
  23611. * - VertexBuffer.MatricesIndicesExtraKind
  23612. * - VertexBuffer.MatricesWeightsKind
  23613. * - VertexBuffer.MatricesWeightsExtraKind
  23614. * @returns an array of strings
  23615. */
  23616. getVerticesDataKinds(): string[];
  23617. /**
  23618. * Returns a positive integer : the total number of indices in this mesh geometry.
  23619. * @returns the numner of indices or zero if the mesh has no geometry.
  23620. */
  23621. getTotalIndices(): number;
  23622. /**
  23623. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23624. * @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.
  23625. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23626. * @returns the indices array or an empty array if the mesh has no geometry
  23627. */
  23628. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23629. readonly isBlocked: boolean;
  23630. /**
  23631. * Determine if the current mesh is ready to be rendered
  23632. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23633. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23634. * @returns true if all associated assets are ready (material, textures, shaders)
  23635. */
  23636. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23637. /**
  23638. * 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.
  23639. */
  23640. readonly areNormalsFrozen: boolean;
  23641. /**
  23642. * 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.
  23643. * @returns the current mesh
  23644. */
  23645. freezeNormals(): Mesh;
  23646. /**
  23647. * 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
  23648. * @returns the current mesh
  23649. */
  23650. unfreezeNormals(): Mesh;
  23651. /**
  23652. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23653. */
  23654. overridenInstanceCount: number;
  23655. /** @hidden */ private _preActivate(): Mesh;
  23656. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): Mesh;
  23657. /** @hidden */ private _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23658. /**
  23659. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23660. * This means the mesh underlying bounding box and sphere are recomputed.
  23661. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23662. * @returns the current mesh
  23663. */
  23664. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23665. /** @hidden */ private _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23666. /**
  23667. * This function will subdivide the mesh into multiple submeshes
  23668. * @param count defines the expected number of submeshes
  23669. */
  23670. subdivide(count: number): void;
  23671. /**
  23672. * Copy a FloatArray into a specific associated vertex buffer
  23673. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23674. * - VertexBuffer.PositionKind
  23675. * - VertexBuffer.UVKind
  23676. * - VertexBuffer.UV2Kind
  23677. * - VertexBuffer.UV3Kind
  23678. * - VertexBuffer.UV4Kind
  23679. * - VertexBuffer.UV5Kind
  23680. * - VertexBuffer.UV6Kind
  23681. * - VertexBuffer.ColorKind
  23682. * - VertexBuffer.MatricesIndicesKind
  23683. * - VertexBuffer.MatricesIndicesExtraKind
  23684. * - VertexBuffer.MatricesWeightsKind
  23685. * - VertexBuffer.MatricesWeightsExtraKind
  23686. * @param data defines the data source
  23687. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23688. * @param stride defines the data stride size (can be null)
  23689. * @returns the current mesh
  23690. */
  23691. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23692. /**
  23693. * Flags an associated vertex buffer as updatable
  23694. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23695. * - VertexBuffer.PositionKind
  23696. * - VertexBuffer.UVKind
  23697. * - VertexBuffer.UV2Kind
  23698. * - VertexBuffer.UV3Kind
  23699. * - VertexBuffer.UV4Kind
  23700. * - VertexBuffer.UV5Kind
  23701. * - VertexBuffer.UV6Kind
  23702. * - VertexBuffer.ColorKind
  23703. * - VertexBuffer.MatricesIndicesKind
  23704. * - VertexBuffer.MatricesIndicesExtraKind
  23705. * - VertexBuffer.MatricesWeightsKind
  23706. * - VertexBuffer.MatricesWeightsExtraKind
  23707. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23708. */
  23709. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23710. /**
  23711. * Sets the mesh global Vertex Buffer
  23712. * @param buffer defines the buffer to use
  23713. * @returns the current mesh
  23714. */
  23715. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23716. /**
  23717. * Update a specific associated vertex buffer
  23718. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23719. * - VertexBuffer.PositionKind
  23720. * - VertexBuffer.UVKind
  23721. * - VertexBuffer.UV2Kind
  23722. * - VertexBuffer.UV3Kind
  23723. * - VertexBuffer.UV4Kind
  23724. * - VertexBuffer.UV5Kind
  23725. * - VertexBuffer.UV6Kind
  23726. * - VertexBuffer.ColorKind
  23727. * - VertexBuffer.MatricesIndicesKind
  23728. * - VertexBuffer.MatricesIndicesExtraKind
  23729. * - VertexBuffer.MatricesWeightsKind
  23730. * - VertexBuffer.MatricesWeightsExtraKind
  23731. * @param data defines the data source
  23732. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23733. * @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)
  23734. * @returns the current mesh
  23735. */
  23736. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23737. /**
  23738. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23739. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23740. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23741. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23742. * @returns the current mesh
  23743. */
  23744. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23745. /**
  23746. * Creates a un-shared specific occurence of the geometry for the mesh.
  23747. * @returns the current mesh
  23748. */
  23749. makeGeometryUnique(): Mesh;
  23750. /**
  23751. * Set the index buffer of this mesh
  23752. * @param indices defines the source data
  23753. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23754. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23755. * @returns the current mesh
  23756. */
  23757. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23758. /**
  23759. * Update the current index buffer
  23760. * @param indices defines the source data
  23761. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23762. * @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)
  23763. * @returns the current mesh
  23764. */
  23765. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23766. /**
  23767. * Invert the geometry to move from a right handed system to a left handed one.
  23768. * @returns the current mesh
  23769. */
  23770. toLeftHanded(): Mesh;
  23771. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23772. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23773. /**
  23774. * Registers for this mesh a javascript function called just before the rendering process
  23775. * @param func defines the function to call before rendering this mesh
  23776. * @returns the current mesh
  23777. */
  23778. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23779. /**
  23780. * Disposes a previously registered javascript function called before the rendering
  23781. * @param func defines the function to remove
  23782. * @returns the current mesh
  23783. */
  23784. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23785. /**
  23786. * Registers for this mesh a javascript function called just after the rendering is complete
  23787. * @param func defines the function to call after rendering this mesh
  23788. * @returns the current mesh
  23789. */
  23790. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23791. /**
  23792. * Disposes a previously registered javascript function called after the rendering.
  23793. * @param func defines the function to remove
  23794. * @returns the current mesh
  23795. */
  23796. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23797. /** @hidden */ private _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23798. /** @hidden */ private _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23799. /** @hidden */ private _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23800. /** @hidden */ private _rebuild(): void;
  23801. /** @hidden */ private _freeze(): void;
  23802. /** @hidden */ private _unFreeze(): void;
  23803. /**
  23804. * 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
  23805. * @param subMesh defines the subMesh to render
  23806. * @param enableAlphaMode defines if alpha mode can be changed
  23807. * @returns the current mesh
  23808. */
  23809. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23810. private _onBeforeDraw;
  23811. /**
  23812. * Renormalize the mesh and patch it up if there are no weights
  23813. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23814. * However in the case of zero weights then we set just a single influence to 1.
  23815. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23816. */
  23817. cleanMatrixWeights(): void;
  23818. private normalizeSkinFourWeights;
  23819. private normalizeSkinWeightsAndExtra;
  23820. /**
  23821. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23822. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23823. * the user know there was an issue with importing the mesh
  23824. * @returns a validation object with skinned, valid and report string
  23825. */
  23826. validateSkinning(): {
  23827. skinned: boolean;
  23828. valid: boolean;
  23829. report: string;
  23830. };
  23831. /** @hidden */ private _checkDelayState(): Mesh;
  23832. private _queueLoad;
  23833. /**
  23834. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23835. * A mesh is in the frustum if its bounding box intersects the frustum
  23836. * @param frustumPlanes defines the frustum to test
  23837. * @returns true if the mesh is in the frustum planes
  23838. */
  23839. isInFrustum(frustumPlanes: Plane[]): boolean;
  23840. /**
  23841. * Sets the mesh material by the material or multiMaterial `id` property
  23842. * @param id is a string identifying the material or the multiMaterial
  23843. * @returns the current mesh
  23844. */
  23845. setMaterialByID(id: string): Mesh;
  23846. /**
  23847. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23848. * @returns an array of IAnimatable
  23849. */
  23850. getAnimatables(): IAnimatable[];
  23851. /**
  23852. * Modifies the mesh geometry according to the passed transformation matrix.
  23853. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23854. * The mesh normals are modified using the same transformation.
  23855. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23856. * @param transform defines the transform matrix to use
  23857. * @see http://doc.babylonjs.com/resources/baking_transformations
  23858. * @returns the current mesh
  23859. */
  23860. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23861. /**
  23862. * Modifies the mesh geometry according to its own current World Matrix.
  23863. * The mesh World Matrix is then reset.
  23864. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23865. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23866. * @see http://doc.babylonjs.com/resources/baking_transformations
  23867. * @returns the current mesh
  23868. */
  23869. bakeCurrentTransformIntoVertices(): Mesh;
  23870. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  23871. /** @hidden */ private _resetPointsArrayCache(): Mesh;
  23872. /** @hidden */ private _generatePointsArray(): boolean;
  23873. /**
  23874. * Returns a new Mesh object generated from the current mesh properties.
  23875. * This method must not get confused with createInstance()
  23876. * @param name is a string, the name given to the new mesh
  23877. * @param newParent can be any Node object (default `null`)
  23878. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23879. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23880. * @returns a new mesh
  23881. */
  23882. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  23883. /**
  23884. * Releases resources associated with this mesh.
  23885. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23886. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23887. */
  23888. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23889. /**
  23890. * Modifies the mesh geometry according to a displacement map.
  23891. * 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.
  23892. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23893. * @param url is a string, the URL from the image file is to be downloaded.
  23894. * @param minHeight is the lower limit of the displacement.
  23895. * @param maxHeight is the upper limit of the displacement.
  23896. * @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.
  23897. * @param uvOffset is an optional vector2 used to offset UV.
  23898. * @param uvScale is an optional vector2 used to scale UV.
  23899. * @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.
  23900. * @returns the Mesh.
  23901. */
  23902. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23903. /**
  23904. * Modifies the mesh geometry according to a displacementMap buffer.
  23905. * 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.
  23906. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23907. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23908. * @param heightMapWidth is the width of the buffer image.
  23909. * @param heightMapHeight is the height of the buffer image.
  23910. * @param minHeight is the lower limit of the displacement.
  23911. * @param maxHeight is the upper limit of the displacement.
  23912. * @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.
  23913. * @param uvOffset is an optional vector2 used to offset UV.
  23914. * @param uvScale is an optional vector2 used to scale UV.
  23915. * @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.
  23916. * @returns the Mesh.
  23917. */
  23918. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23919. /**
  23920. * Modify the mesh to get a flat shading rendering.
  23921. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23922. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23923. * @returns current mesh
  23924. */
  23925. convertToFlatShadedMesh(): Mesh;
  23926. /**
  23927. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23928. * In other words, more vertices, no more indices and a single bigger VBO.
  23929. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23930. * @returns current mesh
  23931. */
  23932. convertToUnIndexedMesh(): Mesh;
  23933. /**
  23934. * Inverses facet orientations.
  23935. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23936. * @param flipNormals will also inverts the normals
  23937. * @returns current mesh
  23938. */
  23939. flipFaces(flipNormals?: boolean): Mesh;
  23940. /**
  23941. * Increase the number of facets and hence vertices in a mesh
  23942. * Vertex normals are interpolated from existing vertex normals
  23943. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23944. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23945. */
  23946. increaseVertices(numberPerEdge: number): void;
  23947. /**
  23948. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23949. * This will undo any application of covertToFlatShadedMesh
  23950. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23951. */
  23952. forceSharedVertices(): void;
  23953. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  23954. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  23955. /**
  23956. * Creates a new InstancedMesh object from the mesh model.
  23957. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23958. * @param name defines the name of the new instance
  23959. * @returns a new InstancedMesh
  23960. */
  23961. createInstance(name: string): InstancedMesh;
  23962. /**
  23963. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  23964. * After this call, all the mesh instances have the same submeshes than the current mesh.
  23965. * @returns the current mesh
  23966. */
  23967. synchronizeInstances(): Mesh;
  23968. /**
  23969. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  23970. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  23971. * This should be used together with the simplification to avoid disappearing triangles.
  23972. * @param successCallback an optional success callback to be called after the optimization finished.
  23973. * @returns the current mesh
  23974. */
  23975. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  23976. /**
  23977. * Serialize current mesh
  23978. * @param serializationObject defines the object which will receive the serialization data
  23979. */
  23980. serialize(serializationObject: any): void;
  23981. /** @hidden */ private _syncGeometryWithMorphTargetManager(): void;
  23982. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  23983. /**
  23984. * Returns a new Mesh object parsed from the source provided.
  23985. * @param parsedMesh is the source
  23986. * @param scene defines the hosting scene
  23987. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  23988. * @returns a new Mesh
  23989. */
  23990. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  23991. /**
  23992. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  23993. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23994. * @param name defines the name of the mesh to create
  23995. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  23996. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  23997. * @param closePath creates a seam between the first and the last points of each path of the path array
  23998. * @param offset is taken in account only if the `pathArray` is containing a single path
  23999. * @param scene defines the hosting scene
  24000. * @param updatable defines if the mesh must be flagged as updatable
  24001. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24002. * @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)
  24003. * @returns a new Mesh
  24004. */
  24005. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24006. /**
  24007. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24008. * @param name defines the name of the mesh to create
  24009. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24010. * @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
  24011. * @param scene defines the hosting scene
  24012. * @param updatable defines if the mesh must be flagged as updatable
  24013. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24014. * @returns a new Mesh
  24015. */
  24016. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24017. /**
  24018. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24019. * @param name defines the name of the mesh to create
  24020. * @param size sets the size (float) of each box side (default 1)
  24021. * @param scene defines the hosting scene
  24022. * @param updatable defines if the mesh must be flagged as updatable
  24023. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24024. * @returns a new Mesh
  24025. */
  24026. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24027. /**
  24028. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24029. * @param name defines the name of the mesh to create
  24030. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24031. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24032. * @param scene defines the hosting scene
  24033. * @param updatable defines if the mesh must be flagged as updatable
  24034. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24035. * @returns a new Mesh
  24036. */
  24037. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24038. /**
  24039. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24040. * @param name defines the name of the mesh to create
  24041. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24042. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24043. * @param scene defines the hosting scene
  24044. * @returns a new Mesh
  24045. */
  24046. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24047. /**
  24048. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24049. * @param name defines the name of the mesh to create
  24050. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24051. * @param diameterTop set the top cap diameter (floats, default 1)
  24052. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24053. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24054. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24055. * @param scene defines the hosting scene
  24056. * @param updatable defines if the mesh must be flagged as updatable
  24057. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24058. * @returns a new Mesh
  24059. */
  24060. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24061. /**
  24062. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24063. * @param name defines the name of the mesh to create
  24064. * @param diameter sets the diameter size (float) of the torus (default 1)
  24065. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24066. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24067. * @param scene defines the hosting scene
  24068. * @param updatable defines if the mesh must be flagged as updatable
  24069. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24070. * @returns a new Mesh
  24071. */
  24072. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24073. /**
  24074. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24075. * @param name defines the name of the mesh to create
  24076. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24077. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24078. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24079. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24080. * @param p the number of windings on X axis (positive integers, default 2)
  24081. * @param q the number of windings on Y axis (positive integers, default 3)
  24082. * @param scene defines the hosting scene
  24083. * @param updatable defines if the mesh must be flagged as updatable
  24084. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24085. * @returns a new Mesh
  24086. */
  24087. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24088. /**
  24089. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24090. * @param name defines the name of the mesh to create
  24091. * @param points is an array successive Vector3
  24092. * @param scene defines the hosting scene
  24093. * @param updatable defines if the mesh must be flagged as updatable
  24094. * @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).
  24095. * @returns a new Mesh
  24096. */
  24097. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24098. /**
  24099. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24100. * @param name defines the name of the mesh to create
  24101. * @param points is an array successive Vector3
  24102. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24103. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24104. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24105. * @param scene defines the hosting scene
  24106. * @param updatable defines if the mesh must be flagged as updatable
  24107. * @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)
  24108. * @returns a new Mesh
  24109. */
  24110. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24111. /**
  24112. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24113. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24114. * 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.
  24115. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24116. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24117. * Remember you can only change the shape positions, not their number when updating a polygon.
  24118. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24119. * @param name defines the name of the mesh to create
  24120. * @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
  24121. * @param scene defines the hosting scene
  24122. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24123. * @param updatable defines if the mesh must be flagged as updatable
  24124. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24125. * @param earcutInjection can be used to inject your own earcut reference
  24126. * @returns a new Mesh
  24127. */
  24128. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24129. /**
  24130. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24131. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24132. * @param name defines the name of the mesh to create
  24133. * @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
  24134. * @param depth defines the height of extrusion
  24135. * @param scene defines the hosting scene
  24136. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24137. * @param updatable defines if the mesh must be flagged as updatable
  24138. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24139. * @param earcutInjection can be used to inject your own earcut reference
  24140. * @returns a new Mesh
  24141. */
  24142. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24143. /**
  24144. * Creates an extruded shape mesh.
  24145. * 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
  24146. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24147. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24148. * @param name defines the name of the mesh to create
  24149. * @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
  24150. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24151. * @param scale is the value to scale the shape
  24152. * @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
  24153. * @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
  24154. * @param scene defines the hosting scene
  24155. * @param updatable defines if the mesh must be flagged as updatable
  24156. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24157. * @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)
  24158. * @returns a new Mesh
  24159. */
  24160. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24161. /**
  24162. * Creates an custom extruded shape mesh.
  24163. * The custom extrusion is a parametric shape.
  24164. * It has no predefined shape. Its final shape will depend on the input parameters.
  24165. * Please consider using the same method from the MeshBuilder class instead
  24166. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24167. * @param name defines the name of the mesh to create
  24168. * @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
  24169. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24170. * @param scaleFunction is a custom Javascript function called on each path point
  24171. * @param rotationFunction is a custom Javascript function called on each path point
  24172. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24173. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  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 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)
  24179. * @returns a new Mesh
  24180. */
  24181. 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;
  24182. /**
  24183. * Creates lathe mesh.
  24184. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24185. * Please consider using the same method from the MeshBuilder class instead
  24186. * @param name defines the name of the mesh to create
  24187. * @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
  24188. * @param radius is the radius value of the lathe
  24189. * @param tessellation is the side number of the lathe.
  24190. * @param scene defines the hosting scene
  24191. * @param updatable defines if the mesh must be flagged as updatable
  24192. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24193. * @returns a new Mesh
  24194. */
  24195. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24196. /**
  24197. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24198. * @param name defines the name of the mesh to create
  24199. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24200. * @param scene defines the hosting scene
  24201. * @param updatable defines if the mesh must be flagged as updatable
  24202. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24203. * @returns a new Mesh
  24204. */
  24205. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24206. /**
  24207. * Creates a ground mesh.
  24208. * Please consider using the same method from the MeshBuilder class instead
  24209. * @param name defines the name of the mesh to create
  24210. * @param width set the width of the ground
  24211. * @param height set the height of the ground
  24212. * @param subdivisions sets the number of subdivisions per side
  24213. * @param scene defines the hosting scene
  24214. * @param updatable defines if the mesh must be flagged as updatable
  24215. * @returns a new Mesh
  24216. */
  24217. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24218. /**
  24219. * Creates a tiled ground mesh.
  24220. * Please consider using the same method from the MeshBuilder class instead
  24221. * @param name defines the name of the mesh to create
  24222. * @param xmin set the ground minimum X coordinate
  24223. * @param zmin set the ground minimum Y coordinate
  24224. * @param xmax set the ground maximum X coordinate
  24225. * @param zmax set the ground maximum Z coordinate
  24226. * @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
  24227. * @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
  24228. * @param scene defines the hosting scene
  24229. * @param updatable defines if the mesh must be flagged as updatable
  24230. * @returns a new Mesh
  24231. */
  24232. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24233. w: number;
  24234. h: number;
  24235. }, precision: {
  24236. w: number;
  24237. h: number;
  24238. }, scene: Scene, updatable?: boolean): Mesh;
  24239. /**
  24240. * Creates a ground mesh from a height map.
  24241. * Please consider using the same method from the MeshBuilder class instead
  24242. * @see http://doc.babylonjs.com/babylon101/height_map
  24243. * @param name defines the name of the mesh to create
  24244. * @param url sets the URL of the height map image resource
  24245. * @param width set the ground width size
  24246. * @param height set the ground height size
  24247. * @param subdivisions sets the number of subdivision per side
  24248. * @param minHeight is the minimum altitude on the ground
  24249. * @param maxHeight is the maximum altitude on the ground
  24250. * @param scene defines the hosting scene
  24251. * @param updatable defines if the mesh must be flagged as updatable
  24252. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24253. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24254. * @returns a new Mesh
  24255. */
  24256. 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;
  24257. /**
  24258. * Creates a tube mesh.
  24259. * The tube is a parametric shape.
  24260. * It has no predefined shape. Its final shape will depend on the input parameters.
  24261. * Please consider using the same method from the MeshBuilder class instead
  24262. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24263. * @param name defines the name of the mesh to create
  24264. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24265. * @param radius sets the tube radius size
  24266. * @param tessellation is the number of sides on the tubular surface
  24267. * @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
  24268. * @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
  24269. * @param scene defines the hosting scene
  24270. * @param updatable defines if the mesh must be flagged as updatable
  24271. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24272. * @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)
  24273. * @returns a new Mesh
  24274. */
  24275. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24276. (i: number, distance: number): number;
  24277. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24278. /**
  24279. * Creates a polyhedron mesh.
  24280. * Please consider using the same method from the MeshBuilder class instead.
  24281. * * 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
  24282. * * The parameter `size` (positive float, default 1) sets the polygon size
  24283. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24284. * * 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`
  24285. * * 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
  24286. * * 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)`)
  24287. * * 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
  24288. * * 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
  24289. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24290. * * 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
  24291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24292. * @param name defines the name of the mesh to create
  24293. * @param options defines the options used to create the mesh
  24294. * @param scene defines the hosting scene
  24295. * @returns a new Mesh
  24296. */
  24297. static CreatePolyhedron(name: string, options: {
  24298. type?: number;
  24299. size?: number;
  24300. sizeX?: number;
  24301. sizeY?: number;
  24302. sizeZ?: number;
  24303. custom?: any;
  24304. faceUV?: Vector4[];
  24305. faceColors?: Color4[];
  24306. updatable?: boolean;
  24307. sideOrientation?: number;
  24308. }, scene: Scene): Mesh;
  24309. /**
  24310. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24311. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24312. * * 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`)
  24313. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24314. * * 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
  24315. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24316. * * 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
  24317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24318. * @param name defines the name of the mesh
  24319. * @param options defines the options used to create the mesh
  24320. * @param scene defines the hosting scene
  24321. * @returns a new Mesh
  24322. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24323. */
  24324. static CreateIcoSphere(name: string, options: {
  24325. radius?: number;
  24326. flat?: boolean;
  24327. subdivisions?: number;
  24328. sideOrientation?: number;
  24329. updatable?: boolean;
  24330. }, scene: Scene): Mesh;
  24331. /**
  24332. * Creates a decal mesh.
  24333. * Please consider using the same method from the MeshBuilder class instead.
  24334. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24335. * @param name defines the name of the mesh
  24336. * @param sourceMesh defines the mesh receiving the decal
  24337. * @param position sets the position of the decal in world coordinates
  24338. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24339. * @param size sets the decal scaling
  24340. * @param angle sets the angle to rotate the decal
  24341. * @returns a new Mesh
  24342. */
  24343. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24344. /**
  24345. * Prepare internal position array for software CPU skinning
  24346. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24347. */
  24348. setPositionsForCPUSkinning(): Float32Array;
  24349. /**
  24350. * Prepare internal normal array for software CPU skinning
  24351. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24352. */
  24353. setNormalsForCPUSkinning(): Float32Array;
  24354. /**
  24355. * Updates the vertex buffer by applying transformation from the bones
  24356. * @param skeleton defines the skeleton to apply to current mesh
  24357. * @returns the current mesh
  24358. */
  24359. applySkeleton(skeleton: Skeleton): Mesh;
  24360. /**
  24361. * 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
  24362. * @param meshes defines the list of meshes to scan
  24363. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24364. */
  24365. static MinMax(meshes: AbstractMesh[]): {
  24366. min: Vector3;
  24367. max: Vector3;
  24368. };
  24369. /**
  24370. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24371. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24372. * @returns a vector3
  24373. */
  24374. static Center(meshesOrMinMaxVector: {
  24375. min: Vector3;
  24376. max: Vector3;
  24377. } | AbstractMesh[]): Vector3;
  24378. /**
  24379. * Merge the array of meshes into a single mesh for performance reasons.
  24380. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24381. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24382. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24383. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24384. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24385. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24386. * @returns a new mesh
  24387. */
  24388. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24389. /** @hidden */
  24390. addInstance(instance: InstancedMesh): void;
  24391. /** @hidden */
  24392. removeInstance(instance: InstancedMesh): void;
  24393. }
  24394. }
  24395. declare module BABYLON {
  24396. /**
  24397. * This is the base class of all the camera used in the application.
  24398. * @see http://doc.babylonjs.com/features/cameras
  24399. */
  24400. export class Camera extends Node {
  24401. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24402. /**
  24403. * This is the default projection mode used by the cameras.
  24404. * It helps recreating a feeling of perspective and better appreciate depth.
  24405. * This is the best way to simulate real life cameras.
  24406. */
  24407. static readonly PERSPECTIVE_CAMERA: number;
  24408. /**
  24409. * This helps creating camera with an orthographic mode.
  24410. * 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.
  24411. */
  24412. static readonly ORTHOGRAPHIC_CAMERA: number;
  24413. /**
  24414. * This is the default FOV mode for perspective cameras.
  24415. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24416. */
  24417. static readonly FOVMODE_VERTICAL_FIXED: number;
  24418. /**
  24419. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24420. */
  24421. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24422. /**
  24423. * This specifies ther is no need for a camera rig.
  24424. * Basically only one eye is rendered corresponding to the camera.
  24425. */
  24426. static readonly RIG_MODE_NONE: number;
  24427. /**
  24428. * Simulates a camera Rig with one blue eye and one red eye.
  24429. * This can be use with 3d blue and red glasses.
  24430. */
  24431. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24432. /**
  24433. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24434. */
  24435. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24436. /**
  24437. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24438. */
  24439. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24440. /**
  24441. * Defines that both eyes of the camera will be rendered over under each other.
  24442. */
  24443. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24444. /**
  24445. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24446. */
  24447. static readonly RIG_MODE_VR: number;
  24448. /**
  24449. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24450. */
  24451. static readonly RIG_MODE_WEBVR: number;
  24452. /**
  24453. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24454. */
  24455. static readonly RIG_MODE_CUSTOM: number;
  24456. /**
  24457. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24458. */
  24459. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24460. /**
  24461. * Define the input manager associated with the camera.
  24462. */
  24463. inputs: CameraInputsManager<Camera>;
  24464. /** @hidden */ private _position: Vector3;
  24465. /**
  24466. * Define the current local position of the camera in the scene
  24467. */
  24468. position: Vector3;
  24469. /**
  24470. * The vector the camera should consider as up.
  24471. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24472. */
  24473. upVector: Vector3;
  24474. /**
  24475. * Define the current limit on the left side for an orthographic camera
  24476. * In scene unit
  24477. */
  24478. orthoLeft: Nullable<number>;
  24479. /**
  24480. * Define the current limit on the right side for an orthographic camera
  24481. * In scene unit
  24482. */
  24483. orthoRight: Nullable<number>;
  24484. /**
  24485. * Define the current limit on the bottom side for an orthographic camera
  24486. * In scene unit
  24487. */
  24488. orthoBottom: Nullable<number>;
  24489. /**
  24490. * Define the current limit on the top side for an orthographic camera
  24491. * In scene unit
  24492. */
  24493. orthoTop: Nullable<number>;
  24494. /**
  24495. * Field Of View is set in Radians. (default is 0.8)
  24496. */
  24497. fov: number;
  24498. /**
  24499. * Define the minimum distance the camera can see from.
  24500. * This is important to note that the depth buffer are not infinite and the closer it starts
  24501. * the more your scene might encounter depth fighting issue.
  24502. */
  24503. minZ: number;
  24504. /**
  24505. * Define the maximum distance the camera can see to.
  24506. * This is important to note that the depth buffer are not infinite and the further it end
  24507. * the more your scene might encounter depth fighting issue.
  24508. */
  24509. maxZ: number;
  24510. /**
  24511. * Define the default inertia of the camera.
  24512. * This helps giving a smooth feeling to the camera movement.
  24513. */
  24514. inertia: number;
  24515. /**
  24516. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24517. */
  24518. mode: number;
  24519. /**
  24520. * Define wether the camera is intermediate.
  24521. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24522. */
  24523. isIntermediate: boolean;
  24524. /**
  24525. * Define the viewport of the camera.
  24526. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24527. */
  24528. viewport: Viewport;
  24529. /**
  24530. * Restricts the camera to viewing objects with the same layerMask.
  24531. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24532. */
  24533. layerMask: number;
  24534. /**
  24535. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24536. */
  24537. fovMode: number;
  24538. /**
  24539. * Rig mode of the camera.
  24540. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24541. * This is normally controlled byt the camera themselves as internal use.
  24542. */
  24543. cameraRigMode: number;
  24544. /**
  24545. * Defines the distance between both "eyes" in case of a RIG
  24546. */
  24547. interaxialDistance: number;
  24548. /**
  24549. * Defines if stereoscopic rendering is done side by side or over under.
  24550. */
  24551. isStereoscopicSideBySide: boolean;
  24552. /**
  24553. * 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
  24554. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24555. * else in the scene. (Eg. security camera)
  24556. *
  24557. * 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)
  24558. */
  24559. customRenderTargets: RenderTargetTexture[];
  24560. /**
  24561. * When set, the camera will render to this render target instead of the default canvas
  24562. *
  24563. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24564. */
  24565. outputRenderTarget: Nullable<RenderTargetTexture>;
  24566. /**
  24567. * Observable triggered when the camera view matrix has changed.
  24568. */
  24569. onViewMatrixChangedObservable: Observable<Camera>;
  24570. /**
  24571. * Observable triggered when the camera Projection matrix has changed.
  24572. */
  24573. onProjectionMatrixChangedObservable: Observable<Camera>;
  24574. /**
  24575. * Observable triggered when the inputs have been processed.
  24576. */
  24577. onAfterCheckInputsObservable: Observable<Camera>;
  24578. /**
  24579. * Observable triggered when reset has been called and applied to the camera.
  24580. */
  24581. onRestoreStateObservable: Observable<Camera>;
  24582. /** @hidden */ private _cameraRigParams: any;
  24583. /** @hidden */ private _rigCameras: Camera[];
  24584. /** @hidden */ private _rigPostProcess: Nullable<PostProcess>;
  24585. protected _webvrViewMatrix: Matrix;
  24586. /** @hidden */ private _skipRendering: boolean;
  24587. /** @hidden */ private _projectionMatrix: Matrix;
  24588. /** @hidden */ private _postProcesses: Nullable<PostProcess>[];
  24589. /** @hidden */ private _activeMeshes: SmartArray<AbstractMesh>;
  24590. protected _globalPosition: Vector3;
  24591. /** @hidden */ private _computedViewMatrix: Matrix;
  24592. private _doNotComputeProjectionMatrix;
  24593. private _transformMatrix;
  24594. private _frustumPlanes;
  24595. private _refreshFrustumPlanes;
  24596. private _storedFov;
  24597. private _stateStored;
  24598. /**
  24599. * Instantiates a new camera object.
  24600. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24601. * @see http://doc.babylonjs.com/features/cameras
  24602. * @param name Defines the name of the camera in the scene
  24603. * @param position Defines the position of the camera
  24604. * @param scene Defines the scene the camera belongs too
  24605. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24606. */
  24607. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24608. /**
  24609. * Store current camera state (fov, position, etc..)
  24610. * @returns the camera
  24611. */
  24612. storeState(): Camera;
  24613. /**
  24614. * Restores the camera state values if it has been stored. You must call storeState() first
  24615. */
  24616. protected _restoreStateValues(): boolean;
  24617. /**
  24618. * Restored camera state. You must call storeState() first.
  24619. * @returns true if restored and false otherwise
  24620. */
  24621. restoreState(): boolean;
  24622. /**
  24623. * Gets the class name of the camera.
  24624. * @returns the class name
  24625. */
  24626. getClassName(): string;
  24627. /** @hidden */ protected readonly _isCamera: boolean;
  24628. /**
  24629. * Gets a string representation of the camera useful for debug purpose.
  24630. * @param fullDetails Defines that a more verboe level of logging is required
  24631. * @returns the string representation
  24632. */
  24633. toString(fullDetails?: boolean): string;
  24634. /**
  24635. * Gets the current world space position of the camera.
  24636. */
  24637. readonly globalPosition: Vector3;
  24638. /**
  24639. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24640. * @returns the active meshe list
  24641. */
  24642. getActiveMeshes(): SmartArray<AbstractMesh>;
  24643. /**
  24644. * Check wether a mesh is part of the current active mesh list of the camera
  24645. * @param mesh Defines the mesh to check
  24646. * @returns true if active, false otherwise
  24647. */
  24648. isActiveMesh(mesh: Mesh): boolean;
  24649. /**
  24650. * Is this camera ready to be used/rendered
  24651. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24652. * @return true if the camera is ready
  24653. */
  24654. isReady(completeCheck?: boolean): boolean;
  24655. /** @hidden */ private _initCache(): void;
  24656. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  24657. /** @hidden */ private _isSynchronized(): boolean;
  24658. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  24659. /** @hidden */ private _isSynchronizedProjectionMatrix(): boolean;
  24660. /**
  24661. * Attach the input controls to a specific dom element to get the input from.
  24662. * @param element Defines the element the controls should be listened from
  24663. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24664. */
  24665. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24666. /**
  24667. * Detach the current controls from the specified dom element.
  24668. * @param element Defines the element to stop listening the inputs from
  24669. */
  24670. detachControl(element: HTMLElement): void;
  24671. /**
  24672. * Update the camera state according to the different inputs gathered during the frame.
  24673. */
  24674. update(): void;
  24675. /** @hidden */ private _checkInputs(): void;
  24676. /** @hidden */
  24677. readonly rigCameras: Camera[];
  24678. /**
  24679. * Gets the post process used by the rig cameras
  24680. */
  24681. readonly rigPostProcess: Nullable<PostProcess>;
  24682. /**
  24683. * Internal, gets the first post proces.
  24684. * @returns the first post process to be run on this camera.
  24685. */ private _getFirstPostProcess(): Nullable<PostProcess>;
  24686. private _cascadePostProcessesToRigCams;
  24687. /**
  24688. * Attach a post process to the camera.
  24689. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24690. * @param postProcess The post process to attach to the camera
  24691. * @param insertAt The position of the post process in case several of them are in use in the scene
  24692. * @returns the position the post process has been inserted at
  24693. */
  24694. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24695. /**
  24696. * Detach a post process to the camera.
  24697. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24698. * @param postProcess The post process to detach from the camera
  24699. */
  24700. detachPostProcess(postProcess: PostProcess): void;
  24701. /**
  24702. * Gets the current world matrix of the camera
  24703. */
  24704. getWorldMatrix(): Matrix;
  24705. /** @hidden */ private _getViewMatrix(): Matrix;
  24706. /**
  24707. * Gets the current view matrix of the camera.
  24708. * @param force forces the camera to recompute the matrix without looking at the cached state
  24709. * @returns the view matrix
  24710. */
  24711. getViewMatrix(force?: boolean): Matrix;
  24712. /**
  24713. * Freeze the projection matrix.
  24714. * It will prevent the cache check of the camera projection compute and can speed up perf
  24715. * if no parameter of the camera are meant to change
  24716. * @param projection Defines manually a projection if necessary
  24717. */
  24718. freezeProjectionMatrix(projection?: Matrix): void;
  24719. /**
  24720. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24721. */
  24722. unfreezeProjectionMatrix(): void;
  24723. /**
  24724. * Gets the current projection matrix of the camera.
  24725. * @param force forces the camera to recompute the matrix without looking at the cached state
  24726. * @returns the projection matrix
  24727. */
  24728. getProjectionMatrix(force?: boolean): Matrix;
  24729. /**
  24730. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24731. * @returns a Matrix
  24732. */
  24733. getTransformationMatrix(): Matrix;
  24734. private _updateFrustumPlanes;
  24735. /**
  24736. * Checks if a cullable object (mesh...) is in the camera frustum
  24737. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24738. * @param target The object to check
  24739. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24740. * @returns true if the object is in frustum otherwise false
  24741. */
  24742. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24743. /**
  24744. * Checks if a cullable object (mesh...) is in the camera frustum
  24745. * Unlike isInFrustum this cheks the full bounding box
  24746. * @param target The object to check
  24747. * @returns true if the object is in frustum otherwise false
  24748. */
  24749. isCompletelyInFrustum(target: ICullable): boolean;
  24750. /**
  24751. * Gets a ray in the forward direction from the camera.
  24752. * @param length Defines the length of the ray to create
  24753. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24754. * @param origin Defines the start point of the ray which defaults to the camera position
  24755. * @returns the forward ray
  24756. */
  24757. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24758. /**
  24759. * Releases resources associated with this node.
  24760. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24761. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24762. */
  24763. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24764. /** @hidden */ private _isLeftCamera: boolean;
  24765. /**
  24766. * Gets the left camera of a rig setup in case of Rigged Camera
  24767. */
  24768. readonly isLeftCamera: boolean;
  24769. /** @hidden */ private _isRightCamera: boolean;
  24770. /**
  24771. * Gets the right camera of a rig setup in case of Rigged Camera
  24772. */
  24773. readonly isRightCamera: boolean;
  24774. /**
  24775. * Gets the left camera of a rig setup in case of Rigged Camera
  24776. */
  24777. readonly leftCamera: Nullable<FreeCamera>;
  24778. /**
  24779. * Gets the right camera of a rig setup in case of Rigged Camera
  24780. */
  24781. readonly rightCamera: Nullable<FreeCamera>;
  24782. /**
  24783. * Gets the left camera target of a rig setup in case of Rigged Camera
  24784. * @returns the target position
  24785. */
  24786. getLeftTarget(): Nullable<Vector3>;
  24787. /**
  24788. * Gets the right camera target of a rig setup in case of Rigged Camera
  24789. * @returns the target position
  24790. */
  24791. getRightTarget(): Nullable<Vector3>;
  24792. /**
  24793. * @hidden
  24794. */
  24795. setCameraRigMode(mode: number, rigParams: any): void;
  24796. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  24797. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24798. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  24799. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24800. /** @hidden */ private _getVRProjectionMatrix(): Matrix;
  24801. protected _updateCameraRotationMatrix(): void;
  24802. protected _updateWebVRCameraRotationMatrix(): void;
  24803. /**
  24804. * This function MUST be overwritten by the different WebVR cameras available.
  24805. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24806. * @hidden
  24807. */ private _getWebVRProjectionMatrix(): Matrix;
  24808. /**
  24809. * This function MUST be overwritten by the different WebVR cameras available.
  24810. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24811. * @hidden
  24812. */ private _getWebVRViewMatrix(): Matrix;
  24813. /** @hidden */
  24814. setCameraRigParameter(name: string, value: any): void;
  24815. /**
  24816. * needs to be overridden by children so sub has required properties to be copied
  24817. * @hidden
  24818. */
  24819. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24820. /**
  24821. * May need to be overridden by children
  24822. * @hidden
  24823. */ private _updateRigCameras(): void;
  24824. /** @hidden */ private _setupInputs(): void;
  24825. /**
  24826. * Serialiaze the camera setup to a json represention
  24827. * @returns the JSON representation
  24828. */
  24829. serialize(): any;
  24830. /**
  24831. * Clones the current camera.
  24832. * @param name The cloned camera name
  24833. * @returns the cloned camera
  24834. */
  24835. clone(name: string): Camera;
  24836. /**
  24837. * Gets the direction of the camera relative to a given local axis.
  24838. * @param localAxis Defines the reference axis to provide a relative direction.
  24839. * @return the direction
  24840. */
  24841. getDirection(localAxis: Vector3): Vector3;
  24842. /**
  24843. * Returns the current camera absolute rotation
  24844. */
  24845. readonly absoluteRotation: Quaternion;
  24846. /**
  24847. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24848. * @param localAxis Defines the reference axis to provide a relative direction.
  24849. * @param result Defines the vector to store the result in
  24850. */
  24851. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24852. /**
  24853. * Gets a camera constructor for a given camera type
  24854. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24855. * @param name The name of the camera the result will be able to instantiate
  24856. * @param scene The scene the result will construct the camera in
  24857. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24858. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24859. * @returns a factory method to construc the camera
  24860. */
  24861. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24862. /**
  24863. * Compute the world matrix of the camera.
  24864. * @returns the camera workd matrix
  24865. */
  24866. computeWorldMatrix(): Matrix;
  24867. /**
  24868. * Parse a JSON and creates the camera from the parsed information
  24869. * @param parsedCamera The JSON to parse
  24870. * @param scene The scene to instantiate the camera in
  24871. * @returns the newly constructed camera
  24872. */
  24873. static Parse(parsedCamera: any, scene: Scene): Camera;
  24874. }
  24875. }
  24876. declare module BABYLON {
  24877. /**
  24878. * Class containing static functions to help procedurally build meshes
  24879. */
  24880. export class DiscBuilder {
  24881. /**
  24882. * Creates a plane polygonal mesh. By default, this is a disc
  24883. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24884. * * 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
  24885. * * 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
  24886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24887. * * 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
  24888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24889. * @param name defines the name of the mesh
  24890. * @param options defines the options used to create the mesh
  24891. * @param scene defines the hosting scene
  24892. * @returns the plane polygonal mesh
  24893. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24894. */
  24895. static CreateDisc(name: string, options: {
  24896. radius?: number;
  24897. tessellation?: number;
  24898. arc?: number;
  24899. updatable?: boolean;
  24900. sideOrientation?: number;
  24901. frontUVs?: Vector4;
  24902. backUVs?: Vector4;
  24903. }, scene?: Nullable<Scene>): Mesh;
  24904. }
  24905. }
  24906. declare module BABYLON {
  24907. /**
  24908. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24909. *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.
  24910. * The SPS is also a particle system. It provides some methods to manage the particles.
  24911. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24912. *
  24913. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24914. */
  24915. export class SolidParticleSystem implements IDisposable {
  24916. /**
  24917. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24918. * Example : var p = SPS.particles[i];
  24919. */
  24920. particles: SolidParticle[];
  24921. /**
  24922. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24923. */
  24924. nbParticles: number;
  24925. /**
  24926. * If the particles must ever face the camera (default false). Useful for planar particles.
  24927. */
  24928. billboard: boolean;
  24929. /**
  24930. * Recompute normals when adding a shape
  24931. */
  24932. recomputeNormals: boolean;
  24933. /**
  24934. * This a counter ofr your own usage. It's not set by any SPS functions.
  24935. */
  24936. counter: number;
  24937. /**
  24938. * The SPS name. This name is also given to the underlying mesh.
  24939. */
  24940. name: string;
  24941. /**
  24942. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24943. */
  24944. mesh: Mesh;
  24945. /**
  24946. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24947. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  24948. */
  24949. vars: any;
  24950. /**
  24951. * This array is populated when the SPS is set as 'pickable'.
  24952. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24953. * Each element of this array is an object `{idx: int, faceId: int}`.
  24954. * `idx` is the picked particle index in the `SPS.particles` array
  24955. * `faceId` is the picked face index counted within this particle.
  24956. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  24957. */
  24958. pickedParticles: {
  24959. idx: number;
  24960. faceId: number;
  24961. }[];
  24962. /**
  24963. * This array is populated when `enableDepthSort` is set to true.
  24964. * Each element of this array is an instance of the class DepthSortedParticle.
  24965. */
  24966. depthSortedParticles: DepthSortedParticle[];
  24967. /**
  24968. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24969. * @hidden
  24970. */ private _bSphereOnly: boolean;
  24971. /**
  24972. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24973. * @hidden
  24974. */ private _bSphereRadiusFactor: number;
  24975. private _scene;
  24976. private _positions;
  24977. private _indices;
  24978. private _normals;
  24979. private _colors;
  24980. private _uvs;
  24981. private _indices32;
  24982. private _positions32;
  24983. private _normals32;
  24984. private _fixedNormal32;
  24985. private _colors32;
  24986. private _uvs32;
  24987. private _index;
  24988. private _updatable;
  24989. private _pickable;
  24990. private _isVisibilityBoxLocked;
  24991. private _alwaysVisible;
  24992. private _depthSort;
  24993. private _shapeCounter;
  24994. private _copy;
  24995. private _color;
  24996. private _computeParticleColor;
  24997. private _computeParticleTexture;
  24998. private _computeParticleRotation;
  24999. private _computeParticleVertex;
  25000. private _computeBoundingBox;
  25001. private _depthSortParticles;
  25002. private _camera;
  25003. private _mustUnrotateFixedNormals;
  25004. private _particlesIntersect;
  25005. private _needs32Bits;
  25006. /**
  25007. * Creates a SPS (Solid Particle System) object.
  25008. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25009. * @param scene (Scene) is the scene in which the SPS is added.
  25010. * @param options defines the options of the sps e.g.
  25011. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25012. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25013. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25014. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25015. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25016. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25017. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25018. */
  25019. constructor(name: string, scene: Scene, options?: {
  25020. updatable?: boolean;
  25021. isPickable?: boolean;
  25022. enableDepthSort?: boolean;
  25023. particleIntersection?: boolean;
  25024. boundingSphereOnly?: boolean;
  25025. bSphereRadiusFactor?: number;
  25026. });
  25027. /**
  25028. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25029. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25030. * @returns the created mesh
  25031. */
  25032. buildMesh(): Mesh;
  25033. /**
  25034. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25035. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25036. * Thus the particles generated from `digest()` have their property `position` set yet.
  25037. * @param mesh ( Mesh ) is the mesh to be digested
  25038. * @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
  25039. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25040. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25041. * @returns the current SPS
  25042. */
  25043. digest(mesh: Mesh, options?: {
  25044. facetNb?: number;
  25045. number?: number;
  25046. delta?: number;
  25047. }): SolidParticleSystem;
  25048. private _unrotateFixedNormals;
  25049. private _resetCopy;
  25050. private _meshBuilder;
  25051. private _posToShape;
  25052. private _uvsToShapeUV;
  25053. private _addParticle;
  25054. /**
  25055. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25056. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25057. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25058. * @param nb (positive integer) the number of particles to be created from this model
  25059. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25060. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25061. * @returns the number of shapes in the system
  25062. */
  25063. addShape(mesh: Mesh, nb: number, options?: {
  25064. positionFunction?: any;
  25065. vertexFunction?: any;
  25066. }): number;
  25067. private _rebuildParticle;
  25068. /**
  25069. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25070. * @returns the SPS.
  25071. */
  25072. rebuildMesh(): SolidParticleSystem;
  25073. /**
  25074. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25075. * This method calls `updateParticle()` for each particle of the SPS.
  25076. * For an animated SPS, it is usually called within the render loop.
  25077. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25078. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25079. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25080. * @returns the SPS.
  25081. */
  25082. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25083. /**
  25084. * Disposes the SPS.
  25085. */
  25086. dispose(): void;
  25087. /**
  25088. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25089. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25090. * @returns the SPS.
  25091. */
  25092. refreshVisibleSize(): SolidParticleSystem;
  25093. /**
  25094. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25095. * @param size the size (float) of the visibility box
  25096. * note : this doesn't lock the SPS mesh bounding box.
  25097. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25098. */
  25099. setVisibilityBox(size: number): void;
  25100. /**
  25101. * Gets whether the SPS as always visible or not
  25102. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25103. */
  25104. /**
  25105. * Sets the SPS as always visible or not
  25106. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25107. */
  25108. isAlwaysVisible: boolean;
  25109. /**
  25110. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25111. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25112. */
  25113. /**
  25114. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25115. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25116. */
  25117. isVisibilityBoxLocked: boolean;
  25118. /**
  25119. * Tells to `setParticles()` to compute the particle rotations or not.
  25120. * Default value : true. The SPS is faster when it's set to false.
  25121. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25122. */
  25123. /**
  25124. * Gets if `setParticles()` computes the particle rotations or not.
  25125. * Default value : true. The SPS is faster when it's set to false.
  25126. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25127. */
  25128. computeParticleRotation: boolean;
  25129. /**
  25130. * Tells to `setParticles()` to compute the particle colors or not.
  25131. * Default value : true. The SPS is faster when it's set to false.
  25132. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25133. */
  25134. /**
  25135. * Gets if `setParticles()` computes the particle colors or not.
  25136. * Default value : true. The SPS is faster when it's set to false.
  25137. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25138. */
  25139. computeParticleColor: boolean;
  25140. /**
  25141. * Gets if `setParticles()` computes the particle textures or not.
  25142. * Default value : true. The SPS is faster when it's set to false.
  25143. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25144. */
  25145. computeParticleTexture: boolean;
  25146. /**
  25147. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25148. * Default value : false. The SPS is faster when it's set to false.
  25149. * Note : the particle custom vertex positions aren't stored values.
  25150. */
  25151. /**
  25152. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25153. * Default value : false. The SPS is faster when it's set to false.
  25154. * Note : the particle custom vertex positions aren't stored values.
  25155. */
  25156. computeParticleVertex: boolean;
  25157. /**
  25158. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25159. */
  25160. /**
  25161. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25162. */
  25163. computeBoundingBox: boolean;
  25164. /**
  25165. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25166. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25167. * Default : `true`
  25168. */
  25169. /**
  25170. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25171. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25172. * Default : `true`
  25173. */
  25174. depthSortParticles: boolean;
  25175. /**
  25176. * This function does nothing. It may be overwritten to set all the particle first values.
  25177. * The SPS doesn't call this function, you may have to call it by your own.
  25178. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25179. */
  25180. initParticles(): void;
  25181. /**
  25182. * This function does nothing. It may be overwritten to recycle a particle.
  25183. * The SPS doesn't call this function, you may have to call it by your own.
  25184. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25185. * @param particle The particle to recycle
  25186. * @returns the recycled particle
  25187. */
  25188. recycleParticle(particle: SolidParticle): SolidParticle;
  25189. /**
  25190. * Updates a particle : this function should be overwritten by the user.
  25191. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25192. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25193. * @example : just set a particle position or velocity and recycle conditions
  25194. * @param particle The particle to update
  25195. * @returns the updated particle
  25196. */
  25197. updateParticle(particle: SolidParticle): SolidParticle;
  25198. /**
  25199. * Updates a vertex of a particle : it can be overwritten by the user.
  25200. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25201. * @param particle the current particle
  25202. * @param vertex the current index of the current particle
  25203. * @param pt the index of the current vertex in the particle shape
  25204. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25205. * @example : just set a vertex particle position
  25206. * @returns the updated vertex
  25207. */
  25208. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25209. /**
  25210. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25211. * This does nothing and may be overwritten by the user.
  25212. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25213. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25214. * @param update the boolean update value actually passed to setParticles()
  25215. */
  25216. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25217. /**
  25218. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25219. * This will be passed three parameters.
  25220. * This does nothing and may be overwritten by the user.
  25221. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25222. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25223. * @param update the boolean update value actually passed to setParticles()
  25224. */
  25225. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25226. }
  25227. }
  25228. declare module BABYLON {
  25229. /**
  25230. * Represents one particle of a solid particle system.
  25231. */
  25232. export class SolidParticle {
  25233. /**
  25234. * particle global index
  25235. */
  25236. idx: number;
  25237. /**
  25238. * The color of the particle
  25239. */
  25240. color: Nullable<Color4>;
  25241. /**
  25242. * The world space position of the particle.
  25243. */
  25244. position: Vector3;
  25245. /**
  25246. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25247. */
  25248. rotation: Vector3;
  25249. /**
  25250. * The world space rotation quaternion of the particle.
  25251. */
  25252. rotationQuaternion: Nullable<Quaternion>;
  25253. /**
  25254. * The scaling of the particle.
  25255. */
  25256. scaling: Vector3;
  25257. /**
  25258. * The uvs of the particle.
  25259. */
  25260. uvs: Vector4;
  25261. /**
  25262. * The current speed of the particle.
  25263. */
  25264. velocity: Vector3;
  25265. /**
  25266. * The pivot point in the particle local space.
  25267. */
  25268. pivot: Vector3;
  25269. /**
  25270. * Must the particle be translated from its pivot point in its local space ?
  25271. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25272. * Default : false
  25273. */
  25274. translateFromPivot: boolean;
  25275. /**
  25276. * Is the particle active or not ?
  25277. */
  25278. alive: boolean;
  25279. /**
  25280. * Is the particle visible or not ?
  25281. */
  25282. isVisible: boolean;
  25283. /**
  25284. * Index of this particle in the global "positions" array (Internal use)
  25285. * @hidden
  25286. */ private _pos: number;
  25287. /**
  25288. * @hidden Index of this particle in the global "indices" array (Internal use)
  25289. */ private _ind: number;
  25290. /**
  25291. * @hidden ModelShape of this particle (Internal use)
  25292. */ private _model: ModelShape;
  25293. /**
  25294. * ModelShape id of this particle
  25295. */
  25296. shapeId: number;
  25297. /**
  25298. * Index of the particle in its shape id
  25299. */
  25300. idxInShape: number;
  25301. /**
  25302. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25303. */ private _modelBoundingInfo: BoundingInfo;
  25304. /**
  25305. * @hidden Particle BoundingInfo object (Internal use)
  25306. */ private _boundingInfo: BoundingInfo;
  25307. /**
  25308. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25309. */ private _sps: SolidParticleSystem;
  25310. /**
  25311. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25312. */ private _stillInvisible: boolean;
  25313. /**
  25314. * @hidden Last computed particle rotation matrix
  25315. */ private _rotationMatrix: number[];
  25316. /**
  25317. * Parent particle Id, if any.
  25318. * Default null.
  25319. */
  25320. parentId: Nullable<number>;
  25321. /**
  25322. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25323. * The possible values are :
  25324. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25325. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25326. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25327. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25328. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25329. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25330. * */
  25331. cullingStrategy: number;
  25332. /**
  25333. * @hidden Internal global position in the SPS.
  25334. */ private _globalPosition: Vector3;
  25335. /**
  25336. * Creates a Solid Particle object.
  25337. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25338. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25339. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25340. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25341. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25342. * @param shapeId (integer) is the model shape identifier in the SPS.
  25343. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25344. * @param sps defines the sps it is associated to
  25345. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25346. */
  25347. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25348. /**
  25349. * Legacy support, changed scale to scaling
  25350. */
  25351. /**
  25352. * Legacy support, changed scale to scaling
  25353. */
  25354. scale: Vector3;
  25355. /**
  25356. * Legacy support, changed quaternion to rotationQuaternion
  25357. */
  25358. /**
  25359. * Legacy support, changed quaternion to rotationQuaternion
  25360. */
  25361. quaternion: Nullable<Quaternion>;
  25362. /**
  25363. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25364. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25365. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25366. * @returns true if it intersects
  25367. */
  25368. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25369. /**
  25370. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25371. * A particle is in the frustum if its bounding box intersects the frustum
  25372. * @param frustumPlanes defines the frustum to test
  25373. * @returns true if the particle is in the frustum planes
  25374. */
  25375. isInFrustum(frustumPlanes: Plane[]): boolean;
  25376. /**
  25377. * get the rotation matrix of the particle
  25378. * @hidden
  25379. */
  25380. getRotationMatrix(m: Matrix): void;
  25381. }
  25382. /**
  25383. * Represents the shape of the model used by one particle of a solid particle system.
  25384. * SPS internal tool, don't use it manually.
  25385. */
  25386. export class ModelShape {
  25387. /**
  25388. * The shape id
  25389. * @hidden
  25390. */
  25391. shapeID: number;
  25392. /**
  25393. * flat array of model positions (internal use)
  25394. * @hidden
  25395. */ private _shape: Vector3[];
  25396. /**
  25397. * flat array of model UVs (internal use)
  25398. * @hidden
  25399. */ private _shapeUV: number[];
  25400. /**
  25401. * length of the shape in the model indices array (internal use)
  25402. * @hidden
  25403. */ private _indicesLength: number;
  25404. /**
  25405. * Custom position function (internal use)
  25406. * @hidden
  25407. */ private _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25408. /**
  25409. * Custom vertex function (internal use)
  25410. * @hidden
  25411. */ private _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25412. /**
  25413. * 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.
  25414. * SPS internal tool, don't use it manually.
  25415. * @hidden
  25416. */
  25417. 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>);
  25418. }
  25419. /**
  25420. * Represents a Depth Sorted Particle in the solid particle system.
  25421. */
  25422. export class DepthSortedParticle {
  25423. /**
  25424. * Index of the particle in the "indices" array
  25425. */
  25426. ind: number;
  25427. /**
  25428. * Length of the particle shape in the "indices" array
  25429. */
  25430. indicesLength: number;
  25431. /**
  25432. * Squared distance from the particle to the camera
  25433. */
  25434. sqDistance: number;
  25435. }
  25436. }
  25437. declare module BABYLON {
  25438. /**
  25439. * @hidden
  25440. */
  25441. 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>>;
  25442. }
  25443. }
  25444. declare module BABYLON {
  25445. /** @hidden */ private class _FacetDataStorage {
  25446. facetPositions: Vector3[];
  25447. facetNormals: Vector3[];
  25448. facetPartitioning: number[][];
  25449. facetNb: number;
  25450. partitioningSubdivisions: number;
  25451. partitioningBBoxRatio: number;
  25452. facetDataEnabled: boolean;
  25453. facetParameters: any;
  25454. bbSize: Vector3;
  25455. subDiv: {
  25456. max: number;
  25457. X: number;
  25458. Y: number;
  25459. Z: number;
  25460. };
  25461. facetDepthSort: boolean;
  25462. facetDepthSortEnabled: boolean;
  25463. depthSortedIndices: IndicesArray;
  25464. depthSortedFacets: {
  25465. ind: number;
  25466. sqDistance: number;
  25467. }[];
  25468. facetDepthSortFunction: (f1: {
  25469. ind: number;
  25470. sqDistance: number;
  25471. }, f2: {
  25472. ind: number;
  25473. sqDistance: number;
  25474. }) => number;
  25475. facetDepthSortFrom: Vector3;
  25476. facetDepthSortOrigin: Vector3;
  25477. invertedMatrix: Matrix;
  25478. }
  25479. /**
  25480. * @hidden
  25481. **/ 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;
  25482. }
  25483. /**
  25484. * Class used to store all common mesh properties
  25485. */
  25486. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25487. /** No occlusion */
  25488. static OCCLUSION_TYPE_NONE: number;
  25489. /** Occlusion set to optimisitic */
  25490. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25491. /** Occlusion set to strict */
  25492. static OCCLUSION_TYPE_STRICT: number;
  25493. /** Use an accurante occlusion algorithm */
  25494. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25495. /** Use a conservative occlusion algorithm */
  25496. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25497. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25498. * Test order :
  25499. * Is the bounding sphere outside the frustum ?
  25500. * If not, are the bounding box vertices outside the frustum ?
  25501. * It not, then the cullable object is in the frustum.
  25502. */
  25503. static readonly CULLINGSTRATEGY_STANDARD: number;
  25504. /** Culling strategy : Bounding Sphere Only.
  25505. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25506. * It's also less accurate than the standard because some not visible objects can still be selected.
  25507. * Test : is the bounding sphere outside the frustum ?
  25508. * If not, then the cullable object is in the frustum.
  25509. */
  25510. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25511. /** Culling strategy : Optimistic Inclusion.
  25512. * This in an inclusion test first, then the standard exclusion test.
  25513. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25514. * 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.
  25515. * Anyway, it's as accurate as the standard strategy.
  25516. * Test :
  25517. * Is the cullable object bounding sphere center in the frustum ?
  25518. * If not, apply the default culling strategy.
  25519. */
  25520. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25521. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25522. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25523. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25524. * 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.
  25525. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25526. * Test :
  25527. * Is the cullable object bounding sphere center in the frustum ?
  25528. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25529. */
  25530. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25531. /**
  25532. * No billboard
  25533. */
  25534. static readonly BILLBOARDMODE_NONE: number;
  25535. /** Billboard on X axis */
  25536. static readonly BILLBOARDMODE_X: number;
  25537. /** Billboard on Y axis */
  25538. static readonly BILLBOARDMODE_Y: number;
  25539. /** Billboard on Z axis */
  25540. static readonly BILLBOARDMODE_Z: number;
  25541. /** Billboard on all axes */
  25542. static readonly BILLBOARDMODE_ALL: number;
  25543. /** Billboard on using position instead of orientation */
  25544. static readonly BILLBOARDMODE_USE_POSITION: number;
  25545. /** @hidden */ private _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25546. /**
  25547. * The culling strategy to use to check whether the mesh must be rendered or not.
  25548. * This value can be changed at any time and will be used on the next render mesh selection.
  25549. * The possible values are :
  25550. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25551. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25552. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25553. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25554. * Please read each static variable documentation to get details about the culling process.
  25555. * */
  25556. cullingStrategy: number;
  25557. /**
  25558. * Gets the number of facets in the mesh
  25559. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25560. */
  25561. readonly facetNb: number;
  25562. /**
  25563. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25564. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25565. */
  25566. partitioningSubdivisions: number;
  25567. /**
  25568. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25569. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25570. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25571. */
  25572. partitioningBBoxRatio: number;
  25573. /**
  25574. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25575. * Works only for updatable meshes.
  25576. * Doesn't work with multi-materials
  25577. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25578. */
  25579. mustDepthSortFacets: boolean;
  25580. /**
  25581. * The location (Vector3) where the facet depth sort must be computed from.
  25582. * By default, the active camera position.
  25583. * Used only when facet depth sort is enabled
  25584. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25585. */
  25586. facetDepthSortFrom: Vector3;
  25587. /**
  25588. * gets a boolean indicating if facetData is enabled
  25589. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25590. */
  25591. readonly isFacetDataEnabled: boolean;
  25592. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  25593. /**
  25594. * An event triggered when this mesh collides with another one
  25595. */
  25596. onCollideObservable: Observable<AbstractMesh>;
  25597. /** Set a function to call when this mesh collides with another one */
  25598. onCollide: () => void;
  25599. /**
  25600. * An event triggered when the collision's position changes
  25601. */
  25602. onCollisionPositionChangeObservable: Observable<Vector3>;
  25603. /** Set a function to call when the collision's position changes */
  25604. onCollisionPositionChange: () => void;
  25605. /**
  25606. * An event triggered when material is changed
  25607. */
  25608. onMaterialChangedObservable: Observable<AbstractMesh>;
  25609. /**
  25610. * Gets or sets the orientation for POV movement & rotation
  25611. */
  25612. definedFacingForward: boolean;
  25613. /** @hidden */ private _occlusionQuery: Nullable<WebGLQuery>;
  25614. /** @hidden */ private _renderingGroup: Nullable<RenderingGroup>;
  25615. /**
  25616. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25617. */
  25618. /**
  25619. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25620. */
  25621. visibility: number;
  25622. /** Gets or sets the alpha index used to sort transparent meshes
  25623. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25624. */
  25625. alphaIndex: number;
  25626. /**
  25627. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25628. */
  25629. isVisible: boolean;
  25630. /**
  25631. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25632. */
  25633. isPickable: boolean;
  25634. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25635. showSubMeshesBoundingBox: boolean;
  25636. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25637. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25638. */
  25639. isBlocker: boolean;
  25640. /**
  25641. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25642. */
  25643. enablePointerMoveEvents: boolean;
  25644. /**
  25645. * Specifies the rendering group id for this mesh (0 by default)
  25646. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25647. */
  25648. renderingGroupId: number;
  25649. private _material;
  25650. /** Gets or sets current material */
  25651. material: Nullable<Material>;
  25652. /**
  25653. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25654. * @see http://doc.babylonjs.com/babylon101/shadows
  25655. */
  25656. receiveShadows: boolean;
  25657. /** Defines color to use when rendering outline */
  25658. outlineColor: Color3;
  25659. /** Define width to use when rendering outline */
  25660. outlineWidth: number;
  25661. /** Defines color to use when rendering overlay */
  25662. overlayColor: Color3;
  25663. /** Defines alpha to use when rendering overlay */
  25664. overlayAlpha: number;
  25665. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25666. hasVertexAlpha: boolean;
  25667. /** 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) */
  25668. useVertexColors: boolean;
  25669. /**
  25670. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25671. */
  25672. computeBonesUsingShaders: boolean;
  25673. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25674. numBoneInfluencers: number;
  25675. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25676. applyFog: boolean;
  25677. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25678. useOctreeForRenderingSelection: boolean;
  25679. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25680. useOctreeForPicking: boolean;
  25681. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25682. useOctreeForCollisions: boolean;
  25683. /**
  25684. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25685. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25686. */
  25687. layerMask: number;
  25688. /**
  25689. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25690. */
  25691. alwaysSelectAsActiveMesh: boolean;
  25692. /**
  25693. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25694. */
  25695. doNotSyncBoundingInfo: boolean;
  25696. /**
  25697. * Gets or sets the current action manager
  25698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25699. */
  25700. actionManager: Nullable<AbstractActionManager>;
  25701. private _meshCollisionData;
  25702. /**
  25703. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25704. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25705. */
  25706. ellipsoid: Vector3;
  25707. /**
  25708. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25709. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25710. */
  25711. ellipsoidOffset: Vector3;
  25712. /**
  25713. * Gets or sets a collision mask used to mask collisions (default is -1).
  25714. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25715. */
  25716. collisionMask: number;
  25717. /**
  25718. * Gets or sets the current collision group mask (-1 by default).
  25719. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25720. */
  25721. collisionGroup: number;
  25722. /**
  25723. * Defines edge width used when edgesRenderer is enabled
  25724. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25725. */
  25726. edgesWidth: number;
  25727. /**
  25728. * Defines edge color used when edgesRenderer is enabled
  25729. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25730. */
  25731. edgesColor: Color4;
  25732. /** @hidden */ private _edgesRenderer: Nullable<IEdgesRenderer>;
  25733. /** @hidden */ private _masterMesh: Nullable<AbstractMesh>;
  25734. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  25735. /** @hidden */ private _renderId: number;
  25736. /**
  25737. * Gets or sets the list of subMeshes
  25738. * @see http://doc.babylonjs.com/how_to/multi_materials
  25739. */
  25740. subMeshes: SubMesh[];
  25741. /** @hidden */ private _intersectionsInProgress: AbstractMesh[];
  25742. /** @hidden */ private _unIndexed: boolean;
  25743. /** @hidden */ private _lightSources: Light[];
  25744. /** Gets the list of lights affecting that mesh */
  25745. readonly lightSources: Light[];
  25746. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  25747. /** @hidden */ private _waitingData: {
  25748. lods: Nullable<any>;
  25749. actions: Nullable<any>;
  25750. freezeWorldMatrix: Nullable<boolean>;
  25751. };
  25752. /** @hidden */ private _bonesTransformMatrices: Nullable<Float32Array>;
  25753. /** @hidden */ private _transformMatrixTexture: Nullable<RawTexture>;
  25754. /**
  25755. * Gets or sets a skeleton to apply skining transformations
  25756. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25757. */
  25758. skeleton: Nullable<Skeleton>;
  25759. /**
  25760. * An event triggered when the mesh is rebuilt.
  25761. */
  25762. onRebuildObservable: Observable<AbstractMesh>;
  25763. /**
  25764. * Creates a new AbstractMesh
  25765. * @param name defines the name of the mesh
  25766. * @param scene defines the hosting scene
  25767. */
  25768. constructor(name: string, scene?: Nullable<Scene>);
  25769. /**
  25770. * Returns the string "AbstractMesh"
  25771. * @returns "AbstractMesh"
  25772. */
  25773. getClassName(): string;
  25774. /**
  25775. * Gets a string representation of the current mesh
  25776. * @param fullDetails defines a boolean indicating if full details must be included
  25777. * @returns a string representation of the current mesh
  25778. */
  25779. toString(fullDetails?: boolean): string;
  25780. /**
  25781. * @hidden
  25782. */
  25783. protected _getEffectiveParent(): Nullable<Node>;
  25784. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25785. /** @hidden */ private _rebuild(): void;
  25786. /** @hidden */ private _resyncLightSources(): void;
  25787. /** @hidden */ private _resyncLighSource(light: Light): void;
  25788. /** @hidden */ private _unBindEffect(): void;
  25789. /** @hidden */ private _removeLightSource(light: Light, dispose: boolean): void;
  25790. private _markSubMeshesAsDirty;
  25791. /** @hidden */ private _markSubMeshesAsLightDirty(dispose?: boolean): void;
  25792. /** @hidden */ private _markSubMeshesAsAttributesDirty(): void;
  25793. /** @hidden */ private _markSubMeshesAsMiscDirty(): void;
  25794. /**
  25795. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25796. */
  25797. scaling: Vector3;
  25798. /**
  25799. * Returns true if the mesh is blocked. Implemented by child classes
  25800. */
  25801. readonly isBlocked: boolean;
  25802. /**
  25803. * Returns the mesh itself by default. Implemented by child classes
  25804. * @param camera defines the camera to use to pick the right LOD level
  25805. * @returns the currentAbstractMesh
  25806. */
  25807. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25808. /**
  25809. * Returns 0 by default. Implemented by child classes
  25810. * @returns an integer
  25811. */
  25812. getTotalVertices(): number;
  25813. /**
  25814. * Returns a positive integer : the total number of indices in this mesh geometry.
  25815. * @returns the numner of indices or zero if the mesh has no geometry.
  25816. */
  25817. getTotalIndices(): number;
  25818. /**
  25819. * Returns null by default. Implemented by child classes
  25820. * @returns null
  25821. */
  25822. getIndices(): Nullable<IndicesArray>;
  25823. /**
  25824. * Returns the array of the requested vertex data kind. Implemented by child classes
  25825. * @param kind defines the vertex data kind to use
  25826. * @returns null
  25827. */
  25828. getVerticesData(kind: string): Nullable<FloatArray>;
  25829. /**
  25830. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25831. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25832. * Note that a new underlying VertexBuffer object is created each call.
  25833. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25834. * @param kind defines vertex data kind:
  25835. * * VertexBuffer.PositionKind
  25836. * * VertexBuffer.UVKind
  25837. * * VertexBuffer.UV2Kind
  25838. * * VertexBuffer.UV3Kind
  25839. * * VertexBuffer.UV4Kind
  25840. * * VertexBuffer.UV5Kind
  25841. * * VertexBuffer.UV6Kind
  25842. * * VertexBuffer.ColorKind
  25843. * * VertexBuffer.MatricesIndicesKind
  25844. * * VertexBuffer.MatricesIndicesExtraKind
  25845. * * VertexBuffer.MatricesWeightsKind
  25846. * * VertexBuffer.MatricesWeightsExtraKind
  25847. * @param data defines the data source
  25848. * @param updatable defines if the data must be flagged as updatable (or static)
  25849. * @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
  25850. * @returns the current mesh
  25851. */
  25852. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25853. /**
  25854. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25855. * If the mesh has no geometry, it is simply returned as it is.
  25856. * @param kind defines vertex data kind:
  25857. * * VertexBuffer.PositionKind
  25858. * * VertexBuffer.UVKind
  25859. * * VertexBuffer.UV2Kind
  25860. * * VertexBuffer.UV3Kind
  25861. * * VertexBuffer.UV4Kind
  25862. * * VertexBuffer.UV5Kind
  25863. * * VertexBuffer.UV6Kind
  25864. * * VertexBuffer.ColorKind
  25865. * * VertexBuffer.MatricesIndicesKind
  25866. * * VertexBuffer.MatricesIndicesExtraKind
  25867. * * VertexBuffer.MatricesWeightsKind
  25868. * * VertexBuffer.MatricesWeightsExtraKind
  25869. * @param data defines the data source
  25870. * @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
  25871. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25872. * @returns the current mesh
  25873. */
  25874. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25875. /**
  25876. * Sets the mesh indices,
  25877. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25878. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25879. * @param totalVertices Defines the total number of vertices
  25880. * @returns the current mesh
  25881. */
  25882. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25883. /**
  25884. * Gets a boolean indicating if specific vertex data is present
  25885. * @param kind defines the vertex data kind to use
  25886. * @returns true is data kind is present
  25887. */
  25888. isVerticesDataPresent(kind: string): boolean;
  25889. /**
  25890. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25891. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25892. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25893. * @returns a BoundingInfo
  25894. */
  25895. getBoundingInfo(): BoundingInfo;
  25896. /**
  25897. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25898. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25899. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25900. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25901. * @returns the current mesh
  25902. */
  25903. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25904. /**
  25905. * Overwrite the current bounding info
  25906. * @param boundingInfo defines the new bounding info
  25907. * @returns the current mesh
  25908. */
  25909. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25910. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25911. readonly useBones: boolean;
  25912. /** @hidden */ private _preActivate(): void;
  25913. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): void;
  25914. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  25915. /** @hidden */ private _postActivate(): void;
  25916. /** @hidden */ private _freeze(): void;
  25917. /** @hidden */ private _unFreeze(): void;
  25918. /**
  25919. * Gets the current world matrix
  25920. * @returns a Matrix
  25921. */
  25922. getWorldMatrix(): Matrix;
  25923. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  25924. /**
  25925. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25926. */
  25927. readonly isAnInstance: boolean;
  25928. /**
  25929. * Gets a boolean indicating if this mesh has instances
  25930. */
  25931. readonly hasInstances: boolean;
  25932. /**
  25933. * Perform relative position change from the point of view of behind the front of the mesh.
  25934. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25935. * Supports definition of mesh facing forward or backward
  25936. * @param amountRight defines the distance on the right axis
  25937. * @param amountUp defines the distance on the up axis
  25938. * @param amountForward defines the distance on the forward axis
  25939. * @returns the current mesh
  25940. */
  25941. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25942. /**
  25943. * Calculate relative position change from the point of view of behind the front of the mesh.
  25944. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25945. * Supports definition of mesh facing forward or backward
  25946. * @param amountRight defines the distance on the right axis
  25947. * @param amountUp defines the distance on the up axis
  25948. * @param amountForward defines the distance on the forward axis
  25949. * @returns the new displacement vector
  25950. */
  25951. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25952. /**
  25953. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25954. * Supports definition of mesh facing forward or backward
  25955. * @param flipBack defines the flip
  25956. * @param twirlClockwise defines the twirl
  25957. * @param tiltRight defines the tilt
  25958. * @returns the current mesh
  25959. */
  25960. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25961. /**
  25962. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25963. * Supports definition of mesh facing forward or backward.
  25964. * @param flipBack defines the flip
  25965. * @param twirlClockwise defines the twirl
  25966. * @param tiltRight defines the tilt
  25967. * @returns the new rotation vector
  25968. */
  25969. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25970. /**
  25971. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25972. * This means the mesh underlying bounding box and sphere are recomputed.
  25973. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25974. * @returns the current mesh
  25975. */
  25976. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25977. /** @hidden */ private _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25978. /** @hidden */ private _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25979. /** @hidden */ private _updateBoundingInfo(): AbstractMesh;
  25980. /** @hidden */ private _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25981. /** @hidden */
  25982. protected _afterComputeWorldMatrix(): void;
  25983. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  25984. /**
  25985. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25986. * A mesh is in the frustum if its bounding box intersects the frustum
  25987. * @param frustumPlanes defines the frustum to test
  25988. * @returns true if the mesh is in the frustum planes
  25989. */
  25990. isInFrustum(frustumPlanes: Plane[]): boolean;
  25991. /**
  25992. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25993. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25994. * @param frustumPlanes defines the frustum to test
  25995. * @returns true if the mesh is completely in the frustum planes
  25996. */
  25997. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25998. /**
  25999. * True if the mesh intersects another mesh or a SolidParticle object
  26000. * @param mesh defines a target mesh or SolidParticle to test
  26001. * @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)
  26002. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26003. * @returns true if there is an intersection
  26004. */
  26005. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26006. /**
  26007. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26008. * @param point defines the point to test
  26009. * @returns true if there is an intersection
  26010. */
  26011. intersectsPoint(point: Vector3): boolean;
  26012. /**
  26013. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26014. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26015. */
  26016. checkCollisions: boolean;
  26017. /**
  26018. * Gets Collider object used to compute collisions (not physics)
  26019. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26020. */
  26021. readonly collider: Nullable<Collider>;
  26022. /**
  26023. * Move the mesh using collision engine
  26024. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26025. * @param displacement defines the requested displacement vector
  26026. * @returns the current mesh
  26027. */
  26028. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26029. private _onCollisionPositionChange;
  26030. /** @hidden */ private _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26031. /** @hidden */ private _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26032. /** @hidden */ private _checkCollision(collider: Collider): AbstractMesh;
  26033. /** @hidden */ private _generatePointsArray(): boolean;
  26034. /**
  26035. * Checks if the passed Ray intersects with the mesh
  26036. * @param ray defines the ray to use
  26037. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26038. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26039. * @returns the picking info
  26040. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26041. */
  26042. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26043. /**
  26044. * Clones the current mesh
  26045. * @param name defines the mesh name
  26046. * @param newParent defines the new mesh parent
  26047. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26048. * @returns the new mesh
  26049. */
  26050. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26051. /**
  26052. * Disposes all the submeshes of the current meshnp
  26053. * @returns the current mesh
  26054. */
  26055. releaseSubMeshes(): AbstractMesh;
  26056. /**
  26057. * Releases resources associated with this abstract mesh.
  26058. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26059. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26060. */
  26061. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26062. /**
  26063. * Adds the passed mesh as a child to the current mesh
  26064. * @param mesh defines the child mesh
  26065. * @returns the current mesh
  26066. */
  26067. addChild(mesh: AbstractMesh): AbstractMesh;
  26068. /**
  26069. * Removes the passed mesh from the current mesh children list
  26070. * @param mesh defines the child mesh
  26071. * @returns the current mesh
  26072. */
  26073. removeChild(mesh: AbstractMesh): AbstractMesh;
  26074. /** @hidden */
  26075. private _initFacetData;
  26076. /**
  26077. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26078. * This method can be called within the render loop.
  26079. * 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
  26080. * @returns the current mesh
  26081. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26082. */
  26083. updateFacetData(): AbstractMesh;
  26084. /**
  26085. * Returns the facetLocalNormals array.
  26086. * The normals are expressed in the mesh local spac
  26087. * @returns an array of Vector3
  26088. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26089. */
  26090. getFacetLocalNormals(): Vector3[];
  26091. /**
  26092. * Returns the facetLocalPositions array.
  26093. * The facet positions are expressed in the mesh local space
  26094. * @returns an array of Vector3
  26095. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26096. */
  26097. getFacetLocalPositions(): Vector3[];
  26098. /**
  26099. * Returns the facetLocalPartioning array
  26100. * @returns an array of array of numbers
  26101. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26102. */
  26103. getFacetLocalPartitioning(): number[][];
  26104. /**
  26105. * Returns the i-th facet position in the world system.
  26106. * This method allocates a new Vector3 per call
  26107. * @param i defines the facet index
  26108. * @returns a new Vector3
  26109. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26110. */
  26111. getFacetPosition(i: number): Vector3;
  26112. /**
  26113. * Sets the reference Vector3 with the i-th facet position in the world system
  26114. * @param i defines the facet index
  26115. * @param ref defines the target vector
  26116. * @returns the current mesh
  26117. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26118. */
  26119. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26120. /**
  26121. * Returns the i-th facet normal in the world system.
  26122. * This method allocates a new Vector3 per call
  26123. * @param i defines the facet index
  26124. * @returns a new Vector3
  26125. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26126. */
  26127. getFacetNormal(i: number): Vector3;
  26128. /**
  26129. * Sets the reference Vector3 with the i-th facet normal in the world system
  26130. * @param i defines the facet index
  26131. * @param ref defines the target vector
  26132. * @returns the current mesh
  26133. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26134. */
  26135. getFacetNormalToRef(i: number, ref: Vector3): this;
  26136. /**
  26137. * 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)
  26138. * @param x defines x coordinate
  26139. * @param y defines y coordinate
  26140. * @param z defines z coordinate
  26141. * @returns the array of facet indexes
  26142. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26143. */
  26144. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26145. /**
  26146. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26147. * @param projected sets as the (x,y,z) world projection on the facet
  26148. * @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
  26149. * @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
  26150. * @param x defines x coordinate
  26151. * @param y defines y coordinate
  26152. * @param z defines z coordinate
  26153. * @returns the face index if found (or null instead)
  26154. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26155. */
  26156. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26157. /**
  26158. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26159. * @param projected sets as the (x,y,z) local projection on the facet
  26160. * @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
  26161. * @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
  26162. * @param x defines x coordinate
  26163. * @param y defines y coordinate
  26164. * @param z defines z coordinate
  26165. * @returns the face index if found (or null instead)
  26166. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26167. */
  26168. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26169. /**
  26170. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26171. * @returns the parameters
  26172. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26173. */
  26174. getFacetDataParameters(): any;
  26175. /**
  26176. * Disables the feature FacetData and frees the related memory
  26177. * @returns the current mesh
  26178. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26179. */
  26180. disableFacetData(): AbstractMesh;
  26181. /**
  26182. * Updates the AbstractMesh indices array
  26183. * @param indices defines the data source
  26184. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26185. * @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)
  26186. * @returns the current mesh
  26187. */
  26188. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26189. /**
  26190. * Creates new normals data for the mesh
  26191. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26192. * @returns the current mesh
  26193. */
  26194. createNormals(updatable: boolean): AbstractMesh;
  26195. /**
  26196. * Align the mesh with a normal
  26197. * @param normal defines the normal to use
  26198. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26199. * @returns the current mesh
  26200. */
  26201. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26202. /** @hidden */ private _checkOcclusionQuery(): boolean;
  26203. /**
  26204. * Disables the mesh edge rendering mode
  26205. * @returns the currentAbstractMesh
  26206. */
  26207. disableEdgesRendering(): AbstractMesh;
  26208. /**
  26209. * Enables the edge rendering mode on the mesh.
  26210. * This mode makes the mesh edges visible
  26211. * @param epsilon defines the maximal distance between two angles to detect a face
  26212. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26213. * @returns the currentAbstractMesh
  26214. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26215. */
  26216. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26217. }
  26218. }
  26219. declare module BABYLON {
  26220. /**
  26221. * Interface used to define ActionEvent
  26222. */
  26223. export interface IActionEvent {
  26224. /** The mesh or sprite that triggered the action */
  26225. source: any;
  26226. /** The X mouse cursor position at the time of the event */
  26227. pointerX: number;
  26228. /** The Y mouse cursor position at the time of the event */
  26229. pointerY: number;
  26230. /** The mesh that is currently pointed at (can be null) */
  26231. meshUnderPointer: Nullable<AbstractMesh>;
  26232. /** the original (browser) event that triggered the ActionEvent */
  26233. sourceEvent?: any;
  26234. /** additional data for the event */
  26235. additionalData?: any;
  26236. }
  26237. /**
  26238. * ActionEvent is the event being sent when an action is triggered.
  26239. */
  26240. export class ActionEvent implements IActionEvent {
  26241. /** The mesh or sprite that triggered the action */
  26242. source: any;
  26243. /** The X mouse cursor position at the time of the event */
  26244. pointerX: number;
  26245. /** The Y mouse cursor position at the time of the event */
  26246. pointerY: number;
  26247. /** The mesh that is currently pointed at (can be null) */
  26248. meshUnderPointer: Nullable<AbstractMesh>;
  26249. /** the original (browser) event that triggered the ActionEvent */
  26250. sourceEvent?: any;
  26251. /** additional data for the event */
  26252. additionalData?: any;
  26253. /**
  26254. * Creates a new ActionEvent
  26255. * @param source The mesh or sprite that triggered the action
  26256. * @param pointerX The X mouse cursor position at the time of the event
  26257. * @param pointerY The Y mouse cursor position at the time of the event
  26258. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26259. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26260. * @param additionalData additional data for the event
  26261. */
  26262. constructor(
  26263. /** The mesh or sprite that triggered the action */
  26264. source: any,
  26265. /** The X mouse cursor position at the time of the event */
  26266. pointerX: number,
  26267. /** The Y mouse cursor position at the time of the event */
  26268. pointerY: number,
  26269. /** The mesh that is currently pointed at (can be null) */
  26270. meshUnderPointer: Nullable<AbstractMesh>,
  26271. /** the original (browser) event that triggered the ActionEvent */
  26272. sourceEvent?: any,
  26273. /** additional data for the event */
  26274. additionalData?: any);
  26275. /**
  26276. * Helper function to auto-create an ActionEvent from a source mesh.
  26277. * @param source The source mesh that triggered the event
  26278. * @param evt The original (browser) event
  26279. * @param additionalData additional data for the event
  26280. * @returns the new ActionEvent
  26281. */
  26282. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26283. /**
  26284. * Helper function to auto-create an ActionEvent from a source sprite
  26285. * @param source The source sprite that triggered the event
  26286. * @param scene Scene associated with the sprite
  26287. * @param evt The original (browser) event
  26288. * @param additionalData additional data for the event
  26289. * @returns the new ActionEvent
  26290. */
  26291. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26292. /**
  26293. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26294. * @param scene the scene where the event occurred
  26295. * @param evt The original (browser) event
  26296. * @returns the new ActionEvent
  26297. */
  26298. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26299. /**
  26300. * Helper function to auto-create an ActionEvent from a primitive
  26301. * @param prim defines the target primitive
  26302. * @param pointerPos defines the pointer position
  26303. * @param evt The original (browser) event
  26304. * @param additionalData additional data for the event
  26305. * @returns the new ActionEvent
  26306. */
  26307. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26308. }
  26309. }
  26310. declare module BABYLON {
  26311. /**
  26312. * Abstract class used to decouple action Manager from scene and meshes.
  26313. * Do not instantiate.
  26314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26315. */
  26316. export abstract class AbstractActionManager implements IDisposable {
  26317. /** Gets the list of active triggers */
  26318. static Triggers: {
  26319. [key: string]: number;
  26320. };
  26321. /** Gets the cursor to use when hovering items */
  26322. hoverCursor: string;
  26323. /** Gets the list of actions */
  26324. actions: IAction[];
  26325. /**
  26326. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26327. */
  26328. isRecursive: boolean;
  26329. /**
  26330. * Releases all associated resources
  26331. */
  26332. abstract dispose(): void;
  26333. /**
  26334. * Does this action manager has pointer triggers
  26335. */
  26336. abstract readonly hasPointerTriggers: boolean;
  26337. /**
  26338. * Does this action manager has pick triggers
  26339. */
  26340. abstract readonly hasPickTriggers: boolean;
  26341. /**
  26342. * Process a specific trigger
  26343. * @param trigger defines the trigger to process
  26344. * @param evt defines the event details to be processed
  26345. */
  26346. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26347. /**
  26348. * Does this action manager handles actions of any of the given triggers
  26349. * @param triggers defines the triggers to be tested
  26350. * @return a boolean indicating whether one (or more) of the triggers is handled
  26351. */
  26352. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26353. /**
  26354. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26355. * speed.
  26356. * @param triggerA defines the trigger to be tested
  26357. * @param triggerB defines the trigger to be tested
  26358. * @return a boolean indicating whether one (or more) of the triggers is handled
  26359. */
  26360. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26361. /**
  26362. * Does this action manager handles actions of a given trigger
  26363. * @param trigger defines the trigger to be tested
  26364. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26365. * @return whether the trigger is handled
  26366. */
  26367. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26368. /**
  26369. * Serialize this manager to a JSON object
  26370. * @param name defines the property name to store this manager
  26371. * @returns a JSON representation of this manager
  26372. */
  26373. abstract serialize(name: string): any;
  26374. /**
  26375. * Registers an action to this action manager
  26376. * @param action defines the action to be registered
  26377. * @return the action amended (prepared) after registration
  26378. */
  26379. abstract registerAction(action: IAction): Nullable<IAction>;
  26380. /**
  26381. * Unregisters an action to this action manager
  26382. * @param action defines the action to be unregistered
  26383. * @return a boolean indicating whether the action has been unregistered
  26384. */
  26385. abstract unregisterAction(action: IAction): Boolean;
  26386. /**
  26387. * Does exist one action manager with at least one trigger
  26388. **/
  26389. static readonly HasTriggers: boolean;
  26390. /**
  26391. * Does exist one action manager with at least one pick trigger
  26392. **/
  26393. static readonly HasPickTriggers: boolean;
  26394. /**
  26395. * Does exist one action manager that handles actions of a given trigger
  26396. * @param trigger defines the trigger to be tested
  26397. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26398. **/
  26399. static HasSpecificTrigger(trigger: number): boolean;
  26400. }
  26401. }
  26402. declare module BABYLON {
  26403. /**
  26404. * Defines how a node can be built from a string name.
  26405. */
  26406. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26407. /**
  26408. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26409. */
  26410. export class Node implements IBehaviorAware<Node> {
  26411. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26412. private static _NodeConstructors;
  26413. /**
  26414. * Add a new node constructor
  26415. * @param type defines the type name of the node to construct
  26416. * @param constructorFunc defines the constructor function
  26417. */
  26418. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26419. /**
  26420. * Returns a node constructor based on type name
  26421. * @param type defines the type name
  26422. * @param name defines the new node name
  26423. * @param scene defines the hosting scene
  26424. * @param options defines optional options to transmit to constructors
  26425. * @returns the new constructor or null
  26426. */
  26427. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26428. /**
  26429. * Gets or sets the name of the node
  26430. */
  26431. name: string;
  26432. /**
  26433. * Gets or sets the id of the node
  26434. */
  26435. id: string;
  26436. /**
  26437. * Gets or sets the unique id of the node
  26438. */
  26439. uniqueId: number;
  26440. /**
  26441. * Gets or sets a string used to store user defined state for the node
  26442. */
  26443. state: string;
  26444. /**
  26445. * Gets or sets an object used to store user defined information for the node
  26446. */
  26447. metadata: any;
  26448. /**
  26449. * For internal use only. Please do not use.
  26450. */
  26451. reservedDataStore: any;
  26452. /**
  26453. * List of inspectable custom properties (used by the Inspector)
  26454. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26455. */
  26456. inspectableCustomProperties: IInspectable[];
  26457. private _doNotSerialize;
  26458. /**
  26459. * Gets or sets a boolean used to define if the node must be serialized
  26460. */
  26461. doNotSerialize: boolean;
  26462. /** @hidden */ private _isDisposed: boolean;
  26463. /**
  26464. * Gets a list of Animations associated with the node
  26465. */
  26466. animations: Animation[];
  26467. protected _ranges: {
  26468. [name: string]: Nullable<AnimationRange>;
  26469. };
  26470. /**
  26471. * Callback raised when the node is ready to be used
  26472. */
  26473. onReady: Nullable<(node: Node) => void>;
  26474. private _isEnabled;
  26475. private _isParentEnabled;
  26476. private _isReady;
  26477. /** @hidden */ private _currentRenderId: number;
  26478. private _parentUpdateId;
  26479. /** @hidden */ private _childUpdateId: number;
  26480. /** @hidden */ private _waitingParentId: Nullable<string>;
  26481. /** @hidden */ private _scene: Scene;
  26482. /** @hidden */ private _cache: any;
  26483. private _parentNode;
  26484. private _children;
  26485. /** @hidden */ private _worldMatrix: Matrix;
  26486. /** @hidden */ private _worldMatrixDeterminant: number;
  26487. /** @hidden */ private _worldMatrixDeterminantIsDirty: boolean;
  26488. /** @hidden */
  26489. private _sceneRootNodesIndex;
  26490. /**
  26491. * Gets a boolean indicating if the node has been disposed
  26492. * @returns true if the node was disposed
  26493. */
  26494. isDisposed(): boolean;
  26495. /**
  26496. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26497. * @see https://doc.babylonjs.com/how_to/parenting
  26498. */
  26499. parent: Nullable<Node>;
  26500. private addToSceneRootNodes;
  26501. private removeFromSceneRootNodes;
  26502. private _animationPropertiesOverride;
  26503. /**
  26504. * Gets or sets the animation properties override
  26505. */
  26506. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26507. /**
  26508. * Gets a string idenfifying the name of the class
  26509. * @returns "Node" string
  26510. */
  26511. getClassName(): string;
  26512. /** @hidden */ protected readonly _isNode: boolean;
  26513. /**
  26514. * An event triggered when the mesh is disposed
  26515. */
  26516. onDisposeObservable: Observable<Node>;
  26517. private _onDisposeObserver;
  26518. /**
  26519. * Sets a callback that will be raised when the node will be disposed
  26520. */
  26521. onDispose: () => void;
  26522. /**
  26523. * Creates a new Node
  26524. * @param name the name and id to be given to this node
  26525. * @param scene the scene this node will be added to
  26526. * @param addToRootNodes the node will be added to scene.rootNodes
  26527. */
  26528. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26529. /**
  26530. * Gets the scene of the node
  26531. * @returns a scene
  26532. */
  26533. getScene(): Scene;
  26534. /**
  26535. * Gets the engine of the node
  26536. * @returns a Engine
  26537. */
  26538. getEngine(): Engine;
  26539. private _behaviors;
  26540. /**
  26541. * Attach a behavior to the node
  26542. * @see http://doc.babylonjs.com/features/behaviour
  26543. * @param behavior defines the behavior to attach
  26544. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26545. * @returns the current Node
  26546. */
  26547. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26548. /**
  26549. * Remove an attached behavior
  26550. * @see http://doc.babylonjs.com/features/behaviour
  26551. * @param behavior defines the behavior to attach
  26552. * @returns the current Node
  26553. */
  26554. removeBehavior(behavior: Behavior<Node>): Node;
  26555. /**
  26556. * Gets the list of attached behaviors
  26557. * @see http://doc.babylonjs.com/features/behaviour
  26558. */
  26559. readonly behaviors: Behavior<Node>[];
  26560. /**
  26561. * Gets an attached behavior by name
  26562. * @param name defines the name of the behavior to look for
  26563. * @see http://doc.babylonjs.com/features/behaviour
  26564. * @returns null if behavior was not found else the requested behavior
  26565. */
  26566. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26567. /**
  26568. * Returns the latest update of the World matrix
  26569. * @returns a Matrix
  26570. */
  26571. getWorldMatrix(): Matrix;
  26572. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  26573. /**
  26574. * Returns directly the latest state of the mesh World matrix.
  26575. * A Matrix is returned.
  26576. */
  26577. readonly worldMatrixFromCache: Matrix;
  26578. /** @hidden */ private _initCache(): void;
  26579. /** @hidden */
  26580. updateCache(force?: boolean): void;
  26581. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26582. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  26583. /** @hidden */ private _isSynchronized(): boolean;
  26584. /** @hidden */ private _markSyncedWithParent(): void;
  26585. /** @hidden */
  26586. isSynchronizedWithParent(): boolean;
  26587. /** @hidden */
  26588. isSynchronized(): boolean;
  26589. /**
  26590. * Is this node ready to be used/rendered
  26591. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26592. * @return true if the node is ready
  26593. */
  26594. isReady(completeCheck?: boolean): boolean;
  26595. /**
  26596. * Is this node enabled?
  26597. * 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
  26598. * @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
  26599. * @return whether this node (and its parent) is enabled
  26600. */
  26601. isEnabled(checkAncestors?: boolean): boolean;
  26602. /** @hidden */
  26603. protected _syncParentEnabledState(): void;
  26604. /**
  26605. * Set the enabled state of this node
  26606. * @param value defines the new enabled state
  26607. */
  26608. setEnabled(value: boolean): void;
  26609. /**
  26610. * Is this node a descendant of the given node?
  26611. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26612. * @param ancestor defines the parent node to inspect
  26613. * @returns a boolean indicating if this node is a descendant of the given node
  26614. */
  26615. isDescendantOf(ancestor: Node): boolean;
  26616. /** @hidden */ private _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26617. /**
  26618. * Will return all nodes that have this node as ascendant
  26619. * @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
  26620. * @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
  26621. * @return all children nodes of all types
  26622. */
  26623. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26624. /**
  26625. * Get all child-meshes of this node
  26626. * @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)
  26627. * @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
  26628. * @returns an array of AbstractMesh
  26629. */
  26630. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26631. /**
  26632. * Get all direct children of this node
  26633. * @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
  26634. * @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)
  26635. * @returns an array of Node
  26636. */
  26637. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26638. /** @hidden */ private _setReady(state: boolean): void;
  26639. /**
  26640. * Get an animation by name
  26641. * @param name defines the name of the animation to look for
  26642. * @returns null if not found else the requested animation
  26643. */
  26644. getAnimationByName(name: string): Nullable<Animation>;
  26645. /**
  26646. * Creates an animation range for this node
  26647. * @param name defines the name of the range
  26648. * @param from defines the starting key
  26649. * @param to defines the end key
  26650. */
  26651. createAnimationRange(name: string, from: number, to: number): void;
  26652. /**
  26653. * Delete a specific animation range
  26654. * @param name defines the name of the range to delete
  26655. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26656. */
  26657. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26658. /**
  26659. * Get an animation range by name
  26660. * @param name defines the name of the animation range to look for
  26661. * @returns null if not found else the requested animation range
  26662. */
  26663. getAnimationRange(name: string): Nullable<AnimationRange>;
  26664. /**
  26665. * Gets the list of all animation ranges defined on this node
  26666. * @returns an array
  26667. */
  26668. getAnimationRanges(): Nullable<AnimationRange>[];
  26669. /**
  26670. * Will start the animation sequence
  26671. * @param name defines the range frames for animation sequence
  26672. * @param loop defines if the animation should loop (false by default)
  26673. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26674. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26675. * @returns the object created for this animation. If range does not exist, it will return null
  26676. */
  26677. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26678. /**
  26679. * Serialize animation ranges into a JSON compatible object
  26680. * @returns serialization object
  26681. */
  26682. serializeAnimationRanges(): any;
  26683. /**
  26684. * Computes the world matrix of the node
  26685. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26686. * @returns the world matrix
  26687. */
  26688. computeWorldMatrix(force?: boolean): Matrix;
  26689. /**
  26690. * Releases resources associated with this node.
  26691. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26692. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26693. */
  26694. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26695. /**
  26696. * Parse animation range data from a serialization object and store them into a given node
  26697. * @param node defines where to store the animation ranges
  26698. * @param parsedNode defines the serialization object to read data from
  26699. * @param scene defines the hosting scene
  26700. */
  26701. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26702. /**
  26703. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26704. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26705. * @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
  26706. * @returns the new bounding vectors
  26707. */
  26708. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26709. min: Vector3;
  26710. max: Vector3;
  26711. };
  26712. }
  26713. }
  26714. declare module BABYLON {
  26715. /**
  26716. * @hidden
  26717. */
  26718. export class _IAnimationState {
  26719. key: number;
  26720. repeatCount: number;
  26721. workValue?: any;
  26722. loopMode?: number;
  26723. offsetValue?: any;
  26724. highLimitValue?: any;
  26725. }
  26726. /**
  26727. * Class used to store any kind of animation
  26728. */
  26729. export class Animation {
  26730. /**Name of the animation */
  26731. name: string;
  26732. /**Property to animate */
  26733. targetProperty: string;
  26734. /**The frames per second of the animation */
  26735. framePerSecond: number;
  26736. /**The data type of the animation */
  26737. dataType: number;
  26738. /**The loop mode of the animation */
  26739. loopMode?: number | undefined;
  26740. /**Specifies if blending should be enabled */
  26741. enableBlending?: boolean | undefined;
  26742. /**
  26743. * Use matrix interpolation instead of using direct key value when animating matrices
  26744. */
  26745. static AllowMatricesInterpolation: boolean;
  26746. /**
  26747. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26748. */
  26749. static AllowMatrixDecomposeForInterpolation: boolean;
  26750. /**
  26751. * Stores the key frames of the animation
  26752. */
  26753. private _keys;
  26754. /**
  26755. * Stores the easing function of the animation
  26756. */
  26757. private _easingFunction;
  26758. /**
  26759. * @hidden Internal use only
  26760. */ private _runtimeAnimations: RuntimeAnimation[];
  26761. /**
  26762. * The set of event that will be linked to this animation
  26763. */
  26764. private _events;
  26765. /**
  26766. * Stores an array of target property paths
  26767. */
  26768. targetPropertyPath: string[];
  26769. /**
  26770. * Stores the blending speed of the animation
  26771. */
  26772. blendingSpeed: number;
  26773. /**
  26774. * Stores the animation ranges for the animation
  26775. */
  26776. private _ranges;
  26777. /**
  26778. * @hidden Internal use
  26779. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26780. /**
  26781. * Sets up an animation
  26782. * @param property The property to animate
  26783. * @param animationType The animation type to apply
  26784. * @param framePerSecond The frames per second of the animation
  26785. * @param easingFunction The easing function used in the animation
  26786. * @returns The created animation
  26787. */
  26788. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26789. /**
  26790. * Create and start an animation on a node
  26791. * @param name defines the name of the global animation that will be run on all nodes
  26792. * @param node defines the root node where the animation will take place
  26793. * @param targetProperty defines property to animate
  26794. * @param framePerSecond defines the number of frame per second yo use
  26795. * @param totalFrame defines the number of frames in total
  26796. * @param from defines the initial value
  26797. * @param to defines the final value
  26798. * @param loopMode defines which loop mode you want to use (off by default)
  26799. * @param easingFunction defines the easing function to use (linear by default)
  26800. * @param onAnimationEnd defines the callback to call when animation end
  26801. * @returns the animatable created for this animation
  26802. */
  26803. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26804. /**
  26805. * Create and start an animation on a node and its descendants
  26806. * @param name defines the name of the global animation that will be run on all nodes
  26807. * @param node defines the root node where the animation will take place
  26808. * @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
  26809. * @param targetProperty defines property to animate
  26810. * @param framePerSecond defines the number of frame per second to use
  26811. * @param totalFrame defines the number of frames in total
  26812. * @param from defines the initial value
  26813. * @param to defines the final value
  26814. * @param loopMode defines which loop mode you want to use (off by default)
  26815. * @param easingFunction defines the easing function to use (linear by default)
  26816. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26817. * @returns the list of animatables created for all nodes
  26818. * @example https://www.babylonjs-playground.com/#MH0VLI
  26819. */
  26820. 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[]>;
  26821. /**
  26822. * Creates a new animation, merges it with the existing animations and starts it
  26823. * @param name Name of the animation
  26824. * @param node Node which contains the scene that begins the animations
  26825. * @param targetProperty Specifies which property to animate
  26826. * @param framePerSecond The frames per second of the animation
  26827. * @param totalFrame The total number of frames
  26828. * @param from The frame at the beginning of the animation
  26829. * @param to The frame at the end of the animation
  26830. * @param loopMode Specifies the loop mode of the animation
  26831. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26832. * @param onAnimationEnd Callback to run once the animation is complete
  26833. * @returns Nullable animation
  26834. */
  26835. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26836. /**
  26837. * Transition property of an host to the target Value
  26838. * @param property The property to transition
  26839. * @param targetValue The target Value of the property
  26840. * @param host The object where the property to animate belongs
  26841. * @param scene Scene used to run the animation
  26842. * @param frameRate Framerate (in frame/s) to use
  26843. * @param transition The transition type we want to use
  26844. * @param duration The duration of the animation, in milliseconds
  26845. * @param onAnimationEnd Callback trigger at the end of the animation
  26846. * @returns Nullable animation
  26847. */
  26848. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26849. /**
  26850. * Return the array of runtime animations currently using this animation
  26851. */
  26852. readonly runtimeAnimations: RuntimeAnimation[];
  26853. /**
  26854. * Specifies if any of the runtime animations are currently running
  26855. */
  26856. readonly hasRunningRuntimeAnimations: boolean;
  26857. /**
  26858. * Initializes the animation
  26859. * @param name Name of the animation
  26860. * @param targetProperty Property to animate
  26861. * @param framePerSecond The frames per second of the animation
  26862. * @param dataType The data type of the animation
  26863. * @param loopMode The loop mode of the animation
  26864. * @param enableBlending Specifies if blending should be enabled
  26865. */
  26866. constructor(
  26867. /**Name of the animation */
  26868. name: string,
  26869. /**Property to animate */
  26870. targetProperty: string,
  26871. /**The frames per second of the animation */
  26872. framePerSecond: number,
  26873. /**The data type of the animation */
  26874. dataType: number,
  26875. /**The loop mode of the animation */
  26876. loopMode?: number | undefined,
  26877. /**Specifies if blending should be enabled */
  26878. enableBlending?: boolean | undefined);
  26879. /**
  26880. * Converts the animation to a string
  26881. * @param fullDetails support for multiple levels of logging within scene loading
  26882. * @returns String form of the animation
  26883. */
  26884. toString(fullDetails?: boolean): string;
  26885. /**
  26886. * Add an event to this animation
  26887. * @param event Event to add
  26888. */
  26889. addEvent(event: AnimationEvent): void;
  26890. /**
  26891. * Remove all events found at the given frame
  26892. * @param frame The frame to remove events from
  26893. */
  26894. removeEvents(frame: number): void;
  26895. /**
  26896. * Retrieves all the events from the animation
  26897. * @returns Events from the animation
  26898. */
  26899. getEvents(): AnimationEvent[];
  26900. /**
  26901. * Creates an animation range
  26902. * @param name Name of the animation range
  26903. * @param from Starting frame of the animation range
  26904. * @param to Ending frame of the animation
  26905. */
  26906. createRange(name: string, from: number, to: number): void;
  26907. /**
  26908. * Deletes an animation range by name
  26909. * @param name Name of the animation range to delete
  26910. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26911. */
  26912. deleteRange(name: string, deleteFrames?: boolean): void;
  26913. /**
  26914. * Gets the animation range by name, or null if not defined
  26915. * @param name Name of the animation range
  26916. * @returns Nullable animation range
  26917. */
  26918. getRange(name: string): Nullable<AnimationRange>;
  26919. /**
  26920. * Gets the key frames from the animation
  26921. * @returns The key frames of the animation
  26922. */
  26923. getKeys(): Array<IAnimationKey>;
  26924. /**
  26925. * Gets the highest frame rate of the animation
  26926. * @returns Highest frame rate of the animation
  26927. */
  26928. getHighestFrame(): number;
  26929. /**
  26930. * Gets the easing function of the animation
  26931. * @returns Easing function of the animation
  26932. */
  26933. getEasingFunction(): IEasingFunction;
  26934. /**
  26935. * Sets the easing function of the animation
  26936. * @param easingFunction A custom mathematical formula for animation
  26937. */
  26938. setEasingFunction(easingFunction: EasingFunction): void;
  26939. /**
  26940. * Interpolates a scalar linearly
  26941. * @param startValue Start value of the animation curve
  26942. * @param endValue End value of the animation curve
  26943. * @param gradient Scalar amount to interpolate
  26944. * @returns Interpolated scalar value
  26945. */
  26946. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26947. /**
  26948. * Interpolates a scalar cubically
  26949. * @param startValue Start value of the animation curve
  26950. * @param outTangent End tangent of the animation
  26951. * @param endValue End value of the animation curve
  26952. * @param inTangent Start tangent of the animation curve
  26953. * @param gradient Scalar amount to interpolate
  26954. * @returns Interpolated scalar value
  26955. */
  26956. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26957. /**
  26958. * Interpolates a quaternion using a spherical linear interpolation
  26959. * @param startValue Start value of the animation curve
  26960. * @param endValue End value of the animation curve
  26961. * @param gradient Scalar amount to interpolate
  26962. * @returns Interpolated quaternion value
  26963. */
  26964. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26965. /**
  26966. * Interpolates a quaternion cubically
  26967. * @param startValue Start value of the animation curve
  26968. * @param outTangent End tangent of the animation curve
  26969. * @param endValue End value of the animation curve
  26970. * @param inTangent Start tangent of the animation curve
  26971. * @param gradient Scalar amount to interpolate
  26972. * @returns Interpolated quaternion value
  26973. */
  26974. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26975. /**
  26976. * Interpolates a Vector3 linearl
  26977. * @param startValue Start value of the animation curve
  26978. * @param endValue End value of the animation curve
  26979. * @param gradient Scalar amount to interpolate
  26980. * @returns Interpolated scalar value
  26981. */
  26982. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26983. /**
  26984. * Interpolates a Vector3 cubically
  26985. * @param startValue Start value of the animation curve
  26986. * @param outTangent End tangent of the animation
  26987. * @param endValue End value of the animation curve
  26988. * @param inTangent Start tangent of the animation curve
  26989. * @param gradient Scalar amount to interpolate
  26990. * @returns InterpolatedVector3 value
  26991. */
  26992. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26993. /**
  26994. * Interpolates a Vector2 linearly
  26995. * @param startValue Start value of the animation curve
  26996. * @param endValue End value of the animation curve
  26997. * @param gradient Scalar amount to interpolate
  26998. * @returns Interpolated Vector2 value
  26999. */
  27000. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27001. /**
  27002. * Interpolates a Vector2 cubically
  27003. * @param startValue Start value of the animation curve
  27004. * @param outTangent End tangent of the animation
  27005. * @param endValue End value of the animation curve
  27006. * @param inTangent Start tangent of the animation curve
  27007. * @param gradient Scalar amount to interpolate
  27008. * @returns Interpolated Vector2 value
  27009. */
  27010. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27011. /**
  27012. * Interpolates a size linearly
  27013. * @param startValue Start value of the animation curve
  27014. * @param endValue End value of the animation curve
  27015. * @param gradient Scalar amount to interpolate
  27016. * @returns Interpolated Size value
  27017. */
  27018. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27019. /**
  27020. * Interpolates a Color3 linearly
  27021. * @param startValue Start value of the animation curve
  27022. * @param endValue End value of the animation curve
  27023. * @param gradient Scalar amount to interpolate
  27024. * @returns Interpolated Color3 value
  27025. */
  27026. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27027. /**
  27028. * @hidden Internal use only
  27029. */ private _getKeyValue(value: any): any;
  27030. /**
  27031. * @hidden Internal use only
  27032. */ private _interpolate(currentFrame: number, state: _IAnimationState): any;
  27033. /**
  27034. * Defines the function to use to interpolate matrices
  27035. * @param startValue defines the start matrix
  27036. * @param endValue defines the end matrix
  27037. * @param gradient defines the gradient between both matrices
  27038. * @param result defines an optional target matrix where to store the interpolation
  27039. * @returns the interpolated matrix
  27040. */
  27041. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27042. /**
  27043. * Makes a copy of the animation
  27044. * @returns Cloned animation
  27045. */
  27046. clone(): Animation;
  27047. /**
  27048. * Sets the key frames of the animation
  27049. * @param values The animation key frames to set
  27050. */
  27051. setKeys(values: Array<IAnimationKey>): void;
  27052. /**
  27053. * Serializes the animation to an object
  27054. * @returns Serialized object
  27055. */
  27056. serialize(): any;
  27057. /**
  27058. * Float animation type
  27059. */
  27060. private static _ANIMATIONTYPE_FLOAT;
  27061. /**
  27062. * Vector3 animation type
  27063. */
  27064. private static _ANIMATIONTYPE_VECTOR3;
  27065. /**
  27066. * Quaternion animation type
  27067. */
  27068. private static _ANIMATIONTYPE_QUATERNION;
  27069. /**
  27070. * Matrix animation type
  27071. */
  27072. private static _ANIMATIONTYPE_MATRIX;
  27073. /**
  27074. * Color3 animation type
  27075. */
  27076. private static _ANIMATIONTYPE_COLOR3;
  27077. /**
  27078. * Vector2 animation type
  27079. */
  27080. private static _ANIMATIONTYPE_VECTOR2;
  27081. /**
  27082. * Size animation type
  27083. */
  27084. private static _ANIMATIONTYPE_SIZE;
  27085. /**
  27086. * Relative Loop Mode
  27087. */
  27088. private static _ANIMATIONLOOPMODE_RELATIVE;
  27089. /**
  27090. * Cycle Loop Mode
  27091. */
  27092. private static _ANIMATIONLOOPMODE_CYCLE;
  27093. /**
  27094. * Constant Loop Mode
  27095. */
  27096. private static _ANIMATIONLOOPMODE_CONSTANT;
  27097. /**
  27098. * Get the float animation type
  27099. */
  27100. static readonly ANIMATIONTYPE_FLOAT: number;
  27101. /**
  27102. * Get the Vector3 animation type
  27103. */
  27104. static readonly ANIMATIONTYPE_VECTOR3: number;
  27105. /**
  27106. * Get the Vector2 animation type
  27107. */
  27108. static readonly ANIMATIONTYPE_VECTOR2: number;
  27109. /**
  27110. * Get the Size animation type
  27111. */
  27112. static readonly ANIMATIONTYPE_SIZE: number;
  27113. /**
  27114. * Get the Quaternion animation type
  27115. */
  27116. static readonly ANIMATIONTYPE_QUATERNION: number;
  27117. /**
  27118. * Get the Matrix animation type
  27119. */
  27120. static readonly ANIMATIONTYPE_MATRIX: number;
  27121. /**
  27122. * Get the Color3 animation type
  27123. */
  27124. static readonly ANIMATIONTYPE_COLOR3: number;
  27125. /**
  27126. * Get the Relative Loop Mode
  27127. */
  27128. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27129. /**
  27130. * Get the Cycle Loop Mode
  27131. */
  27132. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27133. /**
  27134. * Get the Constant Loop Mode
  27135. */
  27136. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27137. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  27138. /**
  27139. * Parses an animation object and creates an animation
  27140. * @param parsedAnimation Parsed animation object
  27141. * @returns Animation object
  27142. */
  27143. static Parse(parsedAnimation: any): Animation;
  27144. /**
  27145. * Appends the serialized animations from the source animations
  27146. * @param source Source containing the animations
  27147. * @param destination Target to store the animations
  27148. */
  27149. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27150. }
  27151. }
  27152. declare module BABYLON {
  27153. /**
  27154. * Interface containing an array of animations
  27155. */
  27156. export interface IAnimatable {
  27157. /**
  27158. * Array of animations
  27159. */
  27160. animations: Nullable<Array<Animation>>;
  27161. }
  27162. }
  27163. declare module BABYLON {
  27164. /**
  27165. * This represents all the required information to add a fresnel effect on a material:
  27166. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27167. */
  27168. export class FresnelParameters {
  27169. private _isEnabled;
  27170. /**
  27171. * Define if the fresnel effect is enable or not.
  27172. */
  27173. isEnabled: boolean;
  27174. /**
  27175. * Define the color used on edges (grazing angle)
  27176. */
  27177. leftColor: Color3;
  27178. /**
  27179. * Define the color used on center
  27180. */
  27181. rightColor: Color3;
  27182. /**
  27183. * Define bias applied to computed fresnel term
  27184. */
  27185. bias: number;
  27186. /**
  27187. * Defined the power exponent applied to fresnel term
  27188. */
  27189. power: number;
  27190. /**
  27191. * Clones the current fresnel and its valuues
  27192. * @returns a clone fresnel configuration
  27193. */
  27194. clone(): FresnelParameters;
  27195. /**
  27196. * Serializes the current fresnel parameters to a JSON representation.
  27197. * @return the JSON serialization
  27198. */
  27199. serialize(): any;
  27200. /**
  27201. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27202. * @param parsedFresnelParameters Define the JSON representation
  27203. * @returns the parsed parameters
  27204. */
  27205. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27206. }
  27207. }
  27208. declare module BABYLON {
  27209. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27210. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27211. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27212. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27213. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27214. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27215. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27216. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27217. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27218. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27219. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27220. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27221. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27222. /**
  27223. * Decorator used to define property that can be serialized as reference to a camera
  27224. * @param sourceName defines the name of the property to decorate
  27225. */
  27226. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27227. /**
  27228. * Class used to help serialization objects
  27229. */
  27230. export class SerializationHelper {
  27231. /** @hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27232. /** @hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27233. /** @hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27234. /** @hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27235. /**
  27236. * Appends the serialized animations from the source animations
  27237. * @param source Source containing the animations
  27238. * @param destination Target to store the animations
  27239. */
  27240. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27241. /**
  27242. * Static function used to serialized a specific entity
  27243. * @param entity defines the entity to serialize
  27244. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27245. * @returns a JSON compatible object representing the serialization of the entity
  27246. */
  27247. static Serialize<T>(entity: T, serializationObject?: any): any;
  27248. /**
  27249. * Creates a new entity from a serialization data object
  27250. * @param creationFunction defines a function used to instanciated the new entity
  27251. * @param source defines the source serialization data
  27252. * @param scene defines the hosting scene
  27253. * @param rootUrl defines the root url for resources
  27254. * @returns a new entity
  27255. */
  27256. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27257. /**
  27258. * Clones an object
  27259. * @param creationFunction defines the function used to instanciate the new object
  27260. * @param source defines the source object
  27261. * @returns the cloned object
  27262. */
  27263. static Clone<T>(creationFunction: () => T, source: T): T;
  27264. /**
  27265. * Instanciates a new object based on a source one (some data will be shared between both object)
  27266. * @param creationFunction defines the function used to instanciate the new object
  27267. * @param source defines the source object
  27268. * @returns the new object
  27269. */
  27270. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27271. }
  27272. }
  27273. declare module BABYLON {
  27274. /**
  27275. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27276. */
  27277. export interface CubeMapInfo {
  27278. /**
  27279. * The pixel array for the front face.
  27280. * This is stored in format, left to right, up to down format.
  27281. */
  27282. front: Nullable<ArrayBufferView>;
  27283. /**
  27284. * The pixel array for the back face.
  27285. * This is stored in format, left to right, up to down format.
  27286. */
  27287. back: Nullable<ArrayBufferView>;
  27288. /**
  27289. * The pixel array for the left face.
  27290. * This is stored in format, left to right, up to down format.
  27291. */
  27292. left: Nullable<ArrayBufferView>;
  27293. /**
  27294. * The pixel array for the right face.
  27295. * This is stored in format, left to right, up to down format.
  27296. */
  27297. right: Nullable<ArrayBufferView>;
  27298. /**
  27299. * The pixel array for the up face.
  27300. * This is stored in format, left to right, up to down format.
  27301. */
  27302. up: Nullable<ArrayBufferView>;
  27303. /**
  27304. * The pixel array for the down face.
  27305. * This is stored in format, left to right, up to down format.
  27306. */
  27307. down: Nullable<ArrayBufferView>;
  27308. /**
  27309. * The size of the cubemap stored.
  27310. *
  27311. * Each faces will be size * size pixels.
  27312. */
  27313. size: number;
  27314. /**
  27315. * The format of the texture.
  27316. *
  27317. * RGBA, RGB.
  27318. */
  27319. format: number;
  27320. /**
  27321. * The type of the texture data.
  27322. *
  27323. * UNSIGNED_INT, FLOAT.
  27324. */
  27325. type: number;
  27326. /**
  27327. * Specifies whether the texture is in gamma space.
  27328. */
  27329. gammaSpace: boolean;
  27330. }
  27331. /**
  27332. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27333. */
  27334. export class PanoramaToCubeMapTools {
  27335. private static FACE_FRONT;
  27336. private static FACE_BACK;
  27337. private static FACE_RIGHT;
  27338. private static FACE_LEFT;
  27339. private static FACE_DOWN;
  27340. private static FACE_UP;
  27341. /**
  27342. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27343. *
  27344. * @param float32Array The source data.
  27345. * @param inputWidth The width of the input panorama.
  27346. * @param inputHeight The height of the input panorama.
  27347. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27348. * @return The cubemap data
  27349. */
  27350. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27351. private static CreateCubemapTexture;
  27352. private static CalcProjectionSpherical;
  27353. }
  27354. }
  27355. declare module BABYLON {
  27356. /**
  27357. * Helper class dealing with the extraction of spherical polynomial dataArray
  27358. * from a cube map.
  27359. */
  27360. export class CubeMapToSphericalPolynomialTools {
  27361. private static FileFaces;
  27362. /**
  27363. * Converts a texture to the according Spherical Polynomial data.
  27364. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27365. *
  27366. * @param texture The texture to extract the information from.
  27367. * @return The Spherical Polynomial data.
  27368. */
  27369. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27370. /**
  27371. * Converts a cubemap to the according Spherical Polynomial data.
  27372. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27373. *
  27374. * @param cubeInfo The Cube map to extract the information from.
  27375. * @return The Spherical Polynomial data.
  27376. */
  27377. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27378. }
  27379. }
  27380. declare module BABYLON {
  27381. /**
  27382. * Class used to manipulate GUIDs
  27383. */
  27384. export class GUID {
  27385. /**
  27386. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27387. * Be aware Math.random() could cause collisions, but:
  27388. * "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"
  27389. * @returns a pseudo random id
  27390. */
  27391. static RandomId(): string;
  27392. }
  27393. }
  27394. declare module BABYLON {
  27395. /**
  27396. * Base class of all the textures in babylon.
  27397. * It groups all the common properties the materials, post process, lights... might need
  27398. * in order to make a correct use of the texture.
  27399. */
  27400. export class BaseTexture implements IAnimatable {
  27401. /**
  27402. * Default anisotropic filtering level for the application.
  27403. * It is set to 4 as a good tradeoff between perf and quality.
  27404. */
  27405. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27406. /**
  27407. * Gets or sets the unique id of the texture
  27408. */
  27409. uniqueId: number;
  27410. /**
  27411. * Define the name of the texture.
  27412. */
  27413. name: string;
  27414. /**
  27415. * Gets or sets an object used to store user defined information.
  27416. */
  27417. metadata: any;
  27418. /**
  27419. * For internal use only. Please do not use.
  27420. */
  27421. reservedDataStore: any;
  27422. private _hasAlpha;
  27423. /**
  27424. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27425. */
  27426. hasAlpha: boolean;
  27427. /**
  27428. * Defines if the alpha value should be determined via the rgb values.
  27429. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27430. */
  27431. getAlphaFromRGB: boolean;
  27432. /**
  27433. * Intensity or strength of the texture.
  27434. * It is commonly used by materials to fine tune the intensity of the texture
  27435. */
  27436. level: number;
  27437. /**
  27438. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27439. * This is part of the texture as textures usually maps to one uv set.
  27440. */
  27441. coordinatesIndex: number;
  27442. private _coordinatesMode;
  27443. /**
  27444. * How a texture is mapped.
  27445. *
  27446. * | Value | Type | Description |
  27447. * | ----- | ----------------------------------- | ----------- |
  27448. * | 0 | EXPLICIT_MODE | |
  27449. * | 1 | SPHERICAL_MODE | |
  27450. * | 2 | PLANAR_MODE | |
  27451. * | 3 | CUBIC_MODE | |
  27452. * | 4 | PROJECTION_MODE | |
  27453. * | 5 | SKYBOX_MODE | |
  27454. * | 6 | INVCUBIC_MODE | |
  27455. * | 7 | EQUIRECTANGULAR_MODE | |
  27456. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27457. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27458. */
  27459. coordinatesMode: number;
  27460. /**
  27461. * | Value | Type | Description |
  27462. * | ----- | ------------------ | ----------- |
  27463. * | 0 | CLAMP_ADDRESSMODE | |
  27464. * | 1 | WRAP_ADDRESSMODE | |
  27465. * | 2 | MIRROR_ADDRESSMODE | |
  27466. */
  27467. wrapU: number;
  27468. /**
  27469. * | Value | Type | Description |
  27470. * | ----- | ------------------ | ----------- |
  27471. * | 0 | CLAMP_ADDRESSMODE | |
  27472. * | 1 | WRAP_ADDRESSMODE | |
  27473. * | 2 | MIRROR_ADDRESSMODE | |
  27474. */
  27475. wrapV: number;
  27476. /**
  27477. * | Value | Type | Description |
  27478. * | ----- | ------------------ | ----------- |
  27479. * | 0 | CLAMP_ADDRESSMODE | |
  27480. * | 1 | WRAP_ADDRESSMODE | |
  27481. * | 2 | MIRROR_ADDRESSMODE | |
  27482. */
  27483. wrapR: number;
  27484. /**
  27485. * With compliant hardware and browser (supporting anisotropic filtering)
  27486. * this defines the level of anisotropic filtering in the texture.
  27487. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27488. */
  27489. anisotropicFilteringLevel: number;
  27490. /**
  27491. * Define if the texture is a cube texture or if false a 2d texture.
  27492. */
  27493. isCube: boolean;
  27494. /**
  27495. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27496. */
  27497. is3D: boolean;
  27498. /**
  27499. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27500. * HDR texture are usually stored in linear space.
  27501. * This only impacts the PBR and Background materials
  27502. */
  27503. gammaSpace: boolean;
  27504. /**
  27505. * Gets or sets whether or not the texture contains RGBD data.
  27506. */
  27507. isRGBD: boolean;
  27508. /**
  27509. * Is Z inverted in the texture (useful in a cube texture).
  27510. */
  27511. invertZ: boolean;
  27512. /**
  27513. * Are mip maps generated for this texture or not.
  27514. */
  27515. readonly noMipmap: boolean;
  27516. /**
  27517. * @hidden
  27518. */
  27519. lodLevelInAlpha: boolean;
  27520. /**
  27521. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27522. */
  27523. lodGenerationOffset: number;
  27524. /**
  27525. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27526. */
  27527. lodGenerationScale: number;
  27528. /**
  27529. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27530. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27531. * average roughness values.
  27532. */
  27533. linearSpecularLOD: boolean;
  27534. /**
  27535. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27536. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27537. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27538. */
  27539. irradianceTexture: Nullable<BaseTexture>;
  27540. /**
  27541. * Define if the texture is a render target.
  27542. */
  27543. isRenderTarget: boolean;
  27544. /**
  27545. * Define the unique id of the texture in the scene.
  27546. */
  27547. readonly uid: string;
  27548. /**
  27549. * Return a string representation of the texture.
  27550. * @returns the texture as a string
  27551. */
  27552. toString(): string;
  27553. /**
  27554. * Get the class name of the texture.
  27555. * @returns "BaseTexture"
  27556. */
  27557. getClassName(): string;
  27558. /**
  27559. * Define the list of animation attached to the texture.
  27560. */
  27561. animations: Animation[];
  27562. /**
  27563. * An event triggered when the texture is disposed.
  27564. */
  27565. onDisposeObservable: Observable<BaseTexture>;
  27566. private _onDisposeObserver;
  27567. /**
  27568. * Callback triggered when the texture has been disposed.
  27569. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27570. */
  27571. onDispose: () => void;
  27572. /**
  27573. * Define the current state of the loading sequence when in delayed load mode.
  27574. */
  27575. delayLoadState: number;
  27576. private _scene;
  27577. /** @hidden */ private _texture: Nullable<InternalTexture>;
  27578. private _uid;
  27579. /**
  27580. * Define if the texture is preventinga material to render or not.
  27581. * If not and the texture is not ready, the engine will use a default black texture instead.
  27582. */
  27583. readonly isBlocking: boolean;
  27584. /**
  27585. * Instantiates a new BaseTexture.
  27586. * Base class of all the textures in babylon.
  27587. * It groups all the common properties the materials, post process, lights... might need
  27588. * in order to make a correct use of the texture.
  27589. * @param scene Define the scene the texture blongs to
  27590. */
  27591. constructor(scene: Nullable<Scene>);
  27592. /**
  27593. * Get the scene the texture belongs to.
  27594. * @returns the scene or null if undefined
  27595. */
  27596. getScene(): Nullable<Scene>;
  27597. /**
  27598. * Get the texture transform matrix used to offset tile the texture for istance.
  27599. * @returns the transformation matrix
  27600. */
  27601. getTextureMatrix(): Matrix;
  27602. /**
  27603. * Get the texture reflection matrix used to rotate/transform the reflection.
  27604. * @returns the reflection matrix
  27605. */
  27606. getReflectionTextureMatrix(): Matrix;
  27607. /**
  27608. * Get the underlying lower level texture from Babylon.
  27609. * @returns the insternal texture
  27610. */
  27611. getInternalTexture(): Nullable<InternalTexture>;
  27612. /**
  27613. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27614. * @returns true if ready or not blocking
  27615. */
  27616. isReadyOrNotBlocking(): boolean;
  27617. /**
  27618. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27619. * @returns true if fully ready
  27620. */
  27621. isReady(): boolean;
  27622. private _cachedSize;
  27623. /**
  27624. * Get the size of the texture.
  27625. * @returns the texture size.
  27626. */
  27627. getSize(): ISize;
  27628. /**
  27629. * Get the base size of the texture.
  27630. * It can be different from the size if the texture has been resized for POT for instance
  27631. * @returns the base size
  27632. */
  27633. getBaseSize(): ISize;
  27634. /**
  27635. * Update the sampling mode of the texture.
  27636. * Default is Trilinear mode.
  27637. *
  27638. * | Value | Type | Description |
  27639. * | ----- | ------------------ | ----------- |
  27640. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27641. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27642. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27643. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27644. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27645. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27646. * | 7 | NEAREST_LINEAR | |
  27647. * | 8 | NEAREST_NEAREST | |
  27648. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27649. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27650. * | 11 | LINEAR_LINEAR | |
  27651. * | 12 | LINEAR_NEAREST | |
  27652. *
  27653. * > _mag_: magnification filter (close to the viewer)
  27654. * > _min_: minification filter (far from the viewer)
  27655. * > _mip_: filter used between mip map levels
  27656. *@param samplingMode Define the new sampling mode of the texture
  27657. */
  27658. updateSamplingMode(samplingMode: number): void;
  27659. /**
  27660. * Scales the texture if is `canRescale()`
  27661. * @param ratio the resize factor we want to use to rescale
  27662. */
  27663. scale(ratio: number): void;
  27664. /**
  27665. * Get if the texture can rescale.
  27666. */
  27667. readonly canRescale: boolean;
  27668. /** @hidden */ private _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27669. /** @hidden */ private _rebuild(): void;
  27670. /**
  27671. * Triggers the load sequence in delayed load mode.
  27672. */
  27673. delayLoad(): void;
  27674. /**
  27675. * Clones the texture.
  27676. * @returns the cloned texture
  27677. */
  27678. clone(): Nullable<BaseTexture>;
  27679. /**
  27680. * Get the texture underlying type (INT, FLOAT...)
  27681. */
  27682. readonly textureType: number;
  27683. /**
  27684. * Get the texture underlying format (RGB, RGBA...)
  27685. */
  27686. readonly textureFormat: number;
  27687. /**
  27688. * Indicates that textures need to be re-calculated for all materials
  27689. */
  27690. protected _markAllSubMeshesAsTexturesDirty(): void;
  27691. /**
  27692. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27693. * This will returns an RGBA array buffer containing either in values (0-255) or
  27694. * float values (0-1) depending of the underlying buffer type.
  27695. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27696. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27697. * @param buffer defines a user defined buffer to fill with data (can be null)
  27698. * @returns The Array buffer containing the pixels data.
  27699. */
  27700. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27701. /**
  27702. * Release and destroy the underlying lower level texture aka internalTexture.
  27703. */
  27704. releaseInternalTexture(): void;
  27705. /**
  27706. * Get the polynomial representation of the texture data.
  27707. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27708. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27709. */
  27710. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27711. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  27712. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  27713. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  27714. /**
  27715. * Dispose the texture and release its associated resources.
  27716. */
  27717. dispose(): void;
  27718. /**
  27719. * Serialize the texture into a JSON representation that can be parsed later on.
  27720. * @returns the JSON representation of the texture
  27721. */
  27722. serialize(): any;
  27723. /**
  27724. * Helper function to be called back once a list of texture contains only ready textures.
  27725. * @param textures Define the list of textures to wait for
  27726. * @param callback Define the callback triggered once the entire list will be ready
  27727. */
  27728. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27729. }
  27730. }
  27731. declare module BABYLON {
  27732. /**
  27733. * Options to be used when creating an effect.
  27734. */
  27735. export class EffectCreationOptions {
  27736. /**
  27737. * Atrributes that will be used in the shader.
  27738. */
  27739. attributes: string[];
  27740. /**
  27741. * Uniform varible names that will be set in the shader.
  27742. */
  27743. uniformsNames: string[];
  27744. /**
  27745. * Uniform buffer varible names that will be set in the shader.
  27746. */
  27747. uniformBuffersNames: string[];
  27748. /**
  27749. * Sampler texture variable names that will be set in the shader.
  27750. */
  27751. samplers: string[];
  27752. /**
  27753. * Define statements that will be set in the shader.
  27754. */
  27755. defines: any;
  27756. /**
  27757. * Possible fallbacks for this effect to improve performance when needed.
  27758. */
  27759. fallbacks: Nullable<IEffectFallbacks>;
  27760. /**
  27761. * Callback that will be called when the shader is compiled.
  27762. */
  27763. onCompiled: Nullable<(effect: Effect) => void>;
  27764. /**
  27765. * Callback that will be called if an error occurs during shader compilation.
  27766. */
  27767. onError: Nullable<(effect: Effect, errors: string) => void>;
  27768. /**
  27769. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27770. */
  27771. indexParameters?: any;
  27772. /**
  27773. * Max number of lights that can be used in the shader.
  27774. */
  27775. maxSimultaneousLights?: number;
  27776. /**
  27777. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  27778. */
  27779. transformFeedbackVaryings?: Nullable<string[]>;
  27780. }
  27781. /**
  27782. * Effect containing vertex and fragment shader that can be executed on an object.
  27783. */
  27784. export class Effect implements IDisposable {
  27785. /**
  27786. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27787. */
  27788. static ShadersRepository: string;
  27789. /**
  27790. * Name of the effect.
  27791. */
  27792. name: any;
  27793. /**
  27794. * String container all the define statements that should be set on the shader.
  27795. */
  27796. defines: string;
  27797. /**
  27798. * Callback that will be called when the shader is compiled.
  27799. */
  27800. onCompiled: Nullable<(effect: Effect) => void>;
  27801. /**
  27802. * Callback that will be called if an error occurs during shader compilation.
  27803. */
  27804. onError: Nullable<(effect: Effect, errors: string) => void>;
  27805. /**
  27806. * Callback that will be called when effect is bound.
  27807. */
  27808. onBind: Nullable<(effect: Effect) => void>;
  27809. /**
  27810. * Unique ID of the effect.
  27811. */
  27812. uniqueId: number;
  27813. /**
  27814. * Observable that will be called when the shader is compiled.
  27815. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  27816. */
  27817. onCompileObservable: Observable<Effect>;
  27818. /**
  27819. * Observable that will be called if an error occurs during shader compilation.
  27820. */
  27821. onErrorObservable: Observable<Effect>;
  27822. /** @hidden */ private _onBindObservable: Nullable<Observable<Effect>>;
  27823. /**
  27824. * Observable that will be called when effect is bound.
  27825. */
  27826. readonly onBindObservable: Observable<Effect>;
  27827. /** @hidden */ private _bonesComputationForcedToCPU: boolean;
  27828. private static _uniqueIdSeed;
  27829. private _engine;
  27830. private _uniformBuffersNames;
  27831. private _uniformsNames;
  27832. private _samplerList;
  27833. private _samplers;
  27834. private _isReady;
  27835. private _compilationError;
  27836. private _attributesNames;
  27837. private _attributes;
  27838. private _uniforms;
  27839. /**
  27840. * Key for the effect.
  27841. * @hidden
  27842. */ private _key: string;
  27843. private _indexParameters;
  27844. private _fallbacks;
  27845. private _vertexSourceCode;
  27846. private _fragmentSourceCode;
  27847. private _vertexSourceCodeOverride;
  27848. private _fragmentSourceCodeOverride;
  27849. private _transformFeedbackVaryings;
  27850. /**
  27851. * Compiled shader to webGL program.
  27852. * @hidden
  27853. */ private _pipelineContext: Nullable<IPipelineContext>;
  27854. private _valueCache;
  27855. private static _baseCache;
  27856. /**
  27857. * Instantiates an effect.
  27858. * An effect can be used to create/manage/execute vertex and fragment shaders.
  27859. * @param baseName Name of the effect.
  27860. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  27861. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  27862. * @param samplers List of sampler variables that will be passed to the shader.
  27863. * @param engine Engine to be used to render the effect
  27864. * @param defines Define statements to be added to the shader.
  27865. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  27866. * @param onCompiled Callback that will be called when the shader is compiled.
  27867. * @param onError Callback that will be called if an error occurs during shader compilation.
  27868. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27869. */
  27870. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  27871. private _useFinalCode;
  27872. /**
  27873. * Unique key for this effect
  27874. */
  27875. readonly key: string;
  27876. /**
  27877. * If the effect has been compiled and prepared.
  27878. * @returns if the effect is compiled and prepared.
  27879. */
  27880. isReady(): boolean;
  27881. private _isReadyInternal;
  27882. /**
  27883. * The engine the effect was initialized with.
  27884. * @returns the engine.
  27885. */
  27886. getEngine(): Engine;
  27887. /**
  27888. * The pipeline context for this effect
  27889. * @returns the associated pipeline context
  27890. */
  27891. getPipelineContext(): Nullable<IPipelineContext>;
  27892. /**
  27893. * The set of names of attribute variables for the shader.
  27894. * @returns An array of attribute names.
  27895. */
  27896. getAttributesNames(): string[];
  27897. /**
  27898. * Returns the attribute at the given index.
  27899. * @param index The index of the attribute.
  27900. * @returns The location of the attribute.
  27901. */
  27902. getAttributeLocation(index: number): number;
  27903. /**
  27904. * Returns the attribute based on the name of the variable.
  27905. * @param name of the attribute to look up.
  27906. * @returns the attribute location.
  27907. */
  27908. getAttributeLocationByName(name: string): number;
  27909. /**
  27910. * The number of attributes.
  27911. * @returns the numnber of attributes.
  27912. */
  27913. getAttributesCount(): number;
  27914. /**
  27915. * Gets the index of a uniform variable.
  27916. * @param uniformName of the uniform to look up.
  27917. * @returns the index.
  27918. */
  27919. getUniformIndex(uniformName: string): number;
  27920. /**
  27921. * Returns the attribute based on the name of the variable.
  27922. * @param uniformName of the uniform to look up.
  27923. * @returns the location of the uniform.
  27924. */
  27925. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  27926. /**
  27927. * Returns an array of sampler variable names
  27928. * @returns The array of sampler variable neames.
  27929. */
  27930. getSamplers(): string[];
  27931. /**
  27932. * The error from the last compilation.
  27933. * @returns the error string.
  27934. */
  27935. getCompilationError(): string;
  27936. /**
  27937. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  27938. * @param func The callback to be used.
  27939. */
  27940. executeWhenCompiled(func: (effect: Effect) => void): void;
  27941. private _checkIsReady;
  27942. /** @hidden */ private _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  27943. /** @hidden */ private _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  27944. /** @hidden */ private _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  27945. /**
  27946. * Recompiles the webGL program
  27947. * @param vertexSourceCode The source code for the vertex shader.
  27948. * @param fragmentSourceCode The source code for the fragment shader.
  27949. * @param onCompiled Callback called when completed.
  27950. * @param onError Callback called on error.
  27951. * @hidden
  27952. */ private _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  27953. /**
  27954. * Prepares the effect
  27955. * @hidden
  27956. */ private _prepareEffect(): void;
  27957. private _processCompilationErrors;
  27958. /**
  27959. * Checks if the effect is supported. (Must be called after compilation)
  27960. */
  27961. readonly isSupported: boolean;
  27962. /**
  27963. * Binds a texture to the engine to be used as output of the shader.
  27964. * @param channel Name of the output variable.
  27965. * @param texture Texture to bind.
  27966. * @hidden
  27967. */ private _bindTexture(channel: string, texture: InternalTexture): void;
  27968. /**
  27969. * Sets a texture on the engine to be used in the shader.
  27970. * @param channel Name of the sampler variable.
  27971. * @param texture Texture to set.
  27972. */
  27973. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  27974. /**
  27975. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  27976. * @param channel Name of the sampler variable.
  27977. * @param texture Texture to set.
  27978. */
  27979. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  27980. /**
  27981. * Sets an array of textures on the engine to be used in the shader.
  27982. * @param channel Name of the variable.
  27983. * @param textures Textures to set.
  27984. */
  27985. setTextureArray(channel: string, textures: BaseTexture[]): void;
  27986. /**
  27987. * 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)
  27988. * @param channel Name of the sampler variable.
  27989. * @param postProcess Post process to get the input texture from.
  27990. */
  27991. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  27992. /**
  27993. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  27994. * 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)
  27995. * @param channel Name of the sampler variable.
  27996. * @param postProcess Post process to get the output texture from.
  27997. */
  27998. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  27999. /** @hidden */ private _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28000. /** @hidden */ private _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28001. /** @hidden */ private _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28002. /** @hidden */ private _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28003. /**
  28004. * Binds a buffer to a uniform.
  28005. * @param buffer Buffer to bind.
  28006. * @param name Name of the uniform variable to bind to.
  28007. */
  28008. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28009. /**
  28010. * Binds block to a uniform.
  28011. * @param blockName Name of the block to bind.
  28012. * @param index Index to bind.
  28013. */
  28014. bindUniformBlock(blockName: string, index: number): void;
  28015. /**
  28016. * Sets an interger value on a uniform variable.
  28017. * @param uniformName Name of the variable.
  28018. * @param value Value to be set.
  28019. * @returns this effect.
  28020. */
  28021. setInt(uniformName: string, value: number): Effect;
  28022. /**
  28023. * Sets an int array on a uniform variable.
  28024. * @param uniformName Name of the variable.
  28025. * @param array array to be set.
  28026. * @returns this effect.
  28027. */
  28028. setIntArray(uniformName: string, array: Int32Array): Effect;
  28029. /**
  28030. * 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)
  28031. * @param uniformName Name of the variable.
  28032. * @param array array to be set.
  28033. * @returns this effect.
  28034. */
  28035. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28036. /**
  28037. * 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)
  28038. * @param uniformName Name of the variable.
  28039. * @param array array to be set.
  28040. * @returns this effect.
  28041. */
  28042. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28043. /**
  28044. * 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)
  28045. * @param uniformName Name of the variable.
  28046. * @param array array to be set.
  28047. * @returns this effect.
  28048. */
  28049. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28050. /**
  28051. * Sets an float array on a uniform variable.
  28052. * @param uniformName Name of the variable.
  28053. * @param array array to be set.
  28054. * @returns this effect.
  28055. */
  28056. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28057. /**
  28058. * 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)
  28059. * @param uniformName Name of the variable.
  28060. * @param array array to be set.
  28061. * @returns this effect.
  28062. */
  28063. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28064. /**
  28065. * 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)
  28066. * @param uniformName Name of the variable.
  28067. * @param array array to be set.
  28068. * @returns this effect.
  28069. */
  28070. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28071. /**
  28072. * 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)
  28073. * @param uniformName Name of the variable.
  28074. * @param array array to be set.
  28075. * @returns this effect.
  28076. */
  28077. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28078. /**
  28079. * Sets an array on a uniform variable.
  28080. * @param uniformName Name of the variable.
  28081. * @param array array to be set.
  28082. * @returns this effect.
  28083. */
  28084. setArray(uniformName: string, array: number[]): Effect;
  28085. /**
  28086. * 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)
  28087. * @param uniformName Name of the variable.
  28088. * @param array array to be set.
  28089. * @returns this effect.
  28090. */
  28091. setArray2(uniformName: string, array: number[]): Effect;
  28092. /**
  28093. * 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)
  28094. * @param uniformName Name of the variable.
  28095. * @param array array to be set.
  28096. * @returns this effect.
  28097. */
  28098. setArray3(uniformName: string, array: number[]): Effect;
  28099. /**
  28100. * 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)
  28101. * @param uniformName Name of the variable.
  28102. * @param array array to be set.
  28103. * @returns this effect.
  28104. */
  28105. setArray4(uniformName: string, array: number[]): Effect;
  28106. /**
  28107. * Sets matrices on a uniform variable.
  28108. * @param uniformName Name of the variable.
  28109. * @param matrices matrices to be set.
  28110. * @returns this effect.
  28111. */
  28112. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28113. /**
  28114. * Sets matrix on a uniform variable.
  28115. * @param uniformName Name of the variable.
  28116. * @param matrix matrix to be set.
  28117. * @returns this effect.
  28118. */
  28119. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28120. /**
  28121. * 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)
  28122. * @param uniformName Name of the variable.
  28123. * @param matrix matrix to be set.
  28124. * @returns this effect.
  28125. */
  28126. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28127. /**
  28128. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28129. * @param uniformName Name of the variable.
  28130. * @param matrix matrix to be set.
  28131. * @returns this effect.
  28132. */
  28133. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28134. /**
  28135. * Sets a float on a uniform variable.
  28136. * @param uniformName Name of the variable.
  28137. * @param value value to be set.
  28138. * @returns this effect.
  28139. */
  28140. setFloat(uniformName: string, value: number): Effect;
  28141. /**
  28142. * Sets a boolean on a uniform variable.
  28143. * @param uniformName Name of the variable.
  28144. * @param bool value to be set.
  28145. * @returns this effect.
  28146. */
  28147. setBool(uniformName: string, bool: boolean): Effect;
  28148. /**
  28149. * Sets a Vector2 on a uniform variable.
  28150. * @param uniformName Name of the variable.
  28151. * @param vector2 vector2 to be set.
  28152. * @returns this effect.
  28153. */
  28154. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28155. /**
  28156. * Sets a float2 on a uniform variable.
  28157. * @param uniformName Name of the variable.
  28158. * @param x First float in float2.
  28159. * @param y Second float in float2.
  28160. * @returns this effect.
  28161. */
  28162. setFloat2(uniformName: string, x: number, y: number): Effect;
  28163. /**
  28164. * Sets a Vector3 on a uniform variable.
  28165. * @param uniformName Name of the variable.
  28166. * @param vector3 Value to be set.
  28167. * @returns this effect.
  28168. */
  28169. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28170. /**
  28171. * Sets a float3 on a uniform variable.
  28172. * @param uniformName Name of the variable.
  28173. * @param x First float in float3.
  28174. * @param y Second float in float3.
  28175. * @param z Third float in float3.
  28176. * @returns this effect.
  28177. */
  28178. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28179. /**
  28180. * Sets a Vector4 on a uniform variable.
  28181. * @param uniformName Name of the variable.
  28182. * @param vector4 Value to be set.
  28183. * @returns this effect.
  28184. */
  28185. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28186. /**
  28187. * Sets a float4 on a uniform variable.
  28188. * @param uniformName Name of the variable.
  28189. * @param x First float in float4.
  28190. * @param y Second float in float4.
  28191. * @param z Third float in float4.
  28192. * @param w Fourth float in float4.
  28193. * @returns this effect.
  28194. */
  28195. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28196. /**
  28197. * Sets a Color3 on a uniform variable.
  28198. * @param uniformName Name of the variable.
  28199. * @param color3 Value to be set.
  28200. * @returns this effect.
  28201. */
  28202. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28203. /**
  28204. * Sets a Color4 on a uniform variable.
  28205. * @param uniformName Name of the variable.
  28206. * @param color3 Value to be set.
  28207. * @param alpha Alpha value to be set.
  28208. * @returns this effect.
  28209. */
  28210. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28211. /**
  28212. * Sets a Color4 on a uniform variable
  28213. * @param uniformName defines the name of the variable
  28214. * @param color4 defines the value to be set
  28215. * @returns this effect.
  28216. */
  28217. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28218. /** Release all associated resources */
  28219. dispose(): void;
  28220. /**
  28221. * This function will add a new shader to the shader store
  28222. * @param name the name of the shader
  28223. * @param pixelShader optional pixel shader content
  28224. * @param vertexShader optional vertex shader content
  28225. */
  28226. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28227. /**
  28228. * Store of each shader (The can be looked up using effect.key)
  28229. */
  28230. static ShadersStore: {
  28231. [key: string]: string;
  28232. };
  28233. /**
  28234. * Store of each included file for a shader (The can be looked up using effect.key)
  28235. */
  28236. static IncludesShadersStore: {
  28237. [key: string]: string;
  28238. };
  28239. /**
  28240. * Resets the cache of effects.
  28241. */
  28242. static ResetCache(): void;
  28243. }
  28244. }
  28245. declare module BABYLON {
  28246. /**
  28247. * Class used to describe the capabilities of the engine relatively to the current browser
  28248. */
  28249. export class EngineCapabilities {
  28250. /** Maximum textures units per fragment shader */
  28251. maxTexturesImageUnits: number;
  28252. /** Maximum texture units per vertex shader */
  28253. maxVertexTextureImageUnits: number;
  28254. /** Maximum textures units in the entire pipeline */
  28255. maxCombinedTexturesImageUnits: number;
  28256. /** Maximum texture size */
  28257. maxTextureSize: number;
  28258. /** Maximum cube texture size */
  28259. maxCubemapTextureSize: number;
  28260. /** Maximum render texture size */
  28261. maxRenderTextureSize: number;
  28262. /** Maximum number of vertex attributes */
  28263. maxVertexAttribs: number;
  28264. /** Maximum number of varyings */
  28265. maxVaryingVectors: number;
  28266. /** Maximum number of uniforms per vertex shader */
  28267. maxVertexUniformVectors: number;
  28268. /** Maximum number of uniforms per fragment shader */
  28269. maxFragmentUniformVectors: number;
  28270. /** Defines if standard derivates (dx/dy) are supported */
  28271. standardDerivatives: boolean;
  28272. /** Defines if s3tc texture compression is supported */
  28273. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28274. /** Defines if pvrtc texture compression is supported */
  28275. pvrtc: any;
  28276. /** Defines if etc1 texture compression is supported */
  28277. etc1: any;
  28278. /** Defines if etc2 texture compression is supported */
  28279. etc2: any;
  28280. /** Defines if astc texture compression is supported */
  28281. astc: any;
  28282. /** Defines if float textures are supported */
  28283. textureFloat: boolean;
  28284. /** Defines if vertex array objects are supported */
  28285. vertexArrayObject: boolean;
  28286. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28287. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28288. /** Gets the maximum level of anisotropy supported */
  28289. maxAnisotropy: number;
  28290. /** Defines if instancing is supported */
  28291. instancedArrays: boolean;
  28292. /** Defines if 32 bits indices are supported */
  28293. uintIndices: boolean;
  28294. /** Defines if high precision shaders are supported */
  28295. highPrecisionShaderSupported: boolean;
  28296. /** Defines if depth reading in the fragment shader is supported */
  28297. fragmentDepthSupported: boolean;
  28298. /** Defines if float texture linear filtering is supported*/
  28299. textureFloatLinearFiltering: boolean;
  28300. /** Defines if rendering to float textures is supported */
  28301. textureFloatRender: boolean;
  28302. /** Defines if half float textures are supported*/
  28303. textureHalfFloat: boolean;
  28304. /** Defines if half float texture linear filtering is supported*/
  28305. textureHalfFloatLinearFiltering: boolean;
  28306. /** Defines if rendering to half float textures is supported */
  28307. textureHalfFloatRender: boolean;
  28308. /** Defines if textureLOD shader command is supported */
  28309. textureLOD: boolean;
  28310. /** Defines if draw buffers extension is supported */
  28311. drawBuffersExtension: boolean;
  28312. /** Defines if depth textures are supported */
  28313. depthTextureExtension: boolean;
  28314. /** Defines if float color buffer are supported */
  28315. colorBufferFloat: boolean;
  28316. /** Gets disjoint timer query extension (null if not supported) */
  28317. timerQuery: EXT_disjoint_timer_query;
  28318. /** Defines if timestamp can be used with timer query */
  28319. canUseTimestampForTimerQuery: boolean;
  28320. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28321. multiview: any;
  28322. /** Function used to let the system compiles shaders in background */
  28323. parallelShaderCompile: {
  28324. COMPLETION_STATUS_KHR: number;
  28325. };
  28326. /** Max number of texture samples for MSAA */
  28327. maxMSAASamples: number;
  28328. /** Defines if the blend min max extension is supported */
  28329. blendMinMax: boolean;
  28330. }
  28331. }
  28332. declare module BABYLON {
  28333. /**
  28334. * @hidden
  28335. **/
  28336. export class DepthCullingState {
  28337. private _isDepthTestDirty;
  28338. private _isDepthMaskDirty;
  28339. private _isDepthFuncDirty;
  28340. private _isCullFaceDirty;
  28341. private _isCullDirty;
  28342. private _isZOffsetDirty;
  28343. private _isFrontFaceDirty;
  28344. private _depthTest;
  28345. private _depthMask;
  28346. private _depthFunc;
  28347. private _cull;
  28348. private _cullFace;
  28349. private _zOffset;
  28350. private _frontFace;
  28351. /**
  28352. * Initializes the state.
  28353. */
  28354. constructor();
  28355. readonly isDirty: boolean;
  28356. zOffset: number;
  28357. cullFace: Nullable<number>;
  28358. cull: Nullable<boolean>;
  28359. depthFunc: Nullable<number>;
  28360. depthMask: boolean;
  28361. depthTest: boolean;
  28362. frontFace: Nullable<number>;
  28363. reset(): void;
  28364. apply(gl: WebGLRenderingContext): void;
  28365. }
  28366. }
  28367. declare module BABYLON {
  28368. /**
  28369. * @hidden
  28370. **/
  28371. export class StencilState {
  28372. /** 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 */
  28373. static readonly ALWAYS: number;
  28374. /** Passed to stencilOperation to specify that stencil value must be kept */
  28375. static readonly KEEP: number;
  28376. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28377. static readonly REPLACE: number;
  28378. private _isStencilTestDirty;
  28379. private _isStencilMaskDirty;
  28380. private _isStencilFuncDirty;
  28381. private _isStencilOpDirty;
  28382. private _stencilTest;
  28383. private _stencilMask;
  28384. private _stencilFunc;
  28385. private _stencilFuncRef;
  28386. private _stencilFuncMask;
  28387. private _stencilOpStencilFail;
  28388. private _stencilOpDepthFail;
  28389. private _stencilOpStencilDepthPass;
  28390. readonly isDirty: boolean;
  28391. stencilFunc: number;
  28392. stencilFuncRef: number;
  28393. stencilFuncMask: number;
  28394. stencilOpStencilFail: number;
  28395. stencilOpDepthFail: number;
  28396. stencilOpStencilDepthPass: number;
  28397. stencilMask: number;
  28398. stencilTest: boolean;
  28399. constructor();
  28400. reset(): void;
  28401. apply(gl: WebGLRenderingContext): void;
  28402. }
  28403. }
  28404. declare module BABYLON {
  28405. /**
  28406. * @hidden
  28407. **/
  28408. export class AlphaState {
  28409. private _isAlphaBlendDirty;
  28410. private _isBlendFunctionParametersDirty;
  28411. private _isBlendEquationParametersDirty;
  28412. private _isBlendConstantsDirty;
  28413. private _alphaBlend;
  28414. private _blendFunctionParameters;
  28415. private _blendEquationParameters;
  28416. private _blendConstants;
  28417. /**
  28418. * Initializes the state.
  28419. */
  28420. constructor();
  28421. readonly isDirty: boolean;
  28422. alphaBlend: boolean;
  28423. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  28424. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  28425. setAlphaEquationParameters(rgb: number, alpha: number): void;
  28426. reset(): void;
  28427. apply(gl: WebGLRenderingContext): void;
  28428. }
  28429. }
  28430. declare module BABYLON {
  28431. /** @hidden */
  28432. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28433. attributeProcessor(attribute: string): string;
  28434. varyingProcessor(varying: string, isFragment: boolean): string;
  28435. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28436. }
  28437. }
  28438. declare module BABYLON {
  28439. /**
  28440. * Interface for attribute information associated with buffer instanciation
  28441. */
  28442. export class InstancingAttributeInfo {
  28443. /**
  28444. * Index/offset of the attribute in the vertex shader
  28445. */
  28446. index: number;
  28447. /**
  28448. * size of the attribute, 1, 2, 3 or 4
  28449. */
  28450. attributeSize: number;
  28451. /**
  28452. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28453. * default is FLOAT
  28454. */
  28455. attribyteType: number;
  28456. /**
  28457. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28458. */
  28459. normalized: boolean;
  28460. /**
  28461. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28462. */
  28463. offset: number;
  28464. /**
  28465. * Name of the GLSL attribute, for debugging purpose only
  28466. */
  28467. attributeName: string;
  28468. }
  28469. }
  28470. declare module BABYLON {
  28471. interface ThinEngine {
  28472. /**
  28473. * Update a video texture
  28474. * @param texture defines the texture to update
  28475. * @param video defines the video element to use
  28476. * @param invertY defines if data must be stored with Y axis inverted
  28477. */
  28478. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28479. }
  28480. }
  28481. declare module BABYLON {
  28482. /**
  28483. * Settings for finer control over video usage
  28484. */
  28485. export interface VideoTextureSettings {
  28486. /**
  28487. * Applies `autoplay` to video, if specified
  28488. */
  28489. autoPlay?: boolean;
  28490. /**
  28491. * Applies `loop` to video, if specified
  28492. */
  28493. loop?: boolean;
  28494. /**
  28495. * Automatically updates internal texture from video at every frame in the render loop
  28496. */
  28497. autoUpdateTexture: boolean;
  28498. /**
  28499. * Image src displayed during the video loading or until the user interacts with the video.
  28500. */
  28501. poster?: string;
  28502. }
  28503. /**
  28504. * If you want to display a video in your scene, this is the special texture for that.
  28505. * This special texture works similar to other textures, with the exception of a few parameters.
  28506. * @see https://doc.babylonjs.com/how_to/video_texture
  28507. */
  28508. export class VideoTexture extends Texture {
  28509. /**
  28510. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  28511. */
  28512. readonly autoUpdateTexture: boolean;
  28513. /**
  28514. * The video instance used by the texture internally
  28515. */
  28516. readonly video: HTMLVideoElement;
  28517. private _onUserActionRequestedObservable;
  28518. /**
  28519. * Event triggerd when a dom action is required by the user to play the video.
  28520. * This happens due to recent changes in browser policies preventing video to auto start.
  28521. */
  28522. readonly onUserActionRequestedObservable: Observable<Texture>;
  28523. private _generateMipMaps;
  28524. private _engine;
  28525. private _stillImageCaptured;
  28526. private _displayingPosterTexture;
  28527. private _settings;
  28528. private _createInternalTextureOnEvent;
  28529. private _frameId;
  28530. /**
  28531. * Creates a video texture.
  28532. * If you want to display a video in your scene, this is the special texture for that.
  28533. * This special texture works similar to other textures, with the exception of a few parameters.
  28534. * @see https://doc.babylonjs.com/how_to/video_texture
  28535. * @param name optional name, will detect from video source, if not defined
  28536. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28537. * @param scene is obviously the current scene.
  28538. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28539. * @param invertY is false by default but can be used to invert video on Y axis
  28540. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28541. * @param settings allows finer control over video usage
  28542. */
  28543. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28544. private _getName;
  28545. private _getVideo;
  28546. private _createInternalTexture;
  28547. private reset;
  28548. /**
  28549. * @hidden Internal method to initiate `update`.
  28550. */ private _rebuild(): void;
  28551. /**
  28552. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28553. */
  28554. update(): void;
  28555. /**
  28556. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28557. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28558. */
  28559. updateTexture(isVisible: boolean): void;
  28560. protected _updateInternalTexture: () => void;
  28561. /**
  28562. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28563. * @param url New url.
  28564. */
  28565. updateURL(url: string): void;
  28566. /**
  28567. * Dispose the texture and release its associated resources.
  28568. */
  28569. dispose(): void;
  28570. /**
  28571. * Creates a video texture straight from a stream.
  28572. * @param scene Define the scene the texture should be created in
  28573. * @param stream Define the stream the texture should be created from
  28574. * @returns The created video texture as a promise
  28575. */
  28576. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28577. /**
  28578. * Creates a video texture straight from your WebCam video feed.
  28579. * @param scene Define the scene the texture should be created in
  28580. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28581. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28582. * @returns The created video texture as a promise
  28583. */
  28584. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28585. minWidth: number;
  28586. maxWidth: number;
  28587. minHeight: number;
  28588. maxHeight: number;
  28589. deviceId: string;
  28590. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28591. /**
  28592. * Creates a video texture straight from your WebCam video feed.
  28593. * @param scene Define the scene the texture should be created in
  28594. * @param onReady Define a callback to triggered once the texture will be ready
  28595. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28596. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28597. */
  28598. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28599. minWidth: number;
  28600. maxWidth: number;
  28601. minHeight: number;
  28602. maxHeight: number;
  28603. deviceId: string;
  28604. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  28605. }
  28606. }
  28607. declare module BABYLON {
  28608. /**
  28609. * Defines the interface used by objects working like Scene
  28610. * @hidden
  28611. */
  28612. interface ISceneLike { private _addPendingData(data: any): void; private _removePendingData(data: any): void;
  28613. offlineProvider: IOfflineProvider;
  28614. }
  28615. /** Interface defining initialization parameters for Engine class */
  28616. export interface EngineOptions extends WebGLContextAttributes {
  28617. /**
  28618. * Defines if the engine should no exceed a specified device ratio
  28619. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28620. */
  28621. limitDeviceRatio?: number;
  28622. /**
  28623. * Defines if webvr should be enabled automatically
  28624. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28625. */
  28626. autoEnableWebVR?: boolean;
  28627. /**
  28628. * Defines if webgl2 should be turned off even if supported
  28629. * @see http://doc.babylonjs.com/features/webgl2
  28630. */
  28631. disableWebGL2Support?: boolean;
  28632. /**
  28633. * Defines if webaudio should be initialized as well
  28634. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28635. */
  28636. audioEngine?: boolean;
  28637. /**
  28638. * Defines if animations should run using a deterministic lock step
  28639. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28640. */
  28641. deterministicLockstep?: boolean;
  28642. /** Defines the maximum steps to use with deterministic lock step mode */
  28643. lockstepMaxSteps?: number;
  28644. /**
  28645. * Defines that engine should ignore context lost events
  28646. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28647. */
  28648. doNotHandleContextLost?: boolean;
  28649. /**
  28650. * Defines that engine should ignore modifying touch action attribute and style
  28651. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28652. */
  28653. doNotHandleTouchAction?: boolean;
  28654. /**
  28655. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28656. */
  28657. useHighPrecisionFloats?: boolean;
  28658. }
  28659. /**
  28660. * The base engine class (root of all engines)
  28661. */
  28662. export class ThinEngine {
  28663. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28664. static ExceptionList: ({
  28665. key: string;
  28666. capture: string;
  28667. captureConstraint: number;
  28668. targets: string[];
  28669. } | {
  28670. key: string;
  28671. capture: null;
  28672. captureConstraint: null;
  28673. targets: string[];
  28674. })[];
  28675. /** @hidden */ private static _TextureLoaders: IInternalTextureLoader[];
  28676. /**
  28677. * Returns the current npm package of the sdk
  28678. */
  28679. static readonly NpmPackage: string;
  28680. /**
  28681. * Returns the current version of the framework
  28682. */
  28683. static readonly Version: string;
  28684. /**
  28685. * Returns a string describing the current engine
  28686. */
  28687. readonly description: string;
  28688. /**
  28689. * Gets or sets the epsilon value used by collision engine
  28690. */
  28691. static CollisionsEpsilon: number;
  28692. /**
  28693. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28694. */
  28695. static ShadersRepository: string;
  28696. /** @hidden */ private _shaderProcessor: IShaderProcessor;
  28697. /**
  28698. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28699. */
  28700. forcePOTTextures: boolean;
  28701. /**
  28702. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28703. */
  28704. isFullscreen: boolean;
  28705. /**
  28706. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28707. */
  28708. cullBackFaces: boolean;
  28709. /**
  28710. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28711. */
  28712. renderEvenInBackground: boolean;
  28713. /**
  28714. * Gets or sets a boolean indicating that cache can be kept between frames
  28715. */
  28716. preventCacheWipeBetweenFrames: boolean;
  28717. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28718. validateShaderPrograms: boolean;
  28719. /**
  28720. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28721. */
  28722. disableUniformBuffers: boolean;
  28723. /** @hidden */ private _uniformBuffers: UniformBuffer[];
  28724. /**
  28725. * Gets a boolean indicating that the engine supports uniform buffers
  28726. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28727. */
  28728. readonly supportsUniformBuffers: boolean;
  28729. /** @hidden */ private _gl: WebGLRenderingContext;
  28730. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  28731. protected _windowIsBackground: boolean;
  28732. protected _webGLVersion: number;
  28733. protected _highPrecisionShadersAllowed: boolean;
  28734. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  28735. /**
  28736. * Gets a boolean indicating that only power of 2 textures are supported
  28737. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28738. */
  28739. readonly needPOTTextures: boolean;
  28740. /** @hidden */ private _badOS: boolean;
  28741. /** @hidden */ private _badDesktopOS: boolean;
  28742. private _hardwareScalingLevel;
  28743. /** @hidden */ private _caps: EngineCapabilities;
  28744. private _isStencilEnable;
  28745. protected _colorWrite: boolean;
  28746. private _glVersion;
  28747. private _glRenderer;
  28748. private _glVendor;
  28749. /** @hidden */ private _videoTextureSupported: boolean;
  28750. protected _renderingQueueLaunched: boolean;
  28751. protected _activeRenderLoops: (() => void)[];
  28752. /**
  28753. * Observable signaled when a context lost event is raised
  28754. */
  28755. onContextLostObservable: Observable<ThinEngine>;
  28756. /**
  28757. * Observable signaled when a context restored event is raised
  28758. */
  28759. onContextRestoredObservable: Observable<ThinEngine>;
  28760. private _onContextLost;
  28761. private _onContextRestored;
  28762. protected _contextWasLost: boolean;
  28763. /** @hidden */ private _doNotHandleContextLost: boolean;
  28764. /**
  28765. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28766. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28767. */
  28768. doNotHandleContextLost: boolean;
  28769. /**
  28770. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28771. */
  28772. disableVertexArrayObjects: boolean;
  28773. /** @hidden */
  28774. protected _depthCullingState: DepthCullingState;
  28775. /** @hidden */
  28776. protected _stencilState: StencilState;
  28777. /** @hidden */
  28778. protected _alphaState: AlphaState;
  28779. /** @hidden */ private _internalTexturesCache: InternalTexture[];
  28780. /** @hidden */
  28781. protected _activeChannel: number;
  28782. private _currentTextureChannel;
  28783. /** @hidden */
  28784. protected _boundTexturesCache: {
  28785. [key: string]: Nullable<InternalTexture>;
  28786. };
  28787. /** @hidden */
  28788. protected _currentEffect: Nullable<Effect>;
  28789. /** @hidden */
  28790. protected _currentProgram: Nullable<WebGLProgram>;
  28791. private _compiledEffects;
  28792. private _vertexAttribArraysEnabled;
  28793. /** @hidden */
  28794. protected _cachedViewport: Nullable<IViewportLike>;
  28795. private _cachedVertexArrayObject;
  28796. /** @hidden */
  28797. protected _cachedVertexBuffers: any;
  28798. /** @hidden */
  28799. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28800. /** @hidden */
  28801. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28802. /** @hidden */ private _currentRenderTarget: Nullable<InternalTexture>;
  28803. private _uintIndicesCurrentlySet;
  28804. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  28805. /** @hidden */
  28806. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28807. private _currentBufferPointers;
  28808. private _currentInstanceLocations;
  28809. private _currentInstanceBuffers;
  28810. private _textureUnits;
  28811. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  28812. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  28813. /** @hidden */ private _bindedRenderFunction: any;
  28814. private _vaoRecordInProgress;
  28815. private _mustWipeVertexAttributes;
  28816. private _emptyTexture;
  28817. private _emptyCubeTexture;
  28818. private _emptyTexture3D;
  28819. /** @hidden */ private _frameHandler: number;
  28820. private _nextFreeTextureSlots;
  28821. private _maxSimultaneousTextures;
  28822. private _activeRequests;
  28823. protected _texturesSupported: string[];
  28824. /** @hidden */ private _textureFormatInUse: Nullable<string>;
  28825. protected readonly _supportsHardwareTextureRescaling: boolean;
  28826. /**
  28827. * Gets the list of texture formats supported
  28828. */
  28829. readonly texturesSupported: Array<string>;
  28830. /**
  28831. * Gets the list of texture formats in use
  28832. */
  28833. readonly textureFormatInUse: Nullable<string>;
  28834. /**
  28835. * Gets the current viewport
  28836. */
  28837. readonly currentViewport: Nullable<IViewportLike>;
  28838. /**
  28839. * Gets the default empty texture
  28840. */
  28841. readonly emptyTexture: InternalTexture;
  28842. /**
  28843. * Gets the default empty 3D texture
  28844. */
  28845. readonly emptyTexture3D: InternalTexture;
  28846. /**
  28847. * Gets the default empty cube texture
  28848. */
  28849. readonly emptyCubeTexture: InternalTexture;
  28850. /**
  28851. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28852. */
  28853. readonly premultipliedAlpha: boolean;
  28854. /**
  28855. * Creates a new engine
  28856. * @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
  28857. * @param antialias defines enable antialiasing (default: false)
  28858. * @param options defines further options to be sent to the getContext() function
  28859. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28860. */
  28861. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28862. private _rebuildInternalTextures;
  28863. private _rebuildEffects;
  28864. /**
  28865. * Gets a boolean indicating if all created effects are ready
  28866. * @returns true if all effects are ready
  28867. */
  28868. areAllEffectsReady(): boolean;
  28869. protected _rebuildBuffers(): void;
  28870. private _initGLContext;
  28871. /**
  28872. * Gets version of the current webGL context
  28873. */
  28874. readonly webGLVersion: number;
  28875. /**
  28876. * Gets a string idenfifying the name of the class
  28877. * @returns "Engine" string
  28878. */
  28879. getClassName(): string;
  28880. /**
  28881. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28882. */
  28883. readonly isStencilEnable: boolean;
  28884. /** @hidden */ private _prepareWorkingCanvas(): void;
  28885. /**
  28886. * Reset the texture cache to empty state
  28887. */
  28888. resetTextureCache(): void;
  28889. /**
  28890. * Gets an object containing information about the current webGL context
  28891. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28892. */
  28893. getGlInfo(): {
  28894. vendor: string;
  28895. renderer: string;
  28896. version: string;
  28897. };
  28898. /**
  28899. * Defines the hardware scaling level.
  28900. * By default the hardware scaling level is computed from the window device ratio.
  28901. * 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.
  28902. * @param level defines the level to use
  28903. */
  28904. setHardwareScalingLevel(level: number): void;
  28905. /**
  28906. * Gets the current hardware scaling level.
  28907. * By default the hardware scaling level is computed from the window device ratio.
  28908. * 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.
  28909. * @returns a number indicating the current hardware scaling level
  28910. */
  28911. getHardwareScalingLevel(): number;
  28912. /**
  28913. * Gets the list of loaded textures
  28914. * @returns an array containing all loaded textures
  28915. */
  28916. getLoadedTexturesCache(): InternalTexture[];
  28917. /**
  28918. * Gets the object containing all engine capabilities
  28919. * @returns the EngineCapabilities object
  28920. */
  28921. getCaps(): EngineCapabilities;
  28922. /**
  28923. * stop executing a render loop function and remove it from the execution array
  28924. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28925. */
  28926. stopRenderLoop(renderFunction?: () => void): void;
  28927. /** @hidden */ private _renderLoop(): void;
  28928. /**
  28929. * Gets the HTML canvas attached with the current webGL context
  28930. * @returns a HTML canvas
  28931. */
  28932. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28933. /**
  28934. * Gets host window
  28935. * @returns the host window object
  28936. */
  28937. getHostWindow(): Window;
  28938. /**
  28939. * Gets the current render width
  28940. * @param useScreen defines if screen size must be used (or the current render target if any)
  28941. * @returns a number defining the current render width
  28942. */
  28943. getRenderWidth(useScreen?: boolean): number;
  28944. /**
  28945. * Gets the current render height
  28946. * @param useScreen defines if screen size must be used (or the current render target if any)
  28947. * @returns a number defining the current render height
  28948. */
  28949. getRenderHeight(useScreen?: boolean): number;
  28950. /**
  28951. * Can be used to override the current requestAnimationFrame requester.
  28952. * @hidden
  28953. */
  28954. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  28955. /**
  28956. * Register and execute a render loop. The engine can have more than one render function
  28957. * @param renderFunction defines the function to continuously execute
  28958. */
  28959. runRenderLoop(renderFunction: () => void): void;
  28960. /**
  28961. * Clear the current render buffer or the current render target (if any is set up)
  28962. * @param color defines the color to use
  28963. * @param backBuffer defines if the back buffer must be cleared
  28964. * @param depth defines if the depth buffer must be cleared
  28965. * @param stencil defines if the stencil buffer must be cleared
  28966. */
  28967. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28968. private _viewportCached;
  28969. /** @hidden */ private _viewport(x: number, y: number, width: number, height: number): void;
  28970. /**
  28971. * Set the WebGL's viewport
  28972. * @param viewport defines the viewport element to be used
  28973. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28974. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28975. */
  28976. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  28977. /**
  28978. * Begin a new frame
  28979. */
  28980. beginFrame(): void;
  28981. /**
  28982. * Enf the current frame
  28983. */
  28984. endFrame(): void;
  28985. /**
  28986. * Resize the view according to the canvas' size
  28987. */
  28988. resize(): void;
  28989. /**
  28990. * Force a specific size of the canvas
  28991. * @param width defines the new canvas' width
  28992. * @param height defines the new canvas' height
  28993. */
  28994. setSize(width: number, height: number): void;
  28995. /**
  28996. * Binds the frame buffer to the specified texture.
  28997. * @param texture The texture to render to or null for the default canvas
  28998. * @param faceIndex The face of the texture to render to in case of cube texture
  28999. * @param requiredWidth The width of the target to render to
  29000. * @param requiredHeight The height of the target to render to
  29001. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29002. * @param depthStencilTexture The depth stencil texture to use to render
  29003. * @param lodLevel defines le lod level to bind to the frame buffer
  29004. */
  29005. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29006. /** @hidden */ private _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29007. /**
  29008. * Unbind the current render target texture from the webGL context
  29009. * @param texture defines the render target texture to unbind
  29010. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29011. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29012. */
  29013. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29014. /**
  29015. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29016. */
  29017. flushFramebuffer(): void;
  29018. /**
  29019. * Unbind the current render target and bind the default framebuffer
  29020. */
  29021. restoreDefaultFramebuffer(): void;
  29022. private _resetVertexBufferBinding;
  29023. /**
  29024. * Creates a vertex buffer
  29025. * @param data the data for the vertex buffer
  29026. * @returns the new WebGL static buffer
  29027. */
  29028. createVertexBuffer(data: DataArray): DataBuffer;
  29029. private _createVertexBuffer;
  29030. /**
  29031. * Creates a dynamic vertex buffer
  29032. * @param data the data for the dynamic vertex buffer
  29033. * @returns the new WebGL dynamic buffer
  29034. */
  29035. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29036. /**
  29037. * Updates a dynamic vertex buffer.
  29038. * @param vertexBuffer the vertex buffer to update
  29039. * @param data the data used to update the vertex buffer
  29040. * @param byteOffset the byte offset of the data
  29041. * @param byteLength the byte length of the data
  29042. */
  29043. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29044. protected _resetIndexBufferBinding(): void;
  29045. /**
  29046. * Creates a new index buffer
  29047. * @param indices defines the content of the index buffer
  29048. * @param updatable defines if the index buffer must be updatable
  29049. * @returns a new webGL buffer
  29050. */
  29051. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29052. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  29053. /**
  29054. * Bind a webGL buffer to the webGL context
  29055. * @param buffer defines the buffer to bind
  29056. */
  29057. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29058. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  29059. private bindBuffer;
  29060. /**
  29061. * update the bound buffer with the given data
  29062. * @param data defines the data to update
  29063. */
  29064. updateArrayBuffer(data: Float32Array): void;
  29065. private _vertexAttribPointer;
  29066. private _bindIndexBufferWithCache;
  29067. private _bindVertexBuffersAttributes;
  29068. /**
  29069. * Records a vertex array object
  29070. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29071. * @param vertexBuffers defines the list of vertex buffers to store
  29072. * @param indexBuffer defines the index buffer to store
  29073. * @param effect defines the effect to store
  29074. * @returns the new vertex array object
  29075. */
  29076. recordVertexArrayObject(vertexBuffers: {
  29077. [key: string]: VertexBuffer;
  29078. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29079. /**
  29080. * Bind a specific vertex array object
  29081. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29082. * @param vertexArrayObject defines the vertex array object to bind
  29083. * @param indexBuffer defines the index buffer to bind
  29084. */
  29085. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29086. /**
  29087. * Bind webGl buffers directly to the webGL context
  29088. * @param vertexBuffer defines the vertex buffer to bind
  29089. * @param indexBuffer defines the index buffer to bind
  29090. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29091. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29092. * @param effect defines the effect associated with the vertex buffer
  29093. */
  29094. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29095. private _unbindVertexArrayObject;
  29096. /**
  29097. * Bind a list of vertex buffers to the webGL context
  29098. * @param vertexBuffers defines the list of vertex buffers to bind
  29099. * @param indexBuffer defines the index buffer to bind
  29100. * @param effect defines the effect associated with the vertex buffers
  29101. */
  29102. bindBuffers(vertexBuffers: {
  29103. [key: string]: Nullable<VertexBuffer>;
  29104. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29105. /**
  29106. * Unbind all instance attributes
  29107. */
  29108. unbindInstanceAttributes(): void;
  29109. /**
  29110. * Release and free the memory of a vertex array object
  29111. * @param vao defines the vertex array object to delete
  29112. */
  29113. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29114. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  29115. protected _deleteBuffer(buffer: DataBuffer): void;
  29116. /**
  29117. * Creates a webGL buffer to use with instanciation
  29118. * @param capacity defines the size of the buffer
  29119. * @returns the webGL buffer
  29120. */
  29121. createInstancesBuffer(capacity: number): DataBuffer;
  29122. /**
  29123. * Delete a webGL buffer used with instanciation
  29124. * @param buffer defines the webGL buffer to delete
  29125. */
  29126. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29127. /**
  29128. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29129. * @param instancesBuffer defines the webGL buffer to update and bind
  29130. * @param data defines the data to store in the buffer
  29131. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29132. */
  29133. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29134. /**
  29135. * Apply all cached states (depth, culling, stencil and alpha)
  29136. */
  29137. applyStates(): void;
  29138. /**
  29139. * Send a draw order
  29140. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29141. * @param indexStart defines the starting index
  29142. * @param indexCount defines the number of index to draw
  29143. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29144. */
  29145. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29146. /**
  29147. * Draw a list of points
  29148. * @param verticesStart defines the index of first vertex to draw
  29149. * @param verticesCount defines the count of vertices to draw
  29150. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29151. */
  29152. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29153. /**
  29154. * Draw a list of unindexed primitives
  29155. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29156. * @param verticesStart defines the index of first vertex to draw
  29157. * @param verticesCount defines the count of vertices to draw
  29158. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29159. */
  29160. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29161. /**
  29162. * Draw a list of indexed primitives
  29163. * @param fillMode defines the primitive to use
  29164. * @param indexStart defines the starting index
  29165. * @param indexCount defines the number of index to draw
  29166. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29167. */
  29168. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29169. /**
  29170. * Draw a list of unindexed primitives
  29171. * @param fillMode defines the primitive to use
  29172. * @param verticesStart defines the index of first vertex to draw
  29173. * @param verticesCount defines the count of vertices to draw
  29174. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29175. */
  29176. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29177. private _drawMode;
  29178. /** @hidden */
  29179. protected _reportDrawCall(): void;
  29180. /** @hidden */ private _releaseEffect(effect: Effect): void;
  29181. /** @hidden */ private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29182. /**
  29183. * Create a new effect (used to store vertex/fragment shaders)
  29184. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29185. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29186. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29187. * @param samplers defines an array of string used to represent textures
  29188. * @param defines defines the string containing the defines to use to compile the shaders
  29189. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29190. * @param onCompiled defines a function to call when the effect creation is successful
  29191. * @param onError defines a function to call when the effect creation has failed
  29192. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29193. * @returns the new Effect
  29194. */
  29195. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29196. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  29197. private _compileShader;
  29198. private _compileRawShader;
  29199. /**
  29200. * Directly creates a webGL program
  29201. * @param pipelineContext defines the pipeline context to attach to
  29202. * @param vertexCode defines the vertex shader code to use
  29203. * @param fragmentCode defines the fragment shader code to use
  29204. * @param context defines the webGL context to use (if not set, the current one will be used)
  29205. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29206. * @returns the new webGL program
  29207. */
  29208. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29209. /**
  29210. * Creates a webGL program
  29211. * @param pipelineContext defines the pipeline context to attach to
  29212. * @param vertexCode defines the vertex shader code to use
  29213. * @param fragmentCode defines the fragment shader code to use
  29214. * @param defines defines the string containing the defines to use to compile the shaders
  29215. * @param context defines the webGL context to use (if not set, the current one will be used)
  29216. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29217. * @returns the new webGL program
  29218. */
  29219. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29220. /**
  29221. * Creates a new pipeline context
  29222. * @returns the new pipeline
  29223. */
  29224. createPipelineContext(): IPipelineContext;
  29225. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29226. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  29227. /** @hidden */ private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29228. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29229. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29230. /**
  29231. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29232. * @param pipelineContext defines the pipeline context to use
  29233. * @param uniformsNames defines the list of uniform names
  29234. * @returns an array of webGL uniform locations
  29235. */
  29236. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29237. /**
  29238. * Gets the lsit of active attributes for a given webGL program
  29239. * @param pipelineContext defines the pipeline context to use
  29240. * @param attributesNames defines the list of attribute names to get
  29241. * @returns an array of indices indicating the offset of each attribute
  29242. */
  29243. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29244. /**
  29245. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29246. * @param effect defines the effect to activate
  29247. */
  29248. enableEffect(effect: Nullable<Effect>): void;
  29249. /**
  29250. * Set the value of an uniform to an array of int32
  29251. * @param uniform defines the webGL uniform location where to store the value
  29252. * @param array defines the array of int32 to store
  29253. */
  29254. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29255. /**
  29256. * Set the value of an uniform to an array of int32 (stored as vec2)
  29257. * @param uniform defines the webGL uniform location where to store the value
  29258. * @param array defines the array of int32 to store
  29259. */
  29260. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29261. /**
  29262. * Set the value of an uniform to an array of int32 (stored as vec3)
  29263. * @param uniform defines the webGL uniform location where to store the value
  29264. * @param array defines the array of int32 to store
  29265. */
  29266. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29267. /**
  29268. * Set the value of an uniform to an array of int32 (stored as vec4)
  29269. * @param uniform defines the webGL uniform location where to store the value
  29270. * @param array defines the array of int32 to store
  29271. */
  29272. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29273. /**
  29274. * Set the value of an uniform to an array of float32
  29275. * @param uniform defines the webGL uniform location where to store the value
  29276. * @param array defines the array of float32 to store
  29277. */
  29278. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29279. /**
  29280. * Set the value of an uniform to an array of float32 (stored as vec2)
  29281. * @param uniform defines the webGL uniform location where to store the value
  29282. * @param array defines the array of float32 to store
  29283. */
  29284. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29285. /**
  29286. * Set the value of an uniform to an array of float32 (stored as vec3)
  29287. * @param uniform defines the webGL uniform location where to store the value
  29288. * @param array defines the array of float32 to store
  29289. */
  29290. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29291. /**
  29292. * Set the value of an uniform to an array of float32 (stored as vec4)
  29293. * @param uniform defines the webGL uniform location where to store the value
  29294. * @param array defines the array of float32 to store
  29295. */
  29296. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29297. /**
  29298. * Set the value of an uniform to an array of number
  29299. * @param uniform defines the webGL uniform location where to store the value
  29300. * @param array defines the array of number to store
  29301. */
  29302. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29303. /**
  29304. * Set the value of an uniform to an array of number (stored as vec2)
  29305. * @param uniform defines the webGL uniform location where to store the value
  29306. * @param array defines the array of number to store
  29307. */
  29308. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29309. /**
  29310. * Set the value of an uniform to an array of number (stored as vec3)
  29311. * @param uniform defines the webGL uniform location where to store the value
  29312. * @param array defines the array of number to store
  29313. */
  29314. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29315. /**
  29316. * Set the value of an uniform to an array of number (stored as vec4)
  29317. * @param uniform defines the webGL uniform location where to store the value
  29318. * @param array defines the array of number to store
  29319. */
  29320. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29321. /**
  29322. * Set the value of an uniform to an array of float32 (stored as matrices)
  29323. * @param uniform defines the webGL uniform location where to store the value
  29324. * @param matrices defines the array of float32 to store
  29325. */
  29326. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29327. /**
  29328. * Set the value of an uniform to a matrix (3x3)
  29329. * @param uniform defines the webGL uniform location where to store the value
  29330. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29331. */
  29332. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29333. /**
  29334. * Set the value of an uniform to a matrix (2x2)
  29335. * @param uniform defines the webGL uniform location where to store the value
  29336. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29337. */
  29338. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29339. /**
  29340. * Set the value of an uniform to a number (int)
  29341. * @param uniform defines the webGL uniform location where to store the value
  29342. * @param value defines the int number to store
  29343. */
  29344. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29345. /**
  29346. * Set the value of an uniform to a number (float)
  29347. * @param uniform defines the webGL uniform location where to store the value
  29348. * @param value defines the float number to store
  29349. */
  29350. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29351. /**
  29352. * Set the value of an uniform to a vec2
  29353. * @param uniform defines the webGL uniform location where to store the value
  29354. * @param x defines the 1st component of the value
  29355. * @param y defines the 2nd component of the value
  29356. */
  29357. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29358. /**
  29359. * Set the value of an uniform to a vec3
  29360. * @param uniform defines the webGL uniform location where to store the value
  29361. * @param x defines the 1st component of the value
  29362. * @param y defines the 2nd component of the value
  29363. * @param z defines the 3rd component of the value
  29364. */
  29365. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29366. /**
  29367. * Set the value of an uniform to a boolean
  29368. * @param uniform defines the webGL uniform location where to store the value
  29369. * @param bool defines the boolean to store
  29370. */
  29371. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29372. /**
  29373. * Set the value of an uniform to a vec4
  29374. * @param uniform defines the webGL uniform location where to store the value
  29375. * @param x defines the 1st component of the value
  29376. * @param y defines the 2nd component of the value
  29377. * @param z defines the 3rd component of the value
  29378. * @param w defines the 4th component of the value
  29379. */
  29380. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29381. /**
  29382. * Sets a Color4 on a uniform variable
  29383. * @param uniform defines the uniform location
  29384. * @param color4 defines the value to be set
  29385. */
  29386. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  29387. /**
  29388. * Gets the depth culling state manager
  29389. */
  29390. readonly depthCullingState: DepthCullingState;
  29391. /**
  29392. * Gets the alpha state manager
  29393. */
  29394. readonly alphaState: AlphaState;
  29395. /**
  29396. * Gets the stencil state manager
  29397. */
  29398. readonly stencilState: StencilState;
  29399. /**
  29400. * Clears the list of texture accessible through engine.
  29401. * This can help preventing texture load conflict due to name collision.
  29402. */
  29403. clearInternalTexturesCache(): void;
  29404. /**
  29405. * Force the entire cache to be cleared
  29406. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29407. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29408. */
  29409. wipeCaches(bruteForce?: boolean): void;
  29410. /** @hidden */ private _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29411. min: number;
  29412. mag: number;
  29413. };
  29414. /** @hidden */ private _createTexture(): WebGLTexture;
  29415. /**
  29416. * Usually called from Texture.ts.
  29417. * Passed information to create a WebGLTexture
  29418. * @param urlArg defines a value which contains one of the following:
  29419. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29420. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29421. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29422. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29423. * @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)
  29424. * @param scene needed for loading to the correct scene
  29425. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29426. * @param onLoad optional callback to be called upon successful completion
  29427. * @param onError optional callback to be called upon failure
  29428. * @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
  29429. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29430. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29431. * @param forcedExtension defines the extension to use to pick the right loader
  29432. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29433. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29434. */
  29435. 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;
  29436. /**
  29437. * @hidden
  29438. */ private _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  29439. /**
  29440. * Creates a raw texture
  29441. * @param data defines the data to store in the texture
  29442. * @param width defines the width of the texture
  29443. * @param height defines the height of the texture
  29444. * @param format defines the format of the data
  29445. * @param generateMipMaps defines if the engine should generate the mip levels
  29446. * @param invertY defines if data must be stored with Y axis inverted
  29447. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29448. * @param compression defines the compression used (null by default)
  29449. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29450. * @returns the raw texture inside an InternalTexture
  29451. */
  29452. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29453. /**
  29454. * Creates a new raw cube texture
  29455. * @param data defines the array of data to use to create each face
  29456. * @param size defines the size of the textures
  29457. * @param format defines the format of the data
  29458. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29459. * @param generateMipMaps defines if the engine should generate the mip levels
  29460. * @param invertY defines if data must be stored with Y axis inverted
  29461. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29462. * @param compression defines the compression used (null by default)
  29463. * @returns the cube texture as an InternalTexture
  29464. */
  29465. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29466. /**
  29467. * Creates a new raw 3D texture
  29468. * @param data defines the data used to create the texture
  29469. * @param width defines the width of the texture
  29470. * @param height defines the height of the texture
  29471. * @param depth defines the depth of the texture
  29472. * @param format defines the format of the texture
  29473. * @param generateMipMaps defines if the engine must generate mip levels
  29474. * @param invertY defines if data must be stored with Y axis inverted
  29475. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29476. * @param compression defines the compressed used (can be null)
  29477. * @param textureType defines the compressed used (can be null)
  29478. * @returns a new raw 3D texture (stored in an InternalTexture)
  29479. */
  29480. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29481. private _unpackFlipYCached;
  29482. /**
  29483. * In case you are sharing the context with other applications, it might
  29484. * be interested to not cache the unpack flip y state to ensure a consistent
  29485. * value would be set.
  29486. */
  29487. enableUnpackFlipYCached: boolean;
  29488. /** @hidden */ private _unpackFlipY(value: boolean): void;
  29489. /** @hidden */ private _getUnpackAlignement(): number;
  29490. /**
  29491. * Update the sampling mode of a given texture
  29492. * @param samplingMode defines the required sampling mode
  29493. * @param texture defines the texture to update
  29494. */
  29495. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29496. /**
  29497. * Updates a depth texture Comparison Mode and Function.
  29498. * If the comparison Function is equal to 0, the mode will be set to none.
  29499. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29500. * @param texture The texture to set the comparison function for
  29501. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29502. */
  29503. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29504. /** @hidden */ private _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29505. width: number;
  29506. height: number;
  29507. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29508. /**
  29509. * Creates a depth stencil texture.
  29510. * This is only available in WebGL 2 or with the depth texture extension available.
  29511. * @param size The size of face edge in the texture.
  29512. * @param options The options defining the texture.
  29513. * @returns The texture
  29514. */
  29515. createDepthStencilTexture(size: number | {
  29516. width: number;
  29517. height: number;
  29518. }, options: DepthTextureCreationOptions): InternalTexture;
  29519. /**
  29520. * Creates a depth stencil texture.
  29521. * This is only available in WebGL 2 or with the depth texture extension available.
  29522. * @param size The size of face edge in the texture.
  29523. * @param options The options defining the texture.
  29524. * @returns The texture
  29525. */
  29526. private _createDepthStencilTexture;
  29527. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29528. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29529. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29530. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29531. /**
  29532. * @hidden
  29533. */ private _setCubeMapTextureParams(loadMipmap: boolean): void;
  29534. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  29535. private _prepareWebGLTexture;
  29536. /** @hidden */ private _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29537. /** @hidden */ private _releaseFramebufferObjects(texture: InternalTexture): void;
  29538. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  29539. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  29540. protected _setProgram(program: WebGLProgram): void;
  29541. protected _boundUniforms: {
  29542. [key: number]: WebGLUniformLocation;
  29543. };
  29544. /**
  29545. * Binds an effect to the webGL context
  29546. * @param effect defines the effect to bind
  29547. */
  29548. bindSamplers(effect: Effect): void;
  29549. private _activateCurrentTexture;
  29550. /** @hidden */ private _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29551. /** @hidden */ private _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29552. /**
  29553. * Unbind all textures from the webGL context
  29554. */
  29555. unbindAllTextures(): void;
  29556. /**
  29557. * Sets a texture to the according uniform.
  29558. * @param channel The texture channel
  29559. * @param uniform The uniform to set
  29560. * @param texture The texture to apply
  29561. */
  29562. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29563. private _bindSamplerUniformToChannel;
  29564. private _getTextureWrapMode;
  29565. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  29566. /**
  29567. * Sets an array of texture to the webGL context
  29568. * @param channel defines the channel where the texture array must be set
  29569. * @param uniform defines the associated uniform location
  29570. * @param textures defines the array of textures to bind
  29571. */
  29572. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29573. /** @hidden */ private _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29574. private _setTextureParameterFloat;
  29575. private _setTextureParameterInteger;
  29576. /**
  29577. * Unbind all vertex attributes from the webGL context
  29578. */
  29579. unbindAllAttributes(): void;
  29580. /**
  29581. * 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
  29582. */
  29583. releaseEffects(): void;
  29584. /**
  29585. * Dispose and release all associated resources
  29586. */
  29587. dispose(): void;
  29588. /**
  29589. * Attach a new callback raised when context lost event is fired
  29590. * @param callback defines the callback to call
  29591. */
  29592. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29593. /**
  29594. * Attach a new callback raised when context restored event is fired
  29595. * @param callback defines the callback to call
  29596. */
  29597. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29598. /**
  29599. * Get the current error code of the webGL context
  29600. * @returns the error code
  29601. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29602. */
  29603. getError(): number;
  29604. private _canRenderToFloatFramebuffer;
  29605. private _canRenderToHalfFloatFramebuffer;
  29606. private _canRenderToFramebuffer;
  29607. /** @hidden */ private _getWebGLTextureType(type: number): number;
  29608. /** @hidden */ private _getInternalFormat(format: number): number;
  29609. /** @hidden */ private _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29610. /** @hidden */ private _getRGBAMultiSampleBufferFormat(type: number): number;
  29611. /** @hidden */ private _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  29612. /**
  29613. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29614. * @returns true if the engine can be created
  29615. * @ignorenaming
  29616. */
  29617. static isSupported(): boolean;
  29618. /**
  29619. * Find the next highest power of two.
  29620. * @param x Number to start search from.
  29621. * @return Next highest power of two.
  29622. */
  29623. static CeilingPOT(x: number): number;
  29624. /**
  29625. * Find the next lowest power of two.
  29626. * @param x Number to start search from.
  29627. * @return Next lowest power of two.
  29628. */
  29629. static FloorPOT(x: number): number;
  29630. /**
  29631. * Find the nearest power of two.
  29632. * @param x Number to start search from.
  29633. * @return Next nearest power of two.
  29634. */
  29635. static NearestPOT(x: number): number;
  29636. /**
  29637. * Get the closest exponent of two
  29638. * @param value defines the value to approximate
  29639. * @param max defines the maximum value to return
  29640. * @param mode defines how to define the closest value
  29641. * @returns closest exponent of two of the given value
  29642. */
  29643. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  29644. /**
  29645. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  29646. * @param func - the function to be called
  29647. * @param requester - the object that will request the next frame. Falls back to window.
  29648. * @returns frame number
  29649. */
  29650. static QueueNewFrame(func: () => void, requester?: any): number;
  29651. }
  29652. }
  29653. declare module BABYLON {
  29654. /**
  29655. * Defines the source of the internal texture
  29656. */
  29657. export enum InternalTextureSource {
  29658. /**
  29659. * The source of the texture data is unknown
  29660. */
  29661. Unknown = 0,
  29662. /**
  29663. * Texture data comes from an URL
  29664. */
  29665. Url = 1,
  29666. /**
  29667. * Texture data is only used for temporary storage
  29668. */
  29669. Temp = 2,
  29670. /**
  29671. * Texture data comes from raw data (ArrayBuffer)
  29672. */
  29673. Raw = 3,
  29674. /**
  29675. * Texture content is dynamic (video or dynamic texture)
  29676. */
  29677. Dynamic = 4,
  29678. /**
  29679. * Texture content is generated by rendering to it
  29680. */
  29681. RenderTarget = 5,
  29682. /**
  29683. * Texture content is part of a multi render target process
  29684. */
  29685. MultiRenderTarget = 6,
  29686. /**
  29687. * Texture data comes from a cube data file
  29688. */
  29689. Cube = 7,
  29690. /**
  29691. * Texture data comes from a raw cube data
  29692. */
  29693. CubeRaw = 8,
  29694. /**
  29695. * Texture data come from a prefiltered cube data file
  29696. */
  29697. CubePrefiltered = 9,
  29698. /**
  29699. * Texture content is raw 3D data
  29700. */
  29701. Raw3D = 10,
  29702. /**
  29703. * Texture content is a depth texture
  29704. */
  29705. Depth = 11,
  29706. /**
  29707. * Texture data comes from a raw cube data encoded with RGBD
  29708. */
  29709. CubeRawRGBD = 12
  29710. }
  29711. /**
  29712. * Class used to store data associated with WebGL texture data for the engine
  29713. * This class should not be used directly
  29714. */
  29715. export class InternalTexture {
  29716. /** @hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  29717. /**
  29718. * Defines if the texture is ready
  29719. */
  29720. isReady: boolean;
  29721. /**
  29722. * Defines if the texture is a cube texture
  29723. */
  29724. isCube: boolean;
  29725. /**
  29726. * Defines if the texture contains 3D data
  29727. */
  29728. is3D: boolean;
  29729. /**
  29730. * Defines if the texture contains multiview data
  29731. */
  29732. isMultiview: boolean;
  29733. /**
  29734. * Gets the URL used to load this texture
  29735. */
  29736. url: string;
  29737. /**
  29738. * Gets the sampling mode of the texture
  29739. */
  29740. samplingMode: number;
  29741. /**
  29742. * Gets a boolean indicating if the texture needs mipmaps generation
  29743. */
  29744. generateMipMaps: boolean;
  29745. /**
  29746. * Gets the number of samples used by the texture (WebGL2+ only)
  29747. */
  29748. samples: number;
  29749. /**
  29750. * Gets the type of the texture (int, float...)
  29751. */
  29752. type: number;
  29753. /**
  29754. * Gets the format of the texture (RGB, RGBA...)
  29755. */
  29756. format: number;
  29757. /**
  29758. * Observable called when the texture is loaded
  29759. */
  29760. onLoadedObservable: Observable<InternalTexture>;
  29761. /**
  29762. * Gets the width of the texture
  29763. */
  29764. width: number;
  29765. /**
  29766. * Gets the height of the texture
  29767. */
  29768. height: number;
  29769. /**
  29770. * Gets the depth of the texture
  29771. */
  29772. depth: number;
  29773. /**
  29774. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  29775. */
  29776. baseWidth: number;
  29777. /**
  29778. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  29779. */
  29780. baseHeight: number;
  29781. /**
  29782. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  29783. */
  29784. baseDepth: number;
  29785. /**
  29786. * Gets a boolean indicating if the texture is inverted on Y axis
  29787. */
  29788. invertY: boolean;
  29789. /** @hidden */ private _invertVScale: boolean;
  29790. /** @hidden */ private _associatedChannel: number;
  29791. /** @hidden */ private _source: InternalTextureSource;
  29792. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  29793. /** @hidden */ private _bufferView: Nullable<ArrayBufferView>;
  29794. /** @hidden */ private _bufferViewArray: Nullable<ArrayBufferView[]>;
  29795. /** @hidden */ private _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  29796. /** @hidden */ private _size: number;
  29797. /** @hidden */ private _extension: string;
  29798. /** @hidden */ private _files: Nullable<string[]>;
  29799. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  29800. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  29801. /** @hidden */ private _framebuffer: Nullable<WebGLFramebuffer>;
  29802. /** @hidden */ private _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  29803. /** @hidden */ private _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  29804. /** @hidden */ private _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  29805. /** @hidden */ private _attachments: Nullable<number[]>;
  29806. /** @hidden */ private _cachedCoordinatesMode: Nullable<number>;
  29807. /** @hidden */ private _cachedWrapU: Nullable<number>;
  29808. /** @hidden */ private _cachedWrapV: Nullable<number>;
  29809. /** @hidden */ private _cachedWrapR: Nullable<number>;
  29810. /** @hidden */ private _cachedAnisotropicFilteringLevel: Nullable<number>;
  29811. /** @hidden */ private _isDisabled: boolean;
  29812. /** @hidden */ private _compression: Nullable<string>;
  29813. /** @hidden */ private _generateStencilBuffer: boolean;
  29814. /** @hidden */ private _generateDepthBuffer: boolean;
  29815. /** @hidden */ private _comparisonFunction: number;
  29816. /** @hidden */ private _sphericalPolynomial: Nullable<SphericalPolynomial>;
  29817. /** @hidden */ private _lodGenerationScale: number;
  29818. /** @hidden */ private _lodGenerationOffset: number;
  29819. /** @hidden */ private _colorTextureArray: Nullable<WebGLTexture>;
  29820. /** @hidden */ private _depthStencilTextureArray: Nullable<WebGLTexture>;
  29821. /** @hidden */ private _lodTextureHigh: Nullable<BaseTexture>;
  29822. /** @hidden */ private _lodTextureMid: Nullable<BaseTexture>;
  29823. /** @hidden */ private _lodTextureLow: Nullable<BaseTexture>;
  29824. /** @hidden */ private _isRGBD: boolean;
  29825. /** @hidden */ private _linearSpecularLOD: boolean;
  29826. /** @hidden */ private _irradianceTexture: Nullable<BaseTexture>;
  29827. /** @hidden */ private _webGLTexture: Nullable<WebGLTexture>;
  29828. /** @hidden */ private _references: number;
  29829. private _engine;
  29830. /**
  29831. * Gets the Engine the texture belongs to.
  29832. * @returns The babylon engine
  29833. */
  29834. getEngine(): ThinEngine;
  29835. /**
  29836. * Gets the data source type of the texture
  29837. */
  29838. readonly source: InternalTextureSource;
  29839. /**
  29840. * Creates a new InternalTexture
  29841. * @param engine defines the engine to use
  29842. * @param source defines the type of data that will be used
  29843. * @param delayAllocation if the texture allocation should be delayed (default: false)
  29844. */
  29845. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  29846. /**
  29847. * Increments the number of references (ie. the number of Texture that point to it)
  29848. */
  29849. incrementReferences(): void;
  29850. /**
  29851. * Change the size of the texture (not the size of the content)
  29852. * @param width defines the new width
  29853. * @param height defines the new height
  29854. * @param depth defines the new depth (1 by default)
  29855. */
  29856. updateSize(width: int, height: int, depth?: int): void;
  29857. /** @hidden */ private _rebuild(): void;
  29858. /** @hidden */ private _swapAndDie(target: InternalTexture): void;
  29859. /**
  29860. * Dispose the current allocated resources
  29861. */
  29862. dispose(): void;
  29863. }
  29864. }
  29865. declare module BABYLON {
  29866. /**
  29867. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29869. */
  29870. export class Analyser {
  29871. /**
  29872. * Gets or sets the smoothing
  29873. * @ignorenaming
  29874. */
  29875. SMOOTHING: number;
  29876. /**
  29877. * Gets or sets the FFT table size
  29878. * @ignorenaming
  29879. */
  29880. FFT_SIZE: number;
  29881. /**
  29882. * Gets or sets the bar graph amplitude
  29883. * @ignorenaming
  29884. */
  29885. BARGRAPHAMPLITUDE: number;
  29886. /**
  29887. * Gets or sets the position of the debug canvas
  29888. * @ignorenaming
  29889. */
  29890. DEBUGCANVASPOS: {
  29891. x: number;
  29892. y: number;
  29893. };
  29894. /**
  29895. * Gets or sets the debug canvas size
  29896. * @ignorenaming
  29897. */
  29898. DEBUGCANVASSIZE: {
  29899. width: number;
  29900. height: number;
  29901. };
  29902. private _byteFreqs;
  29903. private _byteTime;
  29904. private _floatFreqs;
  29905. private _webAudioAnalyser;
  29906. private _debugCanvas;
  29907. private _debugCanvasContext;
  29908. private _scene;
  29909. private _registerFunc;
  29910. private _audioEngine;
  29911. /**
  29912. * Creates a new analyser
  29913. * @param scene defines hosting scene
  29914. */
  29915. constructor(scene: Scene);
  29916. /**
  29917. * Get the number of data values you will have to play with for the visualization
  29918. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29919. * @returns a number
  29920. */
  29921. getFrequencyBinCount(): number;
  29922. /**
  29923. * Gets the current frequency data as a byte array
  29924. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29925. * @returns a Uint8Array
  29926. */
  29927. getByteFrequencyData(): Uint8Array;
  29928. /**
  29929. * Gets the current waveform as a byte array
  29930. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29931. * @returns a Uint8Array
  29932. */
  29933. getByteTimeDomainData(): Uint8Array;
  29934. /**
  29935. * Gets the current frequency data as a float array
  29936. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29937. * @returns a Float32Array
  29938. */
  29939. getFloatFrequencyData(): Float32Array;
  29940. /**
  29941. * Renders the debug canvas
  29942. */
  29943. drawDebugCanvas(): void;
  29944. /**
  29945. * Stops rendering the debug canvas and removes it
  29946. */
  29947. stopDebugCanvas(): void;
  29948. /**
  29949. * Connects two audio nodes
  29950. * @param inputAudioNode defines first node to connect
  29951. * @param outputAudioNode defines second node to connect
  29952. */
  29953. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29954. /**
  29955. * Releases all associated resources
  29956. */
  29957. dispose(): void;
  29958. }
  29959. }
  29960. declare module BABYLON {
  29961. /**
  29962. * This represents an audio engine and it is responsible
  29963. * to play, synchronize and analyse sounds throughout the application.
  29964. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29965. */
  29966. export interface IAudioEngine extends IDisposable {
  29967. /**
  29968. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29969. */
  29970. readonly canUseWebAudio: boolean;
  29971. /**
  29972. * Gets the current AudioContext if available.
  29973. */
  29974. readonly audioContext: Nullable<AudioContext>;
  29975. /**
  29976. * The master gain node defines the global audio volume of your audio engine.
  29977. */
  29978. readonly masterGain: GainNode;
  29979. /**
  29980. * Gets whether or not mp3 are supported by your browser.
  29981. */
  29982. readonly isMP3supported: boolean;
  29983. /**
  29984. * Gets whether or not ogg are supported by your browser.
  29985. */
  29986. readonly isOGGsupported: boolean;
  29987. /**
  29988. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29989. * @ignoreNaming
  29990. */
  29991. WarnedWebAudioUnsupported: boolean;
  29992. /**
  29993. * Defines if the audio engine relies on a custom unlocked button.
  29994. * In this case, the embedded button will not be displayed.
  29995. */
  29996. useCustomUnlockedButton: boolean;
  29997. /**
  29998. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29999. */
  30000. readonly unlocked: boolean;
  30001. /**
  30002. * Event raised when audio has been unlocked on the browser.
  30003. */
  30004. onAudioUnlockedObservable: Observable<AudioEngine>;
  30005. /**
  30006. * Event raised when audio has been locked on the browser.
  30007. */
  30008. onAudioLockedObservable: Observable<AudioEngine>;
  30009. /**
  30010. * Flags the audio engine in Locked state.
  30011. * This happens due to new browser policies preventing audio to autoplay.
  30012. */
  30013. lock(): void;
  30014. /**
  30015. * Unlocks the audio engine once a user action has been done on the dom.
  30016. * This is helpful to resume play once browser policies have been satisfied.
  30017. */
  30018. unlock(): void;
  30019. }
  30020. /**
  30021. * This represents the default audio engine used in babylon.
  30022. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30023. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30024. */
  30025. export class AudioEngine implements IAudioEngine {
  30026. private _audioContext;
  30027. private _audioContextInitialized;
  30028. private _muteButton;
  30029. private _hostElement;
  30030. /**
  30031. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30032. */
  30033. canUseWebAudio: boolean;
  30034. /**
  30035. * The master gain node defines the global audio volume of your audio engine.
  30036. */
  30037. masterGain: GainNode;
  30038. /**
  30039. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30040. * @ignoreNaming
  30041. */
  30042. WarnedWebAudioUnsupported: boolean;
  30043. /**
  30044. * Gets whether or not mp3 are supported by your browser.
  30045. */
  30046. isMP3supported: boolean;
  30047. /**
  30048. * Gets whether or not ogg are supported by your browser.
  30049. */
  30050. isOGGsupported: boolean;
  30051. /**
  30052. * Gets whether audio has been unlocked on the device.
  30053. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30054. * a user interaction has happened.
  30055. */
  30056. unlocked: boolean;
  30057. /**
  30058. * Defines if the audio engine relies on a custom unlocked button.
  30059. * In this case, the embedded button will not be displayed.
  30060. */
  30061. useCustomUnlockedButton: boolean;
  30062. /**
  30063. * Event raised when audio has been unlocked on the browser.
  30064. */
  30065. onAudioUnlockedObservable: Observable<AudioEngine>;
  30066. /**
  30067. * Event raised when audio has been locked on the browser.
  30068. */
  30069. onAudioLockedObservable: Observable<AudioEngine>;
  30070. /**
  30071. * Gets the current AudioContext if available.
  30072. */
  30073. readonly audioContext: Nullable<AudioContext>;
  30074. private _connectedAnalyser;
  30075. /**
  30076. * Instantiates a new audio engine.
  30077. *
  30078. * There should be only one per page as some browsers restrict the number
  30079. * of audio contexts you can create.
  30080. * @param hostElement defines the host element where to display the mute icon if necessary
  30081. */
  30082. constructor(hostElement?: Nullable<HTMLElement>);
  30083. /**
  30084. * Flags the audio engine in Locked state.
  30085. * This happens due to new browser policies preventing audio to autoplay.
  30086. */
  30087. lock(): void;
  30088. /**
  30089. * Unlocks the audio engine once a user action has been done on the dom.
  30090. * This is helpful to resume play once browser policies have been satisfied.
  30091. */
  30092. unlock(): void;
  30093. private _resumeAudioContext;
  30094. private _initializeAudioContext;
  30095. private _tryToRun;
  30096. private _triggerRunningState;
  30097. private _triggerSuspendedState;
  30098. private _displayMuteButton;
  30099. private _moveButtonToTopLeft;
  30100. private _onResize;
  30101. private _hideMuteButton;
  30102. /**
  30103. * Destroy and release the resources associated with the audio ccontext.
  30104. */
  30105. dispose(): void;
  30106. /**
  30107. * Gets the global volume sets on the master gain.
  30108. * @returns the global volume if set or -1 otherwise
  30109. */
  30110. getGlobalVolume(): number;
  30111. /**
  30112. * Sets the global volume of your experience (sets on the master gain).
  30113. * @param newVolume Defines the new global volume of the application
  30114. */
  30115. setGlobalVolume(newVolume: number): void;
  30116. /**
  30117. * Connect the audio engine to an audio analyser allowing some amazing
  30118. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30119. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30120. * @param analyser The analyser to connect to the engine
  30121. */
  30122. connectToAnalyser(analyser: Analyser): void;
  30123. }
  30124. }
  30125. declare module BABYLON {
  30126. /**
  30127. * Interface used to present a loading screen while loading a scene
  30128. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30129. */
  30130. export interface ILoadingScreen {
  30131. /**
  30132. * Function called to display the loading screen
  30133. */
  30134. displayLoadingUI: () => void;
  30135. /**
  30136. * Function called to hide the loading screen
  30137. */
  30138. hideLoadingUI: () => void;
  30139. /**
  30140. * Gets or sets the color to use for the background
  30141. */
  30142. loadingUIBackgroundColor: string;
  30143. /**
  30144. * Gets or sets the text to display while loading
  30145. */
  30146. loadingUIText: string;
  30147. }
  30148. /**
  30149. * Class used for the default loading screen
  30150. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30151. */
  30152. export class DefaultLoadingScreen implements ILoadingScreen {
  30153. private _renderingCanvas;
  30154. private _loadingText;
  30155. private _loadingDivBackgroundColor;
  30156. private _loadingDiv;
  30157. private _loadingTextDiv;
  30158. /** Gets or sets the logo url to use for the default loading screen */
  30159. static DefaultLogoUrl: string;
  30160. /** Gets or sets the spinner url to use for the default loading screen */
  30161. static DefaultSpinnerUrl: string;
  30162. /**
  30163. * Creates a new default loading screen
  30164. * @param _renderingCanvas defines the canvas used to render the scene
  30165. * @param _loadingText defines the default text to display
  30166. * @param _loadingDivBackgroundColor defines the default background color
  30167. */
  30168. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30169. /**
  30170. * Function called to display the loading screen
  30171. */
  30172. displayLoadingUI(): void;
  30173. /**
  30174. * Function called to hide the loading screen
  30175. */
  30176. hideLoadingUI(): void;
  30177. /**
  30178. * Gets or sets the text to display while loading
  30179. */
  30180. loadingUIText: string;
  30181. /**
  30182. * Gets or sets the color to use for the background
  30183. */
  30184. loadingUIBackgroundColor: string;
  30185. private _resizeLoadingUI;
  30186. }
  30187. }
  30188. declare module BABYLON {
  30189. /**
  30190. * Interface for any object that can request an animation frame
  30191. */
  30192. export interface ICustomAnimationFrameRequester {
  30193. /**
  30194. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30195. */
  30196. renderFunction?: Function;
  30197. /**
  30198. * Called to request the next frame to render to
  30199. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30200. */
  30201. requestAnimationFrame: Function;
  30202. /**
  30203. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30204. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30205. */
  30206. requestID?: number;
  30207. }
  30208. }
  30209. declare module BABYLON {
  30210. /**
  30211. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30212. */
  30213. export class PerformanceMonitor {
  30214. private _enabled;
  30215. private _rollingFrameTime;
  30216. private _lastFrameTimeMs;
  30217. /**
  30218. * constructor
  30219. * @param frameSampleSize The number of samples required to saturate the sliding window
  30220. */
  30221. constructor(frameSampleSize?: number);
  30222. /**
  30223. * Samples current frame
  30224. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30225. */
  30226. sampleFrame(timeMs?: number): void;
  30227. /**
  30228. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30229. */
  30230. readonly averageFrameTime: number;
  30231. /**
  30232. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30233. */
  30234. readonly averageFrameTimeVariance: number;
  30235. /**
  30236. * Returns the frame time of the most recent frame
  30237. */
  30238. readonly instantaneousFrameTime: number;
  30239. /**
  30240. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30241. */
  30242. readonly averageFPS: number;
  30243. /**
  30244. * Returns the average framerate in frames per second using the most recent frame time
  30245. */
  30246. readonly instantaneousFPS: number;
  30247. /**
  30248. * Returns true if enough samples have been taken to completely fill the sliding window
  30249. */
  30250. readonly isSaturated: boolean;
  30251. /**
  30252. * Enables contributions to the sliding window sample set
  30253. */
  30254. enable(): void;
  30255. /**
  30256. * Disables contributions to the sliding window sample set
  30257. * Samples will not be interpolated over the disabled period
  30258. */
  30259. disable(): void;
  30260. /**
  30261. * Returns true if sampling is enabled
  30262. */
  30263. readonly isEnabled: boolean;
  30264. /**
  30265. * Resets performance monitor
  30266. */
  30267. reset(): void;
  30268. }
  30269. /**
  30270. * RollingAverage
  30271. *
  30272. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  30273. */
  30274. export class RollingAverage {
  30275. /**
  30276. * Current average
  30277. */
  30278. average: number;
  30279. /**
  30280. * Current variance
  30281. */
  30282. variance: number;
  30283. protected _samples: Array<number>;
  30284. protected _sampleCount: number;
  30285. protected _pos: number;
  30286. protected _m2: number;
  30287. /**
  30288. * constructor
  30289. * @param length The number of samples required to saturate the sliding window
  30290. */
  30291. constructor(length: number);
  30292. /**
  30293. * Adds a sample to the sample set
  30294. * @param v The sample value
  30295. */
  30296. add(v: number): void;
  30297. /**
  30298. * Returns previously added values or null if outside of history or outside the sliding window domain
  30299. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30300. * @return Value previously recorded with add() or null if outside of range
  30301. */
  30302. history(i: number): number;
  30303. /**
  30304. * Returns true if enough samples have been taken to completely fill the sliding window
  30305. * @return true if sample-set saturated
  30306. */
  30307. isSaturated(): boolean;
  30308. /**
  30309. * Resets the rolling average (equivalent to 0 samples taken so far)
  30310. */
  30311. reset(): void;
  30312. /**
  30313. * Wraps a value around the sample range boundaries
  30314. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  30315. * @return Wrapped position in sample range
  30316. */
  30317. protected _wrapPosition(i: number): number;
  30318. }
  30319. }
  30320. declare module BABYLON {
  30321. /**
  30322. * This class is used to track a performance counter which is number based.
  30323. * The user has access to many properties which give statistics of different nature.
  30324. *
  30325. * The implementer can track two kinds of Performance Counter: time and count.
  30326. * 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.
  30327. * 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.
  30328. */
  30329. export class PerfCounter {
  30330. /**
  30331. * Gets or sets a global boolean to turn on and off all the counters
  30332. */
  30333. static Enabled: boolean;
  30334. /**
  30335. * Returns the smallest value ever
  30336. */
  30337. readonly min: number;
  30338. /**
  30339. * Returns the biggest value ever
  30340. */
  30341. readonly max: number;
  30342. /**
  30343. * Returns the average value since the performance counter is running
  30344. */
  30345. readonly average: number;
  30346. /**
  30347. * Returns the average value of the last second the counter was monitored
  30348. */
  30349. readonly lastSecAverage: number;
  30350. /**
  30351. * Returns the current value
  30352. */
  30353. readonly current: number;
  30354. /**
  30355. * Gets the accumulated total
  30356. */
  30357. readonly total: number;
  30358. /**
  30359. * Gets the total value count
  30360. */
  30361. readonly count: number;
  30362. /**
  30363. * Creates a new counter
  30364. */
  30365. constructor();
  30366. /**
  30367. * Call this method to start monitoring a new frame.
  30368. * 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.
  30369. */
  30370. fetchNewFrame(): void;
  30371. /**
  30372. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30373. * @param newCount the count value to add to the monitored count
  30374. * @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.
  30375. */
  30376. addCount(newCount: number, fetchResult: boolean): void;
  30377. /**
  30378. * Start monitoring this performance counter
  30379. */
  30380. beginMonitoring(): void;
  30381. /**
  30382. * Compute the time lapsed since the previous beginMonitoring() call.
  30383. * @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
  30384. */
  30385. endMonitoring(newFrame?: boolean): void;
  30386. private _fetchResult;
  30387. private _startMonitoringTime;
  30388. private _min;
  30389. private _max;
  30390. private _average;
  30391. private _current;
  30392. private _totalValueCount;
  30393. private _totalAccumulated;
  30394. private _lastSecAverage;
  30395. private _lastSecAccumulated;
  30396. private _lastSecTime;
  30397. private _lastSecValueCount;
  30398. }
  30399. }
  30400. declare module BABYLON {
  30401. /**
  30402. * Defines the interface used by display changed events
  30403. */
  30404. export interface IDisplayChangedEventArgs {
  30405. /** Gets the vrDisplay object (if any) */
  30406. vrDisplay: Nullable<any>;
  30407. /** Gets a boolean indicating if webVR is supported */
  30408. vrSupported: boolean;
  30409. }
  30410. /**
  30411. * Defines the interface used by objects containing a viewport (like a camera)
  30412. */
  30413. interface IViewportOwnerLike {
  30414. /**
  30415. * Gets or sets the viewport
  30416. */
  30417. viewport: IViewportLike;
  30418. }
  30419. /**
  30420. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30421. */
  30422. export class Engine extends ThinEngine {
  30423. /** Defines that alpha blending is disabled */
  30424. static readonly ALPHA_DISABLE: number;
  30425. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30426. static readonly ALPHA_ADD: number;
  30427. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30428. static readonly ALPHA_COMBINE: number;
  30429. /** Defines that alpha blending to DEST - SRC * DEST */
  30430. static readonly ALPHA_SUBTRACT: number;
  30431. /** Defines that alpha blending to SRC * DEST */
  30432. static readonly ALPHA_MULTIPLY: number;
  30433. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30434. static readonly ALPHA_MAXIMIZED: number;
  30435. /** Defines that alpha blending to SRC + DEST */
  30436. static readonly ALPHA_ONEONE: number;
  30437. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30438. static readonly ALPHA_PREMULTIPLIED: number;
  30439. /**
  30440. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30441. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30442. */
  30443. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30444. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30445. static readonly ALPHA_INTERPOLATE: number;
  30446. /**
  30447. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30448. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30449. */
  30450. static readonly ALPHA_SCREENMODE: number;
  30451. /** Defines that the ressource is not delayed*/
  30452. static readonly DELAYLOADSTATE_NONE: number;
  30453. /** Defines that the ressource was successfully delay loaded */
  30454. static readonly DELAYLOADSTATE_LOADED: number;
  30455. /** Defines that the ressource is currently delay loading */
  30456. static readonly DELAYLOADSTATE_LOADING: number;
  30457. /** Defines that the ressource is delayed and has not started loading */
  30458. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30459. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30460. static readonly NEVER: number;
  30461. /** 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 */
  30462. static readonly ALWAYS: number;
  30463. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30464. static readonly LESS: number;
  30465. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30466. static readonly EQUAL: number;
  30467. /** 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 */
  30468. static readonly LEQUAL: number;
  30469. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30470. static readonly GREATER: number;
  30471. /** 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 */
  30472. static readonly GEQUAL: number;
  30473. /** 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 */
  30474. static readonly NOTEQUAL: number;
  30475. /** Passed to stencilOperation to specify that stencil value must be kept */
  30476. static readonly KEEP: number;
  30477. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30478. static readonly REPLACE: number;
  30479. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30480. static readonly INCR: number;
  30481. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30482. static readonly DECR: number;
  30483. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30484. static readonly INVERT: number;
  30485. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30486. static readonly INCR_WRAP: number;
  30487. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30488. static readonly DECR_WRAP: number;
  30489. /** Texture is not repeating outside of 0..1 UVs */
  30490. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30491. /** Texture is repeating outside of 0..1 UVs */
  30492. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30493. /** Texture is repeating and mirrored */
  30494. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30495. /** ALPHA */
  30496. static readonly TEXTUREFORMAT_ALPHA: number;
  30497. /** LUMINANCE */
  30498. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30499. /** LUMINANCE_ALPHA */
  30500. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30501. /** RGB */
  30502. static readonly TEXTUREFORMAT_RGB: number;
  30503. /** RGBA */
  30504. static readonly TEXTUREFORMAT_RGBA: number;
  30505. /** RED */
  30506. static readonly TEXTUREFORMAT_RED: number;
  30507. /** RED (2nd reference) */
  30508. static readonly TEXTUREFORMAT_R: number;
  30509. /** RG */
  30510. static readonly TEXTUREFORMAT_RG: number;
  30511. /** RED_INTEGER */
  30512. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30513. /** RED_INTEGER (2nd reference) */
  30514. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30515. /** RG_INTEGER */
  30516. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30517. /** RGB_INTEGER */
  30518. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30519. /** RGBA_INTEGER */
  30520. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30521. /** UNSIGNED_BYTE */
  30522. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30523. /** UNSIGNED_BYTE (2nd reference) */
  30524. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30525. /** FLOAT */
  30526. static readonly TEXTURETYPE_FLOAT: number;
  30527. /** HALF_FLOAT */
  30528. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30529. /** BYTE */
  30530. static readonly TEXTURETYPE_BYTE: number;
  30531. /** SHORT */
  30532. static readonly TEXTURETYPE_SHORT: number;
  30533. /** UNSIGNED_SHORT */
  30534. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30535. /** INT */
  30536. static readonly TEXTURETYPE_INT: number;
  30537. /** UNSIGNED_INT */
  30538. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30539. /** UNSIGNED_SHORT_4_4_4_4 */
  30540. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30541. /** UNSIGNED_SHORT_5_5_5_1 */
  30542. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30543. /** UNSIGNED_SHORT_5_6_5 */
  30544. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30545. /** UNSIGNED_INT_2_10_10_10_REV */
  30546. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30547. /** UNSIGNED_INT_24_8 */
  30548. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30549. /** UNSIGNED_INT_10F_11F_11F_REV */
  30550. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30551. /** UNSIGNED_INT_5_9_9_9_REV */
  30552. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30553. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30554. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30555. /** nearest is mag = nearest and min = nearest and mip = linear */
  30556. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30557. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30558. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30559. /** Trilinear is mag = linear and min = linear and mip = linear */
  30560. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30561. /** nearest is mag = nearest and min = nearest and mip = linear */
  30562. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30563. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30564. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30565. /** Trilinear is mag = linear and min = linear and mip = linear */
  30566. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30567. /** mag = nearest and min = nearest and mip = nearest */
  30568. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30569. /** mag = nearest and min = linear and mip = nearest */
  30570. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30571. /** mag = nearest and min = linear and mip = linear */
  30572. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30573. /** mag = nearest and min = linear and mip = none */
  30574. static readonly TEXTURE_NEAREST_LINEAR: number;
  30575. /** mag = nearest and min = nearest and mip = none */
  30576. static readonly TEXTURE_NEAREST_NEAREST: number;
  30577. /** mag = linear and min = nearest and mip = nearest */
  30578. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30579. /** mag = linear and min = nearest and mip = linear */
  30580. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30581. /** mag = linear and min = linear and mip = none */
  30582. static readonly TEXTURE_LINEAR_LINEAR: number;
  30583. /** mag = linear and min = nearest and mip = none */
  30584. static readonly TEXTURE_LINEAR_NEAREST: number;
  30585. /** Explicit coordinates mode */
  30586. static readonly TEXTURE_EXPLICIT_MODE: number;
  30587. /** Spherical coordinates mode */
  30588. static readonly TEXTURE_SPHERICAL_MODE: number;
  30589. /** Planar coordinates mode */
  30590. static readonly TEXTURE_PLANAR_MODE: number;
  30591. /** Cubic coordinates mode */
  30592. static readonly TEXTURE_CUBIC_MODE: number;
  30593. /** Projection coordinates mode */
  30594. static readonly TEXTURE_PROJECTION_MODE: number;
  30595. /** Skybox coordinates mode */
  30596. static readonly TEXTURE_SKYBOX_MODE: number;
  30597. /** Inverse Cubic coordinates mode */
  30598. static readonly TEXTURE_INVCUBIC_MODE: number;
  30599. /** Equirectangular coordinates mode */
  30600. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30601. /** Equirectangular Fixed coordinates mode */
  30602. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30603. /** Equirectangular Fixed Mirrored coordinates mode */
  30604. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30605. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30606. static readonly SCALEMODE_FLOOR: number;
  30607. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30608. static readonly SCALEMODE_NEAREST: number;
  30609. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30610. static readonly SCALEMODE_CEILING: number;
  30611. /**
  30612. * Returns the current npm package of the sdk
  30613. */
  30614. static readonly NpmPackage: string;
  30615. /**
  30616. * Returns the current version of the framework
  30617. */
  30618. static readonly Version: string;
  30619. /** Gets the list of created engines */
  30620. static readonly Instances: Engine[];
  30621. /**
  30622. * Gets the latest created engine
  30623. */
  30624. static readonly LastCreatedEngine: Nullable<Engine>;
  30625. /**
  30626. * Gets the latest created scene
  30627. */
  30628. static readonly LastCreatedScene: Nullable<Scene>;
  30629. /**
  30630. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30631. * @param flag defines which part of the materials must be marked as dirty
  30632. * @param predicate defines a predicate used to filter which materials should be affected
  30633. */
  30634. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30635. /**
  30636. * Method called to create the default loading screen.
  30637. * This can be overriden in your own app.
  30638. * @param canvas The rendering canvas element
  30639. * @returns The loading screen
  30640. */
  30641. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30642. /**
  30643. * Method called to create the default rescale post process on each engine.
  30644. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30645. /**
  30646. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30647. **/
  30648. enableOfflineSupport: boolean;
  30649. /**
  30650. * 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)
  30651. **/
  30652. disableManifestCheck: boolean;
  30653. /**
  30654. * Gets the list of created scenes
  30655. */
  30656. scenes: Scene[];
  30657. /**
  30658. * Event raised when a new scene is created
  30659. */
  30660. onNewSceneAddedObservable: Observable<Scene>;
  30661. /**
  30662. * Gets the list of created postprocesses
  30663. */
  30664. postProcesses: PostProcess[];
  30665. /**
  30666. * Gets a boolean indicating if the pointer is currently locked
  30667. */
  30668. isPointerLock: boolean;
  30669. /**
  30670. * Observable event triggered each time the rendering canvas is resized
  30671. */
  30672. onResizeObservable: Observable<Engine>;
  30673. /**
  30674. * Observable event triggered each time the canvas loses focus
  30675. */
  30676. onCanvasBlurObservable: Observable<Engine>;
  30677. /**
  30678. * Observable event triggered each time the canvas gains focus
  30679. */
  30680. onCanvasFocusObservable: Observable<Engine>;
  30681. /**
  30682. * Observable event triggered each time the canvas receives pointerout event
  30683. */
  30684. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30685. /**
  30686. * Observable event triggered before each texture is initialized
  30687. */
  30688. onBeforeTextureInitObservable: Observable<Texture>;
  30689. /**
  30690. * Observable raised when the engine begins a new frame
  30691. */
  30692. onBeginFrameObservable: Observable<Engine>;
  30693. /**
  30694. * If set, will be used to request the next animation frame for the render loop
  30695. */
  30696. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30697. /**
  30698. * Observable raised when the engine ends the current frame
  30699. */
  30700. onEndFrameObservable: Observable<Engine>;
  30701. /**
  30702. * Observable raised when the engine is about to compile a shader
  30703. */
  30704. onBeforeShaderCompilationObservable: Observable<Engine>;
  30705. /**
  30706. * Observable raised when the engine has jsut compiled a shader
  30707. */
  30708. onAfterShaderCompilationObservable: Observable<Engine>;
  30709. /**
  30710. * Gets the audio engine
  30711. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30712. * @ignorenaming
  30713. */
  30714. static audioEngine: IAudioEngine;
  30715. /**
  30716. * Default AudioEngine factory responsible of creating the Audio Engine.
  30717. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30718. */
  30719. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30720. /**
  30721. * Default offline support factory responsible of creating a tool used to store data locally.
  30722. * By default, this will create a Database object if the workload has been embedded.
  30723. */
  30724. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30725. private _loadingScreen;
  30726. private _pointerLockRequested;
  30727. private _dummyFramebuffer;
  30728. private _rescalePostProcess;
  30729. /** @hidden */
  30730. protected _alphaMode: number;
  30731. /** @hidden */
  30732. protected _alphaEquation: number;
  30733. private _deterministicLockstep;
  30734. private _lockstepMaxSteps;
  30735. protected readonly _supportsHardwareTextureRescaling: boolean;
  30736. private _fps;
  30737. private _deltaTime;
  30738. /** @hidden */ private _drawCalls: PerfCounter;
  30739. /**
  30740. * Turn this value on if you want to pause FPS computation when in background
  30741. */
  30742. disablePerformanceMonitorInBackground: boolean;
  30743. private _performanceMonitor;
  30744. /**
  30745. * Gets the performance monitor attached to this engine
  30746. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30747. */
  30748. readonly performanceMonitor: PerformanceMonitor;
  30749. private _onFocus;
  30750. private _onBlur;
  30751. private _onCanvasPointerOut;
  30752. private _onCanvasBlur;
  30753. private _onCanvasFocus;
  30754. private _onFullscreenChange;
  30755. private _onPointerLockChange;
  30756. /**
  30757. * Creates a new engine
  30758. * @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
  30759. * @param antialias defines enable antialiasing (default: false)
  30760. * @param options defines further options to be sent to the getContext() function
  30761. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30762. */
  30763. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30764. /**
  30765. * Gets current aspect ratio
  30766. * @param viewportOwner defines the camera to use to get the aspect ratio
  30767. * @param useScreen defines if screen size must be used (or the current render target if any)
  30768. * @returns a number defining the aspect ratio
  30769. */
  30770. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  30771. /**
  30772. * Gets current screen aspect ratio
  30773. * @returns a number defining the aspect ratio
  30774. */
  30775. getScreenAspectRatio(): number;
  30776. /**
  30777. * Gets host document
  30778. * @returns the host document object
  30779. */
  30780. getHostDocument(): Document;
  30781. /**
  30782. * Gets the client rect of the HTML canvas attached with the current webGL context
  30783. * @returns a client rectanglee
  30784. */
  30785. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30786. /**
  30787. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30788. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30789. * @returns true if engine is in deterministic lock step mode
  30790. */
  30791. isDeterministicLockStep(): boolean;
  30792. /**
  30793. * Gets the max steps when engine is running in deterministic lock step
  30794. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30795. * @returns the max steps
  30796. */
  30797. getLockstepMaxSteps(): number;
  30798. /**
  30799. * Force the mipmap generation for the given render target texture
  30800. * @param texture defines the render target texture to use
  30801. */
  30802. generateMipMapsForCubemap(texture: InternalTexture): void;
  30803. /** States */
  30804. /**
  30805. * Set various states to the webGL context
  30806. * @param culling defines backface culling state
  30807. * @param zOffset defines the value to apply to zOffset (0 by default)
  30808. * @param force defines if states must be applied even if cache is up to date
  30809. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  30810. */
  30811. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  30812. /**
  30813. * Set the z offset to apply to current rendering
  30814. * @param value defines the offset to apply
  30815. */
  30816. setZOffset(value: number): void;
  30817. /**
  30818. * Gets the current value of the zOffset
  30819. * @returns the current zOffset state
  30820. */
  30821. getZOffset(): number;
  30822. /**
  30823. * Enable or disable depth buffering
  30824. * @param enable defines the state to set
  30825. */
  30826. setDepthBuffer(enable: boolean): void;
  30827. /**
  30828. * Gets a boolean indicating if depth writing is enabled
  30829. * @returns the current depth writing state
  30830. */
  30831. getDepthWrite(): boolean;
  30832. /**
  30833. * Enable or disable depth writing
  30834. * @param enable defines the state to set
  30835. */
  30836. setDepthWrite(enable: boolean): void;
  30837. /**
  30838. * Enable or disable color writing
  30839. * @param enable defines the state to set
  30840. */
  30841. setColorWrite(enable: boolean): void;
  30842. /**
  30843. * Gets a boolean indicating if color writing is enabled
  30844. * @returns the current color writing state
  30845. */
  30846. getColorWrite(): boolean;
  30847. /**
  30848. * Sets alpha constants used by some alpha blending modes
  30849. * @param r defines the red component
  30850. * @param g defines the green component
  30851. * @param b defines the blue component
  30852. * @param a defines the alpha component
  30853. */
  30854. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  30855. /**
  30856. * Sets the current alpha mode
  30857. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  30858. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  30859. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30860. */
  30861. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  30862. /**
  30863. * Gets the current alpha mode
  30864. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30865. * @returns the current alpha mode
  30866. */
  30867. getAlphaMode(): number;
  30868. /**
  30869. * Sets the current alpha equation
  30870. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  30871. */
  30872. setAlphaEquation(equation: number): void;
  30873. /**
  30874. * Gets the current alpha equation.
  30875. * @returns the current alpha equation
  30876. */
  30877. getAlphaEquation(): number;
  30878. /**
  30879. * Gets a boolean indicating if stencil buffer is enabled
  30880. * @returns the current stencil buffer state
  30881. */
  30882. getStencilBuffer(): boolean;
  30883. /**
  30884. * Enable or disable the stencil buffer
  30885. * @param enable defines if the stencil buffer must be enabled or disabled
  30886. */
  30887. setStencilBuffer(enable: boolean): void;
  30888. /**
  30889. * Gets the current stencil mask
  30890. * @returns a number defining the new stencil mask to use
  30891. */
  30892. getStencilMask(): number;
  30893. /**
  30894. * Sets the current stencil mask
  30895. * @param mask defines the new stencil mask to use
  30896. */
  30897. setStencilMask(mask: number): void;
  30898. /**
  30899. * Gets the current stencil function
  30900. * @returns a number defining the stencil function to use
  30901. */
  30902. getStencilFunction(): number;
  30903. /**
  30904. * Gets the current stencil reference value
  30905. * @returns a number defining the stencil reference value to use
  30906. */
  30907. getStencilFunctionReference(): number;
  30908. /**
  30909. * Gets the current stencil mask
  30910. * @returns a number defining the stencil mask to use
  30911. */
  30912. getStencilFunctionMask(): number;
  30913. /**
  30914. * Sets the current stencil function
  30915. * @param stencilFunc defines the new stencil function to use
  30916. */
  30917. setStencilFunction(stencilFunc: number): void;
  30918. /**
  30919. * Sets the current stencil reference
  30920. * @param reference defines the new stencil reference to use
  30921. */
  30922. setStencilFunctionReference(reference: number): void;
  30923. /**
  30924. * Sets the current stencil mask
  30925. * @param mask defines the new stencil mask to use
  30926. */
  30927. setStencilFunctionMask(mask: number): void;
  30928. /**
  30929. * Gets the current stencil operation when stencil fails
  30930. * @returns a number defining stencil operation to use when stencil fails
  30931. */
  30932. getStencilOperationFail(): number;
  30933. /**
  30934. * Gets the current stencil operation when depth fails
  30935. * @returns a number defining stencil operation to use when depth fails
  30936. */
  30937. getStencilOperationDepthFail(): number;
  30938. /**
  30939. * Gets the current stencil operation when stencil passes
  30940. * @returns a number defining stencil operation to use when stencil passes
  30941. */
  30942. getStencilOperationPass(): number;
  30943. /**
  30944. * Sets the stencil operation to use when stencil fails
  30945. * @param operation defines the stencil operation to use when stencil fails
  30946. */
  30947. setStencilOperationFail(operation: number): void;
  30948. /**
  30949. * Sets the stencil operation to use when depth fails
  30950. * @param operation defines the stencil operation to use when depth fails
  30951. */
  30952. setStencilOperationDepthFail(operation: number): void;
  30953. /**
  30954. * Sets the stencil operation to use when stencil passes
  30955. * @param operation defines the stencil operation to use when stencil passes
  30956. */
  30957. setStencilOperationPass(operation: number): void;
  30958. /**
  30959. * Sets a boolean indicating if the dithering state is enabled or disabled
  30960. * @param value defines the dithering state
  30961. */
  30962. setDitheringState(value: boolean): void;
  30963. /**
  30964. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30965. * @param value defines the rasterizer state
  30966. */
  30967. setRasterizerState(value: boolean): void;
  30968. /**
  30969. * Gets the current depth function
  30970. * @returns a number defining the depth function
  30971. */
  30972. getDepthFunction(): Nullable<number>;
  30973. /**
  30974. * Sets the current depth function
  30975. * @param depthFunc defines the function to use
  30976. */
  30977. setDepthFunction(depthFunc: number): void;
  30978. /**
  30979. * Sets the current depth function to GREATER
  30980. */
  30981. setDepthFunctionToGreater(): void;
  30982. /**
  30983. * Sets the current depth function to GEQUAL
  30984. */
  30985. setDepthFunctionToGreaterOrEqual(): void;
  30986. /**
  30987. * Sets the current depth function to LESS
  30988. */
  30989. setDepthFunctionToLess(): void;
  30990. /**
  30991. * Sets the current depth function to LEQUAL
  30992. */
  30993. setDepthFunctionToLessOrEqual(): void;
  30994. private _cachedStencilBuffer;
  30995. private _cachedStencilFunction;
  30996. private _cachedStencilMask;
  30997. private _cachedStencilOperationPass;
  30998. private _cachedStencilOperationFail;
  30999. private _cachedStencilOperationDepthFail;
  31000. private _cachedStencilReference;
  31001. /**
  31002. * Caches the the state of the stencil buffer
  31003. */
  31004. cacheStencilState(): void;
  31005. /**
  31006. * Restores the state of the stencil buffer
  31007. */
  31008. restoreStencilState(): void;
  31009. /**
  31010. * Directly set the WebGL Viewport
  31011. * @param x defines the x coordinate of the viewport (in screen space)
  31012. * @param y defines the y coordinate of the viewport (in screen space)
  31013. * @param width defines the width of the viewport (in screen space)
  31014. * @param height defines the height of the viewport (in screen space)
  31015. * @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
  31016. */
  31017. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31018. /**
  31019. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31020. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31021. * @param y defines the y-coordinate of the corner of the clear rectangle
  31022. * @param width defines the width of the clear rectangle
  31023. * @param height defines the height of the clear rectangle
  31024. * @param clearColor defines the clear color
  31025. */
  31026. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31027. /**
  31028. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31029. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31030. * @param y defines the y-coordinate of the corner of the clear rectangle
  31031. * @param width defines the width of the clear rectangle
  31032. * @param height defines the height of the clear rectangle
  31033. */
  31034. enableScissor(x: number, y: number, width: number, height: number): void;
  31035. /**
  31036. * Disable previously set scissor test rectangle
  31037. */
  31038. disableScissor(): void;
  31039. protected _reportDrawCall(): void;
  31040. /**
  31041. * Initializes a webVR display and starts listening to display change events
  31042. * The onVRDisplayChangedObservable will be notified upon these changes
  31043. * @returns The onVRDisplayChangedObservable
  31044. */
  31045. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31046. /** @hidden */ private _prepareVRComponent(): void;
  31047. /** @hidden */ private _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  31048. /** @hidden */ private _submitVRFrame(): void;
  31049. /**
  31050. * Call this function to leave webVR mode
  31051. * Will do nothing if webVR is not supported or if there is no webVR device
  31052. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31053. */
  31054. disableVR(): void;
  31055. /**
  31056. * Gets a boolean indicating that the system is in VR mode and is presenting
  31057. * @returns true if VR mode is engaged
  31058. */
  31059. isVRPresenting(): boolean;
  31060. /** @hidden */ private _requestVRFrame(): void;
  31061. /** @hidden */ private _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31062. /**
  31063. * Gets the source code of the vertex shader associated with a specific webGL program
  31064. * @param program defines the program to use
  31065. * @returns a string containing the source code of the vertex shader associated with the program
  31066. */
  31067. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31068. /**
  31069. * Gets the source code of the fragment shader associated with a specific webGL program
  31070. * @param program defines the program to use
  31071. * @returns a string containing the source code of the fragment shader associated with the program
  31072. */
  31073. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31074. /**
  31075. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31076. * @param x defines the x coordinate of the rectangle where pixels must be read
  31077. * @param y defines the y coordinate of the rectangle where pixels must be read
  31078. * @param width defines the width of the rectangle where pixels must be read
  31079. * @param height defines the height of the rectangle where pixels must be read
  31080. * @returns a Uint8Array containing RGBA colors
  31081. */
  31082. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31083. /**
  31084. * Sets a depth stencil texture from a render target to the according uniform.
  31085. * @param channel The texture channel
  31086. * @param uniform The uniform to set
  31087. * @param texture The render target texture containing the depth stencil texture to apply
  31088. */
  31089. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31090. /**
  31091. * Sets a texture to the webGL context from a postprocess
  31092. * @param channel defines the channel to use
  31093. * @param postProcess defines the source postprocess
  31094. */
  31095. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31096. /**
  31097. * Binds the output of the passed in post process to the texture channel specified
  31098. * @param channel The channel the texture should be bound to
  31099. * @param postProcess The post process which's output should be bound
  31100. */
  31101. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31102. /** @hidden */ private _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31103. protected _rebuildBuffers(): void; private _renderLoop(): void;
  31104. /**
  31105. * Toggle full screen mode
  31106. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31107. */
  31108. switchFullscreen(requestPointerLock: boolean): void;
  31109. /**
  31110. * Enters full screen mode
  31111. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31112. */
  31113. enterFullscreen(requestPointerLock: boolean): void;
  31114. /**
  31115. * Exits full screen mode
  31116. */
  31117. exitFullscreen(): void;
  31118. /**
  31119. * Enters Pointerlock mode
  31120. */
  31121. enterPointerlock(): void;
  31122. /**
  31123. * Exits Pointerlock mode
  31124. */
  31125. exitPointerlock(): void;
  31126. /**
  31127. * Begin a new frame
  31128. */
  31129. beginFrame(): void;
  31130. /**
  31131. * Enf the current frame
  31132. */
  31133. endFrame(): void;
  31134. resize(): void;
  31135. /**
  31136. * Set the compressed texture format to use, based on the formats you have, and the formats
  31137. * supported by the hardware / browser.
  31138. *
  31139. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31140. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31141. * to API arguments needed to compressed textures. This puts the burden on the container
  31142. * generator to house the arcane code for determining these for current & future formats.
  31143. *
  31144. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31145. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31146. *
  31147. * Note: The result of this call is not taken into account when a texture is base64.
  31148. *
  31149. * @param formatsAvailable defines the list of those format families you have created
  31150. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31151. *
  31152. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31153. * @returns The extension selected.
  31154. */
  31155. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31156. /**
  31157. * Force a specific size of the canvas
  31158. * @param width defines the new canvas' width
  31159. * @param height defines the new canvas' height
  31160. */
  31161. setSize(width: number, height: number): void; private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31162. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31163. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram; private _releaseTexture(texture: InternalTexture): void;
  31164. /**
  31165. * @hidden
  31166. * Rescales a texture
  31167. * @param source input texutre
  31168. * @param destination destination texture
  31169. * @param scene scene to use to render the resize
  31170. * @param internalFormat format to use when resizing
  31171. * @param onComplete callback to be called when resize has completed
  31172. */ private _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31173. /**
  31174. * Gets the current framerate
  31175. * @returns a number representing the framerate
  31176. */
  31177. getFps(): number;
  31178. /**
  31179. * Gets the time spent between current and previous frame
  31180. * @returns a number representing the delta time in ms
  31181. */
  31182. getDeltaTime(): number;
  31183. private _measureFps;
  31184. /**
  31185. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31186. * @param renderTarget The render target to set the frame buffer for
  31187. */
  31188. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31189. /**
  31190. * Update a dynamic index buffer
  31191. * @param indexBuffer defines the target index buffer
  31192. * @param indices defines the data to update
  31193. * @param offset defines the offset in the target index buffer where update should start
  31194. */
  31195. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31196. /**
  31197. * Updates the sample count of a render target texture
  31198. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31199. * @param texture defines the texture to update
  31200. * @param samples defines the sample count to set
  31201. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31202. */
  31203. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31204. /** @hidden */ private _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31205. dispose(): void;
  31206. private _disableTouchAction;
  31207. /**
  31208. * Display the loading screen
  31209. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31210. */
  31211. displayLoadingUI(): void;
  31212. /**
  31213. * Hide the loading screen
  31214. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31215. */
  31216. hideLoadingUI(): void;
  31217. /**
  31218. * Gets the current loading screen object
  31219. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31220. */
  31221. /**
  31222. * Sets the current loading screen object
  31223. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31224. */
  31225. loadingScreen: ILoadingScreen;
  31226. /**
  31227. * Sets the current loading screen text
  31228. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31229. */
  31230. loadingUIText: string;
  31231. /**
  31232. * Sets the current loading screen background color
  31233. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31234. */
  31235. loadingUIBackgroundColor: string;
  31236. /** Pointerlock and fullscreen */
  31237. /**
  31238. * Ask the browser to promote the current element to pointerlock mode
  31239. * @param element defines the DOM element to promote
  31240. */ private static _RequestPointerlock(element: HTMLElement): void;
  31241. /**
  31242. * Asks the browser to exit pointerlock mode
  31243. */ private static _ExitPointerlock(): void;
  31244. /**
  31245. * Ask the browser to promote the current element to fullscreen rendering mode
  31246. * @param element defines the DOM element to promote
  31247. */ private static _RequestFullscreen(element: HTMLElement): void;
  31248. /**
  31249. * Asks the browser to exit fullscreen mode
  31250. */ private static _ExitFullscreen(): void;
  31251. }
  31252. }
  31253. declare module BABYLON {
  31254. /**
  31255. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31256. * during the life time of the application.
  31257. */
  31258. export class EngineStore {
  31259. /** Gets the list of created engines */
  31260. static Instances: Engine[];
  31261. /** @hidden */ private static _LastCreatedScene: Nullable<Scene>;
  31262. /**
  31263. * Gets the latest created engine
  31264. */
  31265. static readonly LastCreatedEngine: Nullable<Engine>;
  31266. /**
  31267. * Gets the latest created scene
  31268. */
  31269. static readonly LastCreatedScene: Nullable<Scene>;
  31270. /**
  31271. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31272. * @ignorenaming
  31273. */
  31274. static UseFallbackTexture: boolean;
  31275. /**
  31276. * Texture content used if a texture cannot loaded
  31277. * @ignorenaming
  31278. */
  31279. static FallbackTexture: string;
  31280. }
  31281. }
  31282. declare module BABYLON {
  31283. /**
  31284. * Helper class that provides a small promise polyfill
  31285. */
  31286. export class PromisePolyfill {
  31287. /**
  31288. * Static function used to check if the polyfill is required
  31289. * If this is the case then the function will inject the polyfill to window.Promise
  31290. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31291. */
  31292. static Apply(force?: boolean): void;
  31293. }
  31294. }
  31295. declare module BABYLON {
  31296. /**
  31297. * Interface for screenshot methods with describe argument called `size` as object with options
  31298. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31299. */
  31300. export interface IScreenshotSize {
  31301. /**
  31302. * number in pixels for canvas height
  31303. */
  31304. height?: number;
  31305. /**
  31306. * multiplier allowing render at a higher or lower resolution
  31307. * If value is defined then height and width will be ignored and taken from camera
  31308. */
  31309. precision?: number;
  31310. /**
  31311. * number in pixels for canvas width
  31312. */
  31313. width?: number;
  31314. }
  31315. }
  31316. declare module BABYLON {
  31317. interface IColor4Like {
  31318. r: float;
  31319. g: float;
  31320. b: float;
  31321. a: float;
  31322. }
  31323. /**
  31324. * Class containing a set of static utilities functions
  31325. */
  31326. export class Tools {
  31327. /**
  31328. * Gets or sets the base URL to use to load assets
  31329. */
  31330. static BaseUrl: string;
  31331. /**
  31332. * Enable/Disable Custom HTTP Request Headers globally.
  31333. * default = false
  31334. * @see CustomRequestHeaders
  31335. */
  31336. static UseCustomRequestHeaders: boolean;
  31337. /**
  31338. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31339. * i.e. when loading files, where the server/service expects an Authorization header
  31340. */
  31341. static CustomRequestHeaders: {
  31342. [key: string]: string;
  31343. };
  31344. /**
  31345. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31346. */
  31347. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31348. /**
  31349. * Default behaviour for cors in the application.
  31350. * It can be a string if the expected behavior is identical in the entire app.
  31351. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31352. */
  31353. static CorsBehavior: string | ((url: string | string[]) => string);
  31354. /**
  31355. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31356. * @ignorenaming
  31357. */
  31358. static UseFallbackTexture: boolean;
  31359. /**
  31360. * Use this object to register external classes like custom textures or material
  31361. * to allow the laoders to instantiate them
  31362. */
  31363. static RegisteredExternalClasses: {
  31364. [key: string]: Object;
  31365. };
  31366. /**
  31367. * Texture content used if a texture cannot loaded
  31368. * @ignorenaming
  31369. */
  31370. static fallbackTexture: string;
  31371. /**
  31372. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31373. * @param u defines the coordinate on X axis
  31374. * @param v defines the coordinate on Y axis
  31375. * @param width defines the width of the source data
  31376. * @param height defines the height of the source data
  31377. * @param pixels defines the source byte array
  31378. * @param color defines the output color
  31379. */
  31380. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31381. /**
  31382. * Interpolates between a and b via alpha
  31383. * @param a The lower value (returned when alpha = 0)
  31384. * @param b The upper value (returned when alpha = 1)
  31385. * @param alpha The interpolation-factor
  31386. * @return The mixed value
  31387. */
  31388. static Mix(a: number, b: number, alpha: number): number;
  31389. /**
  31390. * Tries to instantiate a new object from a given class name
  31391. * @param className defines the class name to instantiate
  31392. * @returns the new object or null if the system was not able to do the instantiation
  31393. */
  31394. static Instantiate(className: string): any;
  31395. /**
  31396. * Provides a slice function that will work even on IE
  31397. * @param data defines the array to slice
  31398. * @param start defines the start of the data (optional)
  31399. * @param end defines the end of the data (optional)
  31400. * @returns the new sliced array
  31401. */
  31402. static Slice<T>(data: T, start?: number, end?: number): T;
  31403. /**
  31404. * Polyfill for setImmediate
  31405. * @param action defines the action to execute after the current execution block
  31406. */
  31407. static SetImmediate(action: () => void): void;
  31408. /**
  31409. * Function indicating if a number is an exponent of 2
  31410. * @param value defines the value to test
  31411. * @returns true if the value is an exponent of 2
  31412. */
  31413. static IsExponentOfTwo(value: number): boolean;
  31414. private static _tmpFloatArray;
  31415. /**
  31416. * Returns the nearest 32-bit single precision float representation of a Number
  31417. * @param value A Number. If the parameter is of a different type, it will get converted
  31418. * to a number or to NaN if it cannot be converted
  31419. * @returns number
  31420. */
  31421. static FloatRound(value: number): number;
  31422. /**
  31423. * Extracts the filename from a path
  31424. * @param path defines the path to use
  31425. * @returns the filename
  31426. */
  31427. static GetFilename(path: string): string;
  31428. /**
  31429. * Extracts the "folder" part of a path (everything before the filename).
  31430. * @param uri The URI to extract the info from
  31431. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31432. * @returns The "folder" part of the path
  31433. */
  31434. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31435. /**
  31436. * Extracts text content from a DOM element hierarchy
  31437. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31438. */
  31439. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31440. /**
  31441. * Convert an angle in radians to degrees
  31442. * @param angle defines the angle to convert
  31443. * @returns the angle in degrees
  31444. */
  31445. static ToDegrees(angle: number): number;
  31446. /**
  31447. * Convert an angle in degrees to radians
  31448. * @param angle defines the angle to convert
  31449. * @returns the angle in radians
  31450. */
  31451. static ToRadians(angle: number): number;
  31452. /**
  31453. * Encode a buffer to a base64 string
  31454. * @param buffer defines the buffer to encode
  31455. * @returns the encoded string
  31456. */
  31457. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31458. /**
  31459. * Returns an array if obj is not an array
  31460. * @param obj defines the object to evaluate as an array
  31461. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31462. * @returns either obj directly if obj is an array or a new array containing obj
  31463. */
  31464. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31465. /**
  31466. * Gets the pointer prefix to use
  31467. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31468. */
  31469. static GetPointerPrefix(): string;
  31470. /**
  31471. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31472. * @param url define the url we are trying
  31473. * @param element define the dom element where to configure the cors policy
  31474. */
  31475. static SetCorsBehavior(url: string | string[], element: {
  31476. crossOrigin: string | null;
  31477. }): void;
  31478. /**
  31479. * Removes unwanted characters from an url
  31480. * @param url defines the url to clean
  31481. * @returns the cleaned url
  31482. */
  31483. static CleanUrl(url: string): string;
  31484. /**
  31485. * Gets or sets a function used to pre-process url before using them to load assets
  31486. */
  31487. static PreprocessUrl: (url: string) => string;
  31488. /**
  31489. * Loads an image as an HTMLImageElement.
  31490. * @param input url string, ArrayBuffer, or Blob to load
  31491. * @param onLoad callback called when the image successfully loads
  31492. * @param onError callback called when the image fails to load
  31493. * @param offlineProvider offline provider for caching
  31494. * @returns the HTMLImageElement of the loaded image
  31495. */
  31496. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31497. /**
  31498. * Loads a file
  31499. * @param url url string, ArrayBuffer, or Blob to load
  31500. * @param onSuccess callback called when the file successfully loads
  31501. * @param onProgress callback called while file is loading (if the server supports this mode)
  31502. * @param offlineProvider defines the offline provider for caching
  31503. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31504. * @param onError callback called when the file fails to load
  31505. * @returns a file request object
  31506. */
  31507. 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;
  31508. /**
  31509. * Loads a file from a url
  31510. * @param url the file url to load
  31511. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31512. */
  31513. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31514. /**
  31515. * Load a script (identified by an url). When the url returns, the
  31516. * content of this file is added into a new script element, attached to the DOM (body element)
  31517. * @param scriptUrl defines the url of the script to laod
  31518. * @param onSuccess defines the callback called when the script is loaded
  31519. * @param onError defines the callback to call if an error occurs
  31520. * @param scriptId defines the id of the script element
  31521. */
  31522. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31523. /**
  31524. * Load an asynchronous script (identified by an url). When the url returns, the
  31525. * content of this file is added into a new script element, attached to the DOM (body element)
  31526. * @param scriptUrl defines the url of the script to laod
  31527. * @param scriptId defines the id of the script element
  31528. * @returns a promise request object
  31529. */
  31530. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31531. /**
  31532. * Loads a file from a blob
  31533. * @param fileToLoad defines the blob to use
  31534. * @param callback defines the callback to call when data is loaded
  31535. * @param progressCallback defines the callback to call during loading process
  31536. * @returns a file request object
  31537. */
  31538. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31539. /**
  31540. * Loads a file
  31541. * @param fileToLoad defines the file to load
  31542. * @param callback defines the callback to call when data is loaded
  31543. * @param progressCallBack defines the callback to call during loading process
  31544. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31545. * @returns a file request object
  31546. */
  31547. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31548. /**
  31549. * Creates a data url from a given string content
  31550. * @param content defines the content to convert
  31551. * @returns the new data url link
  31552. */
  31553. static FileAsURL(content: string): string;
  31554. /**
  31555. * Format the given number to a specific decimal format
  31556. * @param value defines the number to format
  31557. * @param decimals defines the number of decimals to use
  31558. * @returns the formatted string
  31559. */
  31560. static Format(value: number, decimals?: number): string;
  31561. /**
  31562. * Tries to copy an object by duplicating every property
  31563. * @param source defines the source object
  31564. * @param destination defines the target object
  31565. * @param doNotCopyList defines a list of properties to avoid
  31566. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31567. */
  31568. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31569. /**
  31570. * Gets a boolean indicating if the given object has no own property
  31571. * @param obj defines the object to test
  31572. * @returns true if object has no own property
  31573. */
  31574. static IsEmpty(obj: any): boolean;
  31575. /**
  31576. * Function used to register events at window level
  31577. * @param windowElement defines the Window object to use
  31578. * @param events defines the events to register
  31579. */
  31580. static RegisterTopRootEvents(windowElement: Window, events: {
  31581. name: string;
  31582. handler: Nullable<(e: FocusEvent) => any>;
  31583. }[]): void;
  31584. /**
  31585. * Function used to unregister events from window level
  31586. * @param windowElement defines the Window object to use
  31587. * @param events defines the events to unregister
  31588. */
  31589. static UnregisterTopRootEvents(windowElement: Window, events: {
  31590. name: string;
  31591. handler: Nullable<(e: FocusEvent) => any>;
  31592. }[]): void;
  31593. /**
  31594. * @ignore
  31595. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  31596. /**
  31597. * Dumps the current bound framebuffer
  31598. * @param width defines the rendering width
  31599. * @param height defines the rendering height
  31600. * @param engine defines the hosting engine
  31601. * @param successCallback defines the callback triggered once the data are available
  31602. * @param mimeType defines the mime type of the result
  31603. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31604. */
  31605. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31606. /**
  31607. * Converts the canvas data to blob.
  31608. * This acts as a polyfill for browsers not supporting the to blob function.
  31609. * @param canvas Defines the canvas to extract the data from
  31610. * @param successCallback Defines the callback triggered once the data are available
  31611. * @param mimeType Defines the mime type of the result
  31612. */
  31613. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31614. /**
  31615. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31616. * @param successCallback defines the callback triggered once the data are available
  31617. * @param mimeType defines the mime type of the result
  31618. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31619. */
  31620. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31621. /**
  31622. * Downloads a blob in the browser
  31623. * @param blob defines the blob to download
  31624. * @param fileName defines the name of the downloaded file
  31625. */
  31626. static Download(blob: Blob, fileName: string): void;
  31627. /**
  31628. * Captures a screenshot of the current rendering
  31629. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31630. * @param engine defines the rendering engine
  31631. * @param camera defines the source camera
  31632. * @param size This parameter can be set to a single number or to an object with the
  31633. * following (optional) properties: precision, width, height. If a single number is passed,
  31634. * it will be used for both width and height. If an object is passed, the screenshot size
  31635. * will be derived from the parameters. The precision property is a multiplier allowing
  31636. * rendering at a higher or lower resolution
  31637. * @param successCallback defines the callback receives a single parameter which contains the
  31638. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31639. * src parameter of an <img> to display it
  31640. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31641. * Check your browser for supported MIME types
  31642. */
  31643. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  31644. /**
  31645. * Captures a screenshot of the current rendering
  31646. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31647. * @param engine defines the rendering engine
  31648. * @param camera defines the source camera
  31649. * @param size This parameter can be set to a single number or to an object with the
  31650. * following (optional) properties: precision, width, height. If a single number is passed,
  31651. * it will be used for both width and height. If an object is passed, the screenshot size
  31652. * will be derived from the parameters. The precision property is a multiplier allowing
  31653. * rendering at a higher or lower resolution
  31654. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31655. * Check your browser for supported MIME types
  31656. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31657. * to the src parameter of an <img> to display it
  31658. */
  31659. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  31660. /**
  31661. * Generates an image screenshot from the specified camera.
  31662. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31663. * @param engine The engine to use for rendering
  31664. * @param camera The camera to use for rendering
  31665. * @param size This parameter can be set to a single number or to an object with the
  31666. * following (optional) properties: precision, width, height. If a single number is passed,
  31667. * it will be used for both width and height. If an object is passed, the screenshot size
  31668. * will be derived from the parameters. The precision property is a multiplier allowing
  31669. * rendering at a higher or lower resolution
  31670. * @param successCallback The callback receives a single parameter which contains the
  31671. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31672. * src parameter of an <img> to display it
  31673. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31674. * Check your browser for supported MIME types
  31675. * @param samples Texture samples (default: 1)
  31676. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31677. * @param fileName A name for for the downloaded file.
  31678. */
  31679. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31680. /**
  31681. * Generates an image screenshot from the specified camera.
  31682. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31683. * @param engine The engine to use for rendering
  31684. * @param camera The camera to use for rendering
  31685. * @param size This parameter can be set to a single number or to an object with the
  31686. * following (optional) properties: precision, width, height. If a single number is passed,
  31687. * it will be used for both width and height. If an object is passed, the screenshot size
  31688. * will be derived from the parameters. The precision property is a multiplier allowing
  31689. * rendering at a higher or lower resolution
  31690. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31691. * Check your browser for supported MIME types
  31692. * @param samples Texture samples (default: 1)
  31693. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31694. * @param fileName A name for for the downloaded file.
  31695. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31696. * to the src parameter of an <img> to display it
  31697. */
  31698. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  31699. /**
  31700. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31701. * Be aware Math.random() could cause collisions, but:
  31702. * "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"
  31703. * @returns a pseudo random id
  31704. */
  31705. static RandomId(): string;
  31706. /**
  31707. * Test if the given uri is a base64 string
  31708. * @param uri The uri to test
  31709. * @return True if the uri is a base64 string or false otherwise
  31710. */
  31711. static IsBase64(uri: string): boolean;
  31712. /**
  31713. * Decode the given base64 uri.
  31714. * @param uri The uri to decode
  31715. * @return The decoded base64 data.
  31716. */
  31717. static DecodeBase64(uri: string): ArrayBuffer;
  31718. /**
  31719. * Gets the absolute url.
  31720. * @param url the input url
  31721. * @return the absolute url
  31722. */
  31723. static GetAbsoluteUrl(url: string): string;
  31724. /**
  31725. * No log
  31726. */
  31727. static readonly NoneLogLevel: number;
  31728. /**
  31729. * Only message logs
  31730. */
  31731. static readonly MessageLogLevel: number;
  31732. /**
  31733. * Only warning logs
  31734. */
  31735. static readonly WarningLogLevel: number;
  31736. /**
  31737. * Only error logs
  31738. */
  31739. static readonly ErrorLogLevel: number;
  31740. /**
  31741. * All logs
  31742. */
  31743. static readonly AllLogLevel: number;
  31744. /**
  31745. * Gets a value indicating the number of loading errors
  31746. * @ignorenaming
  31747. */
  31748. static readonly errorsCount: number;
  31749. /**
  31750. * Callback called when a new log is added
  31751. */
  31752. static OnNewCacheEntry: (entry: string) => void;
  31753. /**
  31754. * Log a message to the console
  31755. * @param message defines the message to log
  31756. */
  31757. static Log(message: string): void;
  31758. /**
  31759. * Write a warning message to the console
  31760. * @param message defines the message to log
  31761. */
  31762. static Warn(message: string): void;
  31763. /**
  31764. * Write an error message to the console
  31765. * @param message defines the message to log
  31766. */
  31767. static Error(message: string): void;
  31768. /**
  31769. * Gets current log cache (list of logs)
  31770. */
  31771. static readonly LogCache: string;
  31772. /**
  31773. * Clears the log cache
  31774. */
  31775. static ClearLogCache(): void;
  31776. /**
  31777. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31778. */
  31779. static LogLevels: number;
  31780. /**
  31781. * Checks if the window object exists
  31782. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31783. */
  31784. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31785. /**
  31786. * No performance log
  31787. */
  31788. static readonly PerformanceNoneLogLevel: number;
  31789. /**
  31790. * Use user marks to log performance
  31791. */
  31792. static readonly PerformanceUserMarkLogLevel: number;
  31793. /**
  31794. * Log performance to the console
  31795. */
  31796. static readonly PerformanceConsoleLogLevel: number;
  31797. private static _performance;
  31798. /**
  31799. * Sets the current performance log level
  31800. */
  31801. static PerformanceLogLevel: number;
  31802. private static _StartPerformanceCounterDisabled;
  31803. private static _EndPerformanceCounterDisabled;
  31804. private static _StartUserMark;
  31805. private static _EndUserMark;
  31806. private static _StartPerformanceConsole;
  31807. private static _EndPerformanceConsole;
  31808. /**
  31809. * Starts a performance counter
  31810. */
  31811. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31812. /**
  31813. * Ends a specific performance coutner
  31814. */
  31815. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31816. /**
  31817. * Gets either window.performance.now() if supported or Date.now() else
  31818. */
  31819. static readonly Now: number;
  31820. /**
  31821. * This method will return the name of the class used to create the instance of the given object.
  31822. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31823. * @param object the object to get the class name from
  31824. * @param isType defines if the object is actually a type
  31825. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31826. */
  31827. static GetClassName(object: any, isType?: boolean): string;
  31828. /**
  31829. * Gets the first element of an array satisfying a given predicate
  31830. * @param array defines the array to browse
  31831. * @param predicate defines the predicate to use
  31832. * @returns null if not found or the element
  31833. */
  31834. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31835. /**
  31836. * This method will return the name of the full name of the class, including its owning module (if any).
  31837. * 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).
  31838. * @param object the object to get the class name from
  31839. * @param isType defines if the object is actually a type
  31840. * @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.
  31841. * @ignorenaming
  31842. */
  31843. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31844. /**
  31845. * Returns a promise that resolves after the given amount of time.
  31846. * @param delay Number of milliseconds to delay
  31847. * @returns Promise that resolves after the given amount of time
  31848. */
  31849. static DelayAsync(delay: number): Promise<void>;
  31850. }
  31851. /**
  31852. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31853. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31854. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31855. * @param name The name of the class, case should be preserved
  31856. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31857. */
  31858. export function className(name: string, module?: string): (target: Object) => void;
  31859. /**
  31860. * An implementation of a loop for asynchronous functions.
  31861. */
  31862. export class AsyncLoop {
  31863. /**
  31864. * Defines the number of iterations for the loop
  31865. */
  31866. iterations: number;
  31867. /**
  31868. * Defines the current index of the loop.
  31869. */
  31870. index: number;
  31871. private _done;
  31872. private _fn;
  31873. private _successCallback;
  31874. /**
  31875. * Constructor.
  31876. * @param iterations the number of iterations.
  31877. * @param func the function to run each iteration
  31878. * @param successCallback the callback that will be called upon succesful execution
  31879. * @param offset starting offset.
  31880. */
  31881. constructor(
  31882. /**
  31883. * Defines the number of iterations for the loop
  31884. */
  31885. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31886. /**
  31887. * Execute the next iteration. Must be called after the last iteration was finished.
  31888. */
  31889. executeNext(): void;
  31890. /**
  31891. * Break the loop and run the success callback.
  31892. */
  31893. breakLoop(): void;
  31894. /**
  31895. * Create and run an async loop.
  31896. * @param iterations the number of iterations.
  31897. * @param fn the function to run each iteration
  31898. * @param successCallback the callback that will be called upon succesful execution
  31899. * @param offset starting offset.
  31900. * @returns the created async loop object
  31901. */
  31902. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31903. /**
  31904. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31905. * @param iterations total number of iterations
  31906. * @param syncedIterations number of synchronous iterations in each async iteration.
  31907. * @param fn the function to call each iteration.
  31908. * @param callback a success call back that will be called when iterating stops.
  31909. * @param breakFunction a break condition (optional)
  31910. * @param timeout timeout settings for the setTimeout function. default - 0.
  31911. * @returns the created async loop object
  31912. */
  31913. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31914. }
  31915. }
  31916. declare module BABYLON {
  31917. /**
  31918. * This class implement a typical dictionary using a string as key and the generic type T as value.
  31919. * The underlying implementation relies on an associative array to ensure the best performances.
  31920. * The value can be anything including 'null' but except 'undefined'
  31921. */
  31922. export class StringDictionary<T> {
  31923. /**
  31924. * This will clear this dictionary and copy the content from the 'source' one.
  31925. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  31926. * @param source the dictionary to take the content from and copy to this dictionary
  31927. */
  31928. copyFrom(source: StringDictionary<T>): void;
  31929. /**
  31930. * Get a value based from its key
  31931. * @param key the given key to get the matching value from
  31932. * @return the value if found, otherwise undefined is returned
  31933. */
  31934. get(key: string): T | undefined;
  31935. /**
  31936. * Get a value from its key or add it if it doesn't exist.
  31937. * This method will ensure you that a given key/data will be present in the dictionary.
  31938. * @param key the given key to get the matching value from
  31939. * @param factory the factory that will create the value if the key is not present in the dictionary.
  31940. * The factory will only be invoked if there's no data for the given key.
  31941. * @return the value corresponding to the key.
  31942. */
  31943. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  31944. /**
  31945. * Get a value from its key if present in the dictionary otherwise add it
  31946. * @param key the key to get the value from
  31947. * @param val if there's no such key/value pair in the dictionary add it with this value
  31948. * @return the value corresponding to the key
  31949. */
  31950. getOrAdd(key: string, val: T): T;
  31951. /**
  31952. * Check if there's a given key in the dictionary
  31953. * @param key the key to check for
  31954. * @return true if the key is present, false otherwise
  31955. */
  31956. contains(key: string): boolean;
  31957. /**
  31958. * Add a new key and its corresponding value
  31959. * @param key the key to add
  31960. * @param value the value corresponding to the key
  31961. * @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
  31962. */
  31963. add(key: string, value: T): boolean;
  31964. /**
  31965. * Update a specific value associated to a key
  31966. * @param key defines the key to use
  31967. * @param value defines the value to store
  31968. * @returns true if the value was updated (or false if the key was not found)
  31969. */
  31970. set(key: string, value: T): boolean;
  31971. /**
  31972. * Get the element of the given key and remove it from the dictionary
  31973. * @param key defines the key to search
  31974. * @returns the value associated with the key or null if not found
  31975. */
  31976. getAndRemove(key: string): Nullable<T>;
  31977. /**
  31978. * Remove a key/value from the dictionary.
  31979. * @param key the key to remove
  31980. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  31981. */
  31982. remove(key: string): boolean;
  31983. /**
  31984. * Clear the whole content of the dictionary
  31985. */
  31986. clear(): void;
  31987. /**
  31988. * Gets the current count
  31989. */
  31990. readonly count: number;
  31991. /**
  31992. * Execute a callback on each key/val of the dictionary.
  31993. * Note that you can remove any element in this dictionary in the callback implementation
  31994. * @param callback the callback to execute on a given key/value pair
  31995. */
  31996. forEach(callback: (key: string, val: T) => void): void;
  31997. /**
  31998. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  31999. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32000. * Note that you can remove any element in this dictionary in the callback implementation
  32001. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32002. * @returns the first item
  32003. */
  32004. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32005. private _count;
  32006. private _data;
  32007. }
  32008. }
  32009. declare module BABYLON {
  32010. /** @hidden */
  32011. export interface ICollisionCoordinator {
  32012. createCollider(): Collider;
  32013. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32014. init(scene: Scene): void;
  32015. }
  32016. /** @hidden */
  32017. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32018. private _scene;
  32019. private _scaledPosition;
  32020. private _scaledVelocity;
  32021. private _finalPosition;
  32022. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32023. createCollider(): Collider;
  32024. init(scene: Scene): void;
  32025. private _collideWithWorld;
  32026. }
  32027. }
  32028. declare module BABYLON {
  32029. /**
  32030. * Class used to manage all inputs for the scene.
  32031. */
  32032. export class InputManager {
  32033. /** The distance in pixel that you have to move to prevent some events */
  32034. static DragMovementThreshold: number;
  32035. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32036. static LongPressDelay: number;
  32037. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32038. static DoubleClickDelay: number;
  32039. /** If you need to check double click without raising a single click at first click, enable this flag */
  32040. static ExclusiveDoubleClickMode: boolean;
  32041. private _wheelEventName;
  32042. private _onPointerMove;
  32043. private _onPointerDown;
  32044. private _onPointerUp;
  32045. private _initClickEvent;
  32046. private _initActionManager;
  32047. private _delayedSimpleClick;
  32048. private _delayedSimpleClickTimeout;
  32049. private _previousDelayedSimpleClickTimeout;
  32050. private _meshPickProceed;
  32051. private _previousButtonPressed;
  32052. private _currentPickResult;
  32053. private _previousPickResult;
  32054. private _totalPointersPressed;
  32055. private _doubleClickOccured;
  32056. private _pointerOverMesh;
  32057. private _pickedDownMesh;
  32058. private _pickedUpMesh;
  32059. private _pointerX;
  32060. private _pointerY;
  32061. private _unTranslatedPointerX;
  32062. private _unTranslatedPointerY;
  32063. private _startingPointerPosition;
  32064. private _previousStartingPointerPosition;
  32065. private _startingPointerTime;
  32066. private _previousStartingPointerTime;
  32067. private _pointerCaptures;
  32068. private _onKeyDown;
  32069. private _onKeyUp;
  32070. private _onCanvasFocusObserver;
  32071. private _onCanvasBlurObserver;
  32072. private _scene;
  32073. /**
  32074. * Creates a new InputManager
  32075. * @param scene defines the hosting scene
  32076. */
  32077. constructor(scene: Scene);
  32078. /**
  32079. * Gets the mesh that is currently under the pointer
  32080. */
  32081. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32082. /**
  32083. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32084. */
  32085. readonly unTranslatedPointer: Vector2;
  32086. /**
  32087. * Gets or sets the current on-screen X position of the pointer
  32088. */
  32089. pointerX: number;
  32090. /**
  32091. * Gets or sets the current on-screen Y position of the pointer
  32092. */
  32093. pointerY: number;
  32094. private _updatePointerPosition;
  32095. private _processPointerMove;
  32096. private _setRayOnPointerInfo;
  32097. private _checkPrePointerObservable;
  32098. /**
  32099. * Use this method to simulate a pointer move on a mesh
  32100. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32101. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32102. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32103. */
  32104. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32105. /**
  32106. * Use this method to simulate a pointer down on a mesh
  32107. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32108. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32109. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32110. */
  32111. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32112. private _processPointerDown;
  32113. /** @hidden */ private _isPointerSwiping(): boolean;
  32114. /**
  32115. * Use this method to simulate a pointer up on a mesh
  32116. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32117. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32118. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32119. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32120. */
  32121. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32122. private _processPointerUp;
  32123. /**
  32124. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32125. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32126. * @returns true if the pointer was captured
  32127. */
  32128. isPointerCaptured(pointerId?: number): boolean;
  32129. /**
  32130. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32131. * @param attachUp defines if you want to attach events to pointerup
  32132. * @param attachDown defines if you want to attach events to pointerdown
  32133. * @param attachMove defines if you want to attach events to pointermove
  32134. */
  32135. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32136. /**
  32137. * Detaches all event handlers
  32138. */
  32139. detachControl(): void;
  32140. /**
  32141. * Force the value of meshUnderPointer
  32142. * @param mesh defines the mesh to use
  32143. */
  32144. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32145. /**
  32146. * Gets the mesh under the pointer
  32147. * @returns a Mesh or null if no mesh is under the pointer
  32148. */
  32149. getPointerOverMesh(): Nullable<AbstractMesh>;
  32150. }
  32151. }
  32152. declare module BABYLON {
  32153. /**
  32154. * Helper class used to generate session unique ID
  32155. */
  32156. export class UniqueIdGenerator {
  32157. private static _UniqueIdCounter;
  32158. /**
  32159. * Gets an unique (relatively to the current scene) Id
  32160. */
  32161. static readonly UniqueId: number;
  32162. }
  32163. }
  32164. declare module BABYLON {
  32165. /**
  32166. * This class defines the direct association between an animation and a target
  32167. */
  32168. export class TargetedAnimation {
  32169. /**
  32170. * Animation to perform
  32171. */
  32172. animation: Animation;
  32173. /**
  32174. * Target to animate
  32175. */
  32176. target: any;
  32177. /**
  32178. * Serialize the object
  32179. * @returns the JSON object representing the current entity
  32180. */
  32181. serialize(): any;
  32182. }
  32183. /**
  32184. * Use this class to create coordinated animations on multiple targets
  32185. */
  32186. export class AnimationGroup implements IDisposable {
  32187. /** The name of the animation group */
  32188. name: string;
  32189. private _scene;
  32190. private _targetedAnimations;
  32191. private _animatables;
  32192. private _from;
  32193. private _to;
  32194. private _isStarted;
  32195. private _isPaused;
  32196. private _speedRatio;
  32197. private _loopAnimation;
  32198. /**
  32199. * Gets or sets the unique id of the node
  32200. */
  32201. uniqueId: number;
  32202. /**
  32203. * This observable will notify when one animation have ended
  32204. */
  32205. onAnimationEndObservable: Observable<TargetedAnimation>;
  32206. /**
  32207. * Observer raised when one animation loops
  32208. */
  32209. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32210. /**
  32211. * This observable will notify when all animations have ended.
  32212. */
  32213. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32214. /**
  32215. * This observable will notify when all animations have paused.
  32216. */
  32217. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32218. /**
  32219. * This observable will notify when all animations are playing.
  32220. */
  32221. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32222. /**
  32223. * Gets the first frame
  32224. */
  32225. readonly from: number;
  32226. /**
  32227. * Gets the last frame
  32228. */
  32229. readonly to: number;
  32230. /**
  32231. * Define if the animations are started
  32232. */
  32233. readonly isStarted: boolean;
  32234. /**
  32235. * Gets a value indicating that the current group is playing
  32236. */
  32237. readonly isPlaying: boolean;
  32238. /**
  32239. * Gets or sets the speed ratio to use for all animations
  32240. */
  32241. /**
  32242. * Gets or sets the speed ratio to use for all animations
  32243. */
  32244. speedRatio: number;
  32245. /**
  32246. * Gets or sets if all animations should loop or not
  32247. */
  32248. loopAnimation: boolean;
  32249. /**
  32250. * Gets the targeted animations for this animation group
  32251. */
  32252. readonly targetedAnimations: Array<TargetedAnimation>;
  32253. /**
  32254. * returning the list of animatables controlled by this animation group.
  32255. */
  32256. readonly animatables: Array<Animatable>;
  32257. /**
  32258. * Instantiates a new Animation Group.
  32259. * This helps managing several animations at once.
  32260. * @see http://doc.babylonjs.com/how_to/group
  32261. * @param name Defines the name of the group
  32262. * @param scene Defines the scene the group belongs to
  32263. */
  32264. constructor(
  32265. /** The name of the animation group */
  32266. name: string, scene?: Nullable<Scene>);
  32267. /**
  32268. * Add an animation (with its target) in the group
  32269. * @param animation defines the animation we want to add
  32270. * @param target defines the target of the animation
  32271. * @returns the TargetedAnimation object
  32272. */
  32273. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32274. /**
  32275. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32276. * It can add constant keys at begin or end
  32277. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32278. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32279. * @returns the animation group
  32280. */
  32281. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32282. /**
  32283. * Start all animations on given targets
  32284. * @param loop defines if animations must loop
  32285. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32286. * @param from defines the from key (optional)
  32287. * @param to defines the to key (optional)
  32288. * @returns the current animation group
  32289. */
  32290. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32291. /**
  32292. * Pause all animations
  32293. * @returns the animation group
  32294. */
  32295. pause(): AnimationGroup;
  32296. /**
  32297. * Play all animations to initial state
  32298. * This function will start() the animations if they were not started or will restart() them if they were paused
  32299. * @param loop defines if animations must loop
  32300. * @returns the animation group
  32301. */
  32302. play(loop?: boolean): AnimationGroup;
  32303. /**
  32304. * Reset all animations to initial state
  32305. * @returns the animation group
  32306. */
  32307. reset(): AnimationGroup;
  32308. /**
  32309. * Restart animations from key 0
  32310. * @returns the animation group
  32311. */
  32312. restart(): AnimationGroup;
  32313. /**
  32314. * Stop all animations
  32315. * @returns the animation group
  32316. */
  32317. stop(): AnimationGroup;
  32318. /**
  32319. * Set animation weight for all animatables
  32320. * @param weight defines the weight to use
  32321. * @return the animationGroup
  32322. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32323. */
  32324. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32325. /**
  32326. * Synchronize and normalize all animatables with a source animatable
  32327. * @param root defines the root animatable to synchronize with
  32328. * @return the animationGroup
  32329. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32330. */
  32331. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32332. /**
  32333. * Goes to a specific frame in this animation group
  32334. * @param frame the frame number to go to
  32335. * @return the animationGroup
  32336. */
  32337. goToFrame(frame: number): AnimationGroup;
  32338. /**
  32339. * Dispose all associated resources
  32340. */
  32341. dispose(): void;
  32342. private _checkAnimationGroupEnded;
  32343. /**
  32344. * Clone the current animation group and returns a copy
  32345. * @param newName defines the name of the new group
  32346. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32347. * @returns the new aniamtion group
  32348. */
  32349. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32350. /**
  32351. * Serializes the animationGroup to an object
  32352. * @returns Serialized object
  32353. */
  32354. serialize(): any;
  32355. /**
  32356. * Returns a new AnimationGroup object parsed from the source provided.
  32357. * @param parsedAnimationGroup defines the source
  32358. * @param scene defines the scene that will receive the animationGroup
  32359. * @returns a new AnimationGroup
  32360. */
  32361. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32362. /**
  32363. * Returns the string "AnimationGroup"
  32364. * @returns "AnimationGroup"
  32365. */
  32366. getClassName(): string;
  32367. /**
  32368. * Creates a detailled string about the object
  32369. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32370. * @returns a string representing the object
  32371. */
  32372. toString(fullDetails?: boolean): string;
  32373. }
  32374. }
  32375. declare module BABYLON {
  32376. /**
  32377. * Define an interface for all classes that will hold resources
  32378. */
  32379. export interface IDisposable {
  32380. /**
  32381. * Releases all held resources
  32382. */
  32383. dispose(): void;
  32384. }
  32385. /** Interface defining initialization parameters for Scene class */
  32386. export interface SceneOptions {
  32387. /**
  32388. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32389. * It will improve performance when the number of geometries becomes important.
  32390. */
  32391. useGeometryUniqueIdsMap?: boolean;
  32392. /**
  32393. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32394. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32395. */
  32396. useMaterialMeshMap?: boolean;
  32397. /**
  32398. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32399. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32400. */
  32401. useClonedMeshhMap?: boolean;
  32402. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32403. virtual?: boolean;
  32404. }
  32405. /**
  32406. * Represents a scene to be rendered by the engine.
  32407. * @see http://doc.babylonjs.com/features/scene
  32408. */
  32409. export class Scene extends AbstractScene implements IAnimatable {
  32410. /** The fog is deactivated */
  32411. static readonly FOGMODE_NONE: number;
  32412. /** The fog density is following an exponential function */
  32413. static readonly FOGMODE_EXP: number;
  32414. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32415. static readonly FOGMODE_EXP2: number;
  32416. /** The fog density is following a linear function. */
  32417. static readonly FOGMODE_LINEAR: number;
  32418. /**
  32419. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32420. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32421. */
  32422. static MinDeltaTime: number;
  32423. /**
  32424. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32425. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32426. */
  32427. static MaxDeltaTime: number;
  32428. /**
  32429. * Factory used to create the default material.
  32430. * @param name The name of the material to create
  32431. * @param scene The scene to create the material for
  32432. * @returns The default material
  32433. */
  32434. static DefaultMaterialFactory(scene: Scene): Material;
  32435. /**
  32436. * Factory used to create the a collision coordinator.
  32437. * @returns The collision coordinator
  32438. */
  32439. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32440. /** @hidden */ private _inputManager: InputManager;
  32441. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32442. cameraToUseForPointers: Nullable<Camera>;
  32443. /** @hidden */ protected readonly _isScene: boolean;
  32444. /**
  32445. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32446. */
  32447. autoClear: boolean;
  32448. /**
  32449. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32450. */
  32451. autoClearDepthAndStencil: boolean;
  32452. /**
  32453. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32454. */
  32455. clearColor: Color4;
  32456. /**
  32457. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32458. */
  32459. ambientColor: Color3;
  32460. /**
  32461. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32462. * It should only be one of the following (if not the default embedded one):
  32463. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32464. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32465. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32466. * The material properties need to be setup according to the type of texture in use.
  32467. */
  32468. environmentBRDFTexture: BaseTexture;
  32469. /** @hidden */
  32470. protected _environmentTexture: Nullable<BaseTexture>;
  32471. /**
  32472. * Texture used in all pbr material as the reflection texture.
  32473. * As in the majority of the scene they are the same (exception for multi room and so on),
  32474. * this is easier to reference from here than from all the materials.
  32475. */
  32476. /**
  32477. * Texture used in all pbr material as the reflection texture.
  32478. * As in the majority of the scene they are the same (exception for multi room and so on),
  32479. * this is easier to set here than in all the materials.
  32480. */
  32481. environmentTexture: Nullable<BaseTexture>;
  32482. /** @hidden */
  32483. protected _environmentIntensity: number;
  32484. /**
  32485. * Intensity of the environment in all pbr material.
  32486. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32487. * As in the majority of the scene they are the same (exception for multi room and so on),
  32488. * this is easier to reference from here than from all the materials.
  32489. */
  32490. /**
  32491. * Intensity of the environment in all pbr material.
  32492. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32493. * As in the majority of the scene they are the same (exception for multi room and so on),
  32494. * this is easier to set here than in all the materials.
  32495. */
  32496. environmentIntensity: number;
  32497. /** @hidden */
  32498. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32499. /**
  32500. * Default image processing configuration used either in the rendering
  32501. * Forward main pass or through the imageProcessingPostProcess if present.
  32502. * As in the majority of the scene they are the same (exception for multi camera),
  32503. * this is easier to reference from here than from all the materials and post process.
  32504. *
  32505. * No setter as we it is a shared configuration, you can set the values instead.
  32506. */
  32507. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32508. private _forceWireframe;
  32509. /**
  32510. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32511. */
  32512. forceWireframe: boolean;
  32513. private _forcePointsCloud;
  32514. /**
  32515. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32516. */
  32517. forcePointsCloud: boolean;
  32518. /**
  32519. * Gets or sets the active clipplane 1
  32520. */
  32521. clipPlane: Nullable<Plane>;
  32522. /**
  32523. * Gets or sets the active clipplane 2
  32524. */
  32525. clipPlane2: Nullable<Plane>;
  32526. /**
  32527. * Gets or sets the active clipplane 3
  32528. */
  32529. clipPlane3: Nullable<Plane>;
  32530. /**
  32531. * Gets or sets the active clipplane 4
  32532. */
  32533. clipPlane4: Nullable<Plane>;
  32534. /**
  32535. * Gets or sets a boolean indicating if animations are enabled
  32536. */
  32537. animationsEnabled: boolean;
  32538. private _animationPropertiesOverride;
  32539. /**
  32540. * Gets or sets the animation properties override
  32541. */
  32542. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32543. /**
  32544. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32545. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32546. */
  32547. useConstantAnimationDeltaTime: boolean;
  32548. /**
  32549. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32550. * Please note that it requires to run a ray cast through the scene on every frame
  32551. */
  32552. constantlyUpdateMeshUnderPointer: boolean;
  32553. /**
  32554. * Defines the HTML cursor to use when hovering over interactive elements
  32555. */
  32556. hoverCursor: string;
  32557. /**
  32558. * Defines the HTML default cursor to use (empty by default)
  32559. */
  32560. defaultCursor: string;
  32561. /**
  32562. * This is used to call preventDefault() on pointer down
  32563. * in order to block unwanted artifacts like system double clicks
  32564. */
  32565. preventDefaultOnPointerDown: boolean;
  32566. /**
  32567. * This is used to call preventDefault() on pointer up
  32568. * in order to block unwanted artifacts like system double clicks
  32569. */
  32570. preventDefaultOnPointerUp: boolean;
  32571. /**
  32572. * Gets or sets user defined metadata
  32573. */
  32574. metadata: any;
  32575. /**
  32576. * For internal use only. Please do not use.
  32577. */
  32578. reservedDataStore: any;
  32579. /**
  32580. * Gets the name of the plugin used to load this scene (null by default)
  32581. */
  32582. loadingPluginName: string;
  32583. /**
  32584. * Use this array to add regular expressions used to disable offline support for specific urls
  32585. */
  32586. disableOfflineSupportExceptionRules: RegExp[];
  32587. /**
  32588. * An event triggered when the scene is disposed.
  32589. */
  32590. onDisposeObservable: Observable<Scene>;
  32591. private _onDisposeObserver;
  32592. /** Sets a function to be executed when this scene is disposed. */
  32593. onDispose: () => void;
  32594. /**
  32595. * An event triggered before rendering the scene (right after animations and physics)
  32596. */
  32597. onBeforeRenderObservable: Observable<Scene>;
  32598. private _onBeforeRenderObserver;
  32599. /** Sets a function to be executed before rendering this scene */
  32600. beforeRender: Nullable<() => void>;
  32601. /**
  32602. * An event triggered after rendering the scene
  32603. */
  32604. onAfterRenderObservable: Observable<Scene>;
  32605. /**
  32606. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32607. */
  32608. onAfterRenderCameraObservable: Observable<Camera>;
  32609. private _onAfterRenderObserver;
  32610. /** Sets a function to be executed after rendering this scene */
  32611. afterRender: Nullable<() => void>;
  32612. /**
  32613. * An event triggered before animating the scene
  32614. */
  32615. onBeforeAnimationsObservable: Observable<Scene>;
  32616. /**
  32617. * An event triggered after animations processing
  32618. */
  32619. onAfterAnimationsObservable: Observable<Scene>;
  32620. /**
  32621. * An event triggered before draw calls are ready to be sent
  32622. */
  32623. onBeforeDrawPhaseObservable: Observable<Scene>;
  32624. /**
  32625. * An event triggered after draw calls have been sent
  32626. */
  32627. onAfterDrawPhaseObservable: Observable<Scene>;
  32628. /**
  32629. * An event triggered when the scene is ready
  32630. */
  32631. onReadyObservable: Observable<Scene>;
  32632. /**
  32633. * An event triggered before rendering a camera
  32634. */
  32635. onBeforeCameraRenderObservable: Observable<Camera>;
  32636. private _onBeforeCameraRenderObserver;
  32637. /** Sets a function to be executed before rendering a camera*/
  32638. beforeCameraRender: () => void;
  32639. /**
  32640. * An event triggered after rendering a camera
  32641. */
  32642. onAfterCameraRenderObservable: Observable<Camera>;
  32643. private _onAfterCameraRenderObserver;
  32644. /** Sets a function to be executed after rendering a camera*/
  32645. afterCameraRender: () => void;
  32646. /**
  32647. * An event triggered when active meshes evaluation is about to start
  32648. */
  32649. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32650. /**
  32651. * An event triggered when active meshes evaluation is done
  32652. */
  32653. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32654. /**
  32655. * An event triggered when particles rendering is about to start
  32656. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32657. */
  32658. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32659. /**
  32660. * An event triggered when particles rendering is done
  32661. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32662. */
  32663. onAfterParticlesRenderingObservable: Observable<Scene>;
  32664. /**
  32665. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32666. */
  32667. onDataLoadedObservable: Observable<Scene>;
  32668. /**
  32669. * An event triggered when a camera is created
  32670. */
  32671. onNewCameraAddedObservable: Observable<Camera>;
  32672. /**
  32673. * An event triggered when a camera is removed
  32674. */
  32675. onCameraRemovedObservable: Observable<Camera>;
  32676. /**
  32677. * An event triggered when a light is created
  32678. */
  32679. onNewLightAddedObservable: Observable<Light>;
  32680. /**
  32681. * An event triggered when a light is removed
  32682. */
  32683. onLightRemovedObservable: Observable<Light>;
  32684. /**
  32685. * An event triggered when a geometry is created
  32686. */
  32687. onNewGeometryAddedObservable: Observable<Geometry>;
  32688. /**
  32689. * An event triggered when a geometry is removed
  32690. */
  32691. onGeometryRemovedObservable: Observable<Geometry>;
  32692. /**
  32693. * An event triggered when a transform node is created
  32694. */
  32695. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32696. /**
  32697. * An event triggered when a transform node is removed
  32698. */
  32699. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32700. /**
  32701. * An event triggered when a mesh is created
  32702. */
  32703. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32704. /**
  32705. * An event triggered when a mesh is removed
  32706. */
  32707. onMeshRemovedObservable: Observable<AbstractMesh>;
  32708. /**
  32709. * An event triggered when a skeleton is created
  32710. */
  32711. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32712. /**
  32713. * An event triggered when a skeleton is removed
  32714. */
  32715. onSkeletonRemovedObservable: Observable<Skeleton>;
  32716. /**
  32717. * An event triggered when a material is created
  32718. */
  32719. onNewMaterialAddedObservable: Observable<Material>;
  32720. /**
  32721. * An event triggered when a material is removed
  32722. */
  32723. onMaterialRemovedObservable: Observable<Material>;
  32724. /**
  32725. * An event triggered when a texture is created
  32726. */
  32727. onNewTextureAddedObservable: Observable<BaseTexture>;
  32728. /**
  32729. * An event triggered when a texture is removed
  32730. */
  32731. onTextureRemovedObservable: Observable<BaseTexture>;
  32732. /**
  32733. * An event triggered when render targets are about to be rendered
  32734. * Can happen multiple times per frame.
  32735. */
  32736. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32737. /**
  32738. * An event triggered when render targets were rendered.
  32739. * Can happen multiple times per frame.
  32740. */
  32741. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32742. /**
  32743. * An event triggered before calculating deterministic simulation step
  32744. */
  32745. onBeforeStepObservable: Observable<Scene>;
  32746. /**
  32747. * An event triggered after calculating deterministic simulation step
  32748. */
  32749. onAfterStepObservable: Observable<Scene>;
  32750. /**
  32751. * An event triggered when the activeCamera property is updated
  32752. */
  32753. onActiveCameraChanged: Observable<Scene>;
  32754. /**
  32755. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32756. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32757. * 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)
  32758. */
  32759. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32760. /**
  32761. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32762. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32763. * 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)
  32764. */
  32765. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32766. /**
  32767. * This Observable will when a mesh has been imported into the scene.
  32768. */
  32769. onMeshImportedObservable: Observable<AbstractMesh>;
  32770. /**
  32771. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32772. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32773. */
  32774. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32775. /** @hidden */ private _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32776. /**
  32777. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32778. */
  32779. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32780. /**
  32781. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32782. */
  32783. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32784. /**
  32785. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32786. */
  32787. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32788. /** Callback called when a pointer move is detected */
  32789. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32790. /** Callback called when a pointer down is detected */
  32791. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32792. /** Callback called when a pointer up is detected */
  32793. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32794. /** Callback called when a pointer pick is detected */
  32795. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32796. /**
  32797. * 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).
  32798. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32799. */
  32800. onPrePointerObservable: Observable<PointerInfoPre>;
  32801. /**
  32802. * Observable event triggered each time an input event is received from the rendering canvas
  32803. */
  32804. onPointerObservable: Observable<PointerInfo>;
  32805. /**
  32806. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32807. */
  32808. readonly unTranslatedPointer: Vector2;
  32809. /**
  32810. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32811. */
  32812. static DragMovementThreshold: number;
  32813. /**
  32814. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32815. */
  32816. static LongPressDelay: number;
  32817. /**
  32818. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32819. */
  32820. static DoubleClickDelay: number;
  32821. /** If you need to check double click without raising a single click at first click, enable this flag */
  32822. static ExclusiveDoubleClickMode: boolean;
  32823. /** @hidden */ private _mirroredCameraPosition: Nullable<Vector3>;
  32824. /**
  32825. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32826. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32827. */
  32828. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32829. /**
  32830. * Observable event triggered each time an keyboard event is received from the hosting window
  32831. */
  32832. onKeyboardObservable: Observable<KeyboardInfo>;
  32833. private _useRightHandedSystem;
  32834. /**
  32835. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32836. */
  32837. useRightHandedSystem: boolean;
  32838. private _timeAccumulator;
  32839. private _currentStepId;
  32840. private _currentInternalStep;
  32841. /**
  32842. * Sets the step Id used by deterministic lock step
  32843. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32844. * @param newStepId defines the step Id
  32845. */
  32846. setStepId(newStepId: number): void;
  32847. /**
  32848. * Gets the step Id used by deterministic lock step
  32849. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32850. * @returns the step Id
  32851. */
  32852. getStepId(): number;
  32853. /**
  32854. * Gets the internal step used by deterministic lock step
  32855. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32856. * @returns the internal step
  32857. */
  32858. getInternalStep(): number;
  32859. private _fogEnabled;
  32860. /**
  32861. * Gets or sets a boolean indicating if fog is enabled on this scene
  32862. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32863. * (Default is true)
  32864. */
  32865. fogEnabled: boolean;
  32866. private _fogMode;
  32867. /**
  32868. * Gets or sets the fog mode to use
  32869. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32870. * | mode | value |
  32871. * | --- | --- |
  32872. * | FOGMODE_NONE | 0 |
  32873. * | FOGMODE_EXP | 1 |
  32874. * | FOGMODE_EXP2 | 2 |
  32875. * | FOGMODE_LINEAR | 3 |
  32876. */
  32877. fogMode: number;
  32878. /**
  32879. * Gets or sets the fog color to use
  32880. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32881. * (Default is Color3(0.2, 0.2, 0.3))
  32882. */
  32883. fogColor: Color3;
  32884. /**
  32885. * Gets or sets the fog density to use
  32886. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32887. * (Default is 0.1)
  32888. */
  32889. fogDensity: number;
  32890. /**
  32891. * Gets or sets the fog start distance to use
  32892. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32893. * (Default is 0)
  32894. */
  32895. fogStart: number;
  32896. /**
  32897. * Gets or sets the fog end distance to use
  32898. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32899. * (Default is 1000)
  32900. */
  32901. fogEnd: number;
  32902. private _shadowsEnabled;
  32903. /**
  32904. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32905. */
  32906. shadowsEnabled: boolean;
  32907. private _lightsEnabled;
  32908. /**
  32909. * Gets or sets a boolean indicating if lights are enabled on this scene
  32910. */
  32911. lightsEnabled: boolean;
  32912. /** All of the active cameras added to this scene. */
  32913. activeCameras: Camera[];
  32914. /** @hidden */ private _activeCamera: Nullable<Camera>;
  32915. /** Gets or sets the current active camera */
  32916. activeCamera: Nullable<Camera>;
  32917. private _defaultMaterial;
  32918. /** The default material used on meshes when no material is affected */
  32919. /** The default material used on meshes when no material is affected */
  32920. defaultMaterial: Material;
  32921. private _texturesEnabled;
  32922. /**
  32923. * Gets or sets a boolean indicating if textures are enabled on this scene
  32924. */
  32925. texturesEnabled: boolean;
  32926. /**
  32927. * Gets or sets a boolean indicating if particles are enabled on this scene
  32928. */
  32929. particlesEnabled: boolean;
  32930. /**
  32931. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32932. */
  32933. spritesEnabled: boolean;
  32934. private _skeletonsEnabled;
  32935. /**
  32936. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32937. */
  32938. skeletonsEnabled: boolean;
  32939. /**
  32940. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32941. */
  32942. lensFlaresEnabled: boolean;
  32943. /**
  32944. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32945. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32946. */
  32947. collisionsEnabled: boolean;
  32948. private _collisionCoordinator;
  32949. /** @hidden */
  32950. readonly collisionCoordinator: ICollisionCoordinator;
  32951. /**
  32952. * Defines the gravity applied to this scene (used only for collisions)
  32953. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32954. */
  32955. gravity: Vector3;
  32956. /**
  32957. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32958. */
  32959. postProcessesEnabled: boolean;
  32960. /**
  32961. * The list of postprocesses added to the scene
  32962. */
  32963. postProcesses: PostProcess[];
  32964. /**
  32965. * Gets the current postprocess manager
  32966. */
  32967. postProcessManager: PostProcessManager;
  32968. /**
  32969. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32970. */
  32971. renderTargetsEnabled: boolean;
  32972. /**
  32973. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32974. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32975. */
  32976. dumpNextRenderTargets: boolean;
  32977. /**
  32978. * The list of user defined render targets added to the scene
  32979. */
  32980. customRenderTargets: RenderTargetTexture[];
  32981. /**
  32982. * Defines if texture loading must be delayed
  32983. * If true, textures will only be loaded when they need to be rendered
  32984. */
  32985. useDelayedTextureLoading: boolean;
  32986. /**
  32987. * Gets the list of meshes imported to the scene through SceneLoader
  32988. */
  32989. importedMeshesFiles: String[];
  32990. /**
  32991. * Gets or sets a boolean indicating if probes are enabled on this scene
  32992. */
  32993. probesEnabled: boolean;
  32994. /**
  32995. * Gets or sets the current offline provider to use to store scene data
  32996. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32997. */
  32998. offlineProvider: IOfflineProvider;
  32999. /**
  33000. * Gets or sets the action manager associated with the scene
  33001. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33002. */
  33003. actionManager: AbstractActionManager;
  33004. private _meshesForIntersections;
  33005. /**
  33006. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33007. */
  33008. proceduralTexturesEnabled: boolean;
  33009. private _engine;
  33010. private _totalVertices;
  33011. /** @hidden */ private _activeIndices: PerfCounter;
  33012. /** @hidden */ private _activeParticles: PerfCounter;
  33013. /** @hidden */ private _activeBones: PerfCounter;
  33014. private _animationRatio;
  33015. /** @hidden */ private _animationTimeLast: number;
  33016. /** @hidden */ private _animationTime: number;
  33017. /**
  33018. * Gets or sets a general scale for animation speed
  33019. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33020. */
  33021. animationTimeScale: number;
  33022. /** @hidden */ private _cachedMaterial: Nullable<Material>;
  33023. /** @hidden */ private _cachedEffect: Nullable<Effect>;
  33024. /** @hidden */ private _cachedVisibility: Nullable<number>;
  33025. private _renderId;
  33026. private _frameId;
  33027. private _executeWhenReadyTimeoutId;
  33028. private _intermediateRendering;
  33029. private _viewUpdateFlag;
  33030. private _projectionUpdateFlag;
  33031. /** @hidden */ private _toBeDisposed: Nullable<IDisposable>[];
  33032. private _activeRequests;
  33033. /** @hidden */ private _pendingData: any[];
  33034. private _isDisposed;
  33035. /**
  33036. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33037. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33038. */
  33039. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33040. private _activeMeshes;
  33041. private _processedMaterials;
  33042. private _renderTargets;
  33043. /** @hidden */ private _activeParticleSystems: SmartArray<IParticleSystem>;
  33044. private _activeSkeletons;
  33045. private _softwareSkinnedMeshes;
  33046. private _renderingManager;
  33047. /** @hidden */ private _activeAnimatables: Animatable[];
  33048. private _transformMatrix;
  33049. private _sceneUbo;
  33050. /** @hidden */ private _viewMatrix: Matrix;
  33051. private _projectionMatrix;
  33052. /** @hidden */ private _forcedViewPosition: Nullable<Vector3>;
  33053. /** @hidden */ private _frustumPlanes: Plane[];
  33054. /**
  33055. * Gets the list of frustum planes (built from the active camera)
  33056. */
  33057. readonly frustumPlanes: Plane[];
  33058. /**
  33059. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33060. * This is useful if there are more lights that the maximum simulteanous authorized
  33061. */
  33062. requireLightSorting: boolean;
  33063. /** @hidden */
  33064. readonly useMaterialMeshMap: boolean;
  33065. /** @hidden */
  33066. readonly useClonedMeshhMap: boolean;
  33067. private _externalData;
  33068. private _uid;
  33069. /**
  33070. * @hidden
  33071. * Backing store of defined scene components.
  33072. */ private _components: ISceneComponent[];
  33073. /**
  33074. * @hidden
  33075. * Backing store of defined scene components.
  33076. */ private _serializableComponents: ISceneSerializableComponent[];
  33077. /**
  33078. * List of components to register on the next registration step.
  33079. */
  33080. private _transientComponents;
  33081. /**
  33082. * Registers the transient components if needed.
  33083. */
  33084. private _registerTransientComponents;
  33085. /**
  33086. * @hidden
  33087. * Add a component to the scene.
  33088. * Note that the ccomponent could be registered on th next frame if this is called after
  33089. * the register component stage.
  33090. * @param component Defines the component to add to the scene
  33091. */ private _addComponent(component: ISceneComponent): void;
  33092. /**
  33093. * @hidden
  33094. * Gets a component from the scene.
  33095. * @param name defines the name of the component to retrieve
  33096. * @returns the component or null if not present
  33097. */ private _getComponent(name: string): Nullable<ISceneComponent>;
  33098. /**
  33099. * @hidden
  33100. * Defines the actions happening before camera updates.
  33101. */ private _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33102. /**
  33103. * @hidden
  33104. * Defines the actions happening before clear the canvas.
  33105. */ private _beforeClearStage: Stage<SimpleStageAction>;
  33106. /**
  33107. * @hidden
  33108. * Defines the actions when collecting render targets for the frame.
  33109. */ private _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33110. /**
  33111. * @hidden
  33112. * Defines the actions happening for one camera in the frame.
  33113. */ private _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33114. /**
  33115. * @hidden
  33116. * Defines the actions happening during the per mesh ready checks.
  33117. */ private _isReadyForMeshStage: Stage<MeshStageAction>;
  33118. /**
  33119. * @hidden
  33120. * Defines the actions happening before evaluate active mesh checks.
  33121. */ private _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33122. /**
  33123. * @hidden
  33124. * Defines the actions happening during the evaluate sub mesh checks.
  33125. */ private _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33126. /**
  33127. * @hidden
  33128. * Defines the actions happening during the active mesh stage.
  33129. */ private _activeMeshStage: Stage<ActiveMeshStageAction>;
  33130. /**
  33131. * @hidden
  33132. * Defines the actions happening during the per camera render target step.
  33133. */ private _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33134. /**
  33135. * @hidden
  33136. * Defines the actions happening just before the active camera is drawing.
  33137. */ private _beforeCameraDrawStage: Stage<CameraStageAction>;
  33138. /**
  33139. * @hidden
  33140. * Defines the actions happening just before a render target is drawing.
  33141. */ private _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33142. /**
  33143. * @hidden
  33144. * Defines the actions happening just before a rendering group is drawing.
  33145. */ private _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33146. /**
  33147. * @hidden
  33148. * Defines the actions happening just before a mesh is drawing.
  33149. */ private _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33150. /**
  33151. * @hidden
  33152. * Defines the actions happening just after a mesh has been drawn.
  33153. */ private _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33154. /**
  33155. * @hidden
  33156. * Defines the actions happening just after a rendering group has been drawn.
  33157. */ private _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33158. /**
  33159. * @hidden
  33160. * Defines the actions happening just after the active camera has been drawn.
  33161. */ private _afterCameraDrawStage: Stage<CameraStageAction>;
  33162. /**
  33163. * @hidden
  33164. * Defines the actions happening just after a render target has been drawn.
  33165. */ private _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33166. /**
  33167. * @hidden
  33168. * Defines the actions happening just after rendering all cameras and computing intersections.
  33169. */ private _afterRenderStage: Stage<SimpleStageAction>;
  33170. /**
  33171. * @hidden
  33172. * Defines the actions happening when a pointer move event happens.
  33173. */ private _pointerMoveStage: Stage<PointerMoveStageAction>;
  33174. /**
  33175. * @hidden
  33176. * Defines the actions happening when a pointer down event happens.
  33177. */ private _pointerDownStage: Stage<PointerUpDownStageAction>;
  33178. /**
  33179. * @hidden
  33180. * Defines the actions happening when a pointer up event happens.
  33181. */ private _pointerUpStage: Stage<PointerUpDownStageAction>;
  33182. /**
  33183. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33184. */
  33185. private geometriesByUniqueId;
  33186. /**
  33187. * Creates a new Scene
  33188. * @param engine defines the engine to use to render this scene
  33189. * @param options defines the scene options
  33190. */
  33191. constructor(engine: Engine, options?: SceneOptions);
  33192. /**
  33193. * Gets a string idenfifying the name of the class
  33194. * @returns "Scene" string
  33195. */
  33196. getClassName(): string;
  33197. private _defaultMeshCandidates;
  33198. /**
  33199. * @hidden
  33200. */ private _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33201. private _defaultSubMeshCandidates;
  33202. /**
  33203. * @hidden
  33204. */ private _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33205. /**
  33206. * Sets the default candidate providers for the scene.
  33207. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33208. * and getCollidingSubMeshCandidates to their default function
  33209. */
  33210. setDefaultCandidateProviders(): void;
  33211. /**
  33212. * Gets the mesh that is currently under the pointer
  33213. */
  33214. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33215. /**
  33216. * Gets or sets the current on-screen X position of the pointer
  33217. */
  33218. pointerX: number;
  33219. /**
  33220. * Gets or sets the current on-screen Y position of the pointer
  33221. */
  33222. pointerY: number;
  33223. /**
  33224. * Gets the cached material (ie. the latest rendered one)
  33225. * @returns the cached material
  33226. */
  33227. getCachedMaterial(): Nullable<Material>;
  33228. /**
  33229. * Gets the cached effect (ie. the latest rendered one)
  33230. * @returns the cached effect
  33231. */
  33232. getCachedEffect(): Nullable<Effect>;
  33233. /**
  33234. * Gets the cached visibility state (ie. the latest rendered one)
  33235. * @returns the cached visibility state
  33236. */
  33237. getCachedVisibility(): Nullable<number>;
  33238. /**
  33239. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33240. * @param material defines the current material
  33241. * @param effect defines the current effect
  33242. * @param visibility defines the current visibility state
  33243. * @returns true if one parameter is not cached
  33244. */
  33245. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33246. /**
  33247. * Gets the engine associated with the scene
  33248. * @returns an Engine
  33249. */
  33250. getEngine(): Engine;
  33251. /**
  33252. * Gets the total number of vertices rendered per frame
  33253. * @returns the total number of vertices rendered per frame
  33254. */
  33255. getTotalVertices(): number;
  33256. /**
  33257. * Gets the performance counter for total vertices
  33258. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33259. */
  33260. readonly totalVerticesPerfCounter: PerfCounter;
  33261. /**
  33262. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33263. * @returns the total number of active indices rendered per frame
  33264. */
  33265. getActiveIndices(): number;
  33266. /**
  33267. * Gets the performance counter for active indices
  33268. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33269. */
  33270. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33271. /**
  33272. * Gets the total number of active particles rendered per frame
  33273. * @returns the total number of active particles rendered per frame
  33274. */
  33275. getActiveParticles(): number;
  33276. /**
  33277. * Gets the performance counter for active particles
  33278. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33279. */
  33280. readonly activeParticlesPerfCounter: PerfCounter;
  33281. /**
  33282. * Gets the total number of active bones rendered per frame
  33283. * @returns the total number of active bones rendered per frame
  33284. */
  33285. getActiveBones(): number;
  33286. /**
  33287. * Gets the performance counter for active bones
  33288. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33289. */
  33290. readonly activeBonesPerfCounter: PerfCounter;
  33291. /**
  33292. * Gets the array of active meshes
  33293. * @returns an array of AbstractMesh
  33294. */
  33295. getActiveMeshes(): SmartArray<AbstractMesh>;
  33296. /**
  33297. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33298. * @returns a number
  33299. */
  33300. getAnimationRatio(): number;
  33301. /**
  33302. * Gets an unique Id for the current render phase
  33303. * @returns a number
  33304. */
  33305. getRenderId(): number;
  33306. /**
  33307. * Gets an unique Id for the current frame
  33308. * @returns a number
  33309. */
  33310. getFrameId(): number;
  33311. /** Call this function if you want to manually increment the render Id*/
  33312. incrementRenderId(): void;
  33313. private _createUbo;
  33314. /**
  33315. * Use this method to simulate a pointer move on a mesh
  33316. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33317. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33318. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33319. * @returns the current scene
  33320. */
  33321. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33322. /**
  33323. * Use this method to simulate a pointer down on a mesh
  33324. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33325. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33326. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33327. * @returns the current scene
  33328. */
  33329. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33330. /**
  33331. * Use this method to simulate a pointer up on a mesh
  33332. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33333. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33334. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33335. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33336. * @returns the current scene
  33337. */
  33338. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33339. /**
  33340. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33341. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33342. * @returns true if the pointer was captured
  33343. */
  33344. isPointerCaptured(pointerId?: number): boolean;
  33345. /**
  33346. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33347. * @param attachUp defines if you want to attach events to pointerup
  33348. * @param attachDown defines if you want to attach events to pointerdown
  33349. * @param attachMove defines if you want to attach events to pointermove
  33350. */
  33351. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33352. /** Detaches all event handlers*/
  33353. detachControl(): void;
  33354. /**
  33355. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33356. * Delay loaded resources are not taking in account
  33357. * @return true if all required resources are ready
  33358. */
  33359. isReady(): boolean;
  33360. /** Resets all cached information relative to material (including effect and visibility) */
  33361. resetCachedMaterial(): void;
  33362. /**
  33363. * Registers a function to be called before every frame render
  33364. * @param func defines the function to register
  33365. */
  33366. registerBeforeRender(func: () => void): void;
  33367. /**
  33368. * Unregisters a function called before every frame render
  33369. * @param func defines the function to unregister
  33370. */
  33371. unregisterBeforeRender(func: () => void): void;
  33372. /**
  33373. * Registers a function to be called after every frame render
  33374. * @param func defines the function to register
  33375. */
  33376. registerAfterRender(func: () => void): void;
  33377. /**
  33378. * Unregisters a function called after every frame render
  33379. * @param func defines the function to unregister
  33380. */
  33381. unregisterAfterRender(func: () => void): void;
  33382. private _executeOnceBeforeRender;
  33383. /**
  33384. * The provided function will run before render once and will be disposed afterwards.
  33385. * A timeout delay can be provided so that the function will be executed in N ms.
  33386. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33387. * @param func The function to be executed.
  33388. * @param timeout optional delay in ms
  33389. */
  33390. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33391. /** @hidden */ private _addPendingData(data: any): void;
  33392. /** @hidden */ private _removePendingData(data: any): void;
  33393. /**
  33394. * Returns the number of items waiting to be loaded
  33395. * @returns the number of items waiting to be loaded
  33396. */
  33397. getWaitingItemsCount(): number;
  33398. /**
  33399. * Returns a boolean indicating if the scene is still loading data
  33400. */
  33401. readonly isLoading: boolean;
  33402. /**
  33403. * Registers a function to be executed when the scene is ready
  33404. * @param {Function} func - the function to be executed
  33405. */
  33406. executeWhenReady(func: () => void): void;
  33407. /**
  33408. * Returns a promise that resolves when the scene is ready
  33409. * @returns A promise that resolves when the scene is ready
  33410. */
  33411. whenReadyAsync(): Promise<void>;
  33412. /** @hidden */ private _checkIsReady(): void;
  33413. /**
  33414. * Gets all animatable attached to the scene
  33415. */
  33416. readonly animatables: Animatable[];
  33417. /**
  33418. * Resets the last animation time frame.
  33419. * Useful to override when animations start running when loading a scene for the first time.
  33420. */
  33421. resetLastAnimationTimeFrame(): void;
  33422. /**
  33423. * Gets the current view matrix
  33424. * @returns a Matrix
  33425. */
  33426. getViewMatrix(): Matrix;
  33427. /**
  33428. * Gets the current projection matrix
  33429. * @returns a Matrix
  33430. */
  33431. getProjectionMatrix(): Matrix;
  33432. /**
  33433. * Gets the current transform matrix
  33434. * @returns a Matrix made of View * Projection
  33435. */
  33436. getTransformMatrix(): Matrix;
  33437. /**
  33438. * Sets the current transform matrix
  33439. * @param viewL defines the View matrix to use
  33440. * @param projectionL defines the Projection matrix to use
  33441. * @param viewR defines the right View matrix to use (if provided)
  33442. * @param projectionR defines the right Projection matrix to use (if provided)
  33443. */
  33444. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33445. /**
  33446. * Gets the uniform buffer used to store scene data
  33447. * @returns a UniformBuffer
  33448. */
  33449. getSceneUniformBuffer(): UniformBuffer;
  33450. /**
  33451. * Gets an unique (relatively to the current scene) Id
  33452. * @returns an unique number for the scene
  33453. */
  33454. getUniqueId(): number;
  33455. /**
  33456. * Add a mesh to the list of scene's meshes
  33457. * @param newMesh defines the mesh to add
  33458. * @param recursive if all child meshes should also be added to the scene
  33459. */
  33460. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33461. /**
  33462. * Remove a mesh for the list of scene's meshes
  33463. * @param toRemove defines the mesh to remove
  33464. * @param recursive if all child meshes should also be removed from the scene
  33465. * @returns the index where the mesh was in the mesh list
  33466. */
  33467. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33468. /**
  33469. * Add a transform node to the list of scene's transform nodes
  33470. * @param newTransformNode defines the transform node to add
  33471. */
  33472. addTransformNode(newTransformNode: TransformNode): void;
  33473. /**
  33474. * Remove a transform node for the list of scene's transform nodes
  33475. * @param toRemove defines the transform node to remove
  33476. * @returns the index where the transform node was in the transform node list
  33477. */
  33478. removeTransformNode(toRemove: TransformNode): number;
  33479. /**
  33480. * Remove a skeleton for the list of scene's skeletons
  33481. * @param toRemove defines the skeleton to remove
  33482. * @returns the index where the skeleton was in the skeleton list
  33483. */
  33484. removeSkeleton(toRemove: Skeleton): number;
  33485. /**
  33486. * Remove a morph target for the list of scene's morph targets
  33487. * @param toRemove defines the morph target to remove
  33488. * @returns the index where the morph target was in the morph target list
  33489. */
  33490. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33491. /**
  33492. * Remove a light for the list of scene's lights
  33493. * @param toRemove defines the light to remove
  33494. * @returns the index where the light was in the light list
  33495. */
  33496. removeLight(toRemove: Light): number;
  33497. /**
  33498. * Remove a camera for the list of scene's cameras
  33499. * @param toRemove defines the camera to remove
  33500. * @returns the index where the camera was in the camera list
  33501. */
  33502. removeCamera(toRemove: Camera): number;
  33503. /**
  33504. * Remove a particle system for the list of scene's particle systems
  33505. * @param toRemove defines the particle system to remove
  33506. * @returns the index where the particle system was in the particle system list
  33507. */
  33508. removeParticleSystem(toRemove: IParticleSystem): number;
  33509. /**
  33510. * Remove a animation for the list of scene's animations
  33511. * @param toRemove defines the animation to remove
  33512. * @returns the index where the animation was in the animation list
  33513. */
  33514. removeAnimation(toRemove: Animation): number;
  33515. /**
  33516. * Will stop the animation of the given target
  33517. * @param target - the target
  33518. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33519. * @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)
  33520. */
  33521. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33522. /**
  33523. * Removes the given animation group from this scene.
  33524. * @param toRemove The animation group to remove
  33525. * @returns The index of the removed animation group
  33526. */
  33527. removeAnimationGroup(toRemove: AnimationGroup): number;
  33528. /**
  33529. * Removes the given multi-material from this scene.
  33530. * @param toRemove The multi-material to remove
  33531. * @returns The index of the removed multi-material
  33532. */
  33533. removeMultiMaterial(toRemove: MultiMaterial): number;
  33534. /**
  33535. * Removes the given material from this scene.
  33536. * @param toRemove The material to remove
  33537. * @returns The index of the removed material
  33538. */
  33539. removeMaterial(toRemove: Material): number;
  33540. /**
  33541. * Removes the given action manager from this scene.
  33542. * @param toRemove The action manager to remove
  33543. * @returns The index of the removed action manager
  33544. */
  33545. removeActionManager(toRemove: AbstractActionManager): number;
  33546. /**
  33547. * Removes the given texture from this scene.
  33548. * @param toRemove The texture to remove
  33549. * @returns The index of the removed texture
  33550. */
  33551. removeTexture(toRemove: BaseTexture): number;
  33552. /**
  33553. * Adds the given light to this scene
  33554. * @param newLight The light to add
  33555. */
  33556. addLight(newLight: Light): void;
  33557. /**
  33558. * Sorts the list list based on light priorities
  33559. */
  33560. sortLightsByPriority(): void;
  33561. /**
  33562. * Adds the given camera to this scene
  33563. * @param newCamera The camera to add
  33564. */
  33565. addCamera(newCamera: Camera): void;
  33566. /**
  33567. * Adds the given skeleton to this scene
  33568. * @param newSkeleton The skeleton to add
  33569. */
  33570. addSkeleton(newSkeleton: Skeleton): void;
  33571. /**
  33572. * Adds the given particle system to this scene
  33573. * @param newParticleSystem The particle system to add
  33574. */
  33575. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33576. /**
  33577. * Adds the given animation to this scene
  33578. * @param newAnimation The animation to add
  33579. */
  33580. addAnimation(newAnimation: Animation): void;
  33581. /**
  33582. * Adds the given animation group to this scene.
  33583. * @param newAnimationGroup The animation group to add
  33584. */
  33585. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33586. /**
  33587. * Adds the given multi-material to this scene
  33588. * @param newMultiMaterial The multi-material to add
  33589. */
  33590. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33591. /**
  33592. * Adds the given material to this scene
  33593. * @param newMaterial The material to add
  33594. */
  33595. addMaterial(newMaterial: Material): void;
  33596. /**
  33597. * Adds the given morph target to this scene
  33598. * @param newMorphTargetManager The morph target to add
  33599. */
  33600. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33601. /**
  33602. * Adds the given geometry to this scene
  33603. * @param newGeometry The geometry to add
  33604. */
  33605. addGeometry(newGeometry: Geometry): void;
  33606. /**
  33607. * Adds the given action manager to this scene
  33608. * @param newActionManager The action manager to add
  33609. */
  33610. addActionManager(newActionManager: AbstractActionManager): void;
  33611. /**
  33612. * Adds the given texture to this scene.
  33613. * @param newTexture The texture to add
  33614. */
  33615. addTexture(newTexture: BaseTexture): void;
  33616. /**
  33617. * Switch active camera
  33618. * @param newCamera defines the new active camera
  33619. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33620. */
  33621. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33622. /**
  33623. * sets the active camera of the scene using its ID
  33624. * @param id defines the camera's ID
  33625. * @return the new active camera or null if none found.
  33626. */
  33627. setActiveCameraByID(id: string): Nullable<Camera>;
  33628. /**
  33629. * sets the active camera of the scene using its name
  33630. * @param name defines the camera's name
  33631. * @returns the new active camera or null if none found.
  33632. */
  33633. setActiveCameraByName(name: string): Nullable<Camera>;
  33634. /**
  33635. * get an animation group using its name
  33636. * @param name defines the material's name
  33637. * @return the animation group or null if none found.
  33638. */
  33639. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33640. /**
  33641. * Get a material using its unique id
  33642. * @param uniqueId defines the material's unique id
  33643. * @return the material or null if none found.
  33644. */
  33645. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33646. /**
  33647. * get a material using its id
  33648. * @param id defines the material's ID
  33649. * @return the material or null if none found.
  33650. */
  33651. getMaterialByID(id: string): Nullable<Material>;
  33652. /**
  33653. * Gets a the last added material using a given id
  33654. * @param id defines the material's ID
  33655. * @return the last material with the given id or null if none found.
  33656. */
  33657. getLastMaterialByID(id: string): Nullable<Material>;
  33658. /**
  33659. * Gets a material using its name
  33660. * @param name defines the material's name
  33661. * @return the material or null if none found.
  33662. */
  33663. getMaterialByName(name: string): Nullable<Material>;
  33664. /**
  33665. * Get a texture using its unique id
  33666. * @param uniqueId defines the texture's unique id
  33667. * @return the texture or null if none found.
  33668. */
  33669. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  33670. /**
  33671. * Gets a camera using its id
  33672. * @param id defines the id to look for
  33673. * @returns the camera or null if not found
  33674. */
  33675. getCameraByID(id: string): Nullable<Camera>;
  33676. /**
  33677. * Gets a camera using its unique id
  33678. * @param uniqueId defines the unique id to look for
  33679. * @returns the camera or null if not found
  33680. */
  33681. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33682. /**
  33683. * Gets a camera using its name
  33684. * @param name defines the camera's name
  33685. * @return the camera or null if none found.
  33686. */
  33687. getCameraByName(name: string): Nullable<Camera>;
  33688. /**
  33689. * Gets a bone using its id
  33690. * @param id defines the bone's id
  33691. * @return the bone or null if not found
  33692. */
  33693. getBoneByID(id: string): Nullable<Bone>;
  33694. /**
  33695. * Gets a bone using its id
  33696. * @param name defines the bone's name
  33697. * @return the bone or null if not found
  33698. */
  33699. getBoneByName(name: string): Nullable<Bone>;
  33700. /**
  33701. * Gets a light node using its name
  33702. * @param name defines the the light's name
  33703. * @return the light or null if none found.
  33704. */
  33705. getLightByName(name: string): Nullable<Light>;
  33706. /**
  33707. * Gets a light node using its id
  33708. * @param id defines the light's id
  33709. * @return the light or null if none found.
  33710. */
  33711. getLightByID(id: string): Nullable<Light>;
  33712. /**
  33713. * Gets a light node using its scene-generated unique ID
  33714. * @param uniqueId defines the light's unique id
  33715. * @return the light or null if none found.
  33716. */
  33717. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33718. /**
  33719. * Gets a particle system by id
  33720. * @param id defines the particle system id
  33721. * @return the corresponding system or null if none found
  33722. */
  33723. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33724. /**
  33725. * Gets a geometry using its ID
  33726. * @param id defines the geometry's id
  33727. * @return the geometry or null if none found.
  33728. */
  33729. getGeometryByID(id: string): Nullable<Geometry>;
  33730. private _getGeometryByUniqueID;
  33731. /**
  33732. * Add a new geometry to this scene
  33733. * @param geometry defines the geometry to be added to the scene.
  33734. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33735. * @return a boolean defining if the geometry was added or not
  33736. */
  33737. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33738. /**
  33739. * Removes an existing geometry
  33740. * @param geometry defines the geometry to be removed from the scene
  33741. * @return a boolean defining if the geometry was removed or not
  33742. */
  33743. removeGeometry(geometry: Geometry): boolean;
  33744. /**
  33745. * Gets the list of geometries attached to the scene
  33746. * @returns an array of Geometry
  33747. */
  33748. getGeometries(): Geometry[];
  33749. /**
  33750. * Gets the first added mesh found of a given ID
  33751. * @param id defines the id to search for
  33752. * @return the mesh found or null if not found at all
  33753. */
  33754. getMeshByID(id: string): Nullable<AbstractMesh>;
  33755. /**
  33756. * Gets a list of meshes using their id
  33757. * @param id defines the id to search for
  33758. * @returns a list of meshes
  33759. */
  33760. getMeshesByID(id: string): Array<AbstractMesh>;
  33761. /**
  33762. * Gets the first added transform node found of a given ID
  33763. * @param id defines the id to search for
  33764. * @return the found transform node or null if not found at all.
  33765. */
  33766. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33767. /**
  33768. * Gets a transform node with its auto-generated unique id
  33769. * @param uniqueId efines the unique id to search for
  33770. * @return the found transform node or null if not found at all.
  33771. */
  33772. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33773. /**
  33774. * Gets a list of transform nodes using their id
  33775. * @param id defines the id to search for
  33776. * @returns a list of transform nodes
  33777. */
  33778. getTransformNodesByID(id: string): Array<TransformNode>;
  33779. /**
  33780. * Gets a mesh with its auto-generated unique id
  33781. * @param uniqueId defines the unique id to search for
  33782. * @return the found mesh or null if not found at all.
  33783. */
  33784. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33785. /**
  33786. * Gets a the last added mesh using a given id
  33787. * @param id defines the id to search for
  33788. * @return the found mesh or null if not found at all.
  33789. */
  33790. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33791. /**
  33792. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33793. * @param id defines the id to search for
  33794. * @return the found node or null if not found at all
  33795. */
  33796. getLastEntryByID(id: string): Nullable<Node>;
  33797. /**
  33798. * Gets a node (Mesh, Camera, Light) using a given id
  33799. * @param id defines the id to search for
  33800. * @return the found node or null if not found at all
  33801. */
  33802. getNodeByID(id: string): Nullable<Node>;
  33803. /**
  33804. * Gets a node (Mesh, Camera, Light) using a given name
  33805. * @param name defines the name to search for
  33806. * @return the found node or null if not found at all.
  33807. */
  33808. getNodeByName(name: string): Nullable<Node>;
  33809. /**
  33810. * Gets a mesh using a given name
  33811. * @param name defines the name to search for
  33812. * @return the found mesh or null if not found at all.
  33813. */
  33814. getMeshByName(name: string): Nullable<AbstractMesh>;
  33815. /**
  33816. * Gets a transform node using a given name
  33817. * @param name defines the name to search for
  33818. * @return the found transform node or null if not found at all.
  33819. */
  33820. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33821. /**
  33822. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33823. * @param id defines the id to search for
  33824. * @return the found skeleton or null if not found at all.
  33825. */
  33826. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33827. /**
  33828. * Gets a skeleton using a given auto generated unique id
  33829. * @param uniqueId defines the unique id to search for
  33830. * @return the found skeleton or null if not found at all.
  33831. */
  33832. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33833. /**
  33834. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33835. * @param id defines the id to search for
  33836. * @return the found skeleton or null if not found at all.
  33837. */
  33838. getSkeletonById(id: string): Nullable<Skeleton>;
  33839. /**
  33840. * Gets a skeleton using a given name
  33841. * @param name defines the name to search for
  33842. * @return the found skeleton or null if not found at all.
  33843. */
  33844. getSkeletonByName(name: string): Nullable<Skeleton>;
  33845. /**
  33846. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33847. * @param id defines the id to search for
  33848. * @return the found morph target manager or null if not found at all.
  33849. */
  33850. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33851. /**
  33852. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33853. * @param id defines the id to search for
  33854. * @return the found morph target or null if not found at all.
  33855. */
  33856. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33857. /**
  33858. * Gets a boolean indicating if the given mesh is active
  33859. * @param mesh defines the mesh to look for
  33860. * @returns true if the mesh is in the active list
  33861. */
  33862. isActiveMesh(mesh: AbstractMesh): boolean;
  33863. /**
  33864. * Return a unique id as a string which can serve as an identifier for the scene
  33865. */
  33866. readonly uid: string;
  33867. /**
  33868. * Add an externaly attached data from its key.
  33869. * This method call will fail and return false, if such key already exists.
  33870. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33871. * @param key the unique key that identifies the data
  33872. * @param data the data object to associate to the key for this Engine instance
  33873. * @return true if no such key were already present and the data was added successfully, false otherwise
  33874. */
  33875. addExternalData<T>(key: string, data: T): boolean;
  33876. /**
  33877. * Get an externaly attached data from its key
  33878. * @param key the unique key that identifies the data
  33879. * @return the associated data, if present (can be null), or undefined if not present
  33880. */
  33881. getExternalData<T>(key: string): Nullable<T>;
  33882. /**
  33883. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33884. * @param key the unique key that identifies the data
  33885. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33886. * @return the associated data, can be null if the factory returned null.
  33887. */
  33888. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33889. /**
  33890. * Remove an externaly attached data from the Engine instance
  33891. * @param key the unique key that identifies the data
  33892. * @return true if the data was successfully removed, false if it doesn't exist
  33893. */
  33894. removeExternalData(key: string): boolean;
  33895. private _evaluateSubMesh;
  33896. /**
  33897. * Clear the processed materials smart array preventing retention point in material dispose.
  33898. */
  33899. freeProcessedMaterials(): void;
  33900. private _preventFreeActiveMeshesAndRenderingGroups;
  33901. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33902. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33903. * when disposing several meshes in a row or a hierarchy of meshes.
  33904. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33905. */
  33906. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33907. /**
  33908. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33909. */
  33910. freeActiveMeshes(): void;
  33911. /**
  33912. * Clear the info related to rendering groups preventing retention points during dispose.
  33913. */
  33914. freeRenderingGroups(): void;
  33915. /** @hidden */ private _isInIntermediateRendering(): boolean;
  33916. /**
  33917. * Lambda returning the list of potentially active meshes.
  33918. */
  33919. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33920. /**
  33921. * Lambda returning the list of potentially active sub meshes.
  33922. */
  33923. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33924. /**
  33925. * Lambda returning the list of potentially intersecting sub meshes.
  33926. */
  33927. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33928. /**
  33929. * Lambda returning the list of potentially colliding sub meshes.
  33930. */
  33931. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33932. private _activeMeshesFrozen;
  33933. /**
  33934. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33935. * @returns the current scene
  33936. */
  33937. freezeActiveMeshes(): Scene;
  33938. /**
  33939. * Use this function to restart evaluating active meshes on every frame
  33940. * @returns the current scene
  33941. */
  33942. unfreezeActiveMeshes(): Scene;
  33943. private _evaluateActiveMeshes;
  33944. private _activeMesh;
  33945. /**
  33946. * Update the transform matrix to update from the current active camera
  33947. * @param force defines a boolean used to force the update even if cache is up to date
  33948. */
  33949. updateTransformMatrix(force?: boolean): void;
  33950. private _bindFrameBuffer;
  33951. /** @hidden */ private _allowPostProcessClearColor: boolean;
  33952. /** @hidden */ private _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33953. private _processSubCameras;
  33954. private _checkIntersections;
  33955. /** @hidden */ private _advancePhysicsEngineStep(step: number): void;
  33956. /**
  33957. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33958. */
  33959. getDeterministicFrameTime: () => number;
  33960. /** @hidden */ private _animate(): void;
  33961. /** Execute all animations (for a frame) */
  33962. animate(): void;
  33963. /**
  33964. * Render the scene
  33965. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33966. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33967. */
  33968. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33969. /**
  33970. * Freeze all materials
  33971. * A frozen material will not be updatable but should be faster to render
  33972. */
  33973. freezeMaterials(): void;
  33974. /**
  33975. * Unfreeze all materials
  33976. * A frozen material will not be updatable but should be faster to render
  33977. */
  33978. unfreezeMaterials(): void;
  33979. /**
  33980. * Releases all held ressources
  33981. */
  33982. dispose(): void;
  33983. /**
  33984. * Gets if the scene is already disposed
  33985. */
  33986. readonly isDisposed: boolean;
  33987. /**
  33988. * Call this function to reduce memory footprint of the scene.
  33989. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33990. */
  33991. clearCachedVertexData(): void;
  33992. /**
  33993. * This function will remove the local cached buffer data from texture.
  33994. * It will save memory but will prevent the texture from being rebuilt
  33995. */
  33996. cleanCachedTextureBuffer(): void;
  33997. /**
  33998. * Get the world extend vectors with an optional filter
  33999. *
  34000. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34001. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34002. */
  34003. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34004. min: Vector3;
  34005. max: Vector3;
  34006. };
  34007. /**
  34008. * Creates a ray that can be used to pick in the scene
  34009. * @param x defines the x coordinate of the origin (on-screen)
  34010. * @param y defines the y coordinate of the origin (on-screen)
  34011. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34012. * @param camera defines the camera to use for the picking
  34013. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34014. * @returns a Ray
  34015. */
  34016. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34017. /**
  34018. * Creates a ray that can be used to pick in the scene
  34019. * @param x defines the x coordinate of the origin (on-screen)
  34020. * @param y defines the y coordinate of the origin (on-screen)
  34021. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34022. * @param result defines the ray where to store the picking ray
  34023. * @param camera defines the camera to use for the picking
  34024. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34025. * @returns the current scene
  34026. */
  34027. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34028. /**
  34029. * Creates a ray that can be used to pick in the scene
  34030. * @param x defines the x coordinate of the origin (on-screen)
  34031. * @param y defines the y coordinate of the origin (on-screen)
  34032. * @param camera defines the camera to use for the picking
  34033. * @returns a Ray
  34034. */
  34035. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34036. /**
  34037. * Creates a ray that can be used to pick in the scene
  34038. * @param x defines the x coordinate of the origin (on-screen)
  34039. * @param y defines the y coordinate of the origin (on-screen)
  34040. * @param result defines the ray where to store the picking ray
  34041. * @param camera defines the camera to use for the picking
  34042. * @returns the current scene
  34043. */
  34044. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34045. /** Launch a ray to try to pick a mesh in the scene
  34046. * @param x position on screen
  34047. * @param y position on screen
  34048. * @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
  34049. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34050. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34051. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34052. * @returns a PickingInfo
  34053. */
  34054. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34055. /** Use the given ray to pick a mesh in the scene
  34056. * @param ray The ray to use to pick meshes
  34057. * @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
  34058. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34059. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34060. * @returns a PickingInfo
  34061. */
  34062. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34063. /**
  34064. * Launch a ray to try to pick a mesh in the scene
  34065. * @param x X position on screen
  34066. * @param y Y position on screen
  34067. * @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
  34068. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34069. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34070. * @returns an array of PickingInfo
  34071. */
  34072. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34073. /**
  34074. * Launch a ray to try to pick a mesh in the scene
  34075. * @param ray Ray to use
  34076. * @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
  34077. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34078. * @returns an array of PickingInfo
  34079. */
  34080. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34081. /**
  34082. * Force the value of meshUnderPointer
  34083. * @param mesh defines the mesh to use
  34084. */
  34085. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34086. /**
  34087. * Gets the mesh under the pointer
  34088. * @returns a Mesh or null if no mesh is under the pointer
  34089. */
  34090. getPointerOverMesh(): Nullable<AbstractMesh>;
  34091. /** @hidden */ private _rebuildGeometries(): void;
  34092. /** @hidden */ private _rebuildTextures(): void;
  34093. private _getByTags;
  34094. /**
  34095. * Get a list of meshes by tags
  34096. * @param tagsQuery defines the tags query to use
  34097. * @param forEach defines a predicate used to filter results
  34098. * @returns an array of Mesh
  34099. */
  34100. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34101. /**
  34102. * Get a list of cameras by tags
  34103. * @param tagsQuery defines the tags query to use
  34104. * @param forEach defines a predicate used to filter results
  34105. * @returns an array of Camera
  34106. */
  34107. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34108. /**
  34109. * Get a list of lights by tags
  34110. * @param tagsQuery defines the tags query to use
  34111. * @param forEach defines a predicate used to filter results
  34112. * @returns an array of Light
  34113. */
  34114. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34115. /**
  34116. * Get a list of materials by tags
  34117. * @param tagsQuery defines the tags query to use
  34118. * @param forEach defines a predicate used to filter results
  34119. * @returns an array of Material
  34120. */
  34121. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34122. /**
  34123. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34124. * This allowed control for front to back rendering or reversly depending of the special needs.
  34125. *
  34126. * @param renderingGroupId The rendering group id corresponding to its index
  34127. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34128. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34129. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34130. */
  34131. 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;
  34132. /**
  34133. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34134. *
  34135. * @param renderingGroupId The rendering group id corresponding to its index
  34136. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34137. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34138. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34139. */
  34140. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34141. /**
  34142. * Gets the current auto clear configuration for one rendering group of the rendering
  34143. * manager.
  34144. * @param index the rendering group index to get the information for
  34145. * @returns The auto clear setup for the requested rendering group
  34146. */
  34147. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34148. private _blockMaterialDirtyMechanism;
  34149. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34150. blockMaterialDirtyMechanism: boolean;
  34151. /**
  34152. * Will flag all materials as dirty to trigger new shader compilation
  34153. * @param flag defines the flag used to specify which material part must be marked as dirty
  34154. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34155. */
  34156. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34157. /** @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;
  34158. /** @hidden */ private _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34159. }
  34160. }
  34161. declare module BABYLON {
  34162. /**
  34163. * Set of assets to keep when moving a scene into an asset container.
  34164. */
  34165. export class KeepAssets extends AbstractScene {
  34166. }
  34167. /**
  34168. * Container with a set of assets that can be added or removed from a scene.
  34169. */
  34170. export class AssetContainer extends AbstractScene {
  34171. /**
  34172. * The scene the AssetContainer belongs to.
  34173. */
  34174. scene: Scene;
  34175. /**
  34176. * Instantiates an AssetContainer.
  34177. * @param scene The scene the AssetContainer belongs to.
  34178. */
  34179. constructor(scene: Scene);
  34180. /**
  34181. * Adds all the assets from the container to the scene.
  34182. */
  34183. addAllToScene(): void;
  34184. /**
  34185. * Removes all the assets in the container from the scene
  34186. */
  34187. removeAllFromScene(): void;
  34188. /**
  34189. * Disposes all the assets in the container
  34190. */
  34191. dispose(): void;
  34192. private _moveAssets;
  34193. /**
  34194. * Removes all the assets contained in the scene and adds them to the container.
  34195. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34196. */
  34197. moveAllFromScene(keepAssets?: KeepAssets): void;
  34198. /**
  34199. * 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.
  34200. * @returns the root mesh
  34201. */
  34202. createRootMesh(): Mesh;
  34203. }
  34204. }
  34205. declare module BABYLON {
  34206. /**
  34207. * Defines how the parser contract is defined.
  34208. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34209. */
  34210. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34211. /**
  34212. * Defines how the individual parser contract is defined.
  34213. * These parser can parse an individual asset
  34214. */
  34215. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34216. /**
  34217. * Base class of the scene acting as a container for the different elements composing a scene.
  34218. * This class is dynamically extended by the different components of the scene increasing
  34219. * flexibility and reducing coupling
  34220. */
  34221. export abstract class AbstractScene {
  34222. /**
  34223. * Stores the list of available parsers in the application.
  34224. */
  34225. private static _BabylonFileParsers;
  34226. /**
  34227. * Stores the list of available individual parsers in the application.
  34228. */
  34229. private static _IndividualBabylonFileParsers;
  34230. /**
  34231. * Adds a parser in the list of available ones
  34232. * @param name Defines the name of the parser
  34233. * @param parser Defines the parser to add
  34234. */
  34235. static AddParser(name: string, parser: BabylonFileParser): void;
  34236. /**
  34237. * Gets a general parser from the list of avaialble ones
  34238. * @param name Defines the name of the parser
  34239. * @returns the requested parser or null
  34240. */
  34241. static GetParser(name: string): Nullable<BabylonFileParser>;
  34242. /**
  34243. * Adds n individual parser in the list of available ones
  34244. * @param name Defines the name of the parser
  34245. * @param parser Defines the parser to add
  34246. */
  34247. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34248. /**
  34249. * Gets an individual parser from the list of avaialble ones
  34250. * @param name Defines the name of the parser
  34251. * @returns the requested parser or null
  34252. */
  34253. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34254. /**
  34255. * Parser json data and populate both a scene and its associated container object
  34256. * @param jsonData Defines the data to parse
  34257. * @param scene Defines the scene to parse the data for
  34258. * @param container Defines the container attached to the parsing sequence
  34259. * @param rootUrl Defines the root url of the data
  34260. */
  34261. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34262. /**
  34263. * Gets the list of root nodes (ie. nodes with no parent)
  34264. */
  34265. rootNodes: Node[];
  34266. /** All of the cameras added to this scene
  34267. * @see http://doc.babylonjs.com/babylon101/cameras
  34268. */
  34269. cameras: Camera[];
  34270. /**
  34271. * All of the lights added to this scene
  34272. * @see http://doc.babylonjs.com/babylon101/lights
  34273. */
  34274. lights: Light[];
  34275. /**
  34276. * All of the (abstract) meshes added to this scene
  34277. */
  34278. meshes: AbstractMesh[];
  34279. /**
  34280. * The list of skeletons added to the scene
  34281. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34282. */
  34283. skeletons: Skeleton[];
  34284. /**
  34285. * All of the particle systems added to this scene
  34286. * @see http://doc.babylonjs.com/babylon101/particles
  34287. */
  34288. particleSystems: IParticleSystem[];
  34289. /**
  34290. * Gets a list of Animations associated with the scene
  34291. */
  34292. animations: Animation[];
  34293. /**
  34294. * All of the animation groups added to this scene
  34295. * @see http://doc.babylonjs.com/how_to/group
  34296. */
  34297. animationGroups: AnimationGroup[];
  34298. /**
  34299. * All of the multi-materials added to this scene
  34300. * @see http://doc.babylonjs.com/how_to/multi_materials
  34301. */
  34302. multiMaterials: MultiMaterial[];
  34303. /**
  34304. * All of the materials added to this scene
  34305. * In the context of a Scene, it is not supposed to be modified manually.
  34306. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34307. * Note also that the order of the Material wihin the array is not significant and might change.
  34308. * @see http://doc.babylonjs.com/babylon101/materials
  34309. */
  34310. materials: Material[];
  34311. /**
  34312. * The list of morph target managers added to the scene
  34313. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34314. */
  34315. morphTargetManagers: MorphTargetManager[];
  34316. /**
  34317. * The list of geometries used in the scene.
  34318. */
  34319. geometries: Geometry[];
  34320. /**
  34321. * All of the tranform nodes added to this scene
  34322. * In the context of a Scene, it is not supposed to be modified manually.
  34323. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34324. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34325. * @see http://doc.babylonjs.com/how_to/transformnode
  34326. */
  34327. transformNodes: TransformNode[];
  34328. /**
  34329. * ActionManagers available on the scene.
  34330. */
  34331. actionManagers: AbstractActionManager[];
  34332. /**
  34333. * Textures to keep.
  34334. */
  34335. textures: BaseTexture[];
  34336. /**
  34337. * Environment texture for the scene
  34338. */
  34339. environmentTexture: Nullable<BaseTexture>;
  34340. }
  34341. }
  34342. declare module BABYLON {
  34343. /**
  34344. * Interface used to define options for Sound class
  34345. */
  34346. export interface ISoundOptions {
  34347. /**
  34348. * Does the sound autoplay once loaded.
  34349. */
  34350. autoplay?: boolean;
  34351. /**
  34352. * Does the sound loop after it finishes playing once.
  34353. */
  34354. loop?: boolean;
  34355. /**
  34356. * Sound's volume
  34357. */
  34358. volume?: number;
  34359. /**
  34360. * Is it a spatial sound?
  34361. */
  34362. spatialSound?: boolean;
  34363. /**
  34364. * Maximum distance to hear that sound
  34365. */
  34366. maxDistance?: number;
  34367. /**
  34368. * Uses user defined attenuation function
  34369. */
  34370. useCustomAttenuation?: boolean;
  34371. /**
  34372. * Define the roll off factor of spatial sounds.
  34373. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34374. */
  34375. rolloffFactor?: number;
  34376. /**
  34377. * Define the reference distance the sound should be heard perfectly.
  34378. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34379. */
  34380. refDistance?: number;
  34381. /**
  34382. * Define the distance attenuation model the sound will follow.
  34383. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34384. */
  34385. distanceModel?: string;
  34386. /**
  34387. * Defines the playback speed (1 by default)
  34388. */
  34389. playbackRate?: number;
  34390. /**
  34391. * Defines if the sound is from a streaming source
  34392. */
  34393. streaming?: boolean;
  34394. /**
  34395. * Defines an optional length (in seconds) inside the sound file
  34396. */
  34397. length?: number;
  34398. /**
  34399. * Defines an optional offset (in seconds) inside the sound file
  34400. */
  34401. offset?: number;
  34402. /**
  34403. * If true, URLs will not be required to state the audio file codec to use.
  34404. */
  34405. skipCodecCheck?: boolean;
  34406. }
  34407. /**
  34408. * Defines a sound that can be played in the application.
  34409. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34410. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34411. */
  34412. export class Sound {
  34413. /**
  34414. * The name of the sound in the scene.
  34415. */
  34416. name: string;
  34417. /**
  34418. * Does the sound autoplay once loaded.
  34419. */
  34420. autoplay: boolean;
  34421. /**
  34422. * Does the sound loop after it finishes playing once.
  34423. */
  34424. loop: boolean;
  34425. /**
  34426. * Does the sound use a custom attenuation curve to simulate the falloff
  34427. * happening when the source gets further away from the camera.
  34428. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34429. */
  34430. useCustomAttenuation: boolean;
  34431. /**
  34432. * The sound track id this sound belongs to.
  34433. */
  34434. soundTrackId: number;
  34435. /**
  34436. * Is this sound currently played.
  34437. */
  34438. isPlaying: boolean;
  34439. /**
  34440. * Is this sound currently paused.
  34441. */
  34442. isPaused: boolean;
  34443. /**
  34444. * Does this sound enables spatial sound.
  34445. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34446. */
  34447. spatialSound: boolean;
  34448. /**
  34449. * Define the reference distance the sound should be heard perfectly.
  34450. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34451. */
  34452. refDistance: number;
  34453. /**
  34454. * Define the roll off factor of spatial sounds.
  34455. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34456. */
  34457. rolloffFactor: number;
  34458. /**
  34459. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34460. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34461. */
  34462. maxDistance: number;
  34463. /**
  34464. * Define the distance attenuation model the sound will follow.
  34465. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34466. */
  34467. distanceModel: string;
  34468. /**
  34469. * @hidden
  34470. * Back Compat
  34471. **/
  34472. onended: () => any;
  34473. /**
  34474. * Observable event when the current playing sound finishes.
  34475. */
  34476. onEndedObservable: Observable<Sound>;
  34477. private _panningModel;
  34478. private _playbackRate;
  34479. private _streaming;
  34480. private _startTime;
  34481. private _startOffset;
  34482. private _position;
  34483. /** @hidden */ private _positionInEmitterSpace: boolean;
  34484. private _localDirection;
  34485. private _volume;
  34486. private _isReadyToPlay;
  34487. private _isDirectional;
  34488. private _readyToPlayCallback;
  34489. private _audioBuffer;
  34490. private _soundSource;
  34491. private _streamingSource;
  34492. private _soundPanner;
  34493. private _soundGain;
  34494. private _inputAudioNode;
  34495. private _outputAudioNode;
  34496. private _coneInnerAngle;
  34497. private _coneOuterAngle;
  34498. private _coneOuterGain;
  34499. private _scene;
  34500. private _connectedTransformNode;
  34501. private _customAttenuationFunction;
  34502. private _registerFunc;
  34503. private _isOutputConnected;
  34504. private _htmlAudioElement;
  34505. private _urlType;
  34506. private _length?;
  34507. private _offset?;
  34508. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  34509. /**
  34510. * Create a sound and attach it to a scene
  34511. * @param name Name of your sound
  34512. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34513. * @param scene defines the scene the sound belongs to
  34514. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34515. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34516. */
  34517. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34518. /**
  34519. * Release the sound and its associated resources
  34520. */
  34521. dispose(): void;
  34522. /**
  34523. * Gets if the sounds is ready to be played or not.
  34524. * @returns true if ready, otherwise false
  34525. */
  34526. isReady(): boolean;
  34527. private _soundLoaded;
  34528. /**
  34529. * Sets the data of the sound from an audiobuffer
  34530. * @param audioBuffer The audioBuffer containing the data
  34531. */
  34532. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34533. /**
  34534. * Updates the current sounds options such as maxdistance, loop...
  34535. * @param options A JSON object containing values named as the object properties
  34536. */
  34537. updateOptions(options: ISoundOptions): void;
  34538. private _createSpatialParameters;
  34539. private _updateSpatialParameters;
  34540. /**
  34541. * Switch the panning model to HRTF:
  34542. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34543. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34544. */
  34545. switchPanningModelToHRTF(): void;
  34546. /**
  34547. * Switch the panning model to Equal Power:
  34548. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34549. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34550. */
  34551. switchPanningModelToEqualPower(): void;
  34552. private _switchPanningModel;
  34553. /**
  34554. * Connect this sound to a sound track audio node like gain...
  34555. * @param soundTrackAudioNode the sound track audio node to connect to
  34556. */
  34557. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34558. /**
  34559. * Transform this sound into a directional source
  34560. * @param coneInnerAngle Size of the inner cone in degree
  34561. * @param coneOuterAngle Size of the outer cone in degree
  34562. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34563. */
  34564. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34565. /**
  34566. * Gets or sets the inner angle for the directional cone.
  34567. */
  34568. /**
  34569. * Gets or sets the inner angle for the directional cone.
  34570. */
  34571. directionalConeInnerAngle: number;
  34572. /**
  34573. * Gets or sets the outer angle for the directional cone.
  34574. */
  34575. /**
  34576. * Gets or sets the outer angle for the directional cone.
  34577. */
  34578. directionalConeOuterAngle: number;
  34579. /**
  34580. * Sets the position of the emitter if spatial sound is enabled
  34581. * @param newPosition Defines the new posisiton
  34582. */
  34583. setPosition(newPosition: Vector3): void;
  34584. /**
  34585. * Sets the local direction of the emitter if spatial sound is enabled
  34586. * @param newLocalDirection Defines the new local direction
  34587. */
  34588. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34589. private _updateDirection;
  34590. /** @hidden */
  34591. updateDistanceFromListener(): void;
  34592. /**
  34593. * Sets a new custom attenuation function for the sound.
  34594. * @param callback Defines the function used for the attenuation
  34595. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34596. */
  34597. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34598. /**
  34599. * Play the sound
  34600. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34601. * @param offset (optional) Start the sound at a specific time in seconds
  34602. * @param length (optional) Sound duration (in seconds)
  34603. */
  34604. play(time?: number, offset?: number, length?: number): void;
  34605. private _onended;
  34606. /**
  34607. * Stop the sound
  34608. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34609. */
  34610. stop(time?: number): void;
  34611. /**
  34612. * Put the sound in pause
  34613. */
  34614. pause(): void;
  34615. /**
  34616. * Sets a dedicated volume for this sounds
  34617. * @param newVolume Define the new volume of the sound
  34618. * @param time Define time for gradual change to new volume
  34619. */
  34620. setVolume(newVolume: number, time?: number): void;
  34621. /**
  34622. * Set the sound play back rate
  34623. * @param newPlaybackRate Define the playback rate the sound should be played at
  34624. */
  34625. setPlaybackRate(newPlaybackRate: number): void;
  34626. /**
  34627. * Gets the volume of the sound.
  34628. * @returns the volume of the sound
  34629. */
  34630. getVolume(): number;
  34631. /**
  34632. * Attach the sound to a dedicated mesh
  34633. * @param transformNode The transform node to connect the sound with
  34634. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34635. */
  34636. attachToMesh(transformNode: TransformNode): void;
  34637. /**
  34638. * Detach the sound from the previously attached mesh
  34639. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34640. */
  34641. detachFromMesh(): void;
  34642. private _onRegisterAfterWorldMatrixUpdate;
  34643. /**
  34644. * Clone the current sound in the scene.
  34645. * @returns the new sound clone
  34646. */
  34647. clone(): Nullable<Sound>;
  34648. /**
  34649. * Gets the current underlying audio buffer containing the data
  34650. * @returns the audio buffer
  34651. */
  34652. getAudioBuffer(): Nullable<AudioBuffer>;
  34653. /**
  34654. * Serializes the Sound in a JSON representation
  34655. * @returns the JSON representation of the sound
  34656. */
  34657. serialize(): any;
  34658. /**
  34659. * Parse a JSON representation of a sound to innstantiate in a given scene
  34660. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34661. * @param scene Define the scene the new parsed sound should be created in
  34662. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34663. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34664. * @returns the newly parsed sound
  34665. */
  34666. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34667. }
  34668. }
  34669. declare module BABYLON {
  34670. /**
  34671. * This defines an action helpful to play a defined sound on a triggered action.
  34672. */
  34673. export class PlaySoundAction extends Action {
  34674. private _sound;
  34675. /**
  34676. * Instantiate the action
  34677. * @param triggerOptions defines the trigger options
  34678. * @param sound defines the sound to play
  34679. * @param condition defines the trigger related conditions
  34680. */
  34681. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34682. /** @hidden */ private _prepare(): void;
  34683. /**
  34684. * Execute the action and play the sound.
  34685. */
  34686. execute(): void;
  34687. /**
  34688. * Serializes the actions and its related information.
  34689. * @param parent defines the object to serialize in
  34690. * @returns the serialized object
  34691. */
  34692. serialize(parent: any): any;
  34693. }
  34694. /**
  34695. * This defines an action helpful to stop a defined sound on a triggered action.
  34696. */
  34697. export class StopSoundAction extends Action {
  34698. private _sound;
  34699. /**
  34700. * Instantiate the action
  34701. * @param triggerOptions defines the trigger options
  34702. * @param sound defines the sound to stop
  34703. * @param condition defines the trigger related conditions
  34704. */
  34705. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34706. /** @hidden */ private _prepare(): void;
  34707. /**
  34708. * Execute the action and stop the sound.
  34709. */
  34710. execute(): void;
  34711. /**
  34712. * Serializes the actions and its related information.
  34713. * @param parent defines the object to serialize in
  34714. * @returns the serialized object
  34715. */
  34716. serialize(parent: any): any;
  34717. }
  34718. }
  34719. declare module BABYLON {
  34720. /**
  34721. * This defines an action responsible to change the value of a property
  34722. * by interpolating between its current value and the newly set one once triggered.
  34723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34724. */
  34725. export class InterpolateValueAction extends Action {
  34726. /**
  34727. * Defines the path of the property where the value should be interpolated
  34728. */
  34729. propertyPath: string;
  34730. /**
  34731. * Defines the target value at the end of the interpolation.
  34732. */
  34733. value: any;
  34734. /**
  34735. * Defines the time it will take for the property to interpolate to the value.
  34736. */
  34737. duration: number;
  34738. /**
  34739. * Defines if the other scene animations should be stopped when the action has been triggered
  34740. */
  34741. stopOtherAnimations?: boolean;
  34742. /**
  34743. * Defines a callback raised once the interpolation animation has been done.
  34744. */
  34745. onInterpolationDone?: () => void;
  34746. /**
  34747. * Observable triggered once the interpolation animation has been done.
  34748. */
  34749. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34750. private _target;
  34751. private _effectiveTarget;
  34752. private _property;
  34753. /**
  34754. * Instantiate the action
  34755. * @param triggerOptions defines the trigger options
  34756. * @param target defines the object containing the value to interpolate
  34757. * @param propertyPath defines the path to the property in the target object
  34758. * @param value defines the target value at the end of the interpolation
  34759. * @param duration deines the time it will take for the property to interpolate to the value.
  34760. * @param condition defines the trigger related conditions
  34761. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34762. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34763. */
  34764. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34765. /** @hidden */ private _prepare(): void;
  34766. /**
  34767. * Execute the action starts the value interpolation.
  34768. */
  34769. execute(): void;
  34770. /**
  34771. * Serializes the actions and its related information.
  34772. * @param parent defines the object to serialize in
  34773. * @returns the serialized object
  34774. */
  34775. serialize(parent: any): any;
  34776. }
  34777. }
  34778. declare module BABYLON {
  34779. /**
  34780. * Options allowed during the creation of a sound track.
  34781. */
  34782. export interface ISoundTrackOptions {
  34783. /**
  34784. * The volume the sound track should take during creation
  34785. */
  34786. volume?: number;
  34787. /**
  34788. * Define if the sound track is the main sound track of the scene
  34789. */
  34790. mainTrack?: boolean;
  34791. }
  34792. /**
  34793. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34794. * It will be also used in a future release to apply effects on a specific track.
  34795. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34796. */
  34797. export class SoundTrack {
  34798. /**
  34799. * The unique identifier of the sound track in the scene.
  34800. */
  34801. id: number;
  34802. /**
  34803. * The list of sounds included in the sound track.
  34804. */
  34805. soundCollection: Array<Sound>;
  34806. private _outputAudioNode;
  34807. private _scene;
  34808. private _isMainTrack;
  34809. private _connectedAnalyser;
  34810. private _options;
  34811. private _isInitialized;
  34812. /**
  34813. * Creates a new sound track.
  34814. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34815. * @param scene Define the scene the sound track belongs to
  34816. * @param options
  34817. */
  34818. constructor(scene: Scene, options?: ISoundTrackOptions);
  34819. private _initializeSoundTrackAudioGraph;
  34820. /**
  34821. * Release the sound track and its associated resources
  34822. */
  34823. dispose(): void;
  34824. /**
  34825. * Adds a sound to this sound track
  34826. * @param sound define the cound to add
  34827. * @ignoreNaming
  34828. */
  34829. AddSound(sound: Sound): void;
  34830. /**
  34831. * Removes a sound to this sound track
  34832. * @param sound define the cound to remove
  34833. * @ignoreNaming
  34834. */
  34835. RemoveSound(sound: Sound): void;
  34836. /**
  34837. * Set a global volume for the full sound track.
  34838. * @param newVolume Define the new volume of the sound track
  34839. */
  34840. setVolume(newVolume: number): void;
  34841. /**
  34842. * Switch the panning model to HRTF:
  34843. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34844. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34845. */
  34846. switchPanningModelToHRTF(): void;
  34847. /**
  34848. * Switch the panning model to Equal Power:
  34849. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34850. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34851. */
  34852. switchPanningModelToEqualPower(): void;
  34853. /**
  34854. * Connect the sound track to an audio analyser allowing some amazing
  34855. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34857. * @param analyser The analyser to connect to the engine
  34858. */
  34859. connectToAnalyser(analyser: Analyser): void;
  34860. }
  34861. }
  34862. declare module BABYLON {
  34863. interface AbstractScene {
  34864. /**
  34865. * The list of sounds used in the scene.
  34866. */
  34867. sounds: Nullable<Array<Sound>>;
  34868. }
  34869. interface Scene {
  34870. /**
  34871. * @hidden
  34872. * Backing field
  34873. */ private _mainSoundTrack: SoundTrack;
  34874. /**
  34875. * The main sound track played by the scene.
  34876. * It cotains your primary collection of sounds.
  34877. */
  34878. mainSoundTrack: SoundTrack;
  34879. /**
  34880. * The list of sound tracks added to the scene
  34881. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34882. */
  34883. soundTracks: Nullable<Array<SoundTrack>>;
  34884. /**
  34885. * Gets a sound using a given name
  34886. * @param name defines the name to search for
  34887. * @return the found sound or null if not found at all.
  34888. */
  34889. getSoundByName(name: string): Nullable<Sound>;
  34890. /**
  34891. * Gets or sets if audio support is enabled
  34892. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34893. */
  34894. audioEnabled: boolean;
  34895. /**
  34896. * Gets or sets if audio will be output to headphones
  34897. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34898. */
  34899. headphone: boolean;
  34900. /**
  34901. * Gets or sets custom audio listener position provider
  34902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34903. */
  34904. audioListenerPositionProvider: Nullable<() => Vector3>;
  34905. }
  34906. /**
  34907. * Defines the sound scene component responsible to manage any sounds
  34908. * in a given scene.
  34909. */
  34910. export class AudioSceneComponent implements ISceneSerializableComponent {
  34911. /**
  34912. * The component name helpfull to identify the component in the list of scene components.
  34913. */
  34914. readonly name: string;
  34915. /**
  34916. * The scene the component belongs to.
  34917. */
  34918. scene: Scene;
  34919. private _audioEnabled;
  34920. /**
  34921. * Gets whether audio is enabled or not.
  34922. * Please use related enable/disable method to switch state.
  34923. */
  34924. readonly audioEnabled: boolean;
  34925. private _headphone;
  34926. /**
  34927. * Gets whether audio is outputing to headphone or not.
  34928. * Please use the according Switch methods to change output.
  34929. */
  34930. readonly headphone: boolean;
  34931. private _audioListenerPositionProvider;
  34932. /**
  34933. * Gets the current audio listener position provider
  34934. */
  34935. /**
  34936. * Sets a custom listener position for all sounds in the scene
  34937. * By default, this is the position of the first active camera
  34938. */
  34939. audioListenerPositionProvider: Nullable<() => Vector3>;
  34940. /**
  34941. * Creates a new instance of the component for the given scene
  34942. * @param scene Defines the scene to register the component in
  34943. */
  34944. constructor(scene: Scene);
  34945. /**
  34946. * Registers the component in a given scene
  34947. */
  34948. register(): void;
  34949. /**
  34950. * Rebuilds the elements related to this component in case of
  34951. * context lost for instance.
  34952. */
  34953. rebuild(): void;
  34954. /**
  34955. * Serializes the component data to the specified json object
  34956. * @param serializationObject The object to serialize to
  34957. */
  34958. serialize(serializationObject: any): void;
  34959. /**
  34960. * Adds all the elements from the container to the scene
  34961. * @param container the container holding the elements
  34962. */
  34963. addFromContainer(container: AbstractScene): void;
  34964. /**
  34965. * Removes all the elements in the container from the scene
  34966. * @param container contains the elements to remove
  34967. * @param dispose if the removed element should be disposed (default: false)
  34968. */
  34969. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34970. /**
  34971. * Disposes the component and the associated ressources.
  34972. */
  34973. dispose(): void;
  34974. /**
  34975. * Disables audio in the associated scene.
  34976. */
  34977. disableAudio(): void;
  34978. /**
  34979. * Enables audio in the associated scene.
  34980. */
  34981. enableAudio(): void;
  34982. /**
  34983. * Switch audio to headphone output.
  34984. */
  34985. switchAudioModeForHeadphones(): void;
  34986. /**
  34987. * Switch audio to normal speakers.
  34988. */
  34989. switchAudioModeForNormalSpeakers(): void;
  34990. private _afterRender;
  34991. }
  34992. }
  34993. declare module BABYLON {
  34994. /**
  34995. * Wraps one or more Sound objects and selects one with random weight for playback.
  34996. */
  34997. export class WeightedSound {
  34998. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34999. loop: boolean;
  35000. private _coneInnerAngle;
  35001. private _coneOuterAngle;
  35002. private _volume;
  35003. /** A Sound is currently playing. */
  35004. isPlaying: boolean;
  35005. /** A Sound is currently paused. */
  35006. isPaused: boolean;
  35007. private _sounds;
  35008. private _weights;
  35009. private _currentIndex?;
  35010. /**
  35011. * Creates a new WeightedSound from the list of sounds given.
  35012. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35013. * @param sounds Array of Sounds that will be selected from.
  35014. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35015. */
  35016. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35017. /**
  35018. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35019. */
  35020. /**
  35021. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35022. */
  35023. directionalConeInnerAngle: number;
  35024. /**
  35025. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35026. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35027. */
  35028. /**
  35029. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35030. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35031. */
  35032. directionalConeOuterAngle: number;
  35033. /**
  35034. * Playback volume.
  35035. */
  35036. /**
  35037. * Playback volume.
  35038. */
  35039. volume: number;
  35040. private _onended;
  35041. /**
  35042. * Suspend playback
  35043. */
  35044. pause(): void;
  35045. /**
  35046. * Stop playback
  35047. */
  35048. stop(): void;
  35049. /**
  35050. * Start playback.
  35051. * @param startOffset Position the clip head at a specific time in seconds.
  35052. */
  35053. play(startOffset?: number): void;
  35054. }
  35055. }
  35056. declare module BABYLON {
  35057. /**
  35058. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35059. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35060. */
  35061. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35062. /**
  35063. * Gets the name of the behavior.
  35064. */
  35065. readonly name: string;
  35066. /**
  35067. * The easing function used by animations
  35068. */
  35069. static EasingFunction: BackEase;
  35070. /**
  35071. * The easing mode used by animations
  35072. */
  35073. static EasingMode: number;
  35074. /**
  35075. * The duration of the animation, in milliseconds
  35076. */
  35077. transitionDuration: number;
  35078. /**
  35079. * Length of the distance animated by the transition when lower radius is reached
  35080. */
  35081. lowerRadiusTransitionRange: number;
  35082. /**
  35083. * Length of the distance animated by the transition when upper radius is reached
  35084. */
  35085. upperRadiusTransitionRange: number;
  35086. private _autoTransitionRange;
  35087. /**
  35088. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35089. */
  35090. /**
  35091. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35092. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35093. */
  35094. autoTransitionRange: boolean;
  35095. private _attachedCamera;
  35096. private _onAfterCheckInputsObserver;
  35097. private _onMeshTargetChangedObserver;
  35098. /**
  35099. * Initializes the behavior.
  35100. */
  35101. init(): void;
  35102. /**
  35103. * Attaches the behavior to its arc rotate camera.
  35104. * @param camera Defines the camera to attach the behavior to
  35105. */
  35106. attach(camera: ArcRotateCamera): void;
  35107. /**
  35108. * Detaches the behavior from its current arc rotate camera.
  35109. */
  35110. detach(): void;
  35111. private _radiusIsAnimating;
  35112. private _radiusBounceTransition;
  35113. private _animatables;
  35114. private _cachedWheelPrecision;
  35115. /**
  35116. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35117. * @param radiusLimit The limit to check against.
  35118. * @return Bool to indicate if at limit.
  35119. */
  35120. private _isRadiusAtLimit;
  35121. /**
  35122. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35123. * @param radiusDelta The delta by which to animate to. Can be negative.
  35124. */
  35125. private _applyBoundRadiusAnimation;
  35126. /**
  35127. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35128. */
  35129. protected _clearAnimationLocks(): void;
  35130. /**
  35131. * Stops and removes all animations that have been applied to the camera
  35132. */
  35133. stopAllAnimations(): void;
  35134. }
  35135. }
  35136. declare module BABYLON {
  35137. /**
  35138. * 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.
  35139. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35140. */
  35141. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35142. /**
  35143. * Gets the name of the behavior.
  35144. */
  35145. readonly name: string;
  35146. private _mode;
  35147. private _radiusScale;
  35148. private _positionScale;
  35149. private _defaultElevation;
  35150. private _elevationReturnTime;
  35151. private _elevationReturnWaitTime;
  35152. private _zoomStopsAnimation;
  35153. private _framingTime;
  35154. /**
  35155. * The easing function used by animations
  35156. */
  35157. static EasingFunction: ExponentialEase;
  35158. /**
  35159. * The easing mode used by animations
  35160. */
  35161. static EasingMode: number;
  35162. /**
  35163. * Sets the current mode used by the behavior
  35164. */
  35165. /**
  35166. * Gets current mode used by the behavior.
  35167. */
  35168. mode: number;
  35169. /**
  35170. * Sets the scale applied to the radius (1 by default)
  35171. */
  35172. /**
  35173. * Gets the scale applied to the radius
  35174. */
  35175. radiusScale: number;
  35176. /**
  35177. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35178. */
  35179. /**
  35180. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35181. */
  35182. positionScale: number;
  35183. /**
  35184. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35185. * behaviour is triggered, in radians.
  35186. */
  35187. /**
  35188. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35189. * behaviour is triggered, in radians.
  35190. */
  35191. defaultElevation: number;
  35192. /**
  35193. * Sets the time (in milliseconds) taken to return to the default beta position.
  35194. * Negative value indicates camera should not return to default.
  35195. */
  35196. /**
  35197. * Gets the time (in milliseconds) taken to return to the default beta position.
  35198. * Negative value indicates camera should not return to default.
  35199. */
  35200. elevationReturnTime: number;
  35201. /**
  35202. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35203. */
  35204. /**
  35205. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35206. */
  35207. elevationReturnWaitTime: number;
  35208. /**
  35209. * Sets the flag that indicates if user zooming should stop animation.
  35210. */
  35211. /**
  35212. * Gets the flag that indicates if user zooming should stop animation.
  35213. */
  35214. zoomStopsAnimation: boolean;
  35215. /**
  35216. * Sets the transition time when framing the mesh, in milliseconds
  35217. */
  35218. /**
  35219. * Gets the transition time when framing the mesh, in milliseconds
  35220. */
  35221. framingTime: number;
  35222. /**
  35223. * Define if the behavior should automatically change the configured
  35224. * camera limits and sensibilities.
  35225. */
  35226. autoCorrectCameraLimitsAndSensibility: boolean;
  35227. private _onPrePointerObservableObserver;
  35228. private _onAfterCheckInputsObserver;
  35229. private _onMeshTargetChangedObserver;
  35230. private _attachedCamera;
  35231. private _isPointerDown;
  35232. private _lastInteractionTime;
  35233. /**
  35234. * Initializes the behavior.
  35235. */
  35236. init(): void;
  35237. /**
  35238. * Attaches the behavior to its arc rotate camera.
  35239. * @param camera Defines the camera to attach the behavior to
  35240. */
  35241. attach(camera: ArcRotateCamera): void;
  35242. /**
  35243. * Detaches the behavior from its current arc rotate camera.
  35244. */
  35245. detach(): void;
  35246. private _animatables;
  35247. private _betaIsAnimating;
  35248. private _betaTransition;
  35249. private _radiusTransition;
  35250. private _vectorTransition;
  35251. /**
  35252. * Targets the given mesh and updates zoom level accordingly.
  35253. * @param mesh The mesh to target.
  35254. * @param radius Optional. If a cached radius position already exists, overrides default.
  35255. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35256. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35257. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35258. */
  35259. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35260. /**
  35261. * Targets the given mesh with its children and updates zoom level accordingly.
  35262. * @param mesh The mesh to target.
  35263. * @param radius Optional. If a cached radius position already exists, overrides default.
  35264. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35265. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35266. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35267. */
  35268. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35269. /**
  35270. * Targets the given meshes with their children and updates zoom level accordingly.
  35271. * @param meshes The mesh to target.
  35272. * @param radius Optional. If a cached radius position already exists, overrides default.
  35273. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35274. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35275. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35276. */
  35277. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35278. /**
  35279. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35280. * @param minimumWorld Determines the smaller position of the bounding box extend
  35281. * @param maximumWorld Determines the bigger position of the bounding box extend
  35282. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35283. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35284. */
  35285. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35286. /**
  35287. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35288. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35289. * frustum width.
  35290. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35291. * to fully enclose the mesh in the viewing frustum.
  35292. */
  35293. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35294. /**
  35295. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35296. * is automatically returned to its default position (expected to be above ground plane).
  35297. */
  35298. private _maintainCameraAboveGround;
  35299. /**
  35300. * Returns the frustum slope based on the canvas ratio and camera FOV
  35301. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35302. */
  35303. private _getFrustumSlope;
  35304. /**
  35305. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35306. */
  35307. private _clearAnimationLocks;
  35308. /**
  35309. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35310. */
  35311. private _applyUserInteraction;
  35312. /**
  35313. * Stops and removes all animations that have been applied to the camera
  35314. */
  35315. stopAllAnimations(): void;
  35316. /**
  35317. * Gets a value indicating if the user is moving the camera
  35318. */
  35319. readonly isUserIsMoving: boolean;
  35320. /**
  35321. * The camera can move all the way towards the mesh.
  35322. */
  35323. static IgnoreBoundsSizeMode: number;
  35324. /**
  35325. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35326. */
  35327. static FitFrustumSidesMode: number;
  35328. }
  35329. }
  35330. declare module BABYLON {
  35331. /**
  35332. * Base class for Camera Pointer Inputs.
  35333. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35334. * for example usage.
  35335. */
  35336. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35337. /**
  35338. * Defines the camera the input is attached to.
  35339. */
  35340. abstract camera: Camera;
  35341. /**
  35342. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35343. */
  35344. protected _altKey: boolean;
  35345. protected _ctrlKey: boolean;
  35346. protected _metaKey: boolean;
  35347. protected _shiftKey: boolean;
  35348. /**
  35349. * Which mouse buttons were pressed at time of last mouse event.
  35350. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35351. */
  35352. protected _buttonsPressed: number;
  35353. /**
  35354. * Defines the buttons associated with the input to handle camera move.
  35355. */
  35356. buttons: number[];
  35357. /**
  35358. * Attach the input controls to a specific dom element to get the input from.
  35359. * @param element Defines the element the controls should be listened from
  35360. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35361. */
  35362. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35363. /**
  35364. * Detach the current controls from the specified dom element.
  35365. * @param element Defines the element to stop listening the inputs from
  35366. */
  35367. detachControl(element: Nullable<HTMLElement>): void;
  35368. /**
  35369. * Gets the class name of the current input.
  35370. * @returns the class name
  35371. */
  35372. getClassName(): string;
  35373. /**
  35374. * Get the friendly name associated with the input class.
  35375. * @returns the input friendly name
  35376. */
  35377. getSimpleName(): string;
  35378. /**
  35379. * Called on pointer POINTERDOUBLETAP event.
  35380. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35381. */
  35382. protected onDoubleTap(type: string): void;
  35383. /**
  35384. * Called on pointer POINTERMOVE event if only a single touch is active.
  35385. * Override this method to provide functionality.
  35386. */
  35387. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35388. /**
  35389. * Called on pointer POINTERMOVE event if multiple touches are active.
  35390. * Override this method to provide functionality.
  35391. */
  35392. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35393. /**
  35394. * Called on JS contextmenu event.
  35395. * Override this method to provide functionality.
  35396. */
  35397. protected onContextMenu(evt: PointerEvent): void;
  35398. /**
  35399. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35400. * press.
  35401. * Override this method to provide functionality.
  35402. */
  35403. protected onButtonDown(evt: PointerEvent): void;
  35404. /**
  35405. * Called each time a new POINTERUP event occurs. Ie, for each button
  35406. * release.
  35407. * Override this method to provide functionality.
  35408. */
  35409. protected onButtonUp(evt: PointerEvent): void;
  35410. /**
  35411. * Called when window becomes inactive.
  35412. * Override this method to provide functionality.
  35413. */
  35414. protected onLostFocus(): void;
  35415. private _pointerInput;
  35416. private _observer;
  35417. private _onLostFocus;
  35418. private pointA;
  35419. private pointB;
  35420. }
  35421. }
  35422. declare module BABYLON {
  35423. /**
  35424. * Manage the pointers inputs to control an arc rotate camera.
  35425. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35426. */
  35427. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35428. /**
  35429. * Defines the camera the input is attached to.
  35430. */
  35431. camera: ArcRotateCamera;
  35432. /**
  35433. * Gets the class name of the current input.
  35434. * @returns the class name
  35435. */
  35436. getClassName(): string;
  35437. /**
  35438. * Defines the buttons associated with the input to handle camera move.
  35439. */
  35440. buttons: number[];
  35441. /**
  35442. * Defines the pointer angular sensibility along the X axis or how fast is
  35443. * the camera rotating.
  35444. */
  35445. angularSensibilityX: number;
  35446. /**
  35447. * Defines the pointer angular sensibility along the Y axis or how fast is
  35448. * the camera rotating.
  35449. */
  35450. angularSensibilityY: number;
  35451. /**
  35452. * Defines the pointer pinch precision or how fast is the camera zooming.
  35453. */
  35454. pinchPrecision: number;
  35455. /**
  35456. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35457. * from 0.
  35458. * It defines the percentage of current camera.radius to use as delta when
  35459. * pinch zoom is used.
  35460. */
  35461. pinchDeltaPercentage: number;
  35462. /**
  35463. * Defines the pointer panning sensibility or how fast is the camera moving.
  35464. */
  35465. panningSensibility: number;
  35466. /**
  35467. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35468. */
  35469. multiTouchPanning: boolean;
  35470. /**
  35471. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35472. * zoom (pinch) through multitouch.
  35473. */
  35474. multiTouchPanAndZoom: boolean;
  35475. /**
  35476. * Revers pinch action direction.
  35477. */
  35478. pinchInwards: boolean;
  35479. private _isPanClick;
  35480. private _twoFingerActivityCount;
  35481. private _isPinching;
  35482. /**
  35483. * Called on pointer POINTERMOVE event if only a single touch is active.
  35484. */
  35485. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35486. /**
  35487. * Called on pointer POINTERDOUBLETAP event.
  35488. */
  35489. protected onDoubleTap(type: string): void;
  35490. /**
  35491. * Called on pointer POINTERMOVE event if multiple touches are active.
  35492. */
  35493. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35494. /**
  35495. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35496. * press.
  35497. */
  35498. protected onButtonDown(evt: PointerEvent): void;
  35499. /**
  35500. * Called each time a new POINTERUP event occurs. Ie, for each button
  35501. * release.
  35502. */
  35503. protected onButtonUp(evt: PointerEvent): void;
  35504. /**
  35505. * Called when window becomes inactive.
  35506. */
  35507. protected onLostFocus(): void;
  35508. }
  35509. }
  35510. declare module BABYLON {
  35511. /**
  35512. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35513. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35514. */
  35515. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35516. /**
  35517. * Defines the camera the input is attached to.
  35518. */
  35519. camera: ArcRotateCamera;
  35520. /**
  35521. * Defines the list of key codes associated with the up action (increase alpha)
  35522. */
  35523. keysUp: number[];
  35524. /**
  35525. * Defines the list of key codes associated with the down action (decrease alpha)
  35526. */
  35527. keysDown: number[];
  35528. /**
  35529. * Defines the list of key codes associated with the left action (increase beta)
  35530. */
  35531. keysLeft: number[];
  35532. /**
  35533. * Defines the list of key codes associated with the right action (decrease beta)
  35534. */
  35535. keysRight: number[];
  35536. /**
  35537. * Defines the list of key codes associated with the reset action.
  35538. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35539. */
  35540. keysReset: number[];
  35541. /**
  35542. * Defines the panning sensibility of the inputs.
  35543. * (How fast is the camera paning)
  35544. */
  35545. panningSensibility: number;
  35546. /**
  35547. * Defines the zooming sensibility of the inputs.
  35548. * (How fast is the camera zooming)
  35549. */
  35550. zoomingSensibility: number;
  35551. /**
  35552. * Defines wether maintaining the alt key down switch the movement mode from
  35553. * orientation to zoom.
  35554. */
  35555. useAltToZoom: boolean;
  35556. /**
  35557. * Rotation speed of the camera
  35558. */
  35559. angularSpeed: number;
  35560. private _keys;
  35561. private _ctrlPressed;
  35562. private _altPressed;
  35563. private _onCanvasBlurObserver;
  35564. private _onKeyboardObserver;
  35565. private _engine;
  35566. private _scene;
  35567. /**
  35568. * Attach the input controls to a specific dom element to get the input from.
  35569. * @param element Defines the element the controls should be listened from
  35570. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35571. */
  35572. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35573. /**
  35574. * Detach the current controls from the specified dom element.
  35575. * @param element Defines the element to stop listening the inputs from
  35576. */
  35577. detachControl(element: Nullable<HTMLElement>): void;
  35578. /**
  35579. * Update the current camera state depending on the inputs that have been used this frame.
  35580. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35581. */
  35582. checkInputs(): void;
  35583. /**
  35584. * Gets the class name of the current intput.
  35585. * @returns the class name
  35586. */
  35587. getClassName(): string;
  35588. /**
  35589. * Get the friendly name associated with the input class.
  35590. * @returns the input friendly name
  35591. */
  35592. getSimpleName(): string;
  35593. }
  35594. }
  35595. declare module BABYLON {
  35596. /**
  35597. * Manage the mouse wheel inputs to control an arc rotate camera.
  35598. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35599. */
  35600. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35601. /**
  35602. * Defines the camera the input is attached to.
  35603. */
  35604. camera: ArcRotateCamera;
  35605. /**
  35606. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35607. */
  35608. wheelPrecision: number;
  35609. /**
  35610. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35611. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35612. */
  35613. wheelDeltaPercentage: number;
  35614. private _wheel;
  35615. private _observer;
  35616. private computeDeltaFromMouseWheelLegacyEvent;
  35617. /**
  35618. * Attach the input controls to a specific dom element to get the input from.
  35619. * @param element Defines the element the controls should be listened from
  35620. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35621. */
  35622. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35623. /**
  35624. * Detach the current controls from the specified dom element.
  35625. * @param element Defines the element to stop listening the inputs from
  35626. */
  35627. detachControl(element: Nullable<HTMLElement>): void;
  35628. /**
  35629. * Gets the class name of the current intput.
  35630. * @returns the class name
  35631. */
  35632. getClassName(): string;
  35633. /**
  35634. * Get the friendly name associated with the input class.
  35635. * @returns the input friendly name
  35636. */
  35637. getSimpleName(): string;
  35638. }
  35639. }
  35640. declare module BABYLON {
  35641. /**
  35642. * Default Inputs manager for the ArcRotateCamera.
  35643. * It groups all the default supported inputs for ease of use.
  35644. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35645. */
  35646. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35647. /**
  35648. * Instantiates a new ArcRotateCameraInputsManager.
  35649. * @param camera Defines the camera the inputs belong to
  35650. */
  35651. constructor(camera: ArcRotateCamera);
  35652. /**
  35653. * Add mouse wheel input support to the input manager.
  35654. * @returns the current input manager
  35655. */
  35656. addMouseWheel(): ArcRotateCameraInputsManager;
  35657. /**
  35658. * Add pointers input support to the input manager.
  35659. * @returns the current input manager
  35660. */
  35661. addPointers(): ArcRotateCameraInputsManager;
  35662. /**
  35663. * Add keyboard input support to the input manager.
  35664. * @returns the current input manager
  35665. */
  35666. addKeyboard(): ArcRotateCameraInputsManager;
  35667. }
  35668. }
  35669. declare module BABYLON {
  35670. /**
  35671. * This represents an orbital type of camera.
  35672. *
  35673. * 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.
  35674. * 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.
  35675. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35676. */
  35677. export class ArcRotateCamera extends TargetCamera {
  35678. /**
  35679. * Defines the rotation angle of the camera along the longitudinal axis.
  35680. */
  35681. alpha: number;
  35682. /**
  35683. * Defines the rotation angle of the camera along the latitudinal axis.
  35684. */
  35685. beta: number;
  35686. /**
  35687. * Defines the radius of the camera from it s target point.
  35688. */
  35689. radius: number;
  35690. protected _target: Vector3;
  35691. protected _targetHost: Nullable<AbstractMesh>;
  35692. /**
  35693. * Defines the target point of the camera.
  35694. * The camera looks towards it form the radius distance.
  35695. */
  35696. target: Vector3;
  35697. /**
  35698. * Define the current local position of the camera in the scene
  35699. */
  35700. position: Vector3;
  35701. protected _upVector: Vector3;
  35702. protected _upToYMatrix: Matrix;
  35703. protected _YToUpMatrix: Matrix;
  35704. /**
  35705. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35706. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35707. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35708. */
  35709. upVector: Vector3;
  35710. /**
  35711. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35712. */
  35713. setMatUp(): void;
  35714. /**
  35715. * Current inertia value on the longitudinal axis.
  35716. * The bigger this number the longer it will take for the camera to stop.
  35717. */
  35718. inertialAlphaOffset: number;
  35719. /**
  35720. * Current inertia value on the latitudinal axis.
  35721. * The bigger this number the longer it will take for the camera to stop.
  35722. */
  35723. inertialBetaOffset: number;
  35724. /**
  35725. * Current inertia value on the radius axis.
  35726. * The bigger this number the longer it will take for the camera to stop.
  35727. */
  35728. inertialRadiusOffset: number;
  35729. /**
  35730. * Minimum allowed angle on the longitudinal axis.
  35731. * This can help limiting how the Camera is able to move in the scene.
  35732. */
  35733. lowerAlphaLimit: Nullable<number>;
  35734. /**
  35735. * Maximum allowed angle on the longitudinal axis.
  35736. * This can help limiting how the Camera is able to move in the scene.
  35737. */
  35738. upperAlphaLimit: Nullable<number>;
  35739. /**
  35740. * Minimum allowed angle on the latitudinal axis.
  35741. * This can help limiting how the Camera is able to move in the scene.
  35742. */
  35743. lowerBetaLimit: number;
  35744. /**
  35745. * Maximum allowed angle on the latitudinal axis.
  35746. * This can help limiting how the Camera is able to move in the scene.
  35747. */
  35748. upperBetaLimit: number;
  35749. /**
  35750. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35751. * This can help limiting how the Camera is able to move in the scene.
  35752. */
  35753. lowerRadiusLimit: Nullable<number>;
  35754. /**
  35755. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35756. * This can help limiting how the Camera is able to move in the scene.
  35757. */
  35758. upperRadiusLimit: Nullable<number>;
  35759. /**
  35760. * Defines the current inertia value used during panning of the camera along the X axis.
  35761. */
  35762. inertialPanningX: number;
  35763. /**
  35764. * Defines the current inertia value used during panning of the camera along the Y axis.
  35765. */
  35766. inertialPanningY: number;
  35767. /**
  35768. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35769. * Basically if your fingers moves away from more than this distance you will be considered
  35770. * in pinch mode.
  35771. */
  35772. pinchToPanMaxDistance: number;
  35773. /**
  35774. * Defines the maximum distance the camera can pan.
  35775. * This could help keeping the cammera always in your scene.
  35776. */
  35777. panningDistanceLimit: Nullable<number>;
  35778. /**
  35779. * Defines the target of the camera before paning.
  35780. */
  35781. panningOriginTarget: Vector3;
  35782. /**
  35783. * Defines the value of the inertia used during panning.
  35784. * 0 would mean stop inertia and one would mean no decelleration at all.
  35785. */
  35786. panningInertia: number;
  35787. /**
  35788. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35789. */
  35790. angularSensibilityX: number;
  35791. /**
  35792. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35793. */
  35794. angularSensibilityY: number;
  35795. /**
  35796. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35797. */
  35798. pinchPrecision: number;
  35799. /**
  35800. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35801. * It will be used instead of pinchDeltaPrecision if different from 0.
  35802. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35803. */
  35804. pinchDeltaPercentage: number;
  35805. /**
  35806. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35807. */
  35808. panningSensibility: number;
  35809. /**
  35810. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35811. */
  35812. keysUp: number[];
  35813. /**
  35814. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35815. */
  35816. keysDown: number[];
  35817. /**
  35818. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35819. */
  35820. keysLeft: number[];
  35821. /**
  35822. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35823. */
  35824. keysRight: number[];
  35825. /**
  35826. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35827. */
  35828. wheelPrecision: number;
  35829. /**
  35830. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35831. * It will be used instead of pinchDeltaPrecision if different from 0.
  35832. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35833. */
  35834. wheelDeltaPercentage: number;
  35835. /**
  35836. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35837. */
  35838. zoomOnFactor: number;
  35839. /**
  35840. * Defines a screen offset for the camera position.
  35841. */
  35842. targetScreenOffset: Vector2;
  35843. /**
  35844. * Allows the camera to be completely reversed.
  35845. * If false the camera can not arrive upside down.
  35846. */
  35847. allowUpsideDown: boolean;
  35848. /**
  35849. * Define if double tap/click is used to restore the previously saved state of the camera.
  35850. */
  35851. useInputToRestoreState: boolean;
  35852. /** @hidden */ private _viewMatrix: Matrix;
  35853. /** @hidden */ private _useCtrlForPanning: boolean;
  35854. /** @hidden */ private _panningMouseButton: number;
  35855. /**
  35856. * Defines the input associated to the camera.
  35857. */
  35858. inputs: ArcRotateCameraInputsManager;
  35859. /** @hidden */ private _reset: () => void;
  35860. /**
  35861. * Defines the allowed panning axis.
  35862. */
  35863. panningAxis: Vector3;
  35864. protected _localDirection: Vector3;
  35865. protected _transformedDirection: Vector3;
  35866. private _bouncingBehavior;
  35867. /**
  35868. * Gets the bouncing behavior of the camera if it has been enabled.
  35869. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35870. */
  35871. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35872. /**
  35873. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35874. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35875. */
  35876. useBouncingBehavior: boolean;
  35877. private _framingBehavior;
  35878. /**
  35879. * Gets the framing behavior of the camera if it has been enabled.
  35880. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35881. */
  35882. readonly framingBehavior: Nullable<FramingBehavior>;
  35883. /**
  35884. * Defines if the framing behavior of the camera is enabled on the camera.
  35885. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35886. */
  35887. useFramingBehavior: boolean;
  35888. private _autoRotationBehavior;
  35889. /**
  35890. * Gets the auto rotation behavior of the camera if it has been enabled.
  35891. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35892. */
  35893. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35894. /**
  35895. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35896. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35897. */
  35898. useAutoRotationBehavior: boolean;
  35899. /**
  35900. * Observable triggered when the mesh target has been changed on the camera.
  35901. */
  35902. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35903. /**
  35904. * Event raised when the camera is colliding with a mesh.
  35905. */
  35906. onCollide: (collidedMesh: AbstractMesh) => void;
  35907. /**
  35908. * Defines whether the camera should check collision with the objects oh the scene.
  35909. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35910. */
  35911. checkCollisions: boolean;
  35912. /**
  35913. * Defines the collision radius of the camera.
  35914. * This simulates a sphere around the camera.
  35915. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35916. */
  35917. collisionRadius: Vector3;
  35918. protected _collider: Collider;
  35919. protected _previousPosition: Vector3;
  35920. protected _collisionVelocity: Vector3;
  35921. protected _newPosition: Vector3;
  35922. protected _previousAlpha: number;
  35923. protected _previousBeta: number;
  35924. protected _previousRadius: number;
  35925. protected _collisionTriggered: boolean;
  35926. protected _targetBoundingCenter: Nullable<Vector3>;
  35927. private _computationVector;
  35928. /**
  35929. * Instantiates a new ArcRotateCamera in a given scene
  35930. * @param name Defines the name of the camera
  35931. * @param alpha Defines the camera rotation along the logitudinal axis
  35932. * @param beta Defines the camera rotation along the latitudinal axis
  35933. * @param radius Defines the camera distance from its target
  35934. * @param target Defines the camera target
  35935. * @param scene Defines the scene the camera belongs to
  35936. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35937. */
  35938. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35939. /** @hidden */ private _initCache(): void;
  35940. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  35941. protected _getTargetPosition(): Vector3;
  35942. private _storedAlpha;
  35943. private _storedBeta;
  35944. private _storedRadius;
  35945. private _storedTarget;
  35946. private _storedTargetScreenOffset;
  35947. /**
  35948. * Stores the current state of the camera (alpha, beta, radius and target)
  35949. * @returns the camera itself
  35950. */
  35951. storeState(): Camera;
  35952. /**
  35953. * @hidden
  35954. * Restored camera state. You must call storeState() first
  35955. */ private _restoreStateValues(): boolean;
  35956. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  35957. /**
  35958. * Attached controls to the current camera.
  35959. * @param element Defines the element the controls should be listened from
  35960. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35961. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35962. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35963. */
  35964. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35965. /**
  35966. * Detach the current controls from the camera.
  35967. * The camera will stop reacting to inputs.
  35968. * @param element Defines the element to stop listening the inputs from
  35969. */
  35970. detachControl(element: HTMLElement): void;
  35971. /** @hidden */ private _checkInputs(): void;
  35972. protected _checkLimits(): void;
  35973. /**
  35974. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35975. */
  35976. rebuildAnglesAndRadius(): void;
  35977. /**
  35978. * Use a position to define the current camera related information like alpha, beta and radius
  35979. * @param position Defines the position to set the camera at
  35980. */
  35981. setPosition(position: Vector3): void;
  35982. /**
  35983. * Defines the target the camera should look at.
  35984. * This will automatically adapt alpha beta and radius to fit within the new target.
  35985. * @param target Defines the new target as a Vector or a mesh
  35986. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35987. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35988. */
  35989. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35990. /** @hidden */ private _getViewMatrix(): Matrix;
  35991. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35992. /**
  35993. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35994. * @param meshes Defines the mesh to zoom on
  35995. * @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)
  35996. */
  35997. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35998. /**
  35999. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36000. * The target will be changed but the radius
  36001. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36002. * @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)
  36003. */
  36004. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36005. min: Vector3;
  36006. max: Vector3;
  36007. distance: number;
  36008. }, doNotUpdateMaxZ?: boolean): void;
  36009. /**
  36010. * @override
  36011. * Override Camera.createRigCamera
  36012. */
  36013. createRigCamera(name: string, cameraIndex: number): Camera;
  36014. /**
  36015. * @hidden
  36016. * @override
  36017. * Override Camera._updateRigCameras
  36018. */ private _updateRigCameras(): void;
  36019. /**
  36020. * Destroy the camera and release the current resources hold by it.
  36021. */
  36022. dispose(): void;
  36023. /**
  36024. * Gets the current object class name.
  36025. * @return the class name
  36026. */
  36027. getClassName(): string;
  36028. }
  36029. }
  36030. declare module BABYLON {
  36031. /**
  36032. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36033. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36034. */
  36035. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36036. /**
  36037. * Gets the name of the behavior.
  36038. */
  36039. readonly name: string;
  36040. private _zoomStopsAnimation;
  36041. private _idleRotationSpeed;
  36042. private _idleRotationWaitTime;
  36043. private _idleRotationSpinupTime;
  36044. /**
  36045. * Sets the flag that indicates if user zooming should stop animation.
  36046. */
  36047. /**
  36048. * Gets the flag that indicates if user zooming should stop animation.
  36049. */
  36050. zoomStopsAnimation: boolean;
  36051. /**
  36052. * Sets the default speed at which the camera rotates around the model.
  36053. */
  36054. /**
  36055. * Gets the default speed at which the camera rotates around the model.
  36056. */
  36057. idleRotationSpeed: number;
  36058. /**
  36059. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36060. */
  36061. /**
  36062. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36063. */
  36064. idleRotationWaitTime: number;
  36065. /**
  36066. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36067. */
  36068. /**
  36069. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36070. */
  36071. idleRotationSpinupTime: number;
  36072. /**
  36073. * Gets a value indicating if the camera is currently rotating because of this behavior
  36074. */
  36075. readonly rotationInProgress: boolean;
  36076. private _onPrePointerObservableObserver;
  36077. private _onAfterCheckInputsObserver;
  36078. private _attachedCamera;
  36079. private _isPointerDown;
  36080. private _lastFrameTime;
  36081. private _lastInteractionTime;
  36082. private _cameraRotationSpeed;
  36083. /**
  36084. * Initializes the behavior.
  36085. */
  36086. init(): void;
  36087. /**
  36088. * Attaches the behavior to its arc rotate camera.
  36089. * @param camera Defines the camera to attach the behavior to
  36090. */
  36091. attach(camera: ArcRotateCamera): void;
  36092. /**
  36093. * Detaches the behavior from its current arc rotate camera.
  36094. */
  36095. detach(): void;
  36096. /**
  36097. * Returns true if user is scrolling.
  36098. * @return true if user is scrolling.
  36099. */
  36100. private _userIsZooming;
  36101. private _lastFrameRadius;
  36102. private _shouldAnimationStopForInteraction;
  36103. /**
  36104. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36105. */
  36106. private _applyUserInteraction;
  36107. private _userIsMoving;
  36108. }
  36109. }
  36110. declare module BABYLON {
  36111. /**
  36112. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36113. */
  36114. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36115. private ui;
  36116. /**
  36117. * The name of the behavior
  36118. */
  36119. name: string;
  36120. /**
  36121. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36122. */
  36123. distanceAwayFromFace: number;
  36124. /**
  36125. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36126. */
  36127. distanceAwayFromBottomOfFace: number;
  36128. private _faceVectors;
  36129. private _target;
  36130. private _scene;
  36131. private _onRenderObserver;
  36132. private _tmpMatrix;
  36133. private _tmpVector;
  36134. /**
  36135. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36136. * @param ui The transform node that should be attched to the mesh
  36137. */
  36138. constructor(ui: TransformNode);
  36139. /**
  36140. * Initializes the behavior
  36141. */
  36142. init(): void;
  36143. private _closestFace;
  36144. private _zeroVector;
  36145. private _lookAtTmpMatrix;
  36146. private _lookAtToRef;
  36147. /**
  36148. * Attaches the AttachToBoxBehavior to the passed in mesh
  36149. * @param target The mesh that the specified node will be attached to
  36150. */
  36151. attach(target: Mesh): void;
  36152. /**
  36153. * Detaches the behavior from the mesh
  36154. */
  36155. detach(): void;
  36156. }
  36157. }
  36158. declare module BABYLON {
  36159. /**
  36160. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36161. */
  36162. export class FadeInOutBehavior implements Behavior<Mesh> {
  36163. /**
  36164. * Time in milliseconds to delay before fading in (Default: 0)
  36165. */
  36166. delay: number;
  36167. /**
  36168. * Time in milliseconds for the mesh to fade in (Default: 300)
  36169. */
  36170. fadeInTime: number;
  36171. private _millisecondsPerFrame;
  36172. private _hovered;
  36173. private _hoverValue;
  36174. private _ownerNode;
  36175. /**
  36176. * Instatiates the FadeInOutBehavior
  36177. */
  36178. constructor();
  36179. /**
  36180. * The name of the behavior
  36181. */
  36182. readonly name: string;
  36183. /**
  36184. * Initializes the behavior
  36185. */
  36186. init(): void;
  36187. /**
  36188. * Attaches the fade behavior on the passed in mesh
  36189. * @param ownerNode The mesh that will be faded in/out once attached
  36190. */
  36191. attach(ownerNode: Mesh): void;
  36192. /**
  36193. * Detaches the behavior from the mesh
  36194. */
  36195. detach(): void;
  36196. /**
  36197. * Triggers the mesh to begin fading in or out
  36198. * @param value if the object should fade in or out (true to fade in)
  36199. */
  36200. fadeIn(value: boolean): void;
  36201. private _update;
  36202. private _setAllVisibility;
  36203. }
  36204. }
  36205. declare module BABYLON {
  36206. /**
  36207. * Class containing a set of static utilities functions for managing Pivots
  36208. * @hidden
  36209. */
  36210. export class PivotTools {
  36211. private static _PivotCached;
  36212. private static _OldPivotPoint;
  36213. private static _PivotTranslation;
  36214. private static _PivotTmpVector;
  36215. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36216. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  36217. }
  36218. }
  36219. declare module BABYLON {
  36220. /**
  36221. * Class containing static functions to help procedurally build meshes
  36222. */
  36223. export class PlaneBuilder {
  36224. /**
  36225. * Creates a plane mesh
  36226. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36227. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36228. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36230. * * 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
  36231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36232. * @param name defines the name of the mesh
  36233. * @param options defines the options used to create the mesh
  36234. * @param scene defines the hosting scene
  36235. * @returns the plane mesh
  36236. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36237. */
  36238. static CreatePlane(name: string, options: {
  36239. size?: number;
  36240. width?: number;
  36241. height?: number;
  36242. sideOrientation?: number;
  36243. frontUVs?: Vector4;
  36244. backUVs?: Vector4;
  36245. updatable?: boolean;
  36246. sourcePlane?: Plane;
  36247. }, scene?: Nullable<Scene>): Mesh;
  36248. }
  36249. }
  36250. declare module BABYLON {
  36251. /**
  36252. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36253. */
  36254. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36255. private static _AnyMouseID;
  36256. /**
  36257. * Abstract mesh the behavior is set on
  36258. */
  36259. attachedNode: AbstractMesh;
  36260. private _dragPlane;
  36261. private _scene;
  36262. private _pointerObserver;
  36263. private _beforeRenderObserver;
  36264. private static _planeScene;
  36265. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36266. /**
  36267. * 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)
  36268. */
  36269. maxDragAngle: number;
  36270. /**
  36271. * @hidden
  36272. */ private _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36273. /**
  36274. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36275. */
  36276. currentDraggingPointerID: number;
  36277. /**
  36278. * The last position where the pointer hit the drag plane in world space
  36279. */
  36280. lastDragPosition: Vector3;
  36281. /**
  36282. * If the behavior is currently in a dragging state
  36283. */
  36284. dragging: boolean;
  36285. /**
  36286. * 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)
  36287. */
  36288. dragDeltaRatio: number;
  36289. /**
  36290. * If the drag plane orientation should be updated during the dragging (Default: true)
  36291. */
  36292. updateDragPlane: boolean;
  36293. private _debugMode;
  36294. private _moving;
  36295. /**
  36296. * Fires each time the attached mesh is dragged with the pointer
  36297. * * delta between last drag position and current drag position in world space
  36298. * * dragDistance along the drag axis
  36299. * * dragPlaneNormal normal of the current drag plane used during the drag
  36300. * * dragPlanePoint in world space where the drag intersects the drag plane
  36301. */
  36302. onDragObservable: Observable<{
  36303. delta: Vector3;
  36304. dragPlanePoint: Vector3;
  36305. dragPlaneNormal: Vector3;
  36306. dragDistance: number;
  36307. pointerId: number;
  36308. }>;
  36309. /**
  36310. * Fires each time a drag begins (eg. mouse down on mesh)
  36311. */
  36312. onDragStartObservable: Observable<{
  36313. dragPlanePoint: Vector3;
  36314. pointerId: number;
  36315. }>;
  36316. /**
  36317. * Fires each time a drag ends (eg. mouse release after drag)
  36318. */
  36319. onDragEndObservable: Observable<{
  36320. dragPlanePoint: Vector3;
  36321. pointerId: number;
  36322. }>;
  36323. /**
  36324. * If the attached mesh should be moved when dragged
  36325. */
  36326. moveAttached: boolean;
  36327. /**
  36328. * If the drag behavior will react to drag events (Default: true)
  36329. */
  36330. enabled: boolean;
  36331. /**
  36332. * If pointer events should start and release the drag (Default: true)
  36333. */
  36334. startAndReleaseDragOnPointerEvents: boolean;
  36335. /**
  36336. * If camera controls should be detached during the drag
  36337. */
  36338. detachCameraControls: boolean;
  36339. /**
  36340. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36341. */
  36342. useObjectOrienationForDragging: boolean;
  36343. private _options;
  36344. /**
  36345. * Creates a pointer drag behavior that can be attached to a mesh
  36346. * @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)
  36347. */
  36348. constructor(options?: {
  36349. dragAxis?: Vector3;
  36350. dragPlaneNormal?: Vector3;
  36351. });
  36352. /**
  36353. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36354. */
  36355. validateDrag: (targetPosition: Vector3) => boolean;
  36356. /**
  36357. * The name of the behavior
  36358. */
  36359. readonly name: string;
  36360. /**
  36361. * Initializes the behavior
  36362. */
  36363. init(): void;
  36364. private _tmpVector;
  36365. private _alternatePickedPoint;
  36366. private _worldDragAxis;
  36367. private _targetPosition;
  36368. private _attachedElement;
  36369. /**
  36370. * Attaches the drag behavior the passed in mesh
  36371. * @param ownerNode The mesh that will be dragged around once attached
  36372. * @param predicate Predicate to use for pick filtering
  36373. */
  36374. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  36375. /**
  36376. * Force relase the drag action by code.
  36377. */
  36378. releaseDrag(): void;
  36379. private _startDragRay;
  36380. private _lastPointerRay;
  36381. /**
  36382. * Simulates the start of a pointer drag event on the behavior
  36383. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36384. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36385. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36386. */
  36387. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36388. private _startDrag;
  36389. private _dragDelta;
  36390. private _moveDrag;
  36391. private _pickWithRayOnDragPlane;
  36392. private _pointA;
  36393. private _pointB;
  36394. private _pointC;
  36395. private _lineA;
  36396. private _lineB;
  36397. private _localAxis;
  36398. private _lookAt;
  36399. private _updateDragPlanePosition;
  36400. /**
  36401. * Detaches the behavior from the mesh
  36402. */
  36403. detach(): void;
  36404. }
  36405. }
  36406. declare module BABYLON {
  36407. /**
  36408. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36409. */
  36410. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36411. private _dragBehaviorA;
  36412. private _dragBehaviorB;
  36413. private _startDistance;
  36414. private _initialScale;
  36415. private _targetScale;
  36416. private _ownerNode;
  36417. private _sceneRenderObserver;
  36418. /**
  36419. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36420. */
  36421. constructor();
  36422. /**
  36423. * The name of the behavior
  36424. */
  36425. readonly name: string;
  36426. /**
  36427. * Initializes the behavior
  36428. */
  36429. init(): void;
  36430. private _getCurrentDistance;
  36431. /**
  36432. * Attaches the scale behavior the passed in mesh
  36433. * @param ownerNode The mesh that will be scaled around once attached
  36434. */
  36435. attach(ownerNode: Mesh): void;
  36436. /**
  36437. * Detaches the behavior from the mesh
  36438. */
  36439. detach(): void;
  36440. }
  36441. }
  36442. declare module BABYLON {
  36443. /**
  36444. * 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
  36445. */
  36446. export class SixDofDragBehavior implements Behavior<Mesh> {
  36447. private static _virtualScene;
  36448. private _ownerNode;
  36449. private _sceneRenderObserver;
  36450. private _scene;
  36451. private _targetPosition;
  36452. private _virtualOriginMesh;
  36453. private _virtualDragMesh;
  36454. private _pointerObserver;
  36455. private _moving;
  36456. private _startingOrientation;
  36457. /**
  36458. * 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)
  36459. */
  36460. private zDragFactor;
  36461. /**
  36462. * If the object should rotate to face the drag origin
  36463. */
  36464. rotateDraggedObject: boolean;
  36465. /**
  36466. * If the behavior is currently in a dragging state
  36467. */
  36468. dragging: boolean;
  36469. /**
  36470. * 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)
  36471. */
  36472. dragDeltaRatio: number;
  36473. /**
  36474. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36475. */
  36476. currentDraggingPointerID: number;
  36477. /**
  36478. * If camera controls should be detached during the drag
  36479. */
  36480. detachCameraControls: boolean;
  36481. /**
  36482. * Fires each time a drag starts
  36483. */
  36484. onDragStartObservable: Observable<{}>;
  36485. /**
  36486. * Fires each time a drag ends (eg. mouse release after drag)
  36487. */
  36488. onDragEndObservable: Observable<{}>;
  36489. /**
  36490. * 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
  36491. */
  36492. constructor();
  36493. /**
  36494. * The name of the behavior
  36495. */
  36496. readonly name: string;
  36497. /**
  36498. * Initializes the behavior
  36499. */
  36500. init(): void;
  36501. /**
  36502. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36503. */
  36504. private readonly _pointerCamera;
  36505. /**
  36506. * Attaches the scale behavior the passed in mesh
  36507. * @param ownerNode The mesh that will be scaled around once attached
  36508. */
  36509. attach(ownerNode: Mesh): void;
  36510. /**
  36511. * Detaches the behavior from the mesh
  36512. */
  36513. detach(): void;
  36514. }
  36515. }
  36516. declare module BABYLON {
  36517. /**
  36518. * Class used to apply inverse kinematics to bones
  36519. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36520. */
  36521. export class BoneIKController {
  36522. private static _tmpVecs;
  36523. private static _tmpQuat;
  36524. private static _tmpMats;
  36525. /**
  36526. * Gets or sets the target mesh
  36527. */
  36528. targetMesh: AbstractMesh;
  36529. /** Gets or sets the mesh used as pole */
  36530. poleTargetMesh: AbstractMesh;
  36531. /**
  36532. * Gets or sets the bone used as pole
  36533. */
  36534. poleTargetBone: Nullable<Bone>;
  36535. /**
  36536. * Gets or sets the target position
  36537. */
  36538. targetPosition: Vector3;
  36539. /**
  36540. * Gets or sets the pole target position
  36541. */
  36542. poleTargetPosition: Vector3;
  36543. /**
  36544. * Gets or sets the pole target local offset
  36545. */
  36546. poleTargetLocalOffset: Vector3;
  36547. /**
  36548. * Gets or sets the pole angle
  36549. */
  36550. poleAngle: number;
  36551. /**
  36552. * Gets or sets the mesh associated with the controller
  36553. */
  36554. mesh: AbstractMesh;
  36555. /**
  36556. * 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)
  36557. */
  36558. slerpAmount: number;
  36559. private _bone1Quat;
  36560. private _bone1Mat;
  36561. private _bone2Ang;
  36562. private _bone1;
  36563. private _bone2;
  36564. private _bone1Length;
  36565. private _bone2Length;
  36566. private _maxAngle;
  36567. private _maxReach;
  36568. private _rightHandedSystem;
  36569. private _bendAxis;
  36570. private _slerping;
  36571. private _adjustRoll;
  36572. /**
  36573. * Gets or sets maximum allowed angle
  36574. */
  36575. maxAngle: number;
  36576. /**
  36577. * Creates a new BoneIKController
  36578. * @param mesh defines the mesh to control
  36579. * @param bone defines the bone to control
  36580. * @param options defines options to set up the controller
  36581. */
  36582. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36583. targetMesh?: AbstractMesh;
  36584. poleTargetMesh?: AbstractMesh;
  36585. poleTargetBone?: Bone;
  36586. poleTargetLocalOffset?: Vector3;
  36587. poleAngle?: number;
  36588. bendAxis?: Vector3;
  36589. maxAngle?: number;
  36590. slerpAmount?: number;
  36591. });
  36592. private _setMaxAngle;
  36593. /**
  36594. * Force the controller to update the bones
  36595. */
  36596. update(): void;
  36597. }
  36598. }
  36599. declare module BABYLON {
  36600. /**
  36601. * Class used to make a bone look toward a point in space
  36602. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36603. */
  36604. export class BoneLookController {
  36605. private static _tmpVecs;
  36606. private static _tmpQuat;
  36607. private static _tmpMats;
  36608. /**
  36609. * The target Vector3 that the bone will look at
  36610. */
  36611. target: Vector3;
  36612. /**
  36613. * The mesh that the bone is attached to
  36614. */
  36615. mesh: AbstractMesh;
  36616. /**
  36617. * The bone that will be looking to the target
  36618. */
  36619. bone: Bone;
  36620. /**
  36621. * The up axis of the coordinate system that is used when the bone is rotated
  36622. */
  36623. upAxis: Vector3;
  36624. /**
  36625. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36626. */
  36627. upAxisSpace: Space;
  36628. /**
  36629. * Used to make an adjustment to the yaw of the bone
  36630. */
  36631. adjustYaw: number;
  36632. /**
  36633. * Used to make an adjustment to the pitch of the bone
  36634. */
  36635. adjustPitch: number;
  36636. /**
  36637. * Used to make an adjustment to the roll of the bone
  36638. */
  36639. adjustRoll: number;
  36640. /**
  36641. * 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)
  36642. */
  36643. slerpAmount: number;
  36644. private _minYaw;
  36645. private _maxYaw;
  36646. private _minPitch;
  36647. private _maxPitch;
  36648. private _minYawSin;
  36649. private _minYawCos;
  36650. private _maxYawSin;
  36651. private _maxYawCos;
  36652. private _midYawConstraint;
  36653. private _minPitchTan;
  36654. private _maxPitchTan;
  36655. private _boneQuat;
  36656. private _slerping;
  36657. private _transformYawPitch;
  36658. private _transformYawPitchInv;
  36659. private _firstFrameSkipped;
  36660. private _yawRange;
  36661. private _fowardAxis;
  36662. /**
  36663. * Gets or sets the minimum yaw angle that the bone can look to
  36664. */
  36665. minYaw: number;
  36666. /**
  36667. * Gets or sets the maximum yaw angle that the bone can look to
  36668. */
  36669. maxYaw: number;
  36670. /**
  36671. * Gets or sets the minimum pitch angle that the bone can look to
  36672. */
  36673. minPitch: number;
  36674. /**
  36675. * Gets or sets the maximum pitch angle that the bone can look to
  36676. */
  36677. maxPitch: number;
  36678. /**
  36679. * Create a BoneLookController
  36680. * @param mesh the mesh that the bone belongs to
  36681. * @param bone the bone that will be looking to the target
  36682. * @param target the target Vector3 to look at
  36683. * @param options optional settings:
  36684. * * maxYaw: the maximum angle the bone will yaw to
  36685. * * minYaw: the minimum angle the bone will yaw to
  36686. * * maxPitch: the maximum angle the bone will pitch to
  36687. * * minPitch: the minimum angle the bone will yaw to
  36688. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36689. * * upAxis: the up axis of the coordinate system
  36690. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36691. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36692. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36693. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36694. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36695. * * adjustRoll: used to make an adjustment to the roll of the bone
  36696. **/
  36697. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36698. maxYaw?: number;
  36699. minYaw?: number;
  36700. maxPitch?: number;
  36701. minPitch?: number;
  36702. slerpAmount?: number;
  36703. upAxis?: Vector3;
  36704. upAxisSpace?: Space;
  36705. yawAxis?: Vector3;
  36706. pitchAxis?: Vector3;
  36707. adjustYaw?: number;
  36708. adjustPitch?: number;
  36709. adjustRoll?: number;
  36710. });
  36711. /**
  36712. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36713. */
  36714. update(): void;
  36715. private _getAngleDiff;
  36716. private _getAngleBetween;
  36717. private _isAngleBetween;
  36718. }
  36719. }
  36720. declare module BABYLON {
  36721. /**
  36722. * Manage the gamepad inputs to control an arc rotate camera.
  36723. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36724. */
  36725. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36726. /**
  36727. * Defines the camera the input is attached to.
  36728. */
  36729. camera: ArcRotateCamera;
  36730. /**
  36731. * Defines the gamepad the input is gathering event from.
  36732. */
  36733. gamepad: Nullable<Gamepad>;
  36734. /**
  36735. * Defines the gamepad rotation sensiblity.
  36736. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36737. */
  36738. gamepadRotationSensibility: number;
  36739. /**
  36740. * Defines the gamepad move sensiblity.
  36741. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36742. */
  36743. gamepadMoveSensibility: number;
  36744. private _onGamepadConnectedObserver;
  36745. private _onGamepadDisconnectedObserver;
  36746. /**
  36747. * Attach the input controls to a specific dom element to get the input from.
  36748. * @param element Defines the element the controls should be listened from
  36749. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36750. */
  36751. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36752. /**
  36753. * Detach the current controls from the specified dom element.
  36754. * @param element Defines the element to stop listening the inputs from
  36755. */
  36756. detachControl(element: Nullable<HTMLElement>): void;
  36757. /**
  36758. * Update the current camera state depending on the inputs that have been used this frame.
  36759. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36760. */
  36761. checkInputs(): void;
  36762. /**
  36763. * Gets the class name of the current intput.
  36764. * @returns the class name
  36765. */
  36766. getClassName(): string;
  36767. /**
  36768. * Get the friendly name associated with the input class.
  36769. * @returns the input friendly name
  36770. */
  36771. getSimpleName(): string;
  36772. }
  36773. }
  36774. declare module BABYLON {
  36775. interface ArcRotateCameraInputsManager {
  36776. /**
  36777. * Add orientation input support to the input manager.
  36778. * @returns the current input manager
  36779. */
  36780. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36781. }
  36782. /**
  36783. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36784. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36785. */
  36786. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36787. /**
  36788. * Defines the camera the input is attached to.
  36789. */
  36790. camera: ArcRotateCamera;
  36791. /**
  36792. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36793. */
  36794. alphaCorrection: number;
  36795. /**
  36796. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36797. */
  36798. gammaCorrection: number;
  36799. private _alpha;
  36800. private _gamma;
  36801. private _dirty;
  36802. private _deviceOrientationHandler;
  36803. /**
  36804. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36805. */
  36806. constructor();
  36807. /**
  36808. * Attach the input controls to a specific dom element to get the input from.
  36809. * @param element Defines the element the controls should be listened from
  36810. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36811. */
  36812. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36813. /** @hidden */ private _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36814. /**
  36815. * Update the current camera state depending on the inputs that have been used this frame.
  36816. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36817. */
  36818. checkInputs(): void;
  36819. /**
  36820. * Detach the current controls from the specified dom element.
  36821. * @param element Defines the element to stop listening the inputs from
  36822. */
  36823. detachControl(element: Nullable<HTMLElement>): void;
  36824. /**
  36825. * Gets the class name of the current intput.
  36826. * @returns the class name
  36827. */
  36828. getClassName(): string;
  36829. /**
  36830. * Get the friendly name associated with the input class.
  36831. * @returns the input friendly name
  36832. */
  36833. getSimpleName(): string;
  36834. }
  36835. }
  36836. declare module BABYLON {
  36837. /**
  36838. * Listen to mouse events to control the camera.
  36839. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36840. */
  36841. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36842. /**
  36843. * Defines the camera the input is attached to.
  36844. */
  36845. camera: FlyCamera;
  36846. /**
  36847. * Defines if touch is enabled. (Default is true.)
  36848. */
  36849. touchEnabled: boolean;
  36850. /**
  36851. * Defines the buttons associated with the input to handle camera rotation.
  36852. */
  36853. buttons: number[];
  36854. /**
  36855. * Assign buttons for Yaw control.
  36856. */
  36857. buttonsYaw: number[];
  36858. /**
  36859. * Assign buttons for Pitch control.
  36860. */
  36861. buttonsPitch: number[];
  36862. /**
  36863. * Assign buttons for Roll control.
  36864. */
  36865. buttonsRoll: number[];
  36866. /**
  36867. * Detect if any button is being pressed while mouse is moved.
  36868. * -1 = Mouse locked.
  36869. * 0 = Left button.
  36870. * 1 = Middle Button.
  36871. * 2 = Right Button.
  36872. */
  36873. activeButton: number;
  36874. /**
  36875. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36876. * Higher values reduce its sensitivity.
  36877. */
  36878. angularSensibility: number;
  36879. private _mousemoveCallback;
  36880. private _observer;
  36881. private _rollObserver;
  36882. private previousPosition;
  36883. private noPreventDefault;
  36884. private element;
  36885. /**
  36886. * Listen to mouse events to control the camera.
  36887. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36888. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36889. */
  36890. constructor(touchEnabled?: boolean);
  36891. /**
  36892. * Attach the mouse control to the HTML DOM element.
  36893. * @param element Defines the element that listens to the input events.
  36894. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36895. */
  36896. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36897. /**
  36898. * Detach the current controls from the specified dom element.
  36899. * @param element Defines the element to stop listening the inputs from
  36900. */
  36901. detachControl(element: Nullable<HTMLElement>): void;
  36902. /**
  36903. * Gets the class name of the current input.
  36904. * @returns the class name.
  36905. */
  36906. getClassName(): string;
  36907. /**
  36908. * Get the friendly name associated with the input class.
  36909. * @returns the input's friendly name.
  36910. */
  36911. getSimpleName(): string;
  36912. private _pointerInput;
  36913. private _onMouseMove;
  36914. /**
  36915. * Rotate camera by mouse offset.
  36916. */
  36917. private rotateCamera;
  36918. }
  36919. }
  36920. declare module BABYLON {
  36921. /**
  36922. * Default Inputs manager for the FlyCamera.
  36923. * It groups all the default supported inputs for ease of use.
  36924. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36925. */
  36926. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36927. /**
  36928. * Instantiates a new FlyCameraInputsManager.
  36929. * @param camera Defines the camera the inputs belong to.
  36930. */
  36931. constructor(camera: FlyCamera);
  36932. /**
  36933. * Add keyboard input support to the input manager.
  36934. * @returns the new FlyCameraKeyboardMoveInput().
  36935. */
  36936. addKeyboard(): FlyCameraInputsManager;
  36937. /**
  36938. * Add mouse input support to the input manager.
  36939. * @param touchEnabled Enable touch screen support.
  36940. * @returns the new FlyCameraMouseInput().
  36941. */
  36942. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36943. }
  36944. }
  36945. declare module BABYLON {
  36946. /**
  36947. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36948. * such as in a 3D Space Shooter or a Flight Simulator.
  36949. */
  36950. export class FlyCamera extends TargetCamera {
  36951. /**
  36952. * Define the collision ellipsoid of the camera.
  36953. * This is helpful for simulating a camera body, like a player's body.
  36954. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36955. */
  36956. ellipsoid: Vector3;
  36957. /**
  36958. * Define an offset for the position of the ellipsoid around the camera.
  36959. * This can be helpful if the camera is attached away from the player's body center,
  36960. * such as at its head.
  36961. */
  36962. ellipsoidOffset: Vector3;
  36963. /**
  36964. * Enable or disable collisions of the camera with the rest of the scene objects.
  36965. */
  36966. checkCollisions: boolean;
  36967. /**
  36968. * Enable or disable gravity on the camera.
  36969. */
  36970. applyGravity: boolean;
  36971. /**
  36972. * Define the current direction the camera is moving to.
  36973. */
  36974. cameraDirection: Vector3;
  36975. /**
  36976. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36977. * This overrides and empties cameraRotation.
  36978. */
  36979. rotationQuaternion: Quaternion;
  36980. /**
  36981. * Track Roll to maintain the wanted Rolling when looking around.
  36982. */ private _trackRoll: number;
  36983. /**
  36984. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36985. */
  36986. rollCorrect: number;
  36987. /**
  36988. * Mimic a banked turn, Rolling the camera when Yawing.
  36989. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36990. */
  36991. bankedTurn: boolean;
  36992. /**
  36993. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36994. */
  36995. bankedTurnLimit: number;
  36996. /**
  36997. * Value of 0 disables the banked Roll.
  36998. * Value of 1 is equal to the Yaw angle in radians.
  36999. */
  37000. bankedTurnMultiplier: number;
  37001. /**
  37002. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37003. */
  37004. inputs: FlyCameraInputsManager;
  37005. /**
  37006. * Gets the input sensibility for mouse input.
  37007. * Higher values reduce sensitivity.
  37008. */
  37009. /**
  37010. * Sets the input sensibility for a mouse input.
  37011. * Higher values reduce sensitivity.
  37012. */
  37013. angularSensibility: number;
  37014. /**
  37015. * Get the keys for camera movement forward.
  37016. */
  37017. /**
  37018. * Set the keys for camera movement forward.
  37019. */
  37020. keysForward: number[];
  37021. /**
  37022. * Get the keys for camera movement backward.
  37023. */
  37024. keysBackward: number[];
  37025. /**
  37026. * Get the keys for camera movement up.
  37027. */
  37028. /**
  37029. * Set the keys for camera movement up.
  37030. */
  37031. keysUp: number[];
  37032. /**
  37033. * Get the keys for camera movement down.
  37034. */
  37035. /**
  37036. * Set the keys for camera movement down.
  37037. */
  37038. keysDown: number[];
  37039. /**
  37040. * Get the keys for camera movement left.
  37041. */
  37042. /**
  37043. * Set the keys for camera movement left.
  37044. */
  37045. keysLeft: number[];
  37046. /**
  37047. * Set the keys for camera movement right.
  37048. */
  37049. /**
  37050. * Set the keys for camera movement right.
  37051. */
  37052. keysRight: number[];
  37053. /**
  37054. * Event raised when the camera collides with a mesh in the scene.
  37055. */
  37056. onCollide: (collidedMesh: AbstractMesh) => void;
  37057. private _collider;
  37058. private _needMoveForGravity;
  37059. private _oldPosition;
  37060. private _diffPosition;
  37061. private _newPosition;
  37062. /** @hidden */ private _localDirection: Vector3;
  37063. /** @hidden */ private _transformedDirection: Vector3;
  37064. /**
  37065. * Instantiates a FlyCamera.
  37066. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37067. * such as in a 3D Space Shooter or a Flight Simulator.
  37068. * @param name Define the name of the camera in the scene.
  37069. * @param position Define the starting position of the camera in the scene.
  37070. * @param scene Define the scene the camera belongs to.
  37071. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37072. */
  37073. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37074. /**
  37075. * Attach a control to the HTML DOM element.
  37076. * @param element Defines the element that listens to the input events.
  37077. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37078. */
  37079. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37080. /**
  37081. * Detach a control from the HTML DOM element.
  37082. * The camera will stop reacting to that input.
  37083. * @param element Defines the element that listens to the input events.
  37084. */
  37085. detachControl(element: HTMLElement): void;
  37086. private _collisionMask;
  37087. /**
  37088. * Get the mask that the camera ignores in collision events.
  37089. */
  37090. /**
  37091. * Set the mask that the camera ignores in collision events.
  37092. */
  37093. collisionMask: number;
  37094. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  37095. /** @hidden */
  37096. private _onCollisionPositionChange;
  37097. /** @hidden */ private _checkInputs(): void;
  37098. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  37099. /** @hidden */ private _updatePosition(): void;
  37100. /**
  37101. * Restore the Roll to its target value at the rate specified.
  37102. * @param rate - Higher means slower restoring.
  37103. * @hidden
  37104. */
  37105. restoreRoll(rate: number): void;
  37106. /**
  37107. * Destroy the camera and release the current resources held by it.
  37108. */
  37109. dispose(): void;
  37110. /**
  37111. * Get the current object class name.
  37112. * @returns the class name.
  37113. */
  37114. getClassName(): string;
  37115. }
  37116. }
  37117. declare module BABYLON {
  37118. /**
  37119. * Listen to keyboard events to control the camera.
  37120. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37121. */
  37122. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37123. /**
  37124. * Defines the camera the input is attached to.
  37125. */
  37126. camera: FlyCamera;
  37127. /**
  37128. * The list of keyboard keys used to control the forward move of the camera.
  37129. */
  37130. keysForward: number[];
  37131. /**
  37132. * The list of keyboard keys used to control the backward move of the camera.
  37133. */
  37134. keysBackward: number[];
  37135. /**
  37136. * The list of keyboard keys used to control the forward move of the camera.
  37137. */
  37138. keysUp: number[];
  37139. /**
  37140. * The list of keyboard keys used to control the backward move of the camera.
  37141. */
  37142. keysDown: number[];
  37143. /**
  37144. * The list of keyboard keys used to control the right strafe move of the camera.
  37145. */
  37146. keysRight: number[];
  37147. /**
  37148. * The list of keyboard keys used to control the left strafe move of the camera.
  37149. */
  37150. keysLeft: number[];
  37151. private _keys;
  37152. private _onCanvasBlurObserver;
  37153. private _onKeyboardObserver;
  37154. private _engine;
  37155. private _scene;
  37156. /**
  37157. * Attach the input controls to a specific dom element to get the input from.
  37158. * @param element Defines the element the controls should be listened from
  37159. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37160. */
  37161. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37162. /**
  37163. * Detach the current controls from the specified dom element.
  37164. * @param element Defines the element to stop listening the inputs from
  37165. */
  37166. detachControl(element: Nullable<HTMLElement>): void;
  37167. /**
  37168. * Gets the class name of the current intput.
  37169. * @returns the class name
  37170. */
  37171. getClassName(): string;
  37172. /** @hidden */ private _onLostFocus(e: FocusEvent): void;
  37173. /**
  37174. * Get the friendly name associated with the input class.
  37175. * @returns the input friendly name
  37176. */
  37177. getSimpleName(): string;
  37178. /**
  37179. * Update the current camera state depending on the inputs that have been used this frame.
  37180. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37181. */
  37182. checkInputs(): void;
  37183. }
  37184. }
  37185. declare module BABYLON {
  37186. /**
  37187. * Manage the mouse wheel inputs to control a follow camera.
  37188. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37189. */
  37190. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37191. /**
  37192. * Defines the camera the input is attached to.
  37193. */
  37194. camera: FollowCamera;
  37195. /**
  37196. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37197. */
  37198. axisControlRadius: boolean;
  37199. /**
  37200. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37201. */
  37202. axisControlHeight: boolean;
  37203. /**
  37204. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37205. */
  37206. axisControlRotation: boolean;
  37207. /**
  37208. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37209. * relation to mouseWheel events.
  37210. */
  37211. wheelPrecision: number;
  37212. /**
  37213. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37214. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37215. */
  37216. wheelDeltaPercentage: number;
  37217. private _wheel;
  37218. private _observer;
  37219. /**
  37220. * Attach the input controls to a specific dom element to get the input from.
  37221. * @param element Defines the element the controls should be listened from
  37222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37223. */
  37224. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37225. /**
  37226. * Detach the current controls from the specified dom element.
  37227. * @param element Defines the element to stop listening the inputs from
  37228. */
  37229. detachControl(element: Nullable<HTMLElement>): void;
  37230. /**
  37231. * Gets the class name of the current intput.
  37232. * @returns the class name
  37233. */
  37234. getClassName(): string;
  37235. /**
  37236. * Get the friendly name associated with the input class.
  37237. * @returns the input friendly name
  37238. */
  37239. getSimpleName(): string;
  37240. }
  37241. }
  37242. declare module BABYLON {
  37243. /**
  37244. * Manage the pointers inputs to control an follow camera.
  37245. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37246. */
  37247. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37248. /**
  37249. * Defines the camera the input is attached to.
  37250. */
  37251. camera: FollowCamera;
  37252. /**
  37253. * Gets the class name of the current input.
  37254. * @returns the class name
  37255. */
  37256. getClassName(): string;
  37257. /**
  37258. * Defines the pointer angular sensibility along the X axis or how fast is
  37259. * the camera rotating.
  37260. * A negative number will reverse the axis direction.
  37261. */
  37262. angularSensibilityX: number;
  37263. /**
  37264. * Defines the pointer angular sensibility along the Y axis or how fast is
  37265. * the camera rotating.
  37266. * A negative number will reverse the axis direction.
  37267. */
  37268. angularSensibilityY: number;
  37269. /**
  37270. * Defines the pointer pinch precision or how fast is the camera zooming.
  37271. * A negative number will reverse the axis direction.
  37272. */
  37273. pinchPrecision: number;
  37274. /**
  37275. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37276. * from 0.
  37277. * It defines the percentage of current camera.radius to use as delta when
  37278. * pinch zoom is used.
  37279. */
  37280. pinchDeltaPercentage: number;
  37281. /**
  37282. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37283. */
  37284. axisXControlRadius: boolean;
  37285. /**
  37286. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37287. */
  37288. axisXControlHeight: boolean;
  37289. /**
  37290. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37291. */
  37292. axisXControlRotation: boolean;
  37293. /**
  37294. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37295. */
  37296. axisYControlRadius: boolean;
  37297. /**
  37298. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37299. */
  37300. axisYControlHeight: boolean;
  37301. /**
  37302. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37303. */
  37304. axisYControlRotation: boolean;
  37305. /**
  37306. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37307. */
  37308. axisPinchControlRadius: boolean;
  37309. /**
  37310. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37311. */
  37312. axisPinchControlHeight: boolean;
  37313. /**
  37314. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37315. */
  37316. axisPinchControlRotation: boolean;
  37317. /**
  37318. * Log error messages if basic misconfiguration has occurred.
  37319. */
  37320. warningEnable: boolean;
  37321. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37322. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37323. private _warningCounter;
  37324. private _warning;
  37325. }
  37326. }
  37327. declare module BABYLON {
  37328. /**
  37329. * Default Inputs manager for the FollowCamera.
  37330. * It groups all the default supported inputs for ease of use.
  37331. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37332. */
  37333. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37334. /**
  37335. * Instantiates a new FollowCameraInputsManager.
  37336. * @param camera Defines the camera the inputs belong to
  37337. */
  37338. constructor(camera: FollowCamera);
  37339. /**
  37340. * Add keyboard input support to the input manager.
  37341. * @returns the current input manager
  37342. */
  37343. addKeyboard(): FollowCameraInputsManager;
  37344. /**
  37345. * Add mouse wheel input support to the input manager.
  37346. * @returns the current input manager
  37347. */
  37348. addMouseWheel(): FollowCameraInputsManager;
  37349. /**
  37350. * Add pointers input support to the input manager.
  37351. * @returns the current input manager
  37352. */
  37353. addPointers(): FollowCameraInputsManager;
  37354. /**
  37355. * Add orientation input support to the input manager.
  37356. * @returns the current input manager
  37357. */
  37358. addVRDeviceOrientation(): FollowCameraInputsManager;
  37359. }
  37360. }
  37361. declare module BABYLON {
  37362. /**
  37363. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37364. * an arc rotate version arcFollowCamera are available.
  37365. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37366. */
  37367. export class FollowCamera extends TargetCamera {
  37368. /**
  37369. * Distance the follow camera should follow an object at
  37370. */
  37371. radius: number;
  37372. /**
  37373. * Minimum allowed distance of the camera to the axis of rotation
  37374. * (The camera can not get closer).
  37375. * This can help limiting how the Camera is able to move in the scene.
  37376. */
  37377. lowerRadiusLimit: Nullable<number>;
  37378. /**
  37379. * Maximum allowed distance of the camera to the axis of rotation
  37380. * (The camera can not get further).
  37381. * This can help limiting how the Camera is able to move in the scene.
  37382. */
  37383. upperRadiusLimit: Nullable<number>;
  37384. /**
  37385. * Define a rotation offset between the camera and the object it follows
  37386. */
  37387. rotationOffset: number;
  37388. /**
  37389. * Minimum allowed angle to camera position relative to target object.
  37390. * This can help limiting how the Camera is able to move in the scene.
  37391. */
  37392. lowerRotationOffsetLimit: Nullable<number>;
  37393. /**
  37394. * Maximum allowed angle to camera position relative to target object.
  37395. * This can help limiting how the Camera is able to move in the scene.
  37396. */
  37397. upperRotationOffsetLimit: Nullable<number>;
  37398. /**
  37399. * Define a height offset between the camera and the object it follows.
  37400. * It can help following an object from the top (like a car chaing a plane)
  37401. */
  37402. heightOffset: number;
  37403. /**
  37404. * Minimum allowed height of camera position relative to target object.
  37405. * This can help limiting how the Camera is able to move in the scene.
  37406. */
  37407. lowerHeightOffsetLimit: Nullable<number>;
  37408. /**
  37409. * Maximum allowed height of camera position relative to target object.
  37410. * This can help limiting how the Camera is able to move in the scene.
  37411. */
  37412. upperHeightOffsetLimit: Nullable<number>;
  37413. /**
  37414. * Define how fast the camera can accelerate to follow it s target.
  37415. */
  37416. cameraAcceleration: number;
  37417. /**
  37418. * Define the speed limit of the camera following an object.
  37419. */
  37420. maxCameraSpeed: number;
  37421. /**
  37422. * Define the target of the camera.
  37423. */
  37424. lockedTarget: Nullable<AbstractMesh>;
  37425. /**
  37426. * Defines the input associated with the camera.
  37427. */
  37428. inputs: FollowCameraInputsManager;
  37429. /**
  37430. * Instantiates the follow camera.
  37431. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37432. * @param name Define the name of the camera in the scene
  37433. * @param position Define the position of the camera
  37434. * @param scene Define the scene the camera belong to
  37435. * @param lockedTarget Define the target of the camera
  37436. */
  37437. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37438. private _follow;
  37439. /**
  37440. * Attached controls to the current camera.
  37441. * @param element Defines the element the controls should be listened from
  37442. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37443. */
  37444. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37445. /**
  37446. * Detach the current controls from the camera.
  37447. * The camera will stop reacting to inputs.
  37448. * @param element Defines the element to stop listening the inputs from
  37449. */
  37450. detachControl(element: HTMLElement): void;
  37451. /** @hidden */ private _checkInputs(): void;
  37452. private _checkLimits;
  37453. /**
  37454. * Gets the camera class name.
  37455. * @returns the class name
  37456. */
  37457. getClassName(): string;
  37458. }
  37459. /**
  37460. * Arc Rotate version of the follow camera.
  37461. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37462. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37463. */
  37464. export class ArcFollowCamera extends TargetCamera {
  37465. /** The longitudinal angle of the camera */
  37466. alpha: number;
  37467. /** The latitudinal angle of the camera */
  37468. beta: number;
  37469. /** The radius of the camera from its target */
  37470. radius: number;
  37471. /** Define the camera target (the messh it should follow) */
  37472. target: Nullable<AbstractMesh>;
  37473. private _cartesianCoordinates;
  37474. /**
  37475. * Instantiates a new ArcFollowCamera
  37476. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37477. * @param name Define the name of the camera
  37478. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37479. * @param beta Define the rotation angle of the camera around the elevation axis
  37480. * @param radius Define the radius of the camera from its target point
  37481. * @param target Define the target of the camera
  37482. * @param scene Define the scene the camera belongs to
  37483. */
  37484. constructor(name: string,
  37485. /** The longitudinal angle of the camera */
  37486. alpha: number,
  37487. /** The latitudinal angle of the camera */
  37488. beta: number,
  37489. /** The radius of the camera from its target */
  37490. radius: number,
  37491. /** Define the camera target (the messh it should follow) */
  37492. target: Nullable<AbstractMesh>, scene: Scene);
  37493. private _follow;
  37494. /** @hidden */ private _checkInputs(): void;
  37495. /**
  37496. * Returns the class name of the object.
  37497. * It is mostly used internally for serialization purposes.
  37498. */
  37499. getClassName(): string;
  37500. }
  37501. }
  37502. declare module BABYLON {
  37503. /**
  37504. * Manage the keyboard inputs to control the movement of a follow camera.
  37505. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37506. */
  37507. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37508. /**
  37509. * Defines the camera the input is attached to.
  37510. */
  37511. camera: FollowCamera;
  37512. /**
  37513. * Defines the list of key codes associated with the up action (increase heightOffset)
  37514. */
  37515. keysHeightOffsetIncr: number[];
  37516. /**
  37517. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37518. */
  37519. keysHeightOffsetDecr: number[];
  37520. /**
  37521. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37522. */
  37523. keysHeightOffsetModifierAlt: boolean;
  37524. /**
  37525. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37526. */
  37527. keysHeightOffsetModifierCtrl: boolean;
  37528. /**
  37529. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37530. */
  37531. keysHeightOffsetModifierShift: boolean;
  37532. /**
  37533. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37534. */
  37535. keysRotationOffsetIncr: number[];
  37536. /**
  37537. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37538. */
  37539. keysRotationOffsetDecr: number[];
  37540. /**
  37541. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37542. */
  37543. keysRotationOffsetModifierAlt: boolean;
  37544. /**
  37545. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37546. */
  37547. keysRotationOffsetModifierCtrl: boolean;
  37548. /**
  37549. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37550. */
  37551. keysRotationOffsetModifierShift: boolean;
  37552. /**
  37553. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37554. */
  37555. keysRadiusIncr: number[];
  37556. /**
  37557. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37558. */
  37559. keysRadiusDecr: number[];
  37560. /**
  37561. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37562. */
  37563. keysRadiusModifierAlt: boolean;
  37564. /**
  37565. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37566. */
  37567. keysRadiusModifierCtrl: boolean;
  37568. /**
  37569. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37570. */
  37571. keysRadiusModifierShift: boolean;
  37572. /**
  37573. * Defines the rate of change of heightOffset.
  37574. */
  37575. heightSensibility: number;
  37576. /**
  37577. * Defines the rate of change of rotationOffset.
  37578. */
  37579. rotationSensibility: number;
  37580. /**
  37581. * Defines the rate of change of radius.
  37582. */
  37583. radiusSensibility: number;
  37584. private _keys;
  37585. private _ctrlPressed;
  37586. private _altPressed;
  37587. private _shiftPressed;
  37588. private _onCanvasBlurObserver;
  37589. private _onKeyboardObserver;
  37590. private _engine;
  37591. private _scene;
  37592. /**
  37593. * Attach the input controls to a specific dom element to get the input from.
  37594. * @param element Defines the element the controls should be listened from
  37595. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37596. */
  37597. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37598. /**
  37599. * Detach the current controls from the specified dom element.
  37600. * @param element Defines the element to stop listening the inputs from
  37601. */
  37602. detachControl(element: Nullable<HTMLElement>): void;
  37603. /**
  37604. * Update the current camera state depending on the inputs that have been used this frame.
  37605. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37606. */
  37607. checkInputs(): void;
  37608. /**
  37609. * Gets the class name of the current input.
  37610. * @returns the class name
  37611. */
  37612. getClassName(): string;
  37613. /**
  37614. * Get the friendly name associated with the input class.
  37615. * @returns the input friendly name
  37616. */
  37617. getSimpleName(): string;
  37618. /**
  37619. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37620. * allow modification of the heightOffset value.
  37621. */
  37622. private _modifierHeightOffset;
  37623. /**
  37624. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37625. * allow modification of the rotationOffset value.
  37626. */
  37627. private _modifierRotationOffset;
  37628. /**
  37629. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37630. * allow modification of the radius value.
  37631. */
  37632. private _modifierRadius;
  37633. }
  37634. }
  37635. declare module BABYLON {
  37636. interface FreeCameraInputsManager {
  37637. /**
  37638. * @hidden
  37639. */ private _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37640. /**
  37641. * Add orientation input support to the input manager.
  37642. * @returns the current input manager
  37643. */
  37644. addDeviceOrientation(): FreeCameraInputsManager;
  37645. }
  37646. /**
  37647. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37648. * Screen rotation is taken into account.
  37649. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37650. */
  37651. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37652. private _camera;
  37653. private _screenOrientationAngle;
  37654. private _constantTranform;
  37655. private _screenQuaternion;
  37656. private _alpha;
  37657. private _beta;
  37658. private _gamma;
  37659. /**
  37660. * Can be used to detect if a device orientation sensor is availible on a device
  37661. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37662. * @returns a promise that will resolve on orientation change
  37663. */
  37664. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37665. /**
  37666. * @hidden
  37667. */ private _onDeviceOrientationChangedObservable: Observable<void>;
  37668. /**
  37669. * Instantiates a new input
  37670. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37671. */
  37672. constructor();
  37673. /**
  37674. * Define the camera controlled by the input.
  37675. */
  37676. camera: FreeCamera;
  37677. /**
  37678. * Attach the input controls to a specific dom element to get the input from.
  37679. * @param element Defines the element the controls should be listened from
  37680. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37681. */
  37682. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37683. private _orientationChanged;
  37684. private _deviceOrientation;
  37685. /**
  37686. * Detach the current controls from the specified dom element.
  37687. * @param element Defines the element to stop listening the inputs from
  37688. */
  37689. detachControl(element: Nullable<HTMLElement>): void;
  37690. /**
  37691. * Update the current camera state depending on the inputs that have been used this frame.
  37692. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37693. */
  37694. checkInputs(): void;
  37695. /**
  37696. * Gets the class name of the current intput.
  37697. * @returns the class name
  37698. */
  37699. getClassName(): string;
  37700. /**
  37701. * Get the friendly name associated with the input class.
  37702. * @returns the input friendly name
  37703. */
  37704. getSimpleName(): string;
  37705. }
  37706. }
  37707. declare module BABYLON {
  37708. /**
  37709. * Manage the gamepad inputs to control a free camera.
  37710. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37711. */
  37712. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37713. /**
  37714. * Define the camera the input is attached to.
  37715. */
  37716. camera: FreeCamera;
  37717. /**
  37718. * Define the Gamepad controlling the input
  37719. */
  37720. gamepad: Nullable<Gamepad>;
  37721. /**
  37722. * Defines the gamepad rotation sensiblity.
  37723. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37724. */
  37725. gamepadAngularSensibility: number;
  37726. /**
  37727. * Defines the gamepad move sensiblity.
  37728. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37729. */
  37730. gamepadMoveSensibility: number;
  37731. private _onGamepadConnectedObserver;
  37732. private _onGamepadDisconnectedObserver;
  37733. private _cameraTransform;
  37734. private _deltaTransform;
  37735. private _vector3;
  37736. private _vector2;
  37737. /**
  37738. * Attach the input controls to a specific dom element to get the input from.
  37739. * @param element Defines the element the controls should be listened from
  37740. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37741. */
  37742. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37743. /**
  37744. * Detach the current controls from the specified dom element.
  37745. * @param element Defines the element to stop listening the inputs from
  37746. */
  37747. detachControl(element: Nullable<HTMLElement>): void;
  37748. /**
  37749. * Update the current camera state depending on the inputs that have been used this frame.
  37750. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37751. */
  37752. checkInputs(): void;
  37753. /**
  37754. * Gets the class name of the current intput.
  37755. * @returns the class name
  37756. */
  37757. getClassName(): string;
  37758. /**
  37759. * Get the friendly name associated with the input class.
  37760. * @returns the input friendly name
  37761. */
  37762. getSimpleName(): string;
  37763. }
  37764. }
  37765. declare module BABYLON {
  37766. /**
  37767. * Defines the potential axis of a Joystick
  37768. */
  37769. export enum JoystickAxis {
  37770. /** X axis */
  37771. X = 0,
  37772. /** Y axis */
  37773. Y = 1,
  37774. /** Z axis */
  37775. Z = 2
  37776. }
  37777. /**
  37778. * Class used to define virtual joystick (used in touch mode)
  37779. */
  37780. export class VirtualJoystick {
  37781. /**
  37782. * Gets or sets a boolean indicating that left and right values must be inverted
  37783. */
  37784. reverseLeftRight: boolean;
  37785. /**
  37786. * Gets or sets a boolean indicating that up and down values must be inverted
  37787. */
  37788. reverseUpDown: boolean;
  37789. /**
  37790. * Gets the offset value for the position (ie. the change of the position value)
  37791. */
  37792. deltaPosition: Vector3;
  37793. /**
  37794. * Gets a boolean indicating if the virtual joystick was pressed
  37795. */
  37796. pressed: boolean;
  37797. /**
  37798. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37799. */
  37800. static Canvas: Nullable<HTMLCanvasElement>;
  37801. private static _globalJoystickIndex;
  37802. private static vjCanvasContext;
  37803. private static vjCanvasWidth;
  37804. private static vjCanvasHeight;
  37805. private static halfWidth;
  37806. private _action;
  37807. private _axisTargetedByLeftAndRight;
  37808. private _axisTargetedByUpAndDown;
  37809. private _joystickSensibility;
  37810. private _inversedSensibility;
  37811. private _joystickPointerID;
  37812. private _joystickColor;
  37813. private _joystickPointerPos;
  37814. private _joystickPreviousPointerPos;
  37815. private _joystickPointerStartPos;
  37816. private _deltaJoystickVector;
  37817. private _leftJoystick;
  37818. private _touches;
  37819. private _onPointerDownHandlerRef;
  37820. private _onPointerMoveHandlerRef;
  37821. private _onPointerUpHandlerRef;
  37822. private _onResize;
  37823. /**
  37824. * Creates a new virtual joystick
  37825. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37826. */
  37827. constructor(leftJoystick?: boolean);
  37828. /**
  37829. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37830. * @param newJoystickSensibility defines the new sensibility
  37831. */
  37832. setJoystickSensibility(newJoystickSensibility: number): void;
  37833. private _onPointerDown;
  37834. private _onPointerMove;
  37835. private _onPointerUp;
  37836. /**
  37837. * Change the color of the virtual joystick
  37838. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37839. */
  37840. setJoystickColor(newColor: string): void;
  37841. /**
  37842. * Defines a callback to call when the joystick is touched
  37843. * @param action defines the callback
  37844. */
  37845. setActionOnTouch(action: () => any): void;
  37846. /**
  37847. * Defines which axis you'd like to control for left & right
  37848. * @param axis defines the axis to use
  37849. */
  37850. setAxisForLeftRight(axis: JoystickAxis): void;
  37851. /**
  37852. * Defines which axis you'd like to control for up & down
  37853. * @param axis defines the axis to use
  37854. */
  37855. setAxisForUpDown(axis: JoystickAxis): void;
  37856. private _drawVirtualJoystick;
  37857. /**
  37858. * Release internal HTML canvas
  37859. */
  37860. releaseCanvas(): void;
  37861. }
  37862. }
  37863. declare module BABYLON {
  37864. interface FreeCameraInputsManager {
  37865. /**
  37866. * Add virtual joystick input support to the input manager.
  37867. * @returns the current input manager
  37868. */
  37869. addVirtualJoystick(): FreeCameraInputsManager;
  37870. }
  37871. /**
  37872. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37874. */
  37875. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37876. /**
  37877. * Defines the camera the input is attached to.
  37878. */
  37879. camera: FreeCamera;
  37880. private _leftjoystick;
  37881. private _rightjoystick;
  37882. /**
  37883. * Gets the left stick of the virtual joystick.
  37884. * @returns The virtual Joystick
  37885. */
  37886. getLeftJoystick(): VirtualJoystick;
  37887. /**
  37888. * Gets the right stick of the virtual joystick.
  37889. * @returns The virtual Joystick
  37890. */
  37891. getRightJoystick(): VirtualJoystick;
  37892. /**
  37893. * Update the current camera state depending on the inputs that have been used this frame.
  37894. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37895. */
  37896. checkInputs(): void;
  37897. /**
  37898. * Attach the input controls to a specific dom element to get the input from.
  37899. * @param element Defines the element the controls should be listened from
  37900. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37901. */
  37902. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37903. /**
  37904. * Detach the current controls from the specified dom element.
  37905. * @param element Defines the element to stop listening the inputs from
  37906. */
  37907. detachControl(element: Nullable<HTMLElement>): void;
  37908. /**
  37909. * Gets the class name of the current intput.
  37910. * @returns the class name
  37911. */
  37912. getClassName(): string;
  37913. /**
  37914. * Get the friendly name associated with the input class.
  37915. * @returns the input friendly name
  37916. */
  37917. getSimpleName(): string;
  37918. }
  37919. }
  37920. declare module BABYLON {
  37921. /**
  37922. * This represents a FPS type of camera controlled by touch.
  37923. * This is like a universal camera minus the Gamepad controls.
  37924. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37925. */
  37926. export class TouchCamera extends FreeCamera {
  37927. /**
  37928. * Defines the touch sensibility for rotation.
  37929. * The higher the faster.
  37930. */
  37931. touchAngularSensibility: number;
  37932. /**
  37933. * Defines the touch sensibility for move.
  37934. * The higher the faster.
  37935. */
  37936. touchMoveSensibility: number;
  37937. /**
  37938. * Instantiates a new touch camera.
  37939. * This represents a FPS type of camera controlled by touch.
  37940. * This is like a universal camera minus the Gamepad controls.
  37941. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37942. * @param name Define the name of the camera in the scene
  37943. * @param position Define the start position of the camera in the scene
  37944. * @param scene Define the scene the camera belongs to
  37945. */
  37946. constructor(name: string, position: Vector3, scene: Scene);
  37947. /**
  37948. * Gets the current object class name.
  37949. * @return the class name
  37950. */
  37951. getClassName(): string;
  37952. /** @hidden */ private _setupInputs(): void;
  37953. }
  37954. }
  37955. declare module BABYLON {
  37956. /**
  37957. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37958. * being tilted forward or back and left or right.
  37959. */
  37960. export class DeviceOrientationCamera extends FreeCamera {
  37961. private _initialQuaternion;
  37962. private _quaternionCache;
  37963. private _tmpDragQuaternion;
  37964. private _disablePointerInputWhenUsingDeviceOrientation;
  37965. /**
  37966. * Creates a new device orientation camera
  37967. * @param name The name of the camera
  37968. * @param position The start position camera
  37969. * @param scene The scene the camera belongs to
  37970. */
  37971. constructor(name: string, position: Vector3, scene: Scene);
  37972. /**
  37973. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  37974. */
  37975. disablePointerInputWhenUsingDeviceOrientation: boolean;
  37976. private _dragFactor;
  37977. /**
  37978. * Enabled turning on the y axis when the orientation sensor is active
  37979. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37980. */
  37981. enableHorizontalDragging(dragFactor?: number): void;
  37982. /**
  37983. * Gets the current instance class name ("DeviceOrientationCamera").
  37984. * This helps avoiding instanceof at run time.
  37985. * @returns the class name
  37986. */
  37987. getClassName(): string;
  37988. /**
  37989. * @hidden
  37990. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37991. */ private _checkInputs(): void;
  37992. /**
  37993. * Reset the camera to its default orientation on the specified axis only.
  37994. * @param axis The axis to reset
  37995. */
  37996. resetToCurrentRotation(axis?: Axis): void;
  37997. }
  37998. }
  37999. declare module BABYLON {
  38000. /**
  38001. * Defines supported buttons for XBox360 compatible gamepads
  38002. */
  38003. export enum Xbox360Button {
  38004. /** A */
  38005. A = 0,
  38006. /** B */
  38007. B = 1,
  38008. /** X */
  38009. X = 2,
  38010. /** Y */
  38011. Y = 3,
  38012. /** Start */
  38013. Start = 4,
  38014. /** Back */
  38015. Back = 5,
  38016. /** Left button */
  38017. LB = 6,
  38018. /** Right button */
  38019. RB = 7,
  38020. /** Left stick */
  38021. LeftStick = 8,
  38022. /** Right stick */
  38023. RightStick = 9
  38024. }
  38025. /** Defines values for XBox360 DPad */
  38026. export enum Xbox360Dpad {
  38027. /** Up */
  38028. Up = 0,
  38029. /** Down */
  38030. Down = 1,
  38031. /** Left */
  38032. Left = 2,
  38033. /** Right */
  38034. Right = 3
  38035. }
  38036. /**
  38037. * Defines a XBox360 gamepad
  38038. */
  38039. export class Xbox360Pad extends Gamepad {
  38040. private _leftTrigger;
  38041. private _rightTrigger;
  38042. private _onlefttriggerchanged;
  38043. private _onrighttriggerchanged;
  38044. private _onbuttondown;
  38045. private _onbuttonup;
  38046. private _ondpaddown;
  38047. private _ondpadup;
  38048. /** Observable raised when a button is pressed */
  38049. onButtonDownObservable: Observable<Xbox360Button>;
  38050. /** Observable raised when a button is released */
  38051. onButtonUpObservable: Observable<Xbox360Button>;
  38052. /** Observable raised when a pad is pressed */
  38053. onPadDownObservable: Observable<Xbox360Dpad>;
  38054. /** Observable raised when a pad is released */
  38055. onPadUpObservable: Observable<Xbox360Dpad>;
  38056. private _buttonA;
  38057. private _buttonB;
  38058. private _buttonX;
  38059. private _buttonY;
  38060. private _buttonBack;
  38061. private _buttonStart;
  38062. private _buttonLB;
  38063. private _buttonRB;
  38064. private _buttonLeftStick;
  38065. private _buttonRightStick;
  38066. private _dPadUp;
  38067. private _dPadDown;
  38068. private _dPadLeft;
  38069. private _dPadRight;
  38070. private _isXboxOnePad;
  38071. /**
  38072. * Creates a new XBox360 gamepad object
  38073. * @param id defines the id of this gamepad
  38074. * @param index defines its index
  38075. * @param gamepad defines the internal HTML gamepad object
  38076. * @param xboxOne defines if it is a XBox One gamepad
  38077. */
  38078. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38079. /**
  38080. * Defines the callback to call when left trigger is pressed
  38081. * @param callback defines the callback to use
  38082. */
  38083. onlefttriggerchanged(callback: (value: number) => void): void;
  38084. /**
  38085. * Defines the callback to call when right trigger is pressed
  38086. * @param callback defines the callback to use
  38087. */
  38088. onrighttriggerchanged(callback: (value: number) => void): void;
  38089. /**
  38090. * Gets the left trigger value
  38091. */
  38092. /**
  38093. * Sets the left trigger value
  38094. */
  38095. leftTrigger: number;
  38096. /**
  38097. * Gets the right trigger value
  38098. */
  38099. /**
  38100. * Sets the right trigger value
  38101. */
  38102. rightTrigger: number;
  38103. /**
  38104. * Defines the callback to call when a button is pressed
  38105. * @param callback defines the callback to use
  38106. */
  38107. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38108. /**
  38109. * Defines the callback to call when a button is released
  38110. * @param callback defines the callback to use
  38111. */
  38112. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38113. /**
  38114. * Defines the callback to call when a pad is pressed
  38115. * @param callback defines the callback to use
  38116. */
  38117. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38118. /**
  38119. * Defines the callback to call when a pad is released
  38120. * @param callback defines the callback to use
  38121. */
  38122. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38123. private _setButtonValue;
  38124. private _setDPadValue;
  38125. /**
  38126. * Gets the value of the `A` button
  38127. */
  38128. /**
  38129. * Sets the value of the `A` button
  38130. */
  38131. buttonA: number;
  38132. /**
  38133. * Gets the value of the `B` button
  38134. */
  38135. /**
  38136. * Sets the value of the `B` button
  38137. */
  38138. buttonB: number;
  38139. /**
  38140. * Gets the value of the `X` button
  38141. */
  38142. /**
  38143. * Sets the value of the `X` button
  38144. */
  38145. buttonX: number;
  38146. /**
  38147. * Gets the value of the `Y` button
  38148. */
  38149. /**
  38150. * Sets the value of the `Y` button
  38151. */
  38152. buttonY: number;
  38153. /**
  38154. * Gets the value of the `Start` button
  38155. */
  38156. /**
  38157. * Sets the value of the `Start` button
  38158. */
  38159. buttonStart: number;
  38160. /**
  38161. * Gets the value of the `Back` button
  38162. */
  38163. /**
  38164. * Sets the value of the `Back` button
  38165. */
  38166. buttonBack: number;
  38167. /**
  38168. * Gets the value of the `Left` button
  38169. */
  38170. /**
  38171. * Sets the value of the `Left` button
  38172. */
  38173. buttonLB: number;
  38174. /**
  38175. * Gets the value of the `Right` button
  38176. */
  38177. /**
  38178. * Sets the value of the `Right` button
  38179. */
  38180. buttonRB: number;
  38181. /**
  38182. * Gets the value of the Left joystick
  38183. */
  38184. /**
  38185. * Sets the value of the Left joystick
  38186. */
  38187. buttonLeftStick: number;
  38188. /**
  38189. * Gets the value of the Right joystick
  38190. */
  38191. /**
  38192. * Sets the value of the Right joystick
  38193. */
  38194. buttonRightStick: number;
  38195. /**
  38196. * Gets the value of D-pad up
  38197. */
  38198. /**
  38199. * Sets the value of D-pad up
  38200. */
  38201. dPadUp: number;
  38202. /**
  38203. * Gets the value of D-pad down
  38204. */
  38205. /**
  38206. * Sets the value of D-pad down
  38207. */
  38208. dPadDown: number;
  38209. /**
  38210. * Gets the value of D-pad left
  38211. */
  38212. /**
  38213. * Sets the value of D-pad left
  38214. */
  38215. dPadLeft: number;
  38216. /**
  38217. * Gets the value of D-pad right
  38218. */
  38219. /**
  38220. * Sets the value of D-pad right
  38221. */
  38222. dPadRight: number;
  38223. /**
  38224. * Force the gamepad to synchronize with device values
  38225. */
  38226. update(): void;
  38227. /**
  38228. * Disposes the gamepad
  38229. */
  38230. dispose(): void;
  38231. }
  38232. }
  38233. declare module BABYLON {
  38234. /**
  38235. * Defines supported buttons for DualShock compatible gamepads
  38236. */
  38237. export enum DualShockButton {
  38238. /** Cross */
  38239. Cross = 0,
  38240. /** Circle */
  38241. Circle = 1,
  38242. /** Square */
  38243. Square = 2,
  38244. /** Triangle */
  38245. Triangle = 3,
  38246. /** Options */
  38247. Options = 4,
  38248. /** Share */
  38249. Share = 5,
  38250. /** L1 */
  38251. L1 = 6,
  38252. /** R1 */
  38253. R1 = 7,
  38254. /** Left stick */
  38255. LeftStick = 8,
  38256. /** Right stick */
  38257. RightStick = 9
  38258. }
  38259. /** Defines values for DualShock DPad */
  38260. export enum DualShockDpad {
  38261. /** Up */
  38262. Up = 0,
  38263. /** Down */
  38264. Down = 1,
  38265. /** Left */
  38266. Left = 2,
  38267. /** Right */
  38268. Right = 3
  38269. }
  38270. /**
  38271. * Defines a DualShock gamepad
  38272. */
  38273. export class DualShockPad extends Gamepad {
  38274. private _leftTrigger;
  38275. private _rightTrigger;
  38276. private _onlefttriggerchanged;
  38277. private _onrighttriggerchanged;
  38278. private _onbuttondown;
  38279. private _onbuttonup;
  38280. private _ondpaddown;
  38281. private _ondpadup;
  38282. /** Observable raised when a button is pressed */
  38283. onButtonDownObservable: Observable<DualShockButton>;
  38284. /** Observable raised when a button is released */
  38285. onButtonUpObservable: Observable<DualShockButton>;
  38286. /** Observable raised when a pad is pressed */
  38287. onPadDownObservable: Observable<DualShockDpad>;
  38288. /** Observable raised when a pad is released */
  38289. onPadUpObservable: Observable<DualShockDpad>;
  38290. private _buttonCross;
  38291. private _buttonCircle;
  38292. private _buttonSquare;
  38293. private _buttonTriangle;
  38294. private _buttonShare;
  38295. private _buttonOptions;
  38296. private _buttonL1;
  38297. private _buttonR1;
  38298. private _buttonLeftStick;
  38299. private _buttonRightStick;
  38300. private _dPadUp;
  38301. private _dPadDown;
  38302. private _dPadLeft;
  38303. private _dPadRight;
  38304. /**
  38305. * Creates a new DualShock gamepad object
  38306. * @param id defines the id of this gamepad
  38307. * @param index defines its index
  38308. * @param gamepad defines the internal HTML gamepad object
  38309. */
  38310. constructor(id: string, index: number, gamepad: any);
  38311. /**
  38312. * Defines the callback to call when left trigger is pressed
  38313. * @param callback defines the callback to use
  38314. */
  38315. onlefttriggerchanged(callback: (value: number) => void): void;
  38316. /**
  38317. * Defines the callback to call when right trigger is pressed
  38318. * @param callback defines the callback to use
  38319. */
  38320. onrighttriggerchanged(callback: (value: number) => void): void;
  38321. /**
  38322. * Gets the left trigger value
  38323. */
  38324. /**
  38325. * Sets the left trigger value
  38326. */
  38327. leftTrigger: number;
  38328. /**
  38329. * Gets the right trigger value
  38330. */
  38331. /**
  38332. * Sets the right trigger value
  38333. */
  38334. rightTrigger: number;
  38335. /**
  38336. * Defines the callback to call when a button is pressed
  38337. * @param callback defines the callback to use
  38338. */
  38339. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38340. /**
  38341. * Defines the callback to call when a button is released
  38342. * @param callback defines the callback to use
  38343. */
  38344. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38345. /**
  38346. * Defines the callback to call when a pad is pressed
  38347. * @param callback defines the callback to use
  38348. */
  38349. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38350. /**
  38351. * Defines the callback to call when a pad is released
  38352. * @param callback defines the callback to use
  38353. */
  38354. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38355. private _setButtonValue;
  38356. private _setDPadValue;
  38357. /**
  38358. * Gets the value of the `Cross` button
  38359. */
  38360. /**
  38361. * Sets the value of the `Cross` button
  38362. */
  38363. buttonCross: number;
  38364. /**
  38365. * Gets the value of the `Circle` button
  38366. */
  38367. /**
  38368. * Sets the value of the `Circle` button
  38369. */
  38370. buttonCircle: number;
  38371. /**
  38372. * Gets the value of the `Square` button
  38373. */
  38374. /**
  38375. * Sets the value of the `Square` button
  38376. */
  38377. buttonSquare: number;
  38378. /**
  38379. * Gets the value of the `Triangle` button
  38380. */
  38381. /**
  38382. * Sets the value of the `Triangle` button
  38383. */
  38384. buttonTriangle: number;
  38385. /**
  38386. * Gets the value of the `Options` button
  38387. */
  38388. /**
  38389. * Sets the value of the `Options` button
  38390. */
  38391. buttonOptions: number;
  38392. /**
  38393. * Gets the value of the `Share` button
  38394. */
  38395. /**
  38396. * Sets the value of the `Share` button
  38397. */
  38398. buttonShare: number;
  38399. /**
  38400. * Gets the value of the `L1` button
  38401. */
  38402. /**
  38403. * Sets the value of the `L1` button
  38404. */
  38405. buttonL1: number;
  38406. /**
  38407. * Gets the value of the `R1` button
  38408. */
  38409. /**
  38410. * Sets the value of the `R1` button
  38411. */
  38412. buttonR1: number;
  38413. /**
  38414. * Gets the value of the Left joystick
  38415. */
  38416. /**
  38417. * Sets the value of the Left joystick
  38418. */
  38419. buttonLeftStick: number;
  38420. /**
  38421. * Gets the value of the Right joystick
  38422. */
  38423. /**
  38424. * Sets the value of the Right joystick
  38425. */
  38426. buttonRightStick: number;
  38427. /**
  38428. * Gets the value of D-pad up
  38429. */
  38430. /**
  38431. * Sets the value of D-pad up
  38432. */
  38433. dPadUp: number;
  38434. /**
  38435. * Gets the value of D-pad down
  38436. */
  38437. /**
  38438. * Sets the value of D-pad down
  38439. */
  38440. dPadDown: number;
  38441. /**
  38442. * Gets the value of D-pad left
  38443. */
  38444. /**
  38445. * Sets the value of D-pad left
  38446. */
  38447. dPadLeft: number;
  38448. /**
  38449. * Gets the value of D-pad right
  38450. */
  38451. /**
  38452. * Sets the value of D-pad right
  38453. */
  38454. dPadRight: number;
  38455. /**
  38456. * Force the gamepad to synchronize with device values
  38457. */
  38458. update(): void;
  38459. /**
  38460. * Disposes the gamepad
  38461. */
  38462. dispose(): void;
  38463. }
  38464. }
  38465. declare module BABYLON {
  38466. /**
  38467. * Manager for handling gamepads
  38468. */
  38469. export class GamepadManager {
  38470. private _scene?;
  38471. private _babylonGamepads;
  38472. private _oneGamepadConnected;
  38473. /** @hidden */ private _isMonitoring: boolean;
  38474. private _gamepadEventSupported;
  38475. private _gamepadSupport;
  38476. /**
  38477. * observable to be triggered when the gamepad controller has been connected
  38478. */
  38479. onGamepadConnectedObservable: Observable<Gamepad>;
  38480. /**
  38481. * observable to be triggered when the gamepad controller has been disconnected
  38482. */
  38483. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38484. private _onGamepadConnectedEvent;
  38485. private _onGamepadDisconnectedEvent;
  38486. /**
  38487. * Initializes the gamepad manager
  38488. * @param _scene BabylonJS scene
  38489. */
  38490. constructor(_scene?: Scene | undefined);
  38491. /**
  38492. * The gamepads in the game pad manager
  38493. */
  38494. readonly gamepads: Gamepad[];
  38495. /**
  38496. * Get the gamepad controllers based on type
  38497. * @param type The type of gamepad controller
  38498. * @returns Nullable gamepad
  38499. */
  38500. getGamepadByType(type?: number): Nullable<Gamepad>;
  38501. /**
  38502. * Disposes the gamepad manager
  38503. */
  38504. dispose(): void;
  38505. private _addNewGamepad;
  38506. private _startMonitoringGamepads;
  38507. private _stopMonitoringGamepads;
  38508. /** @hidden */ private _checkGamepadsStatus(): void;
  38509. private _updateGamepadObjects;
  38510. }
  38511. }
  38512. declare module BABYLON {
  38513. interface Scene {
  38514. /** @hidden */ private _gamepadManager: Nullable<GamepadManager>;
  38515. /**
  38516. * Gets the gamepad manager associated with the scene
  38517. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38518. */
  38519. gamepadManager: GamepadManager;
  38520. }
  38521. /**
  38522. * Interface representing a free camera inputs manager
  38523. */
  38524. interface FreeCameraInputsManager {
  38525. /**
  38526. * Adds gamepad input support to the FreeCameraInputsManager.
  38527. * @returns the FreeCameraInputsManager
  38528. */
  38529. addGamepad(): FreeCameraInputsManager;
  38530. }
  38531. /**
  38532. * Interface representing an arc rotate camera inputs manager
  38533. */
  38534. interface ArcRotateCameraInputsManager {
  38535. /**
  38536. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38537. * @returns the camera inputs manager
  38538. */
  38539. addGamepad(): ArcRotateCameraInputsManager;
  38540. }
  38541. /**
  38542. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38543. */
  38544. export class GamepadSystemSceneComponent implements ISceneComponent {
  38545. /**
  38546. * The component name helpfull to identify the component in the list of scene components.
  38547. */
  38548. readonly name: string;
  38549. /**
  38550. * The scene the component belongs to.
  38551. */
  38552. scene: Scene;
  38553. /**
  38554. * Creates a new instance of the component for the given scene
  38555. * @param scene Defines the scene to register the component in
  38556. */
  38557. constructor(scene: Scene);
  38558. /**
  38559. * Registers the component in a given scene
  38560. */
  38561. register(): void;
  38562. /**
  38563. * Rebuilds the elements related to this component in case of
  38564. * context lost for instance.
  38565. */
  38566. rebuild(): void;
  38567. /**
  38568. * Disposes the component and the associated ressources
  38569. */
  38570. dispose(): void;
  38571. private _beforeCameraUpdate;
  38572. }
  38573. }
  38574. declare module BABYLON {
  38575. /**
  38576. * 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,
  38577. * which still works and will still be found in many Playgrounds.
  38578. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38579. */
  38580. export class UniversalCamera extends TouchCamera {
  38581. /**
  38582. * Defines the gamepad rotation sensiblity.
  38583. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38584. */
  38585. gamepadAngularSensibility: number;
  38586. /**
  38587. * Defines the gamepad move sensiblity.
  38588. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38589. */
  38590. gamepadMoveSensibility: number;
  38591. /**
  38592. * 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,
  38593. * which still works and will still be found in many Playgrounds.
  38594. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38595. * @param name Define the name of the camera in the scene
  38596. * @param position Define the start position of the camera in the scene
  38597. * @param scene Define the scene the camera belongs to
  38598. */
  38599. constructor(name: string, position: Vector3, scene: Scene);
  38600. /**
  38601. * Gets the current object class name.
  38602. * @return the class name
  38603. */
  38604. getClassName(): string;
  38605. }
  38606. }
  38607. declare module BABYLON {
  38608. /**
  38609. * This represents a FPS type of camera. This is only here for back compat purpose.
  38610. * Please use the UniversalCamera instead as both are identical.
  38611. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38612. */
  38613. export class GamepadCamera extends UniversalCamera {
  38614. /**
  38615. * Instantiates a new Gamepad Camera
  38616. * This represents a FPS type of camera. This is only here for back compat purpose.
  38617. * Please use the UniversalCamera instead as both are identical.
  38618. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38619. * @param name Define the name of the camera in the scene
  38620. * @param position Define the start position of the camera in the scene
  38621. * @param scene Define the scene the camera belongs to
  38622. */
  38623. constructor(name: string, position: Vector3, scene: Scene);
  38624. /**
  38625. * Gets the current object class name.
  38626. * @return the class name
  38627. */
  38628. getClassName(): string;
  38629. }
  38630. }
  38631. declare module BABYLON {
  38632. /** @hidden */
  38633. export var passPixelShader: {
  38634. name: string;
  38635. shader: string;
  38636. };
  38637. }
  38638. declare module BABYLON {
  38639. /** @hidden */
  38640. export var passCubePixelShader: {
  38641. name: string;
  38642. shader: string;
  38643. };
  38644. }
  38645. declare module BABYLON {
  38646. /**
  38647. * PassPostProcess which produces an output the same as it's input
  38648. */
  38649. export class PassPostProcess extends PostProcess {
  38650. /**
  38651. * Creates the PassPostProcess
  38652. * @param name The name of the effect.
  38653. * @param options The required width/height ratio to downsize to before computing the render pass.
  38654. * @param camera The camera to apply the render pass to.
  38655. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38656. * @param engine The engine which the post process will be applied. (default: current engine)
  38657. * @param reusable If the post process can be reused on the same frame. (default: false)
  38658. * @param textureType The type of texture to be used when performing the post processing.
  38659. * @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)
  38660. */
  38661. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38662. }
  38663. /**
  38664. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38665. */
  38666. export class PassCubePostProcess extends PostProcess {
  38667. private _face;
  38668. /**
  38669. * Gets or sets the cube face to display.
  38670. * * 0 is +X
  38671. * * 1 is -X
  38672. * * 2 is +Y
  38673. * * 3 is -Y
  38674. * * 4 is +Z
  38675. * * 5 is -Z
  38676. */
  38677. face: number;
  38678. /**
  38679. * Creates the PassCubePostProcess
  38680. * @param name The name of the effect.
  38681. * @param options The required width/height ratio to downsize to before computing the render pass.
  38682. * @param camera The camera to apply the render pass to.
  38683. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38684. * @param engine The engine which the post process will be applied. (default: current engine)
  38685. * @param reusable If the post process can be reused on the same frame. (default: false)
  38686. * @param textureType The type of texture to be used when performing the post processing.
  38687. * @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)
  38688. */
  38689. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38690. }
  38691. }
  38692. declare module BABYLON {
  38693. /** @hidden */
  38694. export var anaglyphPixelShader: {
  38695. name: string;
  38696. shader: string;
  38697. };
  38698. }
  38699. declare module BABYLON {
  38700. /**
  38701. * Postprocess used to generate anaglyphic rendering
  38702. */
  38703. export class AnaglyphPostProcess extends PostProcess {
  38704. private _passedProcess;
  38705. /**
  38706. * Creates a new AnaglyphPostProcess
  38707. * @param name defines postprocess name
  38708. * @param options defines creation options or target ratio scale
  38709. * @param rigCameras defines cameras using this postprocess
  38710. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38711. * @param engine defines hosting engine
  38712. * @param reusable defines if the postprocess will be reused multiple times per frame
  38713. */
  38714. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38715. }
  38716. }
  38717. declare module BABYLON {
  38718. /**
  38719. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38720. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38721. */
  38722. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38723. /**
  38724. * Creates a new AnaglyphArcRotateCamera
  38725. * @param name defines camera name
  38726. * @param alpha defines alpha angle (in radians)
  38727. * @param beta defines beta angle (in radians)
  38728. * @param radius defines radius
  38729. * @param target defines camera target
  38730. * @param interaxialDistance defines distance between each color axis
  38731. * @param scene defines the hosting scene
  38732. */
  38733. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38734. /**
  38735. * Gets camera class name
  38736. * @returns AnaglyphArcRotateCamera
  38737. */
  38738. getClassName(): string;
  38739. }
  38740. }
  38741. declare module BABYLON {
  38742. /**
  38743. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38744. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38745. */
  38746. export class AnaglyphFreeCamera extends FreeCamera {
  38747. /**
  38748. * Creates a new AnaglyphFreeCamera
  38749. * @param name defines camera name
  38750. * @param position defines initial position
  38751. * @param interaxialDistance defines distance between each color axis
  38752. * @param scene defines the hosting scene
  38753. */
  38754. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38755. /**
  38756. * Gets camera class name
  38757. * @returns AnaglyphFreeCamera
  38758. */
  38759. getClassName(): string;
  38760. }
  38761. }
  38762. declare module BABYLON {
  38763. /**
  38764. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38765. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38766. */
  38767. export class AnaglyphGamepadCamera extends GamepadCamera {
  38768. /**
  38769. * Creates a new AnaglyphGamepadCamera
  38770. * @param name defines camera name
  38771. * @param position defines initial position
  38772. * @param interaxialDistance defines distance between each color axis
  38773. * @param scene defines the hosting scene
  38774. */
  38775. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38776. /**
  38777. * Gets camera class name
  38778. * @returns AnaglyphGamepadCamera
  38779. */
  38780. getClassName(): string;
  38781. }
  38782. }
  38783. declare module BABYLON {
  38784. /**
  38785. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38786. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38787. */
  38788. export class AnaglyphUniversalCamera extends UniversalCamera {
  38789. /**
  38790. * Creates a new AnaglyphUniversalCamera
  38791. * @param name defines camera name
  38792. * @param position defines initial position
  38793. * @param interaxialDistance defines distance between each color axis
  38794. * @param scene defines the hosting scene
  38795. */
  38796. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38797. /**
  38798. * Gets camera class name
  38799. * @returns AnaglyphUniversalCamera
  38800. */
  38801. getClassName(): string;
  38802. }
  38803. }
  38804. declare module BABYLON {
  38805. /** @hidden */
  38806. export var stereoscopicInterlacePixelShader: {
  38807. name: string;
  38808. shader: string;
  38809. };
  38810. }
  38811. declare module BABYLON {
  38812. /**
  38813. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38814. */
  38815. export class StereoscopicInterlacePostProcess extends PostProcess {
  38816. private _stepSize;
  38817. private _passedProcess;
  38818. /**
  38819. * Initializes a StereoscopicInterlacePostProcess
  38820. * @param name The name of the effect.
  38821. * @param rigCameras The rig cameras to be appled to the post process
  38822. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38823. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38824. * @param engine The engine which the post process will be applied. (default: current engine)
  38825. * @param reusable If the post process can be reused on the same frame. (default: false)
  38826. */
  38827. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38828. }
  38829. }
  38830. declare module BABYLON {
  38831. /**
  38832. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38833. * @see http://doc.babylonjs.com/features/cameras
  38834. */
  38835. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38836. /**
  38837. * Creates a new StereoscopicArcRotateCamera
  38838. * @param name defines camera name
  38839. * @param alpha defines alpha angle (in radians)
  38840. * @param beta defines beta angle (in radians)
  38841. * @param radius defines radius
  38842. * @param target defines camera target
  38843. * @param interaxialDistance defines distance between each color axis
  38844. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38845. * @param scene defines the hosting scene
  38846. */
  38847. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38848. /**
  38849. * Gets camera class name
  38850. * @returns StereoscopicArcRotateCamera
  38851. */
  38852. getClassName(): string;
  38853. }
  38854. }
  38855. declare module BABYLON {
  38856. /**
  38857. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38858. * @see http://doc.babylonjs.com/features/cameras
  38859. */
  38860. export class StereoscopicFreeCamera extends FreeCamera {
  38861. /**
  38862. * Creates a new StereoscopicFreeCamera
  38863. * @param name defines camera name
  38864. * @param position defines initial position
  38865. * @param interaxialDistance defines distance between each color axis
  38866. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38867. * @param scene defines the hosting scene
  38868. */
  38869. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38870. /**
  38871. * Gets camera class name
  38872. * @returns StereoscopicFreeCamera
  38873. */
  38874. getClassName(): string;
  38875. }
  38876. }
  38877. declare module BABYLON {
  38878. /**
  38879. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38880. * @see http://doc.babylonjs.com/features/cameras
  38881. */
  38882. export class StereoscopicGamepadCamera extends GamepadCamera {
  38883. /**
  38884. * Creates a new StereoscopicGamepadCamera
  38885. * @param name defines camera name
  38886. * @param position defines initial position
  38887. * @param interaxialDistance defines distance between each color axis
  38888. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38889. * @param scene defines the hosting scene
  38890. */
  38891. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38892. /**
  38893. * Gets camera class name
  38894. * @returns StereoscopicGamepadCamera
  38895. */
  38896. getClassName(): string;
  38897. }
  38898. }
  38899. declare module BABYLON {
  38900. /**
  38901. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38902. * @see http://doc.babylonjs.com/features/cameras
  38903. */
  38904. export class StereoscopicUniversalCamera extends UniversalCamera {
  38905. /**
  38906. * Creates a new StereoscopicUniversalCamera
  38907. * @param name defines camera name
  38908. * @param position defines initial position
  38909. * @param interaxialDistance defines distance between each color axis
  38910. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38911. * @param scene defines the hosting scene
  38912. */
  38913. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38914. /**
  38915. * Gets camera class name
  38916. * @returns StereoscopicUniversalCamera
  38917. */
  38918. getClassName(): string;
  38919. }
  38920. }
  38921. declare module BABYLON {
  38922. /**
  38923. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38924. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38925. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38926. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38927. */
  38928. export class VirtualJoysticksCamera extends FreeCamera {
  38929. /**
  38930. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38931. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38932. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38933. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38934. * @param name Define the name of the camera in the scene
  38935. * @param position Define the start position of the camera in the scene
  38936. * @param scene Define the scene the camera belongs to
  38937. */
  38938. constructor(name: string, position: Vector3, scene: Scene);
  38939. /**
  38940. * Gets the current object class name.
  38941. * @return the class name
  38942. */
  38943. getClassName(): string;
  38944. }
  38945. }
  38946. declare module BABYLON {
  38947. /**
  38948. * This represents all the required metrics to create a VR camera.
  38949. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38950. */
  38951. export class VRCameraMetrics {
  38952. /**
  38953. * Define the horizontal resolution off the screen.
  38954. */
  38955. hResolution: number;
  38956. /**
  38957. * Define the vertical resolution off the screen.
  38958. */
  38959. vResolution: number;
  38960. /**
  38961. * Define the horizontal screen size.
  38962. */
  38963. hScreenSize: number;
  38964. /**
  38965. * Define the vertical screen size.
  38966. */
  38967. vScreenSize: number;
  38968. /**
  38969. * Define the vertical screen center position.
  38970. */
  38971. vScreenCenter: number;
  38972. /**
  38973. * Define the distance of the eyes to the screen.
  38974. */
  38975. eyeToScreenDistance: number;
  38976. /**
  38977. * Define the distance between both lenses
  38978. */
  38979. lensSeparationDistance: number;
  38980. /**
  38981. * Define the distance between both viewer's eyes.
  38982. */
  38983. interpupillaryDistance: number;
  38984. /**
  38985. * Define the distortion factor of the VR postprocess.
  38986. * Please, touch with care.
  38987. */
  38988. distortionK: number[];
  38989. /**
  38990. * Define the chromatic aberration correction factors for the VR post process.
  38991. */
  38992. chromaAbCorrection: number[];
  38993. /**
  38994. * Define the scale factor of the post process.
  38995. * The smaller the better but the slower.
  38996. */
  38997. postProcessScaleFactor: number;
  38998. /**
  38999. * Define an offset for the lens center.
  39000. */
  39001. lensCenterOffset: number;
  39002. /**
  39003. * Define if the current vr camera should compensate the distortion of the lense or not.
  39004. */
  39005. compensateDistortion: boolean;
  39006. /**
  39007. * Defines if multiview should be enabled when rendering (Default: false)
  39008. */
  39009. multiviewEnabled: boolean;
  39010. /**
  39011. * Gets the rendering aspect ratio based on the provided resolutions.
  39012. */
  39013. readonly aspectRatio: number;
  39014. /**
  39015. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39016. */
  39017. readonly aspectRatioFov: number;
  39018. /**
  39019. * @hidden
  39020. */
  39021. readonly leftHMatrix: Matrix;
  39022. /**
  39023. * @hidden
  39024. */
  39025. readonly rightHMatrix: Matrix;
  39026. /**
  39027. * @hidden
  39028. */
  39029. readonly leftPreViewMatrix: Matrix;
  39030. /**
  39031. * @hidden
  39032. */
  39033. readonly rightPreViewMatrix: Matrix;
  39034. /**
  39035. * Get the default VRMetrics based on the most generic setup.
  39036. * @returns the default vr metrics
  39037. */
  39038. static GetDefault(): VRCameraMetrics;
  39039. }
  39040. }
  39041. declare module BABYLON {
  39042. /** @hidden */
  39043. export var vrDistortionCorrectionPixelShader: {
  39044. name: string;
  39045. shader: string;
  39046. };
  39047. }
  39048. declare module BABYLON {
  39049. /**
  39050. * VRDistortionCorrectionPostProcess used for mobile VR
  39051. */
  39052. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39053. private _isRightEye;
  39054. private _distortionFactors;
  39055. private _postProcessScaleFactor;
  39056. private _lensCenterOffset;
  39057. private _scaleIn;
  39058. private _scaleFactor;
  39059. private _lensCenter;
  39060. /**
  39061. * Initializes the VRDistortionCorrectionPostProcess
  39062. * @param name The name of the effect.
  39063. * @param camera The camera to apply the render pass to.
  39064. * @param isRightEye If this is for the right eye distortion
  39065. * @param vrMetrics All the required metrics for the VR camera
  39066. */
  39067. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39068. }
  39069. }
  39070. declare module BABYLON {
  39071. /**
  39072. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39073. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39074. */
  39075. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39076. /**
  39077. * Creates a new VRDeviceOrientationArcRotateCamera
  39078. * @param name defines camera name
  39079. * @param alpha defines the camera rotation along the logitudinal axis
  39080. * @param beta defines the camera rotation along the latitudinal axis
  39081. * @param radius defines the camera distance from its target
  39082. * @param target defines the camera target
  39083. * @param scene defines the scene the camera belongs to
  39084. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39085. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39086. */
  39087. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39088. /**
  39089. * Gets camera class name
  39090. * @returns VRDeviceOrientationArcRotateCamera
  39091. */
  39092. getClassName(): string;
  39093. }
  39094. }
  39095. declare module BABYLON {
  39096. /**
  39097. * Camera used to simulate VR rendering (based on FreeCamera)
  39098. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39099. */
  39100. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39101. /**
  39102. * Creates a new VRDeviceOrientationFreeCamera
  39103. * @param name defines camera name
  39104. * @param position defines the start position of the camera
  39105. * @param scene defines the scene the camera belongs to
  39106. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39107. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39108. */
  39109. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39110. /**
  39111. * Gets camera class name
  39112. * @returns VRDeviceOrientationFreeCamera
  39113. */
  39114. getClassName(): string;
  39115. }
  39116. }
  39117. declare module BABYLON {
  39118. /**
  39119. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39120. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39121. */
  39122. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39123. /**
  39124. * Creates a new VRDeviceOrientationGamepadCamera
  39125. * @param name defines camera name
  39126. * @param position defines the start position of the camera
  39127. * @param scene defines the scene the camera belongs to
  39128. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39129. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39130. */
  39131. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39132. /**
  39133. * Gets camera class name
  39134. * @returns VRDeviceOrientationGamepadCamera
  39135. */
  39136. getClassName(): string;
  39137. }
  39138. }
  39139. declare module BABYLON {
  39140. /**
  39141. * Base class of materials working in push mode in babylon JS
  39142. * @hidden
  39143. */
  39144. export class PushMaterial extends Material {
  39145. protected _activeEffect: Effect;
  39146. protected _normalMatrix: Matrix;
  39147. /**
  39148. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39149. * This means that the material can keep using a previous shader while a new one is being compiled.
  39150. * This is mostly used when shader parallel compilation is supported (true by default)
  39151. */
  39152. allowShaderHotSwapping: boolean;
  39153. constructor(name: string, scene: Scene);
  39154. getEffect(): Effect;
  39155. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39156. /**
  39157. * Binds the given world matrix to the active effect
  39158. *
  39159. * @param world the matrix to bind
  39160. */
  39161. bindOnlyWorldMatrix(world: Matrix): void;
  39162. /**
  39163. * Binds the given normal matrix to the active effect
  39164. *
  39165. * @param normalMatrix the matrix to bind
  39166. */
  39167. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39168. bind(world: Matrix, mesh?: Mesh): void;
  39169. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39170. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39171. }
  39172. }
  39173. declare module BABYLON {
  39174. /**
  39175. * This groups all the flags used to control the materials channel.
  39176. */
  39177. export class MaterialFlags {
  39178. private static _DiffuseTextureEnabled;
  39179. /**
  39180. * Are diffuse textures enabled in the application.
  39181. */
  39182. static DiffuseTextureEnabled: boolean;
  39183. private static _AmbientTextureEnabled;
  39184. /**
  39185. * Are ambient textures enabled in the application.
  39186. */
  39187. static AmbientTextureEnabled: boolean;
  39188. private static _OpacityTextureEnabled;
  39189. /**
  39190. * Are opacity textures enabled in the application.
  39191. */
  39192. static OpacityTextureEnabled: boolean;
  39193. private static _ReflectionTextureEnabled;
  39194. /**
  39195. * Are reflection textures enabled in the application.
  39196. */
  39197. static ReflectionTextureEnabled: boolean;
  39198. private static _EmissiveTextureEnabled;
  39199. /**
  39200. * Are emissive textures enabled in the application.
  39201. */
  39202. static EmissiveTextureEnabled: boolean;
  39203. private static _SpecularTextureEnabled;
  39204. /**
  39205. * Are specular textures enabled in the application.
  39206. */
  39207. static SpecularTextureEnabled: boolean;
  39208. private static _BumpTextureEnabled;
  39209. /**
  39210. * Are bump textures enabled in the application.
  39211. */
  39212. static BumpTextureEnabled: boolean;
  39213. private static _LightmapTextureEnabled;
  39214. /**
  39215. * Are lightmap textures enabled in the application.
  39216. */
  39217. static LightmapTextureEnabled: boolean;
  39218. private static _RefractionTextureEnabled;
  39219. /**
  39220. * Are refraction textures enabled in the application.
  39221. */
  39222. static RefractionTextureEnabled: boolean;
  39223. private static _ColorGradingTextureEnabled;
  39224. /**
  39225. * Are color grading textures enabled in the application.
  39226. */
  39227. static ColorGradingTextureEnabled: boolean;
  39228. private static _FresnelEnabled;
  39229. /**
  39230. * Are fresnels enabled in the application.
  39231. */
  39232. static FresnelEnabled: boolean;
  39233. private static _ClearCoatTextureEnabled;
  39234. /**
  39235. * Are clear coat textures enabled in the application.
  39236. */
  39237. static ClearCoatTextureEnabled: boolean;
  39238. private static _ClearCoatBumpTextureEnabled;
  39239. /**
  39240. * Are clear coat bump textures enabled in the application.
  39241. */
  39242. static ClearCoatBumpTextureEnabled: boolean;
  39243. private static _ClearCoatTintTextureEnabled;
  39244. /**
  39245. * Are clear coat tint textures enabled in the application.
  39246. */
  39247. static ClearCoatTintTextureEnabled: boolean;
  39248. private static _SheenTextureEnabled;
  39249. /**
  39250. * Are sheen textures enabled in the application.
  39251. */
  39252. static SheenTextureEnabled: boolean;
  39253. private static _AnisotropicTextureEnabled;
  39254. /**
  39255. * Are anisotropic textures enabled in the application.
  39256. */
  39257. static AnisotropicTextureEnabled: boolean;
  39258. private static _ThicknessTextureEnabled;
  39259. /**
  39260. * Are thickness textures enabled in the application.
  39261. */
  39262. static ThicknessTextureEnabled: boolean;
  39263. }
  39264. }
  39265. declare module BABYLON {
  39266. /** @hidden */
  39267. export var defaultFragmentDeclaration: {
  39268. name: string;
  39269. shader: string;
  39270. };
  39271. }
  39272. declare module BABYLON {
  39273. /** @hidden */
  39274. export var defaultUboDeclaration: {
  39275. name: string;
  39276. shader: string;
  39277. };
  39278. }
  39279. declare module BABYLON {
  39280. /** @hidden */
  39281. export var lightFragmentDeclaration: {
  39282. name: string;
  39283. shader: string;
  39284. };
  39285. }
  39286. declare module BABYLON {
  39287. /** @hidden */
  39288. export var lightUboDeclaration: {
  39289. name: string;
  39290. shader: string;
  39291. };
  39292. }
  39293. declare module BABYLON {
  39294. /** @hidden */
  39295. export var lightsFragmentFunctions: {
  39296. name: string;
  39297. shader: string;
  39298. };
  39299. }
  39300. declare module BABYLON {
  39301. /** @hidden */
  39302. export var shadowsFragmentFunctions: {
  39303. name: string;
  39304. shader: string;
  39305. };
  39306. }
  39307. declare module BABYLON {
  39308. /** @hidden */
  39309. export var fresnelFunction: {
  39310. name: string;
  39311. shader: string;
  39312. };
  39313. }
  39314. declare module BABYLON {
  39315. /** @hidden */
  39316. export var reflectionFunction: {
  39317. name: string;
  39318. shader: string;
  39319. };
  39320. }
  39321. declare module BABYLON {
  39322. /** @hidden */
  39323. export var bumpFragmentFunctions: {
  39324. name: string;
  39325. shader: string;
  39326. };
  39327. }
  39328. declare module BABYLON {
  39329. /** @hidden */
  39330. export var logDepthDeclaration: {
  39331. name: string;
  39332. shader: string;
  39333. };
  39334. }
  39335. declare module BABYLON {
  39336. /** @hidden */
  39337. export var bumpFragment: {
  39338. name: string;
  39339. shader: string;
  39340. };
  39341. }
  39342. declare module BABYLON {
  39343. /** @hidden */
  39344. export var depthPrePass: {
  39345. name: string;
  39346. shader: string;
  39347. };
  39348. }
  39349. declare module BABYLON {
  39350. /** @hidden */
  39351. export var lightFragment: {
  39352. name: string;
  39353. shader: string;
  39354. };
  39355. }
  39356. declare module BABYLON {
  39357. /** @hidden */
  39358. export var logDepthFragment: {
  39359. name: string;
  39360. shader: string;
  39361. };
  39362. }
  39363. declare module BABYLON {
  39364. /** @hidden */
  39365. export var defaultPixelShader: {
  39366. name: string;
  39367. shader: string;
  39368. };
  39369. }
  39370. declare module BABYLON {
  39371. /** @hidden */
  39372. export var defaultVertexDeclaration: {
  39373. name: string;
  39374. shader: string;
  39375. };
  39376. }
  39377. declare module BABYLON {
  39378. /** @hidden */
  39379. export var bumpVertexDeclaration: {
  39380. name: string;
  39381. shader: string;
  39382. };
  39383. }
  39384. declare module BABYLON {
  39385. /** @hidden */
  39386. export var bumpVertex: {
  39387. name: string;
  39388. shader: string;
  39389. };
  39390. }
  39391. declare module BABYLON {
  39392. /** @hidden */
  39393. export var fogVertex: {
  39394. name: string;
  39395. shader: string;
  39396. };
  39397. }
  39398. declare module BABYLON {
  39399. /** @hidden */
  39400. export var shadowsVertex: {
  39401. name: string;
  39402. shader: string;
  39403. };
  39404. }
  39405. declare module BABYLON {
  39406. /** @hidden */
  39407. export var pointCloudVertex: {
  39408. name: string;
  39409. shader: string;
  39410. };
  39411. }
  39412. declare module BABYLON {
  39413. /** @hidden */
  39414. export var logDepthVertex: {
  39415. name: string;
  39416. shader: string;
  39417. };
  39418. }
  39419. declare module BABYLON {
  39420. /** @hidden */
  39421. export var defaultVertexShader: {
  39422. name: string;
  39423. shader: string;
  39424. };
  39425. }
  39426. declare module BABYLON {
  39427. /** @hidden */
  39428. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39429. MAINUV1: boolean;
  39430. MAINUV2: boolean;
  39431. DIFFUSE: boolean;
  39432. DIFFUSEDIRECTUV: number;
  39433. AMBIENT: boolean;
  39434. AMBIENTDIRECTUV: number;
  39435. OPACITY: boolean;
  39436. OPACITYDIRECTUV: number;
  39437. OPACITYRGB: boolean;
  39438. REFLECTION: boolean;
  39439. EMISSIVE: boolean;
  39440. EMISSIVEDIRECTUV: number;
  39441. SPECULAR: boolean;
  39442. SPECULARDIRECTUV: number;
  39443. BUMP: boolean;
  39444. BUMPDIRECTUV: number;
  39445. PARALLAX: boolean;
  39446. PARALLAXOCCLUSION: boolean;
  39447. SPECULAROVERALPHA: boolean;
  39448. CLIPPLANE: boolean;
  39449. CLIPPLANE2: boolean;
  39450. CLIPPLANE3: boolean;
  39451. CLIPPLANE4: boolean;
  39452. ALPHATEST: boolean;
  39453. DEPTHPREPASS: boolean;
  39454. ALPHAFROMDIFFUSE: boolean;
  39455. POINTSIZE: boolean;
  39456. FOG: boolean;
  39457. SPECULARTERM: boolean;
  39458. DIFFUSEFRESNEL: boolean;
  39459. OPACITYFRESNEL: boolean;
  39460. REFLECTIONFRESNEL: boolean;
  39461. REFRACTIONFRESNEL: boolean;
  39462. EMISSIVEFRESNEL: boolean;
  39463. FRESNEL: boolean;
  39464. NORMAL: boolean;
  39465. UV1: boolean;
  39466. UV2: boolean;
  39467. VERTEXCOLOR: boolean;
  39468. VERTEXALPHA: boolean;
  39469. NUM_BONE_INFLUENCERS: number;
  39470. BonesPerMesh: number;
  39471. BONETEXTURE: boolean;
  39472. INSTANCES: boolean;
  39473. GLOSSINESS: boolean;
  39474. ROUGHNESS: boolean;
  39475. EMISSIVEASILLUMINATION: boolean;
  39476. LINKEMISSIVEWITHDIFFUSE: boolean;
  39477. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39478. LIGHTMAP: boolean;
  39479. LIGHTMAPDIRECTUV: number;
  39480. OBJECTSPACE_NORMALMAP: boolean;
  39481. USELIGHTMAPASSHADOWMAP: boolean;
  39482. REFLECTIONMAP_3D: boolean;
  39483. REFLECTIONMAP_SPHERICAL: boolean;
  39484. REFLECTIONMAP_PLANAR: boolean;
  39485. REFLECTIONMAP_CUBIC: boolean;
  39486. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39487. REFLECTIONMAP_PROJECTION: boolean;
  39488. REFLECTIONMAP_SKYBOX: boolean;
  39489. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39490. REFLECTIONMAP_EXPLICIT: boolean;
  39491. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39492. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39493. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39494. INVERTCUBICMAP: boolean;
  39495. LOGARITHMICDEPTH: boolean;
  39496. REFRACTION: boolean;
  39497. REFRACTIONMAP_3D: boolean;
  39498. REFLECTIONOVERALPHA: boolean;
  39499. TWOSIDEDLIGHTING: boolean;
  39500. SHADOWFLOAT: boolean;
  39501. MORPHTARGETS: boolean;
  39502. MORPHTARGETS_NORMAL: boolean;
  39503. MORPHTARGETS_TANGENT: boolean;
  39504. MORPHTARGETS_UV: boolean;
  39505. NUM_MORPH_INFLUENCERS: number;
  39506. NONUNIFORMSCALING: boolean;
  39507. PREMULTIPLYALPHA: boolean;
  39508. IMAGEPROCESSING: boolean;
  39509. VIGNETTE: boolean;
  39510. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39511. VIGNETTEBLENDMODEOPAQUE: boolean;
  39512. TONEMAPPING: boolean;
  39513. TONEMAPPING_ACES: boolean;
  39514. CONTRAST: boolean;
  39515. COLORCURVES: boolean;
  39516. COLORGRADING: boolean;
  39517. COLORGRADING3D: boolean;
  39518. SAMPLER3DGREENDEPTH: boolean;
  39519. SAMPLER3DBGRMAP: boolean;
  39520. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39521. MULTIVIEW: boolean;
  39522. /**
  39523. * If the reflection texture on this material is in linear color space
  39524. * @hidden
  39525. */
  39526. IS_REFLECTION_LINEAR: boolean;
  39527. /**
  39528. * If the refraction texture on this material is in linear color space
  39529. * @hidden
  39530. */
  39531. IS_REFRACTION_LINEAR: boolean;
  39532. EXPOSURE: boolean;
  39533. constructor();
  39534. setReflectionMode(modeToEnable: string): void;
  39535. }
  39536. /**
  39537. * This is the default material used in Babylon. It is the best trade off between quality
  39538. * and performances.
  39539. * @see http://doc.babylonjs.com/babylon101/materials
  39540. */
  39541. export class StandardMaterial extends PushMaterial {
  39542. private _diffuseTexture;
  39543. /**
  39544. * The basic texture of the material as viewed under a light.
  39545. */
  39546. diffuseTexture: Nullable<BaseTexture>;
  39547. private _ambientTexture;
  39548. /**
  39549. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39550. */
  39551. ambientTexture: Nullable<BaseTexture>;
  39552. private _opacityTexture;
  39553. /**
  39554. * Define the transparency of the material from a texture.
  39555. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39556. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39557. */
  39558. opacityTexture: Nullable<BaseTexture>;
  39559. private _reflectionTexture;
  39560. /**
  39561. * Define the texture used to display the reflection.
  39562. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39563. */
  39564. reflectionTexture: Nullable<BaseTexture>;
  39565. private _emissiveTexture;
  39566. /**
  39567. * Define texture of the material as if self lit.
  39568. * This will be mixed in the final result even in the absence of light.
  39569. */
  39570. emissiveTexture: Nullable<BaseTexture>;
  39571. private _specularTexture;
  39572. /**
  39573. * Define how the color and intensity of the highlight given by the light in the material.
  39574. */
  39575. specularTexture: Nullable<BaseTexture>;
  39576. private _bumpTexture;
  39577. /**
  39578. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39579. * 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.
  39580. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39581. */
  39582. bumpTexture: Nullable<BaseTexture>;
  39583. private _lightmapTexture;
  39584. /**
  39585. * Complex lighting can be computationally expensive to compute at runtime.
  39586. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39587. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39588. */
  39589. lightmapTexture: Nullable<BaseTexture>;
  39590. private _refractionTexture;
  39591. /**
  39592. * Define the texture used to display the refraction.
  39593. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39594. */
  39595. refractionTexture: Nullable<BaseTexture>;
  39596. /**
  39597. * The color of the material lit by the environmental background lighting.
  39598. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39599. */
  39600. ambientColor: Color3;
  39601. /**
  39602. * The basic color of the material as viewed under a light.
  39603. */
  39604. diffuseColor: Color3;
  39605. /**
  39606. * Define how the color and intensity of the highlight given by the light in the material.
  39607. */
  39608. specularColor: Color3;
  39609. /**
  39610. * Define the color of the material as if self lit.
  39611. * This will be mixed in the final result even in the absence of light.
  39612. */
  39613. emissiveColor: Color3;
  39614. /**
  39615. * Defines how sharp are the highlights in the material.
  39616. * The bigger the value the sharper giving a more glossy feeling to the result.
  39617. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39618. */
  39619. specularPower: number;
  39620. private _useAlphaFromDiffuseTexture;
  39621. /**
  39622. * Does the transparency come from the diffuse texture alpha channel.
  39623. */
  39624. useAlphaFromDiffuseTexture: boolean;
  39625. private _useEmissiveAsIllumination;
  39626. /**
  39627. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39628. */
  39629. useEmissiveAsIllumination: boolean;
  39630. private _linkEmissiveWithDiffuse;
  39631. /**
  39632. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39633. * the emissive level when the final color is close to one.
  39634. */
  39635. linkEmissiveWithDiffuse: boolean;
  39636. private _useSpecularOverAlpha;
  39637. /**
  39638. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39639. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39640. */
  39641. useSpecularOverAlpha: boolean;
  39642. private _useReflectionOverAlpha;
  39643. /**
  39644. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39645. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39646. */
  39647. useReflectionOverAlpha: boolean;
  39648. private _disableLighting;
  39649. /**
  39650. * Does lights from the scene impacts this material.
  39651. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39652. */
  39653. disableLighting: boolean;
  39654. private _useObjectSpaceNormalMap;
  39655. /**
  39656. * Allows using an object space normal map (instead of tangent space).
  39657. */
  39658. useObjectSpaceNormalMap: boolean;
  39659. private _useParallax;
  39660. /**
  39661. * Is parallax enabled or not.
  39662. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39663. */
  39664. useParallax: boolean;
  39665. private _useParallaxOcclusion;
  39666. /**
  39667. * Is parallax occlusion enabled or not.
  39668. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39669. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39670. */
  39671. useParallaxOcclusion: boolean;
  39672. /**
  39673. * 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.
  39674. */
  39675. parallaxScaleBias: number;
  39676. private _roughness;
  39677. /**
  39678. * Helps to define how blurry the reflections should appears in the material.
  39679. */
  39680. roughness: number;
  39681. /**
  39682. * In case of refraction, define the value of the index of refraction.
  39683. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39684. */
  39685. indexOfRefraction: number;
  39686. /**
  39687. * Invert the refraction texture alongside the y axis.
  39688. * It can be useful with procedural textures or probe for instance.
  39689. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39690. */
  39691. invertRefractionY: boolean;
  39692. /**
  39693. * Defines the alpha limits in alpha test mode.
  39694. */
  39695. alphaCutOff: number;
  39696. private _useLightmapAsShadowmap;
  39697. /**
  39698. * In case of light mapping, define whether the map contains light or shadow informations.
  39699. */
  39700. useLightmapAsShadowmap: boolean;
  39701. private _diffuseFresnelParameters;
  39702. /**
  39703. * Define the diffuse fresnel parameters of the material.
  39704. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39705. */
  39706. diffuseFresnelParameters: FresnelParameters;
  39707. private _opacityFresnelParameters;
  39708. /**
  39709. * Define the opacity fresnel parameters of the material.
  39710. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39711. */
  39712. opacityFresnelParameters: FresnelParameters;
  39713. private _reflectionFresnelParameters;
  39714. /**
  39715. * Define the reflection fresnel parameters of the material.
  39716. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39717. */
  39718. reflectionFresnelParameters: FresnelParameters;
  39719. private _refractionFresnelParameters;
  39720. /**
  39721. * Define the refraction fresnel parameters of the material.
  39722. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39723. */
  39724. refractionFresnelParameters: FresnelParameters;
  39725. private _emissiveFresnelParameters;
  39726. /**
  39727. * Define the emissive fresnel parameters of the material.
  39728. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39729. */
  39730. emissiveFresnelParameters: FresnelParameters;
  39731. private _useReflectionFresnelFromSpecular;
  39732. /**
  39733. * If true automatically deducts the fresnels values from the material specularity.
  39734. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39735. */
  39736. useReflectionFresnelFromSpecular: boolean;
  39737. private _useGlossinessFromSpecularMapAlpha;
  39738. /**
  39739. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39740. */
  39741. useGlossinessFromSpecularMapAlpha: boolean;
  39742. private _maxSimultaneousLights;
  39743. /**
  39744. * Defines the maximum number of lights that can be used in the material
  39745. */
  39746. maxSimultaneousLights: number;
  39747. private _invertNormalMapX;
  39748. /**
  39749. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39750. */
  39751. invertNormalMapX: boolean;
  39752. private _invertNormalMapY;
  39753. /**
  39754. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39755. */
  39756. invertNormalMapY: boolean;
  39757. private _twoSidedLighting;
  39758. /**
  39759. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39760. */
  39761. twoSidedLighting: boolean;
  39762. /**
  39763. * Default configuration related to image processing available in the standard Material.
  39764. */
  39765. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39766. /**
  39767. * Gets the image processing configuration used either in this material.
  39768. */
  39769. /**
  39770. * Sets the Default image processing configuration used either in the this material.
  39771. *
  39772. * If sets to null, the scene one is in use.
  39773. */
  39774. imageProcessingConfiguration: ImageProcessingConfiguration;
  39775. /**
  39776. * Keep track of the image processing observer to allow dispose and replace.
  39777. */
  39778. private _imageProcessingObserver;
  39779. /**
  39780. * Attaches a new image processing configuration to the Standard Material.
  39781. * @param configuration
  39782. */
  39783. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39784. /**
  39785. * Gets wether the color curves effect is enabled.
  39786. */
  39787. /**
  39788. * Sets wether the color curves effect is enabled.
  39789. */
  39790. cameraColorCurvesEnabled: boolean;
  39791. /**
  39792. * Gets wether the color grading effect is enabled.
  39793. */
  39794. /**
  39795. * Gets wether the color grading effect is enabled.
  39796. */
  39797. cameraColorGradingEnabled: boolean;
  39798. /**
  39799. * Gets wether tonemapping is enabled or not.
  39800. */
  39801. /**
  39802. * Sets wether tonemapping is enabled or not
  39803. */
  39804. cameraToneMappingEnabled: boolean;
  39805. /**
  39806. * The camera exposure used on this material.
  39807. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39808. * This corresponds to a photographic exposure.
  39809. */
  39810. /**
  39811. * The camera exposure used on this material.
  39812. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39813. * This corresponds to a photographic exposure.
  39814. */
  39815. cameraExposure: number;
  39816. /**
  39817. * Gets The camera contrast used on this material.
  39818. */
  39819. /**
  39820. * Sets The camera contrast used on this material.
  39821. */
  39822. cameraContrast: number;
  39823. /**
  39824. * Gets the Color Grading 2D Lookup Texture.
  39825. */
  39826. /**
  39827. * Sets the Color Grading 2D Lookup Texture.
  39828. */
  39829. cameraColorGradingTexture: Nullable<BaseTexture>;
  39830. /**
  39831. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39832. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39833. * 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;
  39834. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39835. */
  39836. /**
  39837. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39838. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39839. * 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;
  39840. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39841. */
  39842. cameraColorCurves: Nullable<ColorCurves>;
  39843. /**
  39844. * Custom callback helping to override the default shader used in the material.
  39845. */
  39846. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39847. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39848. protected _worldViewProjectionMatrix: Matrix;
  39849. protected _globalAmbientColor: Color3;
  39850. protected _useLogarithmicDepth: boolean;
  39851. protected _rebuildInParallel: boolean;
  39852. /**
  39853. * Instantiates a new standard material.
  39854. * This is the default material used in Babylon. It is the best trade off between quality
  39855. * and performances.
  39856. * @see http://doc.babylonjs.com/babylon101/materials
  39857. * @param name Define the name of the material in the scene
  39858. * @param scene Define the scene the material belong to
  39859. */
  39860. constructor(name: string, scene: Scene);
  39861. /**
  39862. * Gets a boolean indicating that current material needs to register RTT
  39863. */
  39864. readonly hasRenderTargetTextures: boolean;
  39865. /**
  39866. * Gets the current class name of the material e.g. "StandardMaterial"
  39867. * Mainly use in serialization.
  39868. * @returns the class name
  39869. */
  39870. getClassName(): string;
  39871. /**
  39872. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39873. * You can try switching to logarithmic depth.
  39874. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39875. */
  39876. useLogarithmicDepth: boolean;
  39877. /**
  39878. * Specifies if the material will require alpha blending
  39879. * @returns a boolean specifying if alpha blending is needed
  39880. */
  39881. needAlphaBlending(): boolean;
  39882. /**
  39883. * Specifies if this material should be rendered in alpha test mode
  39884. * @returns a boolean specifying if an alpha test is needed.
  39885. */
  39886. needAlphaTesting(): boolean;
  39887. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39888. /**
  39889. * Get the texture used for alpha test purpose.
  39890. * @returns the diffuse texture in case of the standard material.
  39891. */
  39892. getAlphaTestTexture(): Nullable<BaseTexture>;
  39893. /**
  39894. * Get if the submesh is ready to be used and all its information available.
  39895. * Child classes can use it to update shaders
  39896. * @param mesh defines the mesh to check
  39897. * @param subMesh defines which submesh to check
  39898. * @param useInstances specifies that instances should be used
  39899. * @returns a boolean indicating that the submesh is ready or not
  39900. */
  39901. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39902. /**
  39903. * Builds the material UBO layouts.
  39904. * Used internally during the effect preparation.
  39905. */
  39906. buildUniformLayout(): void;
  39907. /**
  39908. * Unbinds the material from the mesh
  39909. */
  39910. unbind(): void;
  39911. /**
  39912. * Binds the submesh to this material by preparing the effect and shader to draw
  39913. * @param world defines the world transformation matrix
  39914. * @param mesh defines the mesh containing the submesh
  39915. * @param subMesh defines the submesh to bind the material to
  39916. */
  39917. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39918. /**
  39919. * Get the list of animatables in the material.
  39920. * @returns the list of animatables object used in the material
  39921. */
  39922. getAnimatables(): IAnimatable[];
  39923. /**
  39924. * Gets the active textures from the material
  39925. * @returns an array of textures
  39926. */
  39927. getActiveTextures(): BaseTexture[];
  39928. /**
  39929. * Specifies if the material uses a texture
  39930. * @param texture defines the texture to check against the material
  39931. * @returns a boolean specifying if the material uses the texture
  39932. */
  39933. hasTexture(texture: BaseTexture): boolean;
  39934. /**
  39935. * Disposes the material
  39936. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39937. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39938. */
  39939. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39940. /**
  39941. * Makes a duplicate of the material, and gives it a new name
  39942. * @param name defines the new name for the duplicated material
  39943. * @returns the cloned material
  39944. */
  39945. clone(name: string): StandardMaterial;
  39946. /**
  39947. * Serializes this material in a JSON representation
  39948. * @returns the serialized material object
  39949. */
  39950. serialize(): any;
  39951. /**
  39952. * Creates a standard material from parsed material data
  39953. * @param source defines the JSON representation of the material
  39954. * @param scene defines the hosting scene
  39955. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39956. * @returns a new standard material
  39957. */
  39958. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39959. /**
  39960. * Are diffuse textures enabled in the application.
  39961. */
  39962. static DiffuseTextureEnabled: boolean;
  39963. /**
  39964. * Are ambient textures enabled in the application.
  39965. */
  39966. static AmbientTextureEnabled: boolean;
  39967. /**
  39968. * Are opacity textures enabled in the application.
  39969. */
  39970. static OpacityTextureEnabled: boolean;
  39971. /**
  39972. * Are reflection textures enabled in the application.
  39973. */
  39974. static ReflectionTextureEnabled: boolean;
  39975. /**
  39976. * Are emissive textures enabled in the application.
  39977. */
  39978. static EmissiveTextureEnabled: boolean;
  39979. /**
  39980. * Are specular textures enabled in the application.
  39981. */
  39982. static SpecularTextureEnabled: boolean;
  39983. /**
  39984. * Are bump textures enabled in the application.
  39985. */
  39986. static BumpTextureEnabled: boolean;
  39987. /**
  39988. * Are lightmap textures enabled in the application.
  39989. */
  39990. static LightmapTextureEnabled: boolean;
  39991. /**
  39992. * Are refraction textures enabled in the application.
  39993. */
  39994. static RefractionTextureEnabled: boolean;
  39995. /**
  39996. * Are color grading textures enabled in the application.
  39997. */
  39998. static ColorGradingTextureEnabled: boolean;
  39999. /**
  40000. * Are fresnels enabled in the application.
  40001. */
  40002. static FresnelEnabled: boolean;
  40003. }
  40004. }
  40005. declare module BABYLON {
  40006. /** @hidden */
  40007. export var imageProcessingPixelShader: {
  40008. name: string;
  40009. shader: string;
  40010. };
  40011. }
  40012. declare module BABYLON {
  40013. /**
  40014. * ImageProcessingPostProcess
  40015. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40016. */
  40017. export class ImageProcessingPostProcess extends PostProcess {
  40018. /**
  40019. * Default configuration related to image processing available in the PBR Material.
  40020. */
  40021. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40022. /**
  40023. * Gets the image processing configuration used either in this material.
  40024. */
  40025. /**
  40026. * Sets the Default image processing configuration used either in the this material.
  40027. *
  40028. * If sets to null, the scene one is in use.
  40029. */
  40030. imageProcessingConfiguration: ImageProcessingConfiguration;
  40031. /**
  40032. * Keep track of the image processing observer to allow dispose and replace.
  40033. */
  40034. private _imageProcessingObserver;
  40035. /**
  40036. * Attaches a new image processing configuration to the PBR Material.
  40037. * @param configuration
  40038. */
  40039. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40040. /**
  40041. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40042. */
  40043. /**
  40044. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40045. */
  40046. colorCurves: Nullable<ColorCurves>;
  40047. /**
  40048. * Gets wether the color curves effect is enabled.
  40049. */
  40050. /**
  40051. * Sets wether the color curves effect is enabled.
  40052. */
  40053. colorCurvesEnabled: boolean;
  40054. /**
  40055. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40056. */
  40057. /**
  40058. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40059. */
  40060. colorGradingTexture: Nullable<BaseTexture>;
  40061. /**
  40062. * Gets wether the color grading effect is enabled.
  40063. */
  40064. /**
  40065. * Gets wether the color grading effect is enabled.
  40066. */
  40067. colorGradingEnabled: boolean;
  40068. /**
  40069. * Gets exposure used in the effect.
  40070. */
  40071. /**
  40072. * Sets exposure used in the effect.
  40073. */
  40074. exposure: number;
  40075. /**
  40076. * Gets wether tonemapping is enabled or not.
  40077. */
  40078. /**
  40079. * Sets wether tonemapping is enabled or not
  40080. */
  40081. toneMappingEnabled: boolean;
  40082. /**
  40083. * Gets the type of tone mapping effect.
  40084. */
  40085. /**
  40086. * Sets the type of tone mapping effect.
  40087. */
  40088. toneMappingType: number;
  40089. /**
  40090. * Gets contrast used in the effect.
  40091. */
  40092. /**
  40093. * Sets contrast used in the effect.
  40094. */
  40095. contrast: number;
  40096. /**
  40097. * Gets Vignette stretch size.
  40098. */
  40099. /**
  40100. * Sets Vignette stretch size.
  40101. */
  40102. vignetteStretch: number;
  40103. /**
  40104. * Gets Vignette centre X Offset.
  40105. */
  40106. /**
  40107. * Sets Vignette centre X Offset.
  40108. */
  40109. vignetteCentreX: number;
  40110. /**
  40111. * Gets Vignette centre Y Offset.
  40112. */
  40113. /**
  40114. * Sets Vignette centre Y Offset.
  40115. */
  40116. vignetteCentreY: number;
  40117. /**
  40118. * Gets Vignette weight or intensity of the vignette effect.
  40119. */
  40120. /**
  40121. * Sets Vignette weight or intensity of the vignette effect.
  40122. */
  40123. vignetteWeight: number;
  40124. /**
  40125. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40126. * if vignetteEnabled is set to true.
  40127. */
  40128. /**
  40129. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40130. * if vignetteEnabled is set to true.
  40131. */
  40132. vignetteColor: Color4;
  40133. /**
  40134. * Gets Camera field of view used by the Vignette effect.
  40135. */
  40136. /**
  40137. * Sets Camera field of view used by the Vignette effect.
  40138. */
  40139. vignetteCameraFov: number;
  40140. /**
  40141. * Gets the vignette blend mode allowing different kind of effect.
  40142. */
  40143. /**
  40144. * Sets the vignette blend mode allowing different kind of effect.
  40145. */
  40146. vignetteBlendMode: number;
  40147. /**
  40148. * Gets wether the vignette effect is enabled.
  40149. */
  40150. /**
  40151. * Sets wether the vignette effect is enabled.
  40152. */
  40153. vignetteEnabled: boolean;
  40154. private _fromLinearSpace;
  40155. /**
  40156. * Gets wether the input of the processing is in Gamma or Linear Space.
  40157. */
  40158. /**
  40159. * Sets wether the input of the processing is in Gamma or Linear Space.
  40160. */
  40161. fromLinearSpace: boolean;
  40162. /**
  40163. * Defines cache preventing GC.
  40164. */
  40165. private _defines;
  40166. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40167. /**
  40168. * "ImageProcessingPostProcess"
  40169. * @returns "ImageProcessingPostProcess"
  40170. */
  40171. getClassName(): string;
  40172. protected _updateParameters(): void;
  40173. dispose(camera?: Camera): void;
  40174. }
  40175. }
  40176. declare module BABYLON {
  40177. /**
  40178. * Class containing static functions to help procedurally build meshes
  40179. */
  40180. export class GroundBuilder {
  40181. /**
  40182. * Creates a ground mesh
  40183. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40184. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40186. * @param name defines the name of the mesh
  40187. * @param options defines the options used to create the mesh
  40188. * @param scene defines the hosting scene
  40189. * @returns the ground mesh
  40190. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40191. */
  40192. static CreateGround(name: string, options: {
  40193. width?: number;
  40194. height?: number;
  40195. subdivisions?: number;
  40196. subdivisionsX?: number;
  40197. subdivisionsY?: number;
  40198. updatable?: boolean;
  40199. }, scene: any): Mesh;
  40200. /**
  40201. * Creates a tiled ground mesh
  40202. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40203. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40204. * * 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
  40205. * * 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
  40206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40207. * @param name defines the name of the mesh
  40208. * @param options defines the options used to create the mesh
  40209. * @param scene defines the hosting scene
  40210. * @returns the tiled ground mesh
  40211. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40212. */
  40213. static CreateTiledGround(name: string, options: {
  40214. xmin: number;
  40215. zmin: number;
  40216. xmax: number;
  40217. zmax: number;
  40218. subdivisions?: {
  40219. w: number;
  40220. h: number;
  40221. };
  40222. precision?: {
  40223. w: number;
  40224. h: number;
  40225. };
  40226. updatable?: boolean;
  40227. }, scene?: Nullable<Scene>): Mesh;
  40228. /**
  40229. * Creates a ground mesh from a height map
  40230. * * The parameter `url` sets the URL of the height map image resource.
  40231. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40232. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40233. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40234. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40235. * * 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.
  40236. * * 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).
  40237. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40239. * @param name defines the name of the mesh
  40240. * @param url defines the url to the height map
  40241. * @param options defines the options used to create the mesh
  40242. * @param scene defines the hosting scene
  40243. * @returns the ground mesh
  40244. * @see https://doc.babylonjs.com/babylon101/height_map
  40245. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40246. */
  40247. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40248. width?: number;
  40249. height?: number;
  40250. subdivisions?: number;
  40251. minHeight?: number;
  40252. maxHeight?: number;
  40253. colorFilter?: Color3;
  40254. alphaFilter?: number;
  40255. updatable?: boolean;
  40256. onReady?: (mesh: GroundMesh) => void;
  40257. }, scene?: Nullable<Scene>): GroundMesh;
  40258. }
  40259. }
  40260. declare module BABYLON {
  40261. /**
  40262. * Class containing static functions to help procedurally build meshes
  40263. */
  40264. export class TorusBuilder {
  40265. /**
  40266. * Creates a torus mesh
  40267. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40268. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40269. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40271. * * 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
  40272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40273. * @param name defines the name of the mesh
  40274. * @param options defines the options used to create the mesh
  40275. * @param scene defines the hosting scene
  40276. * @returns the torus mesh
  40277. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40278. */
  40279. static CreateTorus(name: string, options: {
  40280. diameter?: number;
  40281. thickness?: number;
  40282. tessellation?: number;
  40283. updatable?: boolean;
  40284. sideOrientation?: number;
  40285. frontUVs?: Vector4;
  40286. backUVs?: Vector4;
  40287. }, scene: any): Mesh;
  40288. }
  40289. }
  40290. declare module BABYLON {
  40291. /**
  40292. * Class containing static functions to help procedurally build meshes
  40293. */
  40294. export class CylinderBuilder {
  40295. /**
  40296. * Creates a cylinder or a cone mesh
  40297. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40298. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40299. * * 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.
  40300. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40301. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40302. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40303. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40304. * * 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).
  40305. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40306. * * 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).
  40307. * * 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
  40308. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40309. * * 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
  40310. * * 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.
  40311. * * If `enclose` is false, a ring surface is one element.
  40312. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40313. * * 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
  40314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40315. * * 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
  40316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40317. * @param name defines the name of the mesh
  40318. * @param options defines the options used to create the mesh
  40319. * @param scene defines the hosting scene
  40320. * @returns the cylinder mesh
  40321. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40322. */
  40323. static CreateCylinder(name: string, options: {
  40324. height?: number;
  40325. diameterTop?: number;
  40326. diameterBottom?: number;
  40327. diameter?: number;
  40328. tessellation?: number;
  40329. subdivisions?: number;
  40330. arc?: number;
  40331. faceColors?: Color4[];
  40332. faceUV?: Vector4[];
  40333. updatable?: boolean;
  40334. hasRings?: boolean;
  40335. enclose?: boolean;
  40336. cap?: number;
  40337. sideOrientation?: number;
  40338. frontUVs?: Vector4;
  40339. backUVs?: Vector4;
  40340. }, scene: any): Mesh;
  40341. }
  40342. }
  40343. declare module BABYLON {
  40344. /**
  40345. * Options to modify the vr teleportation behavior.
  40346. */
  40347. export interface VRTeleportationOptions {
  40348. /**
  40349. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40350. */
  40351. floorMeshName?: string;
  40352. /**
  40353. * A list of meshes to be used as the teleportation floor. (default: empty)
  40354. */
  40355. floorMeshes?: Mesh[];
  40356. }
  40357. /**
  40358. * Options to modify the vr experience helper's behavior.
  40359. */
  40360. export interface VRExperienceHelperOptions extends WebVROptions {
  40361. /**
  40362. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40363. */
  40364. createDeviceOrientationCamera?: boolean;
  40365. /**
  40366. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40367. */
  40368. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40369. /**
  40370. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40371. */
  40372. laserToggle?: boolean;
  40373. /**
  40374. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40375. */
  40376. floorMeshes?: Mesh[];
  40377. /**
  40378. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40379. */
  40380. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40381. }
  40382. /**
  40383. * Event containing information after VR has been entered
  40384. */
  40385. export class OnAfterEnteringVRObservableEvent {
  40386. /**
  40387. * If entering vr was successful
  40388. */
  40389. success: boolean;
  40390. }
  40391. /**
  40392. * Helps to quickly add VR support to an existing scene.
  40393. * See http://doc.babylonjs.com/how_to/webvr_helper
  40394. */
  40395. export class VRExperienceHelper {
  40396. /** Options to modify the vr experience helper's behavior. */
  40397. webVROptions: VRExperienceHelperOptions;
  40398. private _scene;
  40399. private _position;
  40400. private _btnVR;
  40401. private _btnVRDisplayed;
  40402. private _webVRsupported;
  40403. private _webVRready;
  40404. private _webVRrequesting;
  40405. private _webVRpresenting;
  40406. private _hasEnteredVR;
  40407. private _fullscreenVRpresenting;
  40408. private _canvas;
  40409. private _webVRCamera;
  40410. private _vrDeviceOrientationCamera;
  40411. private _deviceOrientationCamera;
  40412. private _existingCamera;
  40413. private _onKeyDown;
  40414. private _onVrDisplayPresentChange;
  40415. private _onVRDisplayChanged;
  40416. private _onVRRequestPresentStart;
  40417. private _onVRRequestPresentComplete;
  40418. /**
  40419. * 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)
  40420. */
  40421. enableGazeEvenWhenNoPointerLock: boolean;
  40422. /**
  40423. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40424. */
  40425. exitVROnDoubleTap: boolean;
  40426. /**
  40427. * Observable raised right before entering VR.
  40428. */
  40429. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40430. /**
  40431. * Observable raised when entering VR has completed.
  40432. */
  40433. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40434. /**
  40435. * Observable raised when exiting VR.
  40436. */
  40437. onExitingVRObservable: Observable<VRExperienceHelper>;
  40438. /**
  40439. * Observable raised when controller mesh is loaded.
  40440. */
  40441. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40442. /** Return this.onEnteringVRObservable
  40443. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40444. */
  40445. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40446. /** Return this.onExitingVRObservable
  40447. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40448. */
  40449. readonly onExitingVR: Observable<VRExperienceHelper>;
  40450. /** Return this.onControllerMeshLoadedObservable
  40451. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40452. */
  40453. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40454. private _rayLength;
  40455. private _useCustomVRButton;
  40456. private _teleportationRequested;
  40457. private _teleportActive;
  40458. private _floorMeshName;
  40459. private _floorMeshesCollection;
  40460. private _rotationAllowed;
  40461. private _teleportBackwardsVector;
  40462. private _teleportationTarget;
  40463. private _isDefaultTeleportationTarget;
  40464. private _postProcessMove;
  40465. private _teleportationFillColor;
  40466. private _teleportationBorderColor;
  40467. private _rotationAngle;
  40468. private _haloCenter;
  40469. private _cameraGazer;
  40470. private _padSensibilityUp;
  40471. private _padSensibilityDown;
  40472. private _leftController;
  40473. private _rightController;
  40474. /**
  40475. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40476. */
  40477. onNewMeshSelected: Observable<AbstractMesh>;
  40478. /**
  40479. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  40480. * This observable will provide the mesh and the controller used to select the mesh
  40481. */
  40482. onMeshSelectedWithController: Observable<{
  40483. mesh: AbstractMesh;
  40484. controller: WebVRController;
  40485. }>;
  40486. /**
  40487. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40488. */
  40489. onNewMeshPicked: Observable<PickingInfo>;
  40490. private _circleEase;
  40491. /**
  40492. * Observable raised before camera teleportation
  40493. */
  40494. onBeforeCameraTeleport: Observable<Vector3>;
  40495. /**
  40496. * Observable raised after camera teleportation
  40497. */
  40498. onAfterCameraTeleport: Observable<Vector3>;
  40499. /**
  40500. * Observable raised when current selected mesh gets unselected
  40501. */
  40502. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40503. private _raySelectionPredicate;
  40504. /**
  40505. * To be optionaly changed by user to define custom ray selection
  40506. */
  40507. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40508. /**
  40509. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40510. */
  40511. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40512. /**
  40513. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40514. */
  40515. teleportationEnabled: boolean;
  40516. private _defaultHeight;
  40517. private _teleportationInitialized;
  40518. private _interactionsEnabled;
  40519. private _interactionsRequested;
  40520. private _displayGaze;
  40521. private _displayLaserPointer;
  40522. /**
  40523. * The mesh used to display where the user is going to teleport.
  40524. */
  40525. /**
  40526. * Sets the mesh to be used to display where the user is going to teleport.
  40527. */
  40528. teleportationTarget: Mesh;
  40529. /**
  40530. * 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
  40531. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40532. * See http://doc.babylonjs.com/resources/baking_transformations
  40533. */
  40534. gazeTrackerMesh: Mesh;
  40535. /**
  40536. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40537. */
  40538. updateGazeTrackerScale: boolean;
  40539. /**
  40540. * If the gaze trackers color should be updated when selecting meshes
  40541. */
  40542. updateGazeTrackerColor: boolean;
  40543. /**
  40544. * If the controller laser color should be updated when selecting meshes
  40545. */
  40546. updateControllerLaserColor: boolean;
  40547. /**
  40548. * The gaze tracking mesh corresponding to the left controller
  40549. */
  40550. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40551. /**
  40552. * The gaze tracking mesh corresponding to the right controller
  40553. */
  40554. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40555. /**
  40556. * If the ray of the gaze should be displayed.
  40557. */
  40558. /**
  40559. * Sets if the ray of the gaze should be displayed.
  40560. */
  40561. displayGaze: boolean;
  40562. /**
  40563. * If the ray of the LaserPointer should be displayed.
  40564. */
  40565. /**
  40566. * Sets if the ray of the LaserPointer should be displayed.
  40567. */
  40568. displayLaserPointer: boolean;
  40569. /**
  40570. * The deviceOrientationCamera used as the camera when not in VR.
  40571. */
  40572. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40573. /**
  40574. * Based on the current WebVR support, returns the current VR camera used.
  40575. */
  40576. readonly currentVRCamera: Nullable<Camera>;
  40577. /**
  40578. * The webVRCamera which is used when in VR.
  40579. */
  40580. readonly webVRCamera: WebVRFreeCamera;
  40581. /**
  40582. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40583. */
  40584. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40585. /**
  40586. * The html button that is used to trigger entering into VR.
  40587. */
  40588. readonly vrButton: Nullable<HTMLButtonElement>;
  40589. private readonly _teleportationRequestInitiated;
  40590. /**
  40591. * Defines wether or not Pointer lock should be requested when switching to
  40592. * full screen.
  40593. */
  40594. requestPointerLockOnFullScreen: boolean;
  40595. /**
  40596. * Instantiates a VRExperienceHelper.
  40597. * Helps to quickly add VR support to an existing scene.
  40598. * @param scene The scene the VRExperienceHelper belongs to.
  40599. * @param webVROptions Options to modify the vr experience helper's behavior.
  40600. */
  40601. constructor(scene: Scene,
  40602. /** Options to modify the vr experience helper's behavior. */
  40603. webVROptions?: VRExperienceHelperOptions);
  40604. private _onDefaultMeshLoaded;
  40605. private _onResize;
  40606. private _onFullscreenChange;
  40607. /**
  40608. * Gets a value indicating if we are currently in VR mode.
  40609. */
  40610. readonly isInVRMode: boolean;
  40611. private onVrDisplayPresentChange;
  40612. private onVRDisplayChanged;
  40613. private moveButtonToBottomRight;
  40614. private displayVRButton;
  40615. private updateButtonVisibility;
  40616. private _cachedAngularSensibility;
  40617. /**
  40618. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40619. * Otherwise, will use the fullscreen API.
  40620. */
  40621. enterVR(): void;
  40622. /**
  40623. * Attempt to exit VR, or fullscreen.
  40624. */
  40625. exitVR(): void;
  40626. /**
  40627. * The position of the vr experience helper.
  40628. */
  40629. /**
  40630. * Sets the position of the vr experience helper.
  40631. */
  40632. position: Vector3;
  40633. /**
  40634. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40635. */
  40636. enableInteractions(): void;
  40637. private readonly _noControllerIsActive;
  40638. private beforeRender;
  40639. private _isTeleportationFloor;
  40640. /**
  40641. * Adds a floor mesh to be used for teleportation.
  40642. * @param floorMesh the mesh to be used for teleportation.
  40643. */
  40644. addFloorMesh(floorMesh: Mesh): void;
  40645. /**
  40646. * Removes a floor mesh from being used for teleportation.
  40647. * @param floorMesh the mesh to be removed.
  40648. */
  40649. removeFloorMesh(floorMesh: Mesh): void;
  40650. /**
  40651. * Enables interactions and teleportation using the VR controllers and gaze.
  40652. * @param vrTeleportationOptions options to modify teleportation behavior.
  40653. */
  40654. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40655. private _onNewGamepadConnected;
  40656. private _tryEnableInteractionOnController;
  40657. private _onNewGamepadDisconnected;
  40658. private _enableInteractionOnController;
  40659. private _checkTeleportWithRay;
  40660. private _checkRotate;
  40661. private _checkTeleportBackwards;
  40662. private _enableTeleportationOnController;
  40663. private _createTeleportationCircles;
  40664. private _displayTeleportationTarget;
  40665. private _hideTeleportationTarget;
  40666. private _rotateCamera;
  40667. private _moveTeleportationSelectorTo;
  40668. private _workingVector;
  40669. private _workingQuaternion;
  40670. private _workingMatrix;
  40671. /**
  40672. * Teleports the users feet to the desired location
  40673. * @param location The location where the user's feet should be placed
  40674. */
  40675. teleportCamera(location: Vector3): void;
  40676. private _convertNormalToDirectionOfRay;
  40677. private _castRayAndSelectObject;
  40678. private _notifySelectedMeshUnselected;
  40679. /**
  40680. * Sets the color of the laser ray from the vr controllers.
  40681. * @param color new color for the ray.
  40682. */
  40683. changeLaserColor(color: Color3): void;
  40684. /**
  40685. * Sets the color of the ray from the vr headsets gaze.
  40686. * @param color new color for the ray.
  40687. */
  40688. changeGazeColor(color: Color3): void;
  40689. /**
  40690. * Exits VR and disposes of the vr experience helper
  40691. */
  40692. dispose(): void;
  40693. /**
  40694. * Gets the name of the VRExperienceHelper class
  40695. * @returns "VRExperienceHelper"
  40696. */
  40697. getClassName(): string;
  40698. }
  40699. }
  40700. declare module BABYLON {
  40701. /**
  40702. * Manages an XRSession to work with Babylon's engine
  40703. * @see https://doc.babylonjs.com/how_to/webxr
  40704. */
  40705. export class WebXRSessionManager implements IDisposable {
  40706. private scene;
  40707. /**
  40708. * Fires every time a new xrFrame arrives which can be used to update the camera
  40709. */
  40710. onXRFrameObservable: Observable<any>;
  40711. /**
  40712. * Fires when the xr session is ended either by the device or manually done
  40713. */
  40714. onXRSessionEnded: Observable<any>;
  40715. /**
  40716. * Underlying xr session
  40717. */
  40718. session: XRSession;
  40719. /**
  40720. * Type of reference space used when creating the session
  40721. */
  40722. referenceSpace: XRReferenceSpace;
  40723. /** @hidden */ private _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40724. /**
  40725. * Current XR frame
  40726. */
  40727. currentFrame: Nullable<XRFrame>;
  40728. private _xrNavigator;
  40729. private baseLayer;
  40730. /**
  40731. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40732. * @param scene The scene which the session should be created for
  40733. */
  40734. constructor(scene: Scene);
  40735. /**
  40736. * Initializes the manager
  40737. * After initialization enterXR can be called to start an XR session
  40738. * @returns Promise which resolves after it is initialized
  40739. */
  40740. initializeAsync(): Promise<void>;
  40741. /**
  40742. * Initializes an xr session
  40743. * @param xrSessionMode mode to initialize
  40744. * @returns a promise which will resolve once the session has been initialized
  40745. */
  40746. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  40747. /**
  40748. * Sets the reference space on the xr session
  40749. * @param referenceSpace space to set
  40750. * @returns a promise that will resolve once the reference space has been set
  40751. */
  40752. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  40753. /**
  40754. * Updates the render state of the session
  40755. * @param state state to set
  40756. * @returns a promise that resolves once the render state has been updated
  40757. */
  40758. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  40759. /**
  40760. * Starts rendering to the xr layer
  40761. * @returns a promise that will resolve once rendering has started
  40762. */
  40763. startRenderingToXRAsync(): Promise<void>;
  40764. /**
  40765. * Stops the xrSession and restores the renderloop
  40766. * @returns Promise which resolves after it exits XR
  40767. */
  40768. exitXRAsync(): Promise<unknown>;
  40769. /**
  40770. * Checks if a session would be supported for the creation options specified
  40771. * @param sessionMode session mode to check if supported eg. immersive-vr
  40772. * @returns true if supported
  40773. */
  40774. supportsSessionAsync(sessionMode: XRSessionMode): any;
  40775. /**
  40776. * @hidden
  40777. * Converts the render layer of xrSession to a render target
  40778. * @param session session to create render target for
  40779. * @param scene scene the new render target should be created for
  40780. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  40781. /**
  40782. * Disposes of the session manager
  40783. */
  40784. dispose(): void;
  40785. }
  40786. }
  40787. declare module BABYLON {
  40788. /**
  40789. * WebXR Camera which holds the views for the xrSession
  40790. * @see https://doc.babylonjs.com/how_to/webxr
  40791. */
  40792. export class WebXRCamera extends FreeCamera {
  40793. private static _TmpMatrix;
  40794. /**
  40795. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40796. * @param name the name of the camera
  40797. * @param scene the scene to add the camera to
  40798. */
  40799. constructor(name: string, scene: Scene);
  40800. private _updateNumberOfRigCameras;
  40801. /** @hidden */ private _updateForDualEyeDebugging(pupilDistance?: number): void;
  40802. /**
  40803. * Updates the cameras position from the current pose information of the XR session
  40804. * @param xrSessionManager the session containing pose information
  40805. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40806. */
  40807. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40808. }
  40809. }
  40810. declare module BABYLON {
  40811. /**
  40812. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40813. */
  40814. export class WebXRManagedOutputCanvas implements IDisposable {
  40815. private helper;
  40816. private _canvas;
  40817. /**
  40818. * xrpresent context of the canvas which can be used to display/mirror xr content
  40819. */
  40820. canvasContext: WebGLRenderingContext;
  40821. /**
  40822. * xr layer for the canvas
  40823. */
  40824. xrLayer: Nullable<XRWebGLLayer>;
  40825. /**
  40826. * Initializes the xr layer for the session
  40827. * @param xrSession xr session
  40828. * @returns a promise that will resolve once the XR Layer has been created
  40829. */
  40830. initializeXRLayerAsync(xrSession: any): any;
  40831. /**
  40832. * Initializes the canvas to be added/removed upon entering/exiting xr
  40833. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40834. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40835. */
  40836. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40837. /**
  40838. * Disposes of the object
  40839. */
  40840. dispose(): void;
  40841. private _setManagedOutputCanvas;
  40842. private _addCanvas;
  40843. private _removeCanvas;
  40844. }
  40845. }
  40846. declare module BABYLON {
  40847. /**
  40848. * States of the webXR experience
  40849. */
  40850. export enum WebXRState {
  40851. /**
  40852. * Transitioning to being in XR mode
  40853. */
  40854. ENTERING_XR = 0,
  40855. /**
  40856. * Transitioning to non XR mode
  40857. */
  40858. EXITING_XR = 1,
  40859. /**
  40860. * In XR mode and presenting
  40861. */
  40862. IN_XR = 2,
  40863. /**
  40864. * Not entered XR mode
  40865. */
  40866. NOT_IN_XR = 3
  40867. }
  40868. /**
  40869. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  40870. * @see https://doc.babylonjs.com/how_to/webxr
  40871. */
  40872. export class WebXRExperienceHelper implements IDisposable {
  40873. private scene;
  40874. /**
  40875. * 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
  40876. */
  40877. container: AbstractMesh;
  40878. /**
  40879. * Camera used to render xr content
  40880. */
  40881. camera: WebXRCamera;
  40882. /**
  40883. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40884. */
  40885. state: WebXRState;
  40886. private _setState;
  40887. private static _TmpVector;
  40888. /**
  40889. * Fires when the state of the experience helper has changed
  40890. */
  40891. onStateChangedObservable: Observable<WebXRState>;
  40892. /** Session manager used to keep track of xr session */
  40893. sessionManager: WebXRSessionManager;
  40894. private _nonVRCamera;
  40895. private _originalSceneAutoClear;
  40896. private _supported;
  40897. /**
  40898. * Creates the experience helper
  40899. * @param scene the scene to attach the experience helper to
  40900. * @returns a promise for the experience helper
  40901. */
  40902. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40903. /**
  40904. * Creates a WebXRExperienceHelper
  40905. * @param scene The scene the helper should be created in
  40906. */
  40907. private constructor();
  40908. /**
  40909. * Exits XR mode and returns the scene to its original state
  40910. * @returns promise that resolves after xr mode has exited
  40911. */
  40912. exitXRAsync(): Promise<unknown>;
  40913. /**
  40914. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40915. * @param sessionCreationOptions options for the XR session
  40916. * @param referenceSpaceType frame of reference of the XR session
  40917. * @param outputCanvas the output canvas that will be used to enter XR mode
  40918. * @returns promise that resolves after xr mode has entered
  40919. */
  40920. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  40921. /**
  40922. * Updates the global position of the camera by moving the camera's container
  40923. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40924. * @param position The desired global position of the camera
  40925. */
  40926. setPositionOfCameraUsingContainer(position: Vector3): void;
  40927. /**
  40928. * Rotates the xr camera by rotating the camera's container around the camera's position
  40929. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40930. * @param rotation the desired quaternion rotation to apply to the camera
  40931. */
  40932. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40933. /**
  40934. * Disposes of the experience helper
  40935. */
  40936. dispose(): void;
  40937. }
  40938. }
  40939. declare module BABYLON {
  40940. /**
  40941. * Button which can be used to enter a different mode of XR
  40942. */
  40943. export class WebXREnterExitUIButton {
  40944. /** button element */
  40945. element: HTMLElement;
  40946. /** XR initialization options for the button */
  40947. sessionMode: XRSessionMode;
  40948. /** Reference space type */
  40949. referenceSpaceType: XRReferenceSpaceType;
  40950. /**
  40951. * Creates a WebXREnterExitUIButton
  40952. * @param element button element
  40953. * @param sessionMode XR initialization session mode
  40954. * @param referenceSpaceType the type of reference space to be used
  40955. */
  40956. constructor(
  40957. /** button element */
  40958. element: HTMLElement,
  40959. /** XR initialization options for the button */
  40960. sessionMode: XRSessionMode,
  40961. /** Reference space type */
  40962. referenceSpaceType: XRReferenceSpaceType);
  40963. /**
  40964. * Overwritable function which can be used to update the button's visuals when the state changes
  40965. * @param activeButton the current active button in the UI
  40966. */
  40967. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40968. }
  40969. /**
  40970. * Options to create the webXR UI
  40971. */
  40972. export class WebXREnterExitUIOptions {
  40973. /**
  40974. * Context to enter xr with
  40975. */
  40976. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  40977. /**
  40978. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40979. */
  40980. customButtons?: Array<WebXREnterExitUIButton>;
  40981. }
  40982. /**
  40983. * UI to allow the user to enter/exit XR mode
  40984. */
  40985. export class WebXREnterExitUI implements IDisposable {
  40986. private scene;
  40987. private _overlay;
  40988. private _buttons;
  40989. private _activeButton;
  40990. /**
  40991. * Fired every time the active button is changed.
  40992. *
  40993. * When xr is entered via a button that launches xr that button will be the callback parameter
  40994. *
  40995. * When exiting xr the callback parameter will be null)
  40996. */
  40997. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40998. /**
  40999. * Creates UI to allow the user to enter/exit XR mode
  41000. * @param scene the scene to add the ui to
  41001. * @param helper the xr experience helper to enter/exit xr with
  41002. * @param options options to configure the UI
  41003. * @returns the created ui
  41004. */
  41005. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41006. private constructor();
  41007. private _updateButtons;
  41008. /**
  41009. * Disposes of the object
  41010. */
  41011. dispose(): void;
  41012. }
  41013. }
  41014. declare module BABYLON {
  41015. /**
  41016. * Represents an XR input
  41017. */
  41018. export class WebXRController {
  41019. private scene;
  41020. /** The underlying input source for the controller */
  41021. inputSource: XRInputSource;
  41022. private parentContainer;
  41023. /**
  41024. * 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
  41025. */
  41026. grip?: AbstractMesh;
  41027. /**
  41028. * Pointer which can be used to select objects or attach a visible laser to
  41029. */
  41030. pointer: AbstractMesh;
  41031. /**
  41032. * Event that fires when the controller is removed/disposed
  41033. */
  41034. onDisposeObservable: Observable<{}>;
  41035. private _tmpMatrix;
  41036. private _tmpQuaternion;
  41037. private _tmpVector;
  41038. /**
  41039. * Creates the controller
  41040. * @see https://doc.babylonjs.com/how_to/webxr
  41041. * @param scene the scene which the controller should be associated to
  41042. * @param inputSource the underlying input source for the controller
  41043. * @param parentContainer parent that the controller meshes should be children of
  41044. */
  41045. constructor(scene: Scene,
  41046. /** The underlying input source for the controller */
  41047. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41048. /**
  41049. * Updates the controller pose based on the given XRFrame
  41050. * @param xrFrame xr frame to update the pose with
  41051. * @param referenceSpace reference space to use
  41052. */
  41053. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41054. /**
  41055. * Gets a world space ray coming from the controller
  41056. * @param result the resulting ray
  41057. */
  41058. getWorldPointerRayToRef(result: Ray): void;
  41059. /**
  41060. * Disposes of the object
  41061. */
  41062. dispose(): void;
  41063. }
  41064. }
  41065. declare module BABYLON {
  41066. /**
  41067. * XR input used to track XR inputs such as controllers/rays
  41068. */
  41069. export class WebXRInput implements IDisposable {
  41070. /**
  41071. * Base experience the input listens to
  41072. */
  41073. baseExperience: WebXRExperienceHelper;
  41074. /**
  41075. * XR controllers being tracked
  41076. */
  41077. controllers: Array<WebXRController>;
  41078. private _frameObserver;
  41079. private _stateObserver;
  41080. /**
  41081. * Event when a controller has been connected/added
  41082. */
  41083. onControllerAddedObservable: Observable<WebXRController>;
  41084. /**
  41085. * Event when a controller has been removed/disconnected
  41086. */
  41087. onControllerRemovedObservable: Observable<WebXRController>;
  41088. /**
  41089. * Initializes the WebXRInput
  41090. * @param baseExperience experience helper which the input should be created for
  41091. */
  41092. constructor(
  41093. /**
  41094. * Base experience the input listens to
  41095. */
  41096. baseExperience: WebXRExperienceHelper);
  41097. private _onInputSourcesChange;
  41098. private _addAndRemoveControllers;
  41099. /**
  41100. * Disposes of the object
  41101. */
  41102. dispose(): void;
  41103. }
  41104. }
  41105. declare module BABYLON {
  41106. /**
  41107. * Enables teleportation
  41108. */
  41109. export class WebXRControllerTeleportation {
  41110. private _teleportationFillColor;
  41111. private _teleportationBorderColor;
  41112. private _tmpRay;
  41113. private _tmpVector;
  41114. /**
  41115. * Creates a WebXRControllerTeleportation
  41116. * @param input input manager to add teleportation to
  41117. * @param floorMeshes floormeshes which can be teleported to
  41118. */
  41119. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41120. }
  41121. }
  41122. declare module BABYLON {
  41123. /**
  41124. * Handles pointer input automatically for the pointer of XR controllers
  41125. */
  41126. export class WebXRControllerPointerSelection {
  41127. private static _idCounter;
  41128. private _tmpRay;
  41129. /**
  41130. * Creates a WebXRControllerPointerSelection
  41131. * @param input input manager to setup pointer selection
  41132. */
  41133. constructor(input: WebXRInput);
  41134. private _convertNormalToDirectionOfRay;
  41135. private _updatePointerDistance;
  41136. }
  41137. }
  41138. declare module BABYLON {
  41139. /**
  41140. * Class used to represent data loading progression
  41141. */
  41142. export class SceneLoaderProgressEvent {
  41143. /** defines if data length to load can be evaluated */
  41144. readonly lengthComputable: boolean;
  41145. /** defines the loaded data length */
  41146. readonly loaded: number;
  41147. /** defines the data length to load */
  41148. readonly total: number;
  41149. /**
  41150. * Create a new progress event
  41151. * @param lengthComputable defines if data length to load can be evaluated
  41152. * @param loaded defines the loaded data length
  41153. * @param total defines the data length to load
  41154. */
  41155. constructor(
  41156. /** defines if data length to load can be evaluated */
  41157. lengthComputable: boolean,
  41158. /** defines the loaded data length */
  41159. loaded: number,
  41160. /** defines the data length to load */
  41161. total: number);
  41162. /**
  41163. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41164. * @param event defines the source event
  41165. * @returns a new SceneLoaderProgressEvent
  41166. */
  41167. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41168. }
  41169. /**
  41170. * Interface used by SceneLoader plugins to define supported file extensions
  41171. */
  41172. export interface ISceneLoaderPluginExtensions {
  41173. /**
  41174. * Defines the list of supported extensions
  41175. */
  41176. [extension: string]: {
  41177. isBinary: boolean;
  41178. };
  41179. }
  41180. /**
  41181. * Interface used by SceneLoader plugin factory
  41182. */
  41183. export interface ISceneLoaderPluginFactory {
  41184. /**
  41185. * Defines the name of the factory
  41186. */
  41187. name: string;
  41188. /**
  41189. * Function called to create a new plugin
  41190. * @return the new plugin
  41191. */
  41192. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41193. /**
  41194. * Boolean indicating if the plugin can direct load specific data
  41195. */
  41196. canDirectLoad?: (data: string) => boolean;
  41197. }
  41198. /**
  41199. * Interface used to define a SceneLoader plugin
  41200. */
  41201. export interface ISceneLoaderPlugin {
  41202. /**
  41203. * The friendly name of this plugin.
  41204. */
  41205. name: string;
  41206. /**
  41207. * The file extensions supported by this plugin.
  41208. */
  41209. extensions: string | ISceneLoaderPluginExtensions;
  41210. /**
  41211. * Import meshes into a scene.
  41212. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41213. * @param scene The scene to import into
  41214. * @param data The data to import
  41215. * @param rootUrl The root url for scene and resources
  41216. * @param meshes The meshes array to import into
  41217. * @param particleSystems The particle systems array to import into
  41218. * @param skeletons The skeletons array to import into
  41219. * @param onError The callback when import fails
  41220. * @returns True if successful or false otherwise
  41221. */
  41222. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41223. /**
  41224. * Load into a scene.
  41225. * @param scene The scene to load into
  41226. * @param data The data to import
  41227. * @param rootUrl The root url for scene and resources
  41228. * @param onError The callback when import fails
  41229. * @returns true if successful or false otherwise
  41230. */
  41231. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41232. /**
  41233. * The callback that returns true if the data can be directly loaded.
  41234. */
  41235. canDirectLoad?: (data: string) => boolean;
  41236. /**
  41237. * The callback that allows custom handling of the root url based on the response url.
  41238. */
  41239. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41240. /**
  41241. * Load into an asset container.
  41242. * @param scene The scene to load into
  41243. * @param data The data to import
  41244. * @param rootUrl The root url for scene and resources
  41245. * @param onError The callback when import fails
  41246. * @returns The loaded asset container
  41247. */
  41248. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41249. }
  41250. /**
  41251. * Interface used to define an async SceneLoader plugin
  41252. */
  41253. export interface ISceneLoaderPluginAsync {
  41254. /**
  41255. * The friendly name of this plugin.
  41256. */
  41257. name: string;
  41258. /**
  41259. * The file extensions supported by this plugin.
  41260. */
  41261. extensions: string | ISceneLoaderPluginExtensions;
  41262. /**
  41263. * Import meshes into a scene.
  41264. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41265. * @param scene The scene to import into
  41266. * @param data The data to import
  41267. * @param rootUrl The root url for scene and resources
  41268. * @param onProgress The callback when the load progresses
  41269. * @param fileName Defines the name of the file to load
  41270. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41271. */
  41272. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41273. meshes: AbstractMesh[];
  41274. particleSystems: IParticleSystem[];
  41275. skeletons: Skeleton[];
  41276. animationGroups: AnimationGroup[];
  41277. }>;
  41278. /**
  41279. * Load into a scene.
  41280. * @param scene The scene to load into
  41281. * @param data The data to import
  41282. * @param rootUrl The root url for scene and resources
  41283. * @param onProgress The callback when the load progresses
  41284. * @param fileName Defines the name of the file to load
  41285. * @returns Nothing
  41286. */
  41287. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41288. /**
  41289. * The callback that returns true if the data can be directly loaded.
  41290. */
  41291. canDirectLoad?: (data: string) => boolean;
  41292. /**
  41293. * The callback that allows custom handling of the root url based on the response url.
  41294. */
  41295. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41296. /**
  41297. * Load into an asset container.
  41298. * @param scene The scene to load into
  41299. * @param data The data to import
  41300. * @param rootUrl The root url for scene and resources
  41301. * @param onProgress The callback when the load progresses
  41302. * @param fileName Defines the name of the file to load
  41303. * @returns The loaded asset container
  41304. */
  41305. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41306. }
  41307. /**
  41308. * Class used to load scene from various file formats using registered plugins
  41309. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41310. */
  41311. export class SceneLoader {
  41312. /**
  41313. * No logging while loading
  41314. */
  41315. static readonly NO_LOGGING: number;
  41316. /**
  41317. * Minimal logging while loading
  41318. */
  41319. static readonly MINIMAL_LOGGING: number;
  41320. /**
  41321. * Summary logging while loading
  41322. */
  41323. static readonly SUMMARY_LOGGING: number;
  41324. /**
  41325. * Detailled logging while loading
  41326. */
  41327. static readonly DETAILED_LOGGING: number;
  41328. /**
  41329. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41330. */
  41331. static ForceFullSceneLoadingForIncremental: boolean;
  41332. /**
  41333. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41334. */
  41335. static ShowLoadingScreen: boolean;
  41336. /**
  41337. * Defines the current logging level (while loading the scene)
  41338. * @ignorenaming
  41339. */
  41340. static loggingLevel: number;
  41341. /**
  41342. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41343. */
  41344. static CleanBoneMatrixWeights: boolean;
  41345. /**
  41346. * Event raised when a plugin is used to load a scene
  41347. */
  41348. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41349. private static _registeredPlugins;
  41350. private static _getDefaultPlugin;
  41351. private static _getPluginForExtension;
  41352. private static _getPluginForDirectLoad;
  41353. private static _getPluginForFilename;
  41354. private static _getDirectLoad;
  41355. private static _loadData;
  41356. private static _getFileInfo;
  41357. /**
  41358. * Gets a plugin that can load the given extension
  41359. * @param extension defines the extension to load
  41360. * @returns a plugin or null if none works
  41361. */
  41362. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41363. /**
  41364. * Gets a boolean indicating that the given extension can be loaded
  41365. * @param extension defines the extension to load
  41366. * @returns true if the extension is supported
  41367. */
  41368. static IsPluginForExtensionAvailable(extension: string): boolean;
  41369. /**
  41370. * Adds a new plugin to the list of registered plugins
  41371. * @param plugin defines the plugin to add
  41372. */
  41373. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41374. /**
  41375. * Import meshes into a scene
  41376. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41377. * @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)
  41378. * @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)
  41379. * @param scene the instance of BABYLON.Scene to append to
  41380. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41381. * @param onProgress a callback with a progress event for each file being loaded
  41382. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41383. * @param pluginExtension the extension used to determine the plugin
  41384. * @returns The loaded plugin
  41385. */
  41386. 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>;
  41387. /**
  41388. * Import meshes into a scene
  41389. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41390. * @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)
  41391. * @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)
  41392. * @param scene the instance of BABYLON.Scene to append to
  41393. * @param onProgress a callback with a progress event for each file being loaded
  41394. * @param pluginExtension the extension used to determine the plugin
  41395. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41396. */
  41397. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41398. meshes: AbstractMesh[];
  41399. particleSystems: IParticleSystem[];
  41400. skeletons: Skeleton[];
  41401. animationGroups: AnimationGroup[];
  41402. }>;
  41403. /**
  41404. * Load a scene
  41405. * @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)
  41406. * @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)
  41407. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41408. * @param onSuccess a callback with the scene when import succeeds
  41409. * @param onProgress a callback with a progress event for each file being loaded
  41410. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41411. * @param pluginExtension the extension used to determine the plugin
  41412. * @returns The loaded plugin
  41413. */
  41414. 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>;
  41415. /**
  41416. * Load a scene
  41417. * @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)
  41418. * @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)
  41419. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41420. * @param onProgress a callback with a progress event for each file being loaded
  41421. * @param pluginExtension the extension used to determine the plugin
  41422. * @returns The loaded scene
  41423. */
  41424. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41425. /**
  41426. * Append a scene
  41427. * @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)
  41428. * @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)
  41429. * @param scene is the instance of BABYLON.Scene to append to
  41430. * @param onSuccess a callback with the scene when import succeeds
  41431. * @param onProgress a callback with a progress event for each file being loaded
  41432. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41433. * @param pluginExtension the extension used to determine the plugin
  41434. * @returns The loaded plugin
  41435. */
  41436. 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>;
  41437. /**
  41438. * Append a scene
  41439. * @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)
  41440. * @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)
  41441. * @param scene is the instance of BABYLON.Scene to append to
  41442. * @param onProgress a callback with a progress event for each file being loaded
  41443. * @param pluginExtension the extension used to determine the plugin
  41444. * @returns The given scene
  41445. */
  41446. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41447. /**
  41448. * Load a scene into an asset container
  41449. * @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)
  41450. * @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)
  41451. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41452. * @param onSuccess a callback with the scene when import succeeds
  41453. * @param onProgress a callback with a progress event for each file being loaded
  41454. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41455. * @param pluginExtension the extension used to determine the plugin
  41456. * @returns The loaded plugin
  41457. */
  41458. 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>;
  41459. /**
  41460. * Load a scene into an asset container
  41461. * @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)
  41462. * @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)
  41463. * @param scene is the instance of Scene to append to
  41464. * @param onProgress a callback with a progress event for each file being loaded
  41465. * @param pluginExtension the extension used to determine the plugin
  41466. * @returns The loaded asset container
  41467. */
  41468. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41469. }
  41470. }
  41471. declare module BABYLON {
  41472. /**
  41473. * Generic Controller
  41474. */
  41475. export class GenericController extends WebVRController {
  41476. /**
  41477. * Base Url for the controller model.
  41478. */
  41479. static readonly MODEL_BASE_URL: string;
  41480. /**
  41481. * File name for the controller model.
  41482. */
  41483. static readonly MODEL_FILENAME: string;
  41484. /**
  41485. * Creates a new GenericController from a gamepad
  41486. * @param vrGamepad the gamepad that the controller should be created from
  41487. */
  41488. constructor(vrGamepad: any);
  41489. /**
  41490. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41491. * @param scene scene in which to add meshes
  41492. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41493. */
  41494. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41495. /**
  41496. * Called once for each button that changed state since the last frame
  41497. * @param buttonIdx Which button index changed
  41498. * @param state New state of the button
  41499. * @param changes Which properties on the state changed since last frame
  41500. */
  41501. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41502. }
  41503. }
  41504. declare module BABYLON {
  41505. /**
  41506. * Defines the WindowsMotionController object that the state of the windows motion controller
  41507. */
  41508. export class WindowsMotionController extends WebVRController {
  41509. /**
  41510. * The base url used to load the left and right controller models
  41511. */
  41512. static MODEL_BASE_URL: string;
  41513. /**
  41514. * The name of the left controller model file
  41515. */
  41516. static MODEL_LEFT_FILENAME: string;
  41517. /**
  41518. * The name of the right controller model file
  41519. */
  41520. static MODEL_RIGHT_FILENAME: string;
  41521. /**
  41522. * The controller name prefix for this controller type
  41523. */
  41524. static readonly GAMEPAD_ID_PREFIX: string;
  41525. /**
  41526. * The controller id pattern for this controller type
  41527. */
  41528. private static readonly GAMEPAD_ID_PATTERN;
  41529. private _loadedMeshInfo;
  41530. private readonly _mapping;
  41531. /**
  41532. * Fired when the trackpad on this controller is clicked
  41533. */
  41534. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41535. /**
  41536. * Fired when the trackpad on this controller is modified
  41537. */
  41538. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41539. /**
  41540. * The current x and y values of this controller's trackpad
  41541. */
  41542. trackpad: StickValues;
  41543. /**
  41544. * Creates a new WindowsMotionController from a gamepad
  41545. * @param vrGamepad the gamepad that the controller should be created from
  41546. */
  41547. constructor(vrGamepad: any);
  41548. /**
  41549. * Fired when the trigger on this controller is modified
  41550. */
  41551. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41552. /**
  41553. * Fired when the menu button on this controller is modified
  41554. */
  41555. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41556. /**
  41557. * Fired when the grip button on this controller is modified
  41558. */
  41559. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41560. /**
  41561. * Fired when the thumbstick button on this controller is modified
  41562. */
  41563. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41564. /**
  41565. * Fired when the touchpad button on this controller is modified
  41566. */
  41567. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41568. /**
  41569. * Fired when the touchpad values on this controller are modified
  41570. */
  41571. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41572. private _updateTrackpad;
  41573. /**
  41574. * Called once per frame by the engine.
  41575. */
  41576. update(): void;
  41577. /**
  41578. * Called once for each button that changed state since the last frame
  41579. * @param buttonIdx Which button index changed
  41580. * @param state New state of the button
  41581. * @param changes Which properties on the state changed since last frame
  41582. */
  41583. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41584. /**
  41585. * Moves the buttons on the controller mesh based on their current state
  41586. * @param buttonName the name of the button to move
  41587. * @param buttonValue the value of the button which determines the buttons new position
  41588. */
  41589. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41590. /**
  41591. * Moves the axis on the controller mesh based on its current state
  41592. * @param axis the index of the axis
  41593. * @param axisValue the value of the axis which determines the meshes new position
  41594. * @hidden
  41595. */
  41596. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41597. /**
  41598. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41599. * @param scene scene in which to add meshes
  41600. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41601. */
  41602. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41603. /**
  41604. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41605. * can be transformed by button presses and axes values, based on this._mapping.
  41606. *
  41607. * @param scene scene in which the meshes exist
  41608. * @param meshes list of meshes that make up the controller model to process
  41609. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41610. */
  41611. private processModel;
  41612. private createMeshInfo;
  41613. /**
  41614. * Gets the ray of the controller in the direction the controller is pointing
  41615. * @param length the length the resulting ray should be
  41616. * @returns a ray in the direction the controller is pointing
  41617. */
  41618. getForwardRay(length?: number): Ray;
  41619. /**
  41620. * Disposes of the controller
  41621. */
  41622. dispose(): void;
  41623. }
  41624. }
  41625. declare module BABYLON {
  41626. /**
  41627. * Oculus Touch Controller
  41628. */
  41629. export class OculusTouchController extends WebVRController {
  41630. /**
  41631. * Base Url for the controller model.
  41632. */
  41633. static MODEL_BASE_URL: string;
  41634. /**
  41635. * File name for the left controller model.
  41636. */
  41637. static MODEL_LEFT_FILENAME: string;
  41638. /**
  41639. * File name for the right controller model.
  41640. */
  41641. static MODEL_RIGHT_FILENAME: string;
  41642. /**
  41643. * Base Url for the Quest controller model.
  41644. */
  41645. static QUEST_MODEL_BASE_URL: string;
  41646. /**
  41647. * @hidden
  41648. * If the controllers are running on a device that needs the updated Quest controller models
  41649. */ private static _IsQuest: boolean;
  41650. /**
  41651. * Fired when the secondary trigger on this controller is modified
  41652. */
  41653. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41654. /**
  41655. * Fired when the thumb rest on this controller is modified
  41656. */
  41657. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41658. /**
  41659. * Creates a new OculusTouchController from a gamepad
  41660. * @param vrGamepad the gamepad that the controller should be created from
  41661. */
  41662. constructor(vrGamepad: any);
  41663. /**
  41664. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41665. * @param scene scene in which to add meshes
  41666. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41667. */
  41668. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41669. /**
  41670. * Fired when the A button on this controller is modified
  41671. */
  41672. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41673. /**
  41674. * Fired when the B button on this controller is modified
  41675. */
  41676. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41677. /**
  41678. * Fired when the X button on this controller is modified
  41679. */
  41680. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41681. /**
  41682. * Fired when the Y button on this controller is modified
  41683. */
  41684. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41685. /**
  41686. * Called once for each button that changed state since the last frame
  41687. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41688. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41689. * 2) secondary trigger (same)
  41690. * 3) A (right) X (left), touch, pressed = value
  41691. * 4) B / Y
  41692. * 5) thumb rest
  41693. * @param buttonIdx Which button index changed
  41694. * @param state New state of the button
  41695. * @param changes Which properties on the state changed since last frame
  41696. */
  41697. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41698. }
  41699. }
  41700. declare module BABYLON {
  41701. /**
  41702. * Vive Controller
  41703. */
  41704. export class ViveController extends WebVRController {
  41705. /**
  41706. * Base Url for the controller model.
  41707. */
  41708. static MODEL_BASE_URL: string;
  41709. /**
  41710. * File name for the controller model.
  41711. */
  41712. static MODEL_FILENAME: string;
  41713. /**
  41714. * Creates a new ViveController from a gamepad
  41715. * @param vrGamepad the gamepad that the controller should be created from
  41716. */
  41717. constructor(vrGamepad: any);
  41718. /**
  41719. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41720. * @param scene scene in which to add meshes
  41721. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41722. */
  41723. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41724. /**
  41725. * Fired when the left button on this controller is modified
  41726. */
  41727. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41728. /**
  41729. * Fired when the right button on this controller is modified
  41730. */
  41731. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41732. /**
  41733. * Fired when the menu button on this controller is modified
  41734. */
  41735. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41736. /**
  41737. * Called once for each button that changed state since the last frame
  41738. * Vive mapping:
  41739. * 0: touchpad
  41740. * 1: trigger
  41741. * 2: left AND right buttons
  41742. * 3: menu button
  41743. * @param buttonIdx Which button index changed
  41744. * @param state New state of the button
  41745. * @param changes Which properties on the state changed since last frame
  41746. */
  41747. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41748. }
  41749. }
  41750. declare module BABYLON {
  41751. /**
  41752. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  41753. */
  41754. export class WebXRControllerModelLoader {
  41755. /**
  41756. * Creates the WebXRControllerModelLoader
  41757. * @param input xr input that creates the controllers
  41758. */
  41759. constructor(input: WebXRInput);
  41760. }
  41761. }
  41762. declare module BABYLON {
  41763. /**
  41764. * Contains an array of blocks representing the octree
  41765. */
  41766. export interface IOctreeContainer<T> {
  41767. /**
  41768. * Blocks within the octree
  41769. */
  41770. blocks: Array<OctreeBlock<T>>;
  41771. }
  41772. /**
  41773. * Class used to store a cell in an octree
  41774. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41775. */
  41776. export class OctreeBlock<T> {
  41777. /**
  41778. * Gets the content of the current block
  41779. */
  41780. entries: T[];
  41781. /**
  41782. * Gets the list of block children
  41783. */
  41784. blocks: Array<OctreeBlock<T>>;
  41785. private _depth;
  41786. private _maxDepth;
  41787. private _capacity;
  41788. private _minPoint;
  41789. private _maxPoint;
  41790. private _boundingVectors;
  41791. private _creationFunc;
  41792. /**
  41793. * Creates a new block
  41794. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41795. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41796. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41797. * @param depth defines the current depth of this block in the octree
  41798. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41799. * @param creationFunc defines a callback to call when an element is added to the block
  41800. */
  41801. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41802. /**
  41803. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41804. */
  41805. readonly capacity: number;
  41806. /**
  41807. * Gets the minimum vector (in world space) of the block's bounding box
  41808. */
  41809. readonly minPoint: Vector3;
  41810. /**
  41811. * Gets the maximum vector (in world space) of the block's bounding box
  41812. */
  41813. readonly maxPoint: Vector3;
  41814. /**
  41815. * Add a new element to this block
  41816. * @param entry defines the element to add
  41817. */
  41818. addEntry(entry: T): void;
  41819. /**
  41820. * Remove an element from this block
  41821. * @param entry defines the element to remove
  41822. */
  41823. removeEntry(entry: T): void;
  41824. /**
  41825. * Add an array of elements to this block
  41826. * @param entries defines the array of elements to add
  41827. */
  41828. addEntries(entries: T[]): void;
  41829. /**
  41830. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41831. * @param frustumPlanes defines the frustum planes to test
  41832. * @param selection defines the array to store current content if selection is positive
  41833. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41834. */
  41835. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41836. /**
  41837. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41838. * @param sphereCenter defines the bounding sphere center
  41839. * @param sphereRadius defines the bounding sphere radius
  41840. * @param selection defines the array to store current content if selection is positive
  41841. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41842. */
  41843. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41844. /**
  41845. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41846. * @param ray defines the ray to test with
  41847. * @param selection defines the array to store current content if selection is positive
  41848. */
  41849. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41850. /**
  41851. * Subdivide the content into child blocks (this block will then be empty)
  41852. */
  41853. createInnerBlocks(): void;
  41854. /**
  41855. * @hidden
  41856. */ 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;
  41857. }
  41858. }
  41859. declare module BABYLON {
  41860. /**
  41861. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41862. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41863. */
  41864. export class Octree<T> {
  41865. /** 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.) */
  41866. maxDepth: number;
  41867. /**
  41868. * Blocks within the octree containing objects
  41869. */
  41870. blocks: Array<OctreeBlock<T>>;
  41871. /**
  41872. * Content stored in the octree
  41873. */
  41874. dynamicContent: T[];
  41875. private _maxBlockCapacity;
  41876. private _selectionContent;
  41877. private _creationFunc;
  41878. /**
  41879. * Creates a octree
  41880. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41881. * @param creationFunc function to be used to instatiate the octree
  41882. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41883. * @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.)
  41884. */
  41885. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41886. /** 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.) */
  41887. maxDepth?: number);
  41888. /**
  41889. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41890. * @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);
  41891. * @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);
  41892. * @param entries meshes to be added to the octree blocks
  41893. */
  41894. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41895. /**
  41896. * Adds a mesh to the octree
  41897. * @param entry Mesh to add to the octree
  41898. */
  41899. addMesh(entry: T): void;
  41900. /**
  41901. * Remove an element from the octree
  41902. * @param entry defines the element to remove
  41903. */
  41904. removeMesh(entry: T): void;
  41905. /**
  41906. * Selects an array of meshes within the frustum
  41907. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41908. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41909. * @returns array of meshes within the frustum
  41910. */
  41911. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41912. /**
  41913. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41914. * @param sphereCenter defines the bounding sphere center
  41915. * @param sphereRadius defines the bounding sphere radius
  41916. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41917. * @returns an array of objects that intersect the sphere
  41918. */
  41919. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41920. /**
  41921. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41922. * @param ray defines the ray to test with
  41923. * @returns array of intersected objects
  41924. */
  41925. intersectsRay(ray: Ray): SmartArray<T>;
  41926. /**
  41927. * Adds a mesh into the octree block if it intersects the block
  41928. */
  41929. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41930. /**
  41931. * Adds a submesh into the octree block if it intersects the block
  41932. */
  41933. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41934. }
  41935. }
  41936. declare module BABYLON {
  41937. interface Scene {
  41938. /**
  41939. * @hidden
  41940. * Backing Filed
  41941. */ private _selectionOctree: Octree<AbstractMesh>;
  41942. /**
  41943. * Gets the octree used to boost mesh selection (picking)
  41944. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41945. */
  41946. selectionOctree: Octree<AbstractMesh>;
  41947. /**
  41948. * Creates or updates the octree used to boost selection (picking)
  41949. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41950. * @param maxCapacity defines the maximum capacity per leaf
  41951. * @param maxDepth defines the maximum depth of the octree
  41952. * @returns an octree of AbstractMesh
  41953. */
  41954. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41955. }
  41956. interface AbstractMesh {
  41957. /**
  41958. * @hidden
  41959. * Backing Field
  41960. */ private _submeshesOctree: Octree<SubMesh>;
  41961. /**
  41962. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41963. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41964. * @param maxCapacity defines the maximum size of each block (64 by default)
  41965. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41966. * @returns the new octree
  41967. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41968. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41969. */
  41970. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41971. }
  41972. /**
  41973. * Defines the octree scene component responsible to manage any octrees
  41974. * in a given scene.
  41975. */
  41976. export class OctreeSceneComponent {
  41977. /**
  41978. * The component name help to identify the component in the list of scene components.
  41979. */
  41980. readonly name: string;
  41981. /**
  41982. * The scene the component belongs to.
  41983. */
  41984. scene: Scene;
  41985. /**
  41986. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41987. */
  41988. readonly checksIsEnabled: boolean;
  41989. /**
  41990. * Creates a new instance of the component for the given scene
  41991. * @param scene Defines the scene to register the component in
  41992. */
  41993. constructor(scene: Scene);
  41994. /**
  41995. * Registers the component in a given scene
  41996. */
  41997. register(): void;
  41998. /**
  41999. * Return the list of active meshes
  42000. * @returns the list of active meshes
  42001. */
  42002. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42003. /**
  42004. * Return the list of active sub meshes
  42005. * @param mesh The mesh to get the candidates sub meshes from
  42006. * @returns the list of active sub meshes
  42007. */
  42008. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42009. private _tempRay;
  42010. /**
  42011. * Return the list of sub meshes intersecting with a given local ray
  42012. * @param mesh defines the mesh to find the submesh for
  42013. * @param localRay defines the ray in local space
  42014. * @returns the list of intersecting sub meshes
  42015. */
  42016. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42017. /**
  42018. * Return the list of sub meshes colliding with a collider
  42019. * @param mesh defines the mesh to find the submesh for
  42020. * @param collider defines the collider to evaluate the collision against
  42021. * @returns the list of colliding sub meshes
  42022. */
  42023. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42024. /**
  42025. * Rebuilds the elements related to this component in case of
  42026. * context lost for instance.
  42027. */
  42028. rebuild(): void;
  42029. /**
  42030. * Disposes the component and the associated ressources.
  42031. */
  42032. dispose(): void;
  42033. }
  42034. }
  42035. declare module BABYLON {
  42036. /**
  42037. * Renders a layer on top of an existing scene
  42038. */
  42039. export class UtilityLayerRenderer implements IDisposable {
  42040. /** the original scene that will be rendered on top of */
  42041. originalScene: Scene;
  42042. private _pointerCaptures;
  42043. private _lastPointerEvents;
  42044. private static _DefaultUtilityLayer;
  42045. private static _DefaultKeepDepthUtilityLayer;
  42046. private _sharedGizmoLight;
  42047. private _renderCamera;
  42048. /**
  42049. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42050. * @returns the camera that is used when rendering the utility layer
  42051. */
  42052. getRenderCamera(): Nullable<Camera>;
  42053. /**
  42054. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42055. * @param cam the camera that should be used when rendering the utility layer
  42056. */
  42057. setRenderCamera(cam: Nullable<Camera>): void;
  42058. /**
  42059. * @hidden
  42060. * Light which used by gizmos to get light shading
  42061. */ private _getSharedGizmoLight(): HemisphericLight;
  42062. /**
  42063. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42064. */
  42065. pickUtilitySceneFirst: boolean;
  42066. /**
  42067. * 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)
  42068. */
  42069. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42070. /**
  42071. * 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)
  42072. */
  42073. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42074. /**
  42075. * The scene that is rendered on top of the original scene
  42076. */
  42077. utilityLayerScene: Scene;
  42078. /**
  42079. * If the utility layer should automatically be rendered on top of existing scene
  42080. */
  42081. shouldRender: boolean;
  42082. /**
  42083. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42084. */
  42085. onlyCheckPointerDownEvents: boolean;
  42086. /**
  42087. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42088. */
  42089. processAllEvents: boolean;
  42090. /**
  42091. * Observable raised when the pointer move from the utility layer scene to the main scene
  42092. */
  42093. onPointerOutObservable: Observable<number>;
  42094. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42095. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42096. private _afterRenderObserver;
  42097. private _sceneDisposeObserver;
  42098. private _originalPointerObserver;
  42099. /**
  42100. * Instantiates a UtilityLayerRenderer
  42101. * @param originalScene the original scene that will be rendered on top of
  42102. * @param handleEvents boolean indicating if the utility layer should handle events
  42103. */
  42104. constructor(
  42105. /** the original scene that will be rendered on top of */
  42106. originalScene: Scene, handleEvents?: boolean);
  42107. private _notifyObservers;
  42108. /**
  42109. * Renders the utility layers scene on top of the original scene
  42110. */
  42111. render(): void;
  42112. /**
  42113. * Disposes of the renderer
  42114. */
  42115. dispose(): void;
  42116. private _updateCamera;
  42117. }
  42118. }
  42119. declare module BABYLON {
  42120. /**
  42121. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42122. */
  42123. export class Gizmo implements IDisposable {
  42124. /** The utility layer the gizmo will be added to */
  42125. gizmoLayer: UtilityLayerRenderer;
  42126. /**
  42127. * The root mesh of the gizmo
  42128. */ private _rootMesh: Mesh;
  42129. private _attachedMesh;
  42130. /**
  42131. * Ratio for the scale of the gizmo (Default: 1)
  42132. */
  42133. scaleRatio: number;
  42134. /**
  42135. * If a custom mesh has been set (Default: false)
  42136. */
  42137. protected _customMeshSet: boolean;
  42138. /**
  42139. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42140. * * When set, interactions will be enabled
  42141. */
  42142. attachedMesh: Nullable<AbstractMesh>;
  42143. /**
  42144. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42145. * @param mesh The mesh to replace the default mesh of the gizmo
  42146. */
  42147. setCustomMesh(mesh: Mesh): void;
  42148. /**
  42149. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42150. */
  42151. updateGizmoRotationToMatchAttachedMesh: boolean;
  42152. /**
  42153. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42154. */
  42155. updateGizmoPositionToMatchAttachedMesh: boolean;
  42156. /**
  42157. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42158. */
  42159. updateScale: boolean;
  42160. protected _interactionsEnabled: boolean;
  42161. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42162. private _beforeRenderObserver;
  42163. private _tempVector;
  42164. /**
  42165. * Creates a gizmo
  42166. * @param gizmoLayer The utility layer the gizmo will be added to
  42167. */
  42168. constructor(
  42169. /** The utility layer the gizmo will be added to */
  42170. gizmoLayer?: UtilityLayerRenderer);
  42171. /**
  42172. * Updates the gizmo to match the attached mesh's position/rotation
  42173. */
  42174. protected _update(): void;
  42175. /**
  42176. * Disposes of the gizmo
  42177. */
  42178. dispose(): void;
  42179. }
  42180. }
  42181. declare module BABYLON {
  42182. /**
  42183. * Single plane drag gizmo
  42184. */
  42185. export class PlaneDragGizmo extends Gizmo {
  42186. /**
  42187. * Drag behavior responsible for the gizmos dragging interactions
  42188. */
  42189. dragBehavior: PointerDragBehavior;
  42190. private _pointerObserver;
  42191. /**
  42192. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42193. */
  42194. snapDistance: number;
  42195. /**
  42196. * Event that fires each time the gizmo snaps to a new location.
  42197. * * snapDistance is the the change in distance
  42198. */
  42199. onSnapObservable: Observable<{
  42200. snapDistance: number;
  42201. }>;
  42202. private _plane;
  42203. private _coloredMaterial;
  42204. private _hoverMaterial;
  42205. private _isEnabled;
  42206. private _parent;
  42207. /** @hidden */ private static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42208. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42209. /**
  42210. * Creates a PlaneDragGizmo
  42211. * @param gizmoLayer The utility layer the gizmo will be added to
  42212. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42213. * @param color The color of the gizmo
  42214. */
  42215. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42216. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42217. /**
  42218. * If the gizmo is enabled
  42219. */
  42220. isEnabled: boolean;
  42221. /**
  42222. * Disposes of the gizmo
  42223. */
  42224. dispose(): void;
  42225. }
  42226. }
  42227. declare module BABYLON {
  42228. /**
  42229. * Gizmo that enables dragging a mesh along 3 axis
  42230. */
  42231. export class PositionGizmo extends Gizmo {
  42232. /**
  42233. * Internal gizmo used for interactions on the x axis
  42234. */
  42235. xGizmo: AxisDragGizmo;
  42236. /**
  42237. * Internal gizmo used for interactions on the y axis
  42238. */
  42239. yGizmo: AxisDragGizmo;
  42240. /**
  42241. * Internal gizmo used for interactions on the z axis
  42242. */
  42243. zGizmo: AxisDragGizmo;
  42244. /**
  42245. * Internal gizmo used for interactions on the yz plane
  42246. */
  42247. xPlaneGizmo: PlaneDragGizmo;
  42248. /**
  42249. * Internal gizmo used for interactions on the xz plane
  42250. */
  42251. yPlaneGizmo: PlaneDragGizmo;
  42252. /**
  42253. * Internal gizmo used for interactions on the xy plane
  42254. */
  42255. zPlaneGizmo: PlaneDragGizmo;
  42256. /**
  42257. * private variables
  42258. */
  42259. private _meshAttached;
  42260. private _updateGizmoRotationToMatchAttachedMesh;
  42261. private _snapDistance;
  42262. private _scaleRatio;
  42263. /** Fires an event when any of it's sub gizmos are dragged */
  42264. onDragStartObservable: Observable<unknown>;
  42265. /** Fires an event when any of it's sub gizmos are released from dragging */
  42266. onDragEndObservable: Observable<unknown>;
  42267. /**
  42268. * If set to true, planar drag is enabled
  42269. */
  42270. private _planarGizmoEnabled;
  42271. attachedMesh: Nullable<AbstractMesh>;
  42272. /**
  42273. * Creates a PositionGizmo
  42274. * @param gizmoLayer The utility layer the gizmo will be added to
  42275. */
  42276. constructor(gizmoLayer?: UtilityLayerRenderer);
  42277. /**
  42278. * If the planar drag gizmo is enabled
  42279. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42280. */
  42281. planarGizmoEnabled: boolean;
  42282. updateGizmoRotationToMatchAttachedMesh: boolean;
  42283. /**
  42284. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42285. */
  42286. snapDistance: number;
  42287. /**
  42288. * Ratio for the scale of the gizmo (Default: 1)
  42289. */
  42290. scaleRatio: number;
  42291. /**
  42292. * Disposes of the gizmo
  42293. */
  42294. dispose(): void;
  42295. /**
  42296. * CustomMeshes are not supported by this gizmo
  42297. * @param mesh The mesh to replace the default mesh of the gizmo
  42298. */
  42299. setCustomMesh(mesh: Mesh): void;
  42300. }
  42301. }
  42302. declare module BABYLON {
  42303. /**
  42304. * Single axis drag gizmo
  42305. */
  42306. export class AxisDragGizmo extends Gizmo {
  42307. /**
  42308. * Drag behavior responsible for the gizmos dragging interactions
  42309. */
  42310. dragBehavior: PointerDragBehavior;
  42311. private _pointerObserver;
  42312. /**
  42313. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42314. */
  42315. snapDistance: number;
  42316. /**
  42317. * Event that fires each time the gizmo snaps to a new location.
  42318. * * snapDistance is the the change in distance
  42319. */
  42320. onSnapObservable: Observable<{
  42321. snapDistance: number;
  42322. }>;
  42323. private _isEnabled;
  42324. private _parent;
  42325. private _arrow;
  42326. private _coloredMaterial;
  42327. private _hoverMaterial;
  42328. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42329. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42330. /**
  42331. * Creates an AxisDragGizmo
  42332. * @param gizmoLayer The utility layer the gizmo will be added to
  42333. * @param dragAxis The axis which the gizmo will be able to drag on
  42334. * @param color The color of the gizmo
  42335. */
  42336. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42337. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42338. /**
  42339. * If the gizmo is enabled
  42340. */
  42341. isEnabled: boolean;
  42342. /**
  42343. * Disposes of the gizmo
  42344. */
  42345. dispose(): void;
  42346. }
  42347. }
  42348. declare module BABYLON.Debug {
  42349. /**
  42350. * The Axes viewer will show 3 axes in a specific point in space
  42351. */
  42352. export class AxesViewer {
  42353. private _xAxis;
  42354. private _yAxis;
  42355. private _zAxis;
  42356. private _scaleLinesFactor;
  42357. private _instanced;
  42358. /**
  42359. * Gets the hosting scene
  42360. */
  42361. scene: Scene;
  42362. /**
  42363. * Gets or sets a number used to scale line length
  42364. */
  42365. scaleLines: number;
  42366. /** Gets the node hierarchy used to render x-axis */
  42367. readonly xAxis: TransformNode;
  42368. /** Gets the node hierarchy used to render y-axis */
  42369. readonly yAxis: TransformNode;
  42370. /** Gets the node hierarchy used to render z-axis */
  42371. readonly zAxis: TransformNode;
  42372. /**
  42373. * Creates a new AxesViewer
  42374. * @param scene defines the hosting scene
  42375. * @param scaleLines defines a number used to scale line length (1 by default)
  42376. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42377. * @param xAxis defines the node hierarchy used to render the x-axis
  42378. * @param yAxis defines the node hierarchy used to render the y-axis
  42379. * @param zAxis defines the node hierarchy used to render the z-axis
  42380. */
  42381. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42382. /**
  42383. * Force the viewer to update
  42384. * @param position defines the position of the viewer
  42385. * @param xaxis defines the x axis of the viewer
  42386. * @param yaxis defines the y axis of the viewer
  42387. * @param zaxis defines the z axis of the viewer
  42388. */
  42389. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42390. /**
  42391. * Creates an instance of this axes viewer.
  42392. * @returns a new axes viewer with instanced meshes
  42393. */
  42394. createInstance(): AxesViewer;
  42395. /** Releases resources */
  42396. dispose(): void;
  42397. private static _SetRenderingGroupId;
  42398. }
  42399. }
  42400. declare module BABYLON.Debug {
  42401. /**
  42402. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42403. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42404. */
  42405. export class BoneAxesViewer extends AxesViewer {
  42406. /**
  42407. * Gets or sets the target mesh where to display the axes viewer
  42408. */
  42409. mesh: Nullable<Mesh>;
  42410. /**
  42411. * Gets or sets the target bone where to display the axes viewer
  42412. */
  42413. bone: Nullable<Bone>;
  42414. /** Gets current position */
  42415. pos: Vector3;
  42416. /** Gets direction of X axis */
  42417. xaxis: Vector3;
  42418. /** Gets direction of Y axis */
  42419. yaxis: Vector3;
  42420. /** Gets direction of Z axis */
  42421. zaxis: Vector3;
  42422. /**
  42423. * Creates a new BoneAxesViewer
  42424. * @param scene defines the hosting scene
  42425. * @param bone defines the target bone
  42426. * @param mesh defines the target mesh
  42427. * @param scaleLines defines a scaling factor for line length (1 by default)
  42428. */
  42429. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42430. /**
  42431. * Force the viewer to update
  42432. */
  42433. update(): void;
  42434. /** Releases resources */
  42435. dispose(): void;
  42436. }
  42437. }
  42438. declare module BABYLON {
  42439. /**
  42440. * Interface used to define scene explorer extensibility option
  42441. */
  42442. export interface IExplorerExtensibilityOption {
  42443. /**
  42444. * Define the option label
  42445. */
  42446. label: string;
  42447. /**
  42448. * Defines the action to execute on click
  42449. */
  42450. action: (entity: any) => void;
  42451. }
  42452. /**
  42453. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42454. */
  42455. export interface IExplorerExtensibilityGroup {
  42456. /**
  42457. * Defines a predicate to test if a given type mut be extended
  42458. */
  42459. predicate: (entity: any) => boolean;
  42460. /**
  42461. * Gets the list of options added to a type
  42462. */
  42463. entries: IExplorerExtensibilityOption[];
  42464. }
  42465. /**
  42466. * Interface used to define the options to use to create the Inspector
  42467. */
  42468. export interface IInspectorOptions {
  42469. /**
  42470. * Display in overlay mode (default: false)
  42471. */
  42472. overlay?: boolean;
  42473. /**
  42474. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42475. */
  42476. globalRoot?: HTMLElement;
  42477. /**
  42478. * Display the Scene explorer
  42479. */
  42480. showExplorer?: boolean;
  42481. /**
  42482. * Display the property inspector
  42483. */
  42484. showInspector?: boolean;
  42485. /**
  42486. * Display in embed mode (both panes on the right)
  42487. */
  42488. embedMode?: boolean;
  42489. /**
  42490. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42491. */
  42492. handleResize?: boolean;
  42493. /**
  42494. * Allow the panes to popup (default: true)
  42495. */
  42496. enablePopup?: boolean;
  42497. /**
  42498. * Allow the panes to be closed by users (default: true)
  42499. */
  42500. enableClose?: boolean;
  42501. /**
  42502. * Optional list of extensibility entries
  42503. */
  42504. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42505. /**
  42506. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42507. */
  42508. inspectorURL?: string;
  42509. }
  42510. interface Scene {
  42511. /**
  42512. * @hidden
  42513. * Backing field
  42514. */ private _debugLayer: DebugLayer;
  42515. /**
  42516. * Gets the debug layer (aka Inspector) associated with the scene
  42517. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42518. */
  42519. debugLayer: DebugLayer;
  42520. }
  42521. /**
  42522. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42523. * what is happening in your scene
  42524. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42525. */
  42526. export class DebugLayer {
  42527. /**
  42528. * Define the url to get the inspector script from.
  42529. * By default it uses the babylonjs CDN.
  42530. * @ignoreNaming
  42531. */
  42532. static InspectorURL: string;
  42533. private _scene;
  42534. private BJSINSPECTOR;
  42535. private _onPropertyChangedObservable?;
  42536. /**
  42537. * Observable triggered when a property is changed through the inspector.
  42538. */
  42539. readonly onPropertyChangedObservable: any;
  42540. /**
  42541. * Instantiates a new debug layer.
  42542. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42543. * what is happening in your scene
  42544. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42545. * @param scene Defines the scene to inspect
  42546. */
  42547. constructor(scene: Scene);
  42548. /** Creates the inspector window. */
  42549. private _createInspector;
  42550. /**
  42551. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42552. * @param entity defines the entity to select
  42553. * @param lineContainerTitle defines the specific block to highlight
  42554. */
  42555. select(entity: any, lineContainerTitle?: string): void;
  42556. /** Get the inspector from bundle or global */
  42557. private _getGlobalInspector;
  42558. /**
  42559. * Get if the inspector is visible or not.
  42560. * @returns true if visible otherwise, false
  42561. */
  42562. isVisible(): boolean;
  42563. /**
  42564. * Hide the inspector and close its window.
  42565. */
  42566. hide(): void;
  42567. /**
  42568. * Launch the debugLayer.
  42569. * @param config Define the configuration of the inspector
  42570. * @return a promise fulfilled when the debug layer is visible
  42571. */
  42572. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42573. }
  42574. }
  42575. declare module BABYLON {
  42576. /**
  42577. * Class containing static functions to help procedurally build meshes
  42578. */
  42579. export class BoxBuilder {
  42580. /**
  42581. * Creates a box mesh
  42582. * * The parameter `size` sets the size (float) of each box side (default 1)
  42583. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42584. * * 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)
  42585. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42586. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42587. * * 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
  42588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42589. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42590. * @param name defines the name of the mesh
  42591. * @param options defines the options used to create the mesh
  42592. * @param scene defines the hosting scene
  42593. * @returns the box mesh
  42594. */
  42595. static CreateBox(name: string, options: {
  42596. size?: number;
  42597. width?: number;
  42598. height?: number;
  42599. depth?: number;
  42600. faceUV?: Vector4[];
  42601. faceColors?: Color4[];
  42602. sideOrientation?: number;
  42603. frontUVs?: Vector4;
  42604. backUVs?: Vector4;
  42605. wrap?: boolean;
  42606. topBaseAt?: number;
  42607. bottomBaseAt?: number;
  42608. updatable?: boolean;
  42609. }, scene?: Nullable<Scene>): Mesh;
  42610. }
  42611. }
  42612. declare module BABYLON {
  42613. /**
  42614. * Class containing static functions to help procedurally build meshes
  42615. */
  42616. export class SphereBuilder {
  42617. /**
  42618. * Creates a sphere mesh
  42619. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42620. * * 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`)
  42621. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42622. * * 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
  42623. * * 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)
  42624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42625. * * 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
  42626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42627. * @param name defines the name of the mesh
  42628. * @param options defines the options used to create the mesh
  42629. * @param scene defines the hosting scene
  42630. * @returns the sphere mesh
  42631. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42632. */
  42633. static CreateSphere(name: string, options: {
  42634. segments?: number;
  42635. diameter?: number;
  42636. diameterX?: number;
  42637. diameterY?: number;
  42638. diameterZ?: number;
  42639. arc?: number;
  42640. slice?: number;
  42641. sideOrientation?: number;
  42642. frontUVs?: Vector4;
  42643. backUVs?: Vector4;
  42644. updatable?: boolean;
  42645. }, scene?: Nullable<Scene>): Mesh;
  42646. }
  42647. }
  42648. declare module BABYLON.Debug {
  42649. /**
  42650. * Used to show the physics impostor around the specific mesh
  42651. */
  42652. export class PhysicsViewer {
  42653. /** @hidden */
  42654. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42655. /** @hidden */
  42656. protected _meshes: Array<Nullable<AbstractMesh>>;
  42657. /** @hidden */
  42658. protected _scene: Nullable<Scene>;
  42659. /** @hidden */
  42660. protected _numMeshes: number;
  42661. /** @hidden */
  42662. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42663. private _renderFunction;
  42664. private _utilityLayer;
  42665. private _debugBoxMesh;
  42666. private _debugSphereMesh;
  42667. private _debugCylinderMesh;
  42668. private _debugMaterial;
  42669. private _debugMeshMeshes;
  42670. /**
  42671. * Creates a new PhysicsViewer
  42672. * @param scene defines the hosting scene
  42673. */
  42674. constructor(scene: Scene);
  42675. /** @hidden */
  42676. protected _updateDebugMeshes(): void;
  42677. /**
  42678. * Renders a specified physic impostor
  42679. * @param impostor defines the impostor to render
  42680. * @param targetMesh defines the mesh represented by the impostor
  42681. * @returns the new debug mesh used to render the impostor
  42682. */
  42683. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42684. /**
  42685. * Hides a specified physic impostor
  42686. * @param impostor defines the impostor to hide
  42687. */
  42688. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42689. private _getDebugMaterial;
  42690. private _getDebugBoxMesh;
  42691. private _getDebugSphereMesh;
  42692. private _getDebugCylinderMesh;
  42693. private _getDebugMeshMesh;
  42694. private _getDebugMesh;
  42695. /** Releases all resources */
  42696. dispose(): void;
  42697. }
  42698. }
  42699. declare module BABYLON {
  42700. /**
  42701. * Class containing static functions to help procedurally build meshes
  42702. */
  42703. export class LinesBuilder {
  42704. /**
  42705. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42706. * * 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
  42707. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42708. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42709. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42710. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42711. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42712. * * 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
  42713. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42715. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42716. * @param name defines the name of the new line system
  42717. * @param options defines the options used to create the line system
  42718. * @param scene defines the hosting scene
  42719. * @returns a new line system mesh
  42720. */
  42721. static CreateLineSystem(name: string, options: {
  42722. lines: Vector3[][];
  42723. updatable?: boolean;
  42724. instance?: Nullable<LinesMesh>;
  42725. colors?: Nullable<Color4[][]>;
  42726. useVertexAlpha?: boolean;
  42727. }, scene: Nullable<Scene>): LinesMesh;
  42728. /**
  42729. * Creates a line mesh
  42730. * 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
  42731. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42732. * * The parameter `points` is an array successive Vector3
  42733. * * 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
  42734. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42735. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42736. * * When updating an instance, remember that only point positions can change, not the number of points
  42737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42738. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42739. * @param name defines the name of the new line system
  42740. * @param options defines the options used to create the line system
  42741. * @param scene defines the hosting scene
  42742. * @returns a new line mesh
  42743. */
  42744. static CreateLines(name: string, options: {
  42745. points: Vector3[];
  42746. updatable?: boolean;
  42747. instance?: Nullable<LinesMesh>;
  42748. colors?: Color4[];
  42749. useVertexAlpha?: boolean;
  42750. }, scene?: Nullable<Scene>): LinesMesh;
  42751. /**
  42752. * Creates a dashed line mesh
  42753. * * 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
  42754. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42755. * * The parameter `points` is an array successive Vector3
  42756. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42757. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42758. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42759. * * 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
  42760. * * When updating an instance, remember that only point positions can change, not the number of points
  42761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42762. * @param name defines the name of the mesh
  42763. * @param options defines the options used to create the mesh
  42764. * @param scene defines the hosting scene
  42765. * @returns the dashed line mesh
  42766. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42767. */
  42768. static CreateDashedLines(name: string, options: {
  42769. points: Vector3[];
  42770. dashSize?: number;
  42771. gapSize?: number;
  42772. dashNb?: number;
  42773. updatable?: boolean;
  42774. instance?: LinesMesh;
  42775. }, scene?: Nullable<Scene>): LinesMesh;
  42776. }
  42777. }
  42778. declare module BABYLON {
  42779. /**
  42780. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42781. * in order to better appreciate the issue one might have.
  42782. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42783. */
  42784. export class RayHelper {
  42785. /**
  42786. * Defines the ray we are currently tryin to visualize.
  42787. */
  42788. ray: Nullable<Ray>;
  42789. private _renderPoints;
  42790. private _renderLine;
  42791. private _renderFunction;
  42792. private _scene;
  42793. private _updateToMeshFunction;
  42794. private _attachedToMesh;
  42795. private _meshSpaceDirection;
  42796. private _meshSpaceOrigin;
  42797. /**
  42798. * Helper function to create a colored helper in a scene in one line.
  42799. * @param ray Defines the ray we are currently tryin to visualize
  42800. * @param scene Defines the scene the ray is used in
  42801. * @param color Defines the color we want to see the ray in
  42802. * @returns The newly created ray helper.
  42803. */
  42804. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42805. /**
  42806. * Instantiate a new ray helper.
  42807. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42808. * in order to better appreciate the issue one might have.
  42809. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42810. * @param ray Defines the ray we are currently tryin to visualize
  42811. */
  42812. constructor(ray: Ray);
  42813. /**
  42814. * Shows the ray we are willing to debug.
  42815. * @param scene Defines the scene the ray needs to be rendered in
  42816. * @param color Defines the color the ray needs to be rendered in
  42817. */
  42818. show(scene: Scene, color?: Color3): void;
  42819. /**
  42820. * Hides the ray we are debugging.
  42821. */
  42822. hide(): void;
  42823. private _render;
  42824. /**
  42825. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42826. * @param mesh Defines the mesh we want the helper attached to
  42827. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42828. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42829. * @param length Defines the length of the ray
  42830. */
  42831. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42832. /**
  42833. * Detach the ray helper from the mesh it has previously been attached to.
  42834. */
  42835. detachFromMesh(): void;
  42836. private _updateToMesh;
  42837. /**
  42838. * Dispose the helper and release its associated resources.
  42839. */
  42840. dispose(): void;
  42841. }
  42842. }
  42843. declare module BABYLON.Debug {
  42844. /**
  42845. * Class used to render a debug view of a given skeleton
  42846. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42847. */
  42848. export class SkeletonViewer {
  42849. /** defines the skeleton to render */
  42850. skeleton: Skeleton;
  42851. /** defines the mesh attached to the skeleton */
  42852. mesh: AbstractMesh;
  42853. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42854. autoUpdateBonesMatrices: boolean;
  42855. /** defines the rendering group id to use with the viewer */
  42856. renderingGroupId: number;
  42857. /** Gets or sets the color used to render the skeleton */
  42858. color: Color3;
  42859. private _scene;
  42860. private _debugLines;
  42861. private _debugMesh;
  42862. private _isEnabled;
  42863. private _renderFunction;
  42864. private _utilityLayer;
  42865. /**
  42866. * Returns the mesh used to render the bones
  42867. */
  42868. readonly debugMesh: Nullable<LinesMesh>;
  42869. /**
  42870. * Creates a new SkeletonViewer
  42871. * @param skeleton defines the skeleton to render
  42872. * @param mesh defines the mesh attached to the skeleton
  42873. * @param scene defines the hosting scene
  42874. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42875. * @param renderingGroupId defines the rendering group id to use with the viewer
  42876. */
  42877. constructor(
  42878. /** defines the skeleton to render */
  42879. skeleton: Skeleton,
  42880. /** defines the mesh attached to the skeleton */
  42881. mesh: AbstractMesh, scene: Scene,
  42882. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42883. autoUpdateBonesMatrices?: boolean,
  42884. /** defines the rendering group id to use with the viewer */
  42885. renderingGroupId?: number);
  42886. /** Gets or sets a boolean indicating if the viewer is enabled */
  42887. isEnabled: boolean;
  42888. private _getBonePosition;
  42889. private _getLinesForBonesWithLength;
  42890. private _getLinesForBonesNoLength;
  42891. /** Update the viewer to sync with current skeleton state */
  42892. update(): void;
  42893. /** Release associated resources */
  42894. dispose(): void;
  42895. }
  42896. }
  42897. declare module BABYLON {
  42898. /**
  42899. * Options to create the null engine
  42900. */
  42901. export class NullEngineOptions {
  42902. /**
  42903. * Render width (Default: 512)
  42904. */
  42905. renderWidth: number;
  42906. /**
  42907. * Render height (Default: 256)
  42908. */
  42909. renderHeight: number;
  42910. /**
  42911. * Texture size (Default: 512)
  42912. */
  42913. textureSize: number;
  42914. /**
  42915. * If delta time between frames should be constant
  42916. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42917. */
  42918. deterministicLockstep: boolean;
  42919. /**
  42920. * Maximum about of steps between frames (Default: 4)
  42921. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42922. */
  42923. lockstepMaxSteps: number;
  42924. }
  42925. /**
  42926. * The null engine class provides support for headless version of babylon.js.
  42927. * This can be used in server side scenario or for testing purposes
  42928. */
  42929. export class NullEngine extends Engine {
  42930. private _options;
  42931. /**
  42932. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42933. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42934. * @returns true if engine is in deterministic lock step mode
  42935. */
  42936. isDeterministicLockStep(): boolean;
  42937. /**
  42938. * Gets the max steps when engine is running in deterministic lock step
  42939. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42940. * @returns the max steps
  42941. */
  42942. getLockstepMaxSteps(): number;
  42943. /**
  42944. * Gets the current hardware scaling level.
  42945. * By default the hardware scaling level is computed from the window device ratio.
  42946. * 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.
  42947. * @returns a number indicating the current hardware scaling level
  42948. */
  42949. getHardwareScalingLevel(): number;
  42950. constructor(options?: NullEngineOptions);
  42951. /**
  42952. * Creates a vertex buffer
  42953. * @param vertices the data for the vertex buffer
  42954. * @returns the new WebGL static buffer
  42955. */
  42956. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42957. /**
  42958. * Creates a new index buffer
  42959. * @param indices defines the content of the index buffer
  42960. * @param updatable defines if the index buffer must be updatable
  42961. * @returns a new webGL buffer
  42962. */
  42963. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42964. /**
  42965. * Clear the current render buffer or the current render target (if any is set up)
  42966. * @param color defines the color to use
  42967. * @param backBuffer defines if the back buffer must be cleared
  42968. * @param depth defines if the depth buffer must be cleared
  42969. * @param stencil defines if the stencil buffer must be cleared
  42970. */
  42971. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42972. /**
  42973. * Gets the current render width
  42974. * @param useScreen defines if screen size must be used (or the current render target if any)
  42975. * @returns a number defining the current render width
  42976. */
  42977. getRenderWidth(useScreen?: boolean): number;
  42978. /**
  42979. * Gets the current render height
  42980. * @param useScreen defines if screen size must be used (or the current render target if any)
  42981. * @returns a number defining the current render height
  42982. */
  42983. getRenderHeight(useScreen?: boolean): number;
  42984. /**
  42985. * Set the WebGL's viewport
  42986. * @param viewport defines the viewport element to be used
  42987. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  42988. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  42989. */
  42990. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  42991. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42992. /**
  42993. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  42994. * @param pipelineContext defines the pipeline context to use
  42995. * @param uniformsNames defines the list of uniform names
  42996. * @returns an array of webGL uniform locations
  42997. */
  42998. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42999. /**
  43000. * Gets the lsit of active attributes for a given webGL program
  43001. * @param pipelineContext defines the pipeline context to use
  43002. * @param attributesNames defines the list of attribute names to get
  43003. * @returns an array of indices indicating the offset of each attribute
  43004. */
  43005. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43006. /**
  43007. * Binds an effect to the webGL context
  43008. * @param effect defines the effect to bind
  43009. */
  43010. bindSamplers(effect: Effect): void;
  43011. /**
  43012. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  43013. * @param effect defines the effect to activate
  43014. */
  43015. enableEffect(effect: Effect): void;
  43016. /**
  43017. * Set various states to the webGL context
  43018. * @param culling defines backface culling state
  43019. * @param zOffset defines the value to apply to zOffset (0 by default)
  43020. * @param force defines if states must be applied even if cache is up to date
  43021. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  43022. */
  43023. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43024. /**
  43025. * Set the value of an uniform to an array of int32
  43026. * @param uniform defines the webGL uniform location where to store the value
  43027. * @param array defines the array of int32 to store
  43028. */
  43029. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43030. /**
  43031. * Set the value of an uniform to an array of int32 (stored as vec2)
  43032. * @param uniform defines the webGL uniform location where to store the value
  43033. * @param array defines the array of int32 to store
  43034. */
  43035. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43036. /**
  43037. * Set the value of an uniform to an array of int32 (stored as vec3)
  43038. * @param uniform defines the webGL uniform location where to store the value
  43039. * @param array defines the array of int32 to store
  43040. */
  43041. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43042. /**
  43043. * Set the value of an uniform to an array of int32 (stored as vec4)
  43044. * @param uniform defines the webGL uniform location where to store the value
  43045. * @param array defines the array of int32 to store
  43046. */
  43047. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43048. /**
  43049. * Set the value of an uniform to an array of float32
  43050. * @param uniform defines the webGL uniform location where to store the value
  43051. * @param array defines the array of float32 to store
  43052. */
  43053. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43054. /**
  43055. * Set the value of an uniform to an array of float32 (stored as vec2)
  43056. * @param uniform defines the webGL uniform location where to store the value
  43057. * @param array defines the array of float32 to store
  43058. */
  43059. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43060. /**
  43061. * Set the value of an uniform to an array of float32 (stored as vec3)
  43062. * @param uniform defines the webGL uniform location where to store the value
  43063. * @param array defines the array of float32 to store
  43064. */
  43065. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43066. /**
  43067. * Set the value of an uniform to an array of float32 (stored as vec4)
  43068. * @param uniform defines the webGL uniform location where to store the value
  43069. * @param array defines the array of float32 to store
  43070. */
  43071. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43072. /**
  43073. * Set the value of an uniform to an array of number
  43074. * @param uniform defines the webGL uniform location where to store the value
  43075. * @param array defines the array of number to store
  43076. */
  43077. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43078. /**
  43079. * Set the value of an uniform to an array of number (stored as vec2)
  43080. * @param uniform defines the webGL uniform location where to store the value
  43081. * @param array defines the array of number to store
  43082. */
  43083. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43084. /**
  43085. * Set the value of an uniform to an array of number (stored as vec3)
  43086. * @param uniform defines the webGL uniform location where to store the value
  43087. * @param array defines the array of number to store
  43088. */
  43089. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43090. /**
  43091. * Set the value of an uniform to an array of number (stored as vec4)
  43092. * @param uniform defines the webGL uniform location where to store the value
  43093. * @param array defines the array of number to store
  43094. */
  43095. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43096. /**
  43097. * Set the value of an uniform to an array of float32 (stored as matrices)
  43098. * @param uniform defines the webGL uniform location where to store the value
  43099. * @param matrices defines the array of float32 to store
  43100. */
  43101. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43102. /**
  43103. * Set the value of an uniform to a matrix (3x3)
  43104. * @param uniform defines the webGL uniform location where to store the value
  43105. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  43106. */
  43107. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43108. /**
  43109. * Set the value of an uniform to a matrix (2x2)
  43110. * @param uniform defines the webGL uniform location where to store the value
  43111. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  43112. */
  43113. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43114. /**
  43115. * Set the value of an uniform to a number (float)
  43116. * @param uniform defines the webGL uniform location where to store the value
  43117. * @param value defines the float number to store
  43118. */
  43119. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43120. /**
  43121. * Set the value of an uniform to a vec2
  43122. * @param uniform defines the webGL uniform location where to store the value
  43123. * @param x defines the 1st component of the value
  43124. * @param y defines the 2nd component of the value
  43125. */
  43126. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43127. /**
  43128. * Set the value of an uniform to a vec3
  43129. * @param uniform defines the webGL uniform location where to store the value
  43130. * @param x defines the 1st component of the value
  43131. * @param y defines the 2nd component of the value
  43132. * @param z defines the 3rd component of the value
  43133. */
  43134. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43135. /**
  43136. * Set the value of an uniform to a boolean
  43137. * @param uniform defines the webGL uniform location where to store the value
  43138. * @param bool defines the boolean to store
  43139. */
  43140. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43141. /**
  43142. * Set the value of an uniform to a vec4
  43143. * @param uniform defines the webGL uniform location where to store the value
  43144. * @param x defines the 1st component of the value
  43145. * @param y defines the 2nd component of the value
  43146. * @param z defines the 3rd component of the value
  43147. * @param w defines the 4th component of the value
  43148. */
  43149. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43150. /**
  43151. * Sets the current alpha mode
  43152. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  43153. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  43154. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43155. */
  43156. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43157. /**
  43158. * Bind webGl buffers directly to the webGL context
  43159. * @param vertexBuffers defines the vertex buffer to bind
  43160. * @param indexBuffer defines the index buffer to bind
  43161. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  43162. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  43163. * @param effect defines the effect associated with the vertex buffer
  43164. */
  43165. bindBuffers(vertexBuffers: {
  43166. [key: string]: VertexBuffer;
  43167. }, indexBuffer: DataBuffer, effect: Effect): void;
  43168. /**
  43169. * Force the entire cache to be cleared
  43170. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  43171. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  43172. */
  43173. wipeCaches(bruteForce?: boolean): void;
  43174. /**
  43175. * Send a draw order
  43176. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  43177. * @param indexStart defines the starting index
  43178. * @param indexCount defines the number of index to draw
  43179. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43180. */
  43181. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43182. /**
  43183. * Draw a list of indexed primitives
  43184. * @param fillMode defines the primitive to use
  43185. * @param indexStart defines the starting index
  43186. * @param indexCount defines the number of index to draw
  43187. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43188. */
  43189. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43190. /**
  43191. * Draw a list of unindexed primitives
  43192. * @param fillMode defines the primitive to use
  43193. * @param verticesStart defines the index of first vertex to draw
  43194. * @param verticesCount defines the count of vertices to draw
  43195. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43196. */
  43197. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43198. /** @hidden */ private _createTexture(): WebGLTexture;
  43199. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  43200. /**
  43201. * Usually called from Texture.ts.
  43202. * Passed information to create a WebGLTexture
  43203. * @param urlArg defines a value which contains one of the following:
  43204. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  43205. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  43206. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  43207. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  43208. * @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)
  43209. * @param scene needed for loading to the correct scene
  43210. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  43211. * @param onLoad optional callback to be called upon successful completion
  43212. * @param onError optional callback to be called upon failure
  43213. * @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
  43214. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  43215. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  43216. * @param forcedExtension defines the extension to use to pick the right loader
  43217. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  43218. * @returns a InternalTexture for assignment back into BABYLON.Texture
  43219. */
  43220. 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;
  43221. /**
  43222. * Creates a new render target texture
  43223. * @param size defines the size of the texture
  43224. * @param options defines the options used to create the texture
  43225. * @returns a new render target texture stored in an InternalTexture
  43226. */
  43227. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43228. /**
  43229. * Update the sampling mode of a given texture
  43230. * @param samplingMode defines the required sampling mode
  43231. * @param texture defines the texture to update
  43232. */
  43233. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43234. /**
  43235. * Binds the frame buffer to the specified texture.
  43236. * @param texture The texture to render to or null for the default canvas
  43237. * @param faceIndex The face of the texture to render to in case of cube texture
  43238. * @param requiredWidth The width of the target to render to
  43239. * @param requiredHeight The height of the target to render to
  43240. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  43241. * @param depthStencilTexture The depth stencil texture to use to render
  43242. * @param lodLevel defines le lod level to bind to the frame buffer
  43243. */
  43244. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43245. /**
  43246. * Unbind the current render target texture from the webGL context
  43247. * @param texture defines the render target texture to unbind
  43248. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43249. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43250. */
  43251. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43252. /**
  43253. * Creates a dynamic vertex buffer
  43254. * @param vertices the data for the dynamic vertex buffer
  43255. * @returns the new WebGL dynamic buffer
  43256. */
  43257. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43258. /**
  43259. * Update the content of a dynamic texture
  43260. * @param texture defines the texture to update
  43261. * @param canvas defines the canvas containing the source
  43262. * @param invertY defines if data must be stored with Y axis inverted
  43263. * @param premulAlpha defines if alpha is stored as premultiplied
  43264. * @param format defines the format of the data
  43265. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  43266. */
  43267. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43268. /**
  43269. * Gets a boolean indicating if all created effects are ready
  43270. * @returns true if all effects are ready
  43271. */
  43272. areAllEffectsReady(): boolean;
  43273. /**
  43274. * @hidden
  43275. * Get the current error code of the webGL context
  43276. * @returns the error code
  43277. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43278. */
  43279. getError(): number;
  43280. /** @hidden */ private _getUnpackAlignement(): number;
  43281. /** @hidden */ private _unpackFlipY(value: boolean): void;
  43282. /**
  43283. * Update a dynamic index buffer
  43284. * @param indexBuffer defines the target index buffer
  43285. * @param indices defines the data to update
  43286. * @param offset defines the offset in the target index buffer where update should start
  43287. */
  43288. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43289. /**
  43290. * Updates a dynamic vertex buffer.
  43291. * @param vertexBuffer the vertex buffer to update
  43292. * @param vertices the data used to update the vertex buffer
  43293. * @param byteOffset the byte offset of the data (optional)
  43294. * @param byteLength the byte length of the data (optional)
  43295. */
  43296. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43297. /** @hidden */ private _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43298. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  43299. protected _deleteBuffer(buffer: WebGLBuffer): void;
  43300. /**
  43301. * 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
  43302. */
  43303. releaseEffects(): void;
  43304. displayLoadingUI(): void;
  43305. hideLoadingUI(): void;
  43306. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43307. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43308. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43309. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43310. }
  43311. }
  43312. declare module BABYLON {
  43313. /** @hidden */
  43314. export class _OcclusionDataStorage {
  43315. /** @hidden */
  43316. occlusionInternalRetryCounter: number;
  43317. /** @hidden */
  43318. isOcclusionQueryInProgress: boolean;
  43319. /** @hidden */
  43320. isOccluded: boolean;
  43321. /** @hidden */
  43322. occlusionRetryCount: number;
  43323. /** @hidden */
  43324. occlusionType: number;
  43325. /** @hidden */
  43326. occlusionQueryAlgorithmType: number;
  43327. }
  43328. interface Engine {
  43329. /**
  43330. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43331. * @return the new query
  43332. */
  43333. createQuery(): WebGLQuery;
  43334. /**
  43335. * Delete and release a webGL query
  43336. * @param query defines the query to delete
  43337. * @return the current engine
  43338. */
  43339. deleteQuery(query: WebGLQuery): Engine;
  43340. /**
  43341. * Check if a given query has resolved and got its value
  43342. * @param query defines the query to check
  43343. * @returns true if the query got its value
  43344. */
  43345. isQueryResultAvailable(query: WebGLQuery): boolean;
  43346. /**
  43347. * Gets the value of a given query
  43348. * @param query defines the query to check
  43349. * @returns the value of the query
  43350. */
  43351. getQueryResult(query: WebGLQuery): number;
  43352. /**
  43353. * Initiates an occlusion query
  43354. * @param algorithmType defines the algorithm to use
  43355. * @param query defines the query to use
  43356. * @returns the current engine
  43357. * @see http://doc.babylonjs.com/features/occlusionquery
  43358. */
  43359. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43360. /**
  43361. * Ends an occlusion query
  43362. * @see http://doc.babylonjs.com/features/occlusionquery
  43363. * @param algorithmType defines the algorithm to use
  43364. * @returns the current engine
  43365. */
  43366. endOcclusionQuery(algorithmType: number): Engine;
  43367. /**
  43368. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43369. * Please note that only one query can be issued at a time
  43370. * @returns a time token used to track the time span
  43371. */
  43372. startTimeQuery(): Nullable<_TimeToken>;
  43373. /**
  43374. * Ends a time query
  43375. * @param token defines the token used to measure the time span
  43376. * @returns the time spent (in ns)
  43377. */
  43378. endTimeQuery(token: _TimeToken): int;
  43379. /** @hidden */ private _currentNonTimestampToken: Nullable<_TimeToken>;
  43380. /** @hidden */ private _createTimeQuery(): WebGLQuery;
  43381. /** @hidden */ private _deleteTimeQuery(query: WebGLQuery): void;
  43382. /** @hidden */ private _getGlAlgorithmType(algorithmType: number): number;
  43383. /** @hidden */ private _getTimeQueryResult(query: WebGLQuery): any;
  43384. /** @hidden */ private _getTimeQueryAvailability(query: WebGLQuery): any;
  43385. }
  43386. interface AbstractMesh {
  43387. /**
  43388. * Backing filed
  43389. * @hidden
  43390. */ private __occlusionDataStorage: _OcclusionDataStorage;
  43391. /**
  43392. * Access property
  43393. * @hidden
  43394. */ private _occlusionDataStorage: _OcclusionDataStorage;
  43395. /**
  43396. * 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.
  43397. * The default value is -1 which means don't break the query and wait till the result
  43398. * @see http://doc.babylonjs.com/features/occlusionquery
  43399. */
  43400. occlusionRetryCount: number;
  43401. /**
  43402. * 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:
  43403. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43404. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43405. * * 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.
  43406. * @see http://doc.babylonjs.com/features/occlusionquery
  43407. */
  43408. occlusionType: number;
  43409. /**
  43410. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43411. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43412. * * 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.
  43413. * @see http://doc.babylonjs.com/features/occlusionquery
  43414. */
  43415. occlusionQueryAlgorithmType: number;
  43416. /**
  43417. * 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
  43418. * @see http://doc.babylonjs.com/features/occlusionquery
  43419. */
  43420. isOccluded: boolean;
  43421. /**
  43422. * Flag to check the progress status of the query
  43423. * @see http://doc.babylonjs.com/features/occlusionquery
  43424. */
  43425. isOcclusionQueryInProgress: boolean;
  43426. }
  43427. }
  43428. declare module BABYLON {
  43429. /** @hidden */
  43430. export var _forceTransformFeedbackToBundle: boolean;
  43431. interface Engine {
  43432. /**
  43433. * Creates a webGL transform feedback object
  43434. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43435. * @returns the webGL transform feedback object
  43436. */
  43437. createTransformFeedback(): WebGLTransformFeedback;
  43438. /**
  43439. * Delete a webGL transform feedback object
  43440. * @param value defines the webGL transform feedback object to delete
  43441. */
  43442. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43443. /**
  43444. * Bind a webGL transform feedback object to the webgl context
  43445. * @param value defines the webGL transform feedback object to bind
  43446. */
  43447. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43448. /**
  43449. * Begins a transform feedback operation
  43450. * @param usePoints defines if points or triangles must be used
  43451. */
  43452. beginTransformFeedback(usePoints: boolean): void;
  43453. /**
  43454. * Ends a transform feedback operation
  43455. */
  43456. endTransformFeedback(): void;
  43457. /**
  43458. * Specify the varyings to use with transform feedback
  43459. * @param program defines the associated webGL program
  43460. * @param value defines the list of strings representing the varying names
  43461. */
  43462. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43463. /**
  43464. * Bind a webGL buffer for a transform feedback operation
  43465. * @param value defines the webGL buffer to bind
  43466. */
  43467. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43468. }
  43469. }
  43470. declare module BABYLON {
  43471. /**
  43472. * Creation options of the multi render target texture.
  43473. */
  43474. export interface IMultiRenderTargetOptions {
  43475. /**
  43476. * Define if the texture needs to create mip maps after render.
  43477. */
  43478. generateMipMaps?: boolean;
  43479. /**
  43480. * Define the types of all the draw buffers we want to create
  43481. */
  43482. types?: number[];
  43483. /**
  43484. * Define the sampling modes of all the draw buffers we want to create
  43485. */
  43486. samplingModes?: number[];
  43487. /**
  43488. * Define if a depth buffer is required
  43489. */
  43490. generateDepthBuffer?: boolean;
  43491. /**
  43492. * Define if a stencil buffer is required
  43493. */
  43494. generateStencilBuffer?: boolean;
  43495. /**
  43496. * Define if a depth texture is required instead of a depth buffer
  43497. */
  43498. generateDepthTexture?: boolean;
  43499. /**
  43500. * Define the number of desired draw buffers
  43501. */
  43502. textureCount?: number;
  43503. /**
  43504. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43505. */
  43506. doNotChangeAspectRatio?: boolean;
  43507. /**
  43508. * Define the default type of the buffers we are creating
  43509. */
  43510. defaultType?: number;
  43511. }
  43512. /**
  43513. * A multi render target, like a render target provides the ability to render to a texture.
  43514. * Unlike the render target, it can render to several draw buffers in one draw.
  43515. * This is specially interesting in deferred rendering or for any effects requiring more than
  43516. * just one color from a single pass.
  43517. */
  43518. export class MultiRenderTarget extends RenderTargetTexture {
  43519. private _internalTextures;
  43520. private _textures;
  43521. private _multiRenderTargetOptions;
  43522. /**
  43523. * Get if draw buffers are currently supported by the used hardware and browser.
  43524. */
  43525. readonly isSupported: boolean;
  43526. /**
  43527. * Get the list of textures generated by the multi render target.
  43528. */
  43529. readonly textures: Texture[];
  43530. /**
  43531. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43532. */
  43533. readonly depthTexture: Texture;
  43534. /**
  43535. * Set the wrapping mode on U of all the textures we are rendering to.
  43536. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43537. */
  43538. wrapU: number;
  43539. /**
  43540. * Set the wrapping mode on V of all the textures we are rendering to.
  43541. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43542. */
  43543. wrapV: number;
  43544. /**
  43545. * Instantiate a new multi render target texture.
  43546. * A multi render target, like a render target provides the ability to render to a texture.
  43547. * Unlike the render target, it can render to several draw buffers in one draw.
  43548. * This is specially interesting in deferred rendering or for any effects requiring more than
  43549. * just one color from a single pass.
  43550. * @param name Define the name of the texture
  43551. * @param size Define the size of the buffers to render to
  43552. * @param count Define the number of target we are rendering into
  43553. * @param scene Define the scene the texture belongs to
  43554. * @param options Define the options used to create the multi render target
  43555. */
  43556. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43557. /** @hidden */ private _rebuild(): void;
  43558. private _createInternalTextures;
  43559. private _createTextures;
  43560. /**
  43561. * Define the number of samples used if MSAA is enabled.
  43562. */
  43563. samples: number;
  43564. /**
  43565. * Resize all the textures in the multi render target.
  43566. * Be carrefull as it will recreate all the data in the new texture.
  43567. * @param size Define the new size
  43568. */
  43569. resize(size: any): void;
  43570. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43571. /**
  43572. * Dispose the render targets and their associated resources
  43573. */
  43574. dispose(): void;
  43575. /**
  43576. * Release all the underlying texture used as draw buffers.
  43577. */
  43578. releaseInternalTextures(): void;
  43579. }
  43580. }
  43581. declare module BABYLON {
  43582. interface ThinEngine {
  43583. /**
  43584. * Unbind a list of render target textures from the webGL context
  43585. * This is used only when drawBuffer extension or webGL2 are active
  43586. * @param textures defines the render target textures to unbind
  43587. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43588. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43589. */
  43590. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43591. /**
  43592. * Create a multi render target texture
  43593. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43594. * @param size defines the size of the texture
  43595. * @param options defines the creation options
  43596. * @returns the cube texture as an InternalTexture
  43597. */
  43598. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43599. /**
  43600. * Update the sample count for a given multiple render target texture
  43601. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43602. * @param textures defines the textures to update
  43603. * @param samples defines the sample count to set
  43604. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43605. */
  43606. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43607. }
  43608. }
  43609. declare module BABYLON {
  43610. /** @hidden */
  43611. export var rgbdEncodePixelShader: {
  43612. name: string;
  43613. shader: string;
  43614. };
  43615. }
  43616. declare module BABYLON {
  43617. /** @hidden */
  43618. export var rgbdDecodePixelShader: {
  43619. name: string;
  43620. shader: string;
  43621. };
  43622. }
  43623. declare module BABYLON {
  43624. /**
  43625. * Raw texture data and descriptor sufficient for WebGL texture upload
  43626. */
  43627. export interface EnvironmentTextureInfo {
  43628. /**
  43629. * Version of the environment map
  43630. */
  43631. version: number;
  43632. /**
  43633. * Width of image
  43634. */
  43635. width: number;
  43636. /**
  43637. * Irradiance information stored in the file.
  43638. */
  43639. irradiance: any;
  43640. /**
  43641. * Specular information stored in the file.
  43642. */
  43643. specular: any;
  43644. }
  43645. /**
  43646. * Defines One Image in the file. It requires only the position in the file
  43647. * as well as the length.
  43648. */
  43649. interface BufferImageData {
  43650. /**
  43651. * Length of the image data.
  43652. */
  43653. length: number;
  43654. /**
  43655. * Position of the data from the null terminator delimiting the end of the JSON.
  43656. */
  43657. position: number;
  43658. }
  43659. /**
  43660. * Defines the specular data enclosed in the file.
  43661. * This corresponds to the version 1 of the data.
  43662. */
  43663. export interface EnvironmentTextureSpecularInfoV1 {
  43664. /**
  43665. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  43666. */
  43667. specularDataPosition?: number;
  43668. /**
  43669. * This contains all the images data needed to reconstruct the cubemap.
  43670. */
  43671. mipmaps: Array<BufferImageData>;
  43672. /**
  43673. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  43674. */
  43675. lodGenerationScale: number;
  43676. }
  43677. /**
  43678. * Sets of helpers addressing the serialization and deserialization of environment texture
  43679. * stored in a BabylonJS env file.
  43680. * Those files are usually stored as .env files.
  43681. */
  43682. export class EnvironmentTextureTools {
  43683. /**
  43684. * Magic number identifying the env file.
  43685. */
  43686. private static _MagicBytes;
  43687. /**
  43688. * Gets the environment info from an env file.
  43689. * @param data The array buffer containing the .env bytes.
  43690. * @returns the environment file info (the json header) if successfully parsed.
  43691. */
  43692. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  43693. /**
  43694. * Creates an environment texture from a loaded cube texture.
  43695. * @param texture defines the cube texture to convert in env file
  43696. * @return a promise containing the environment data if succesfull.
  43697. */
  43698. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  43699. /**
  43700. * Creates a JSON representation of the spherical data.
  43701. * @param texture defines the texture containing the polynomials
  43702. * @return the JSON representation of the spherical info
  43703. */
  43704. private static _CreateEnvTextureIrradiance;
  43705. /**
  43706. * Creates the ArrayBufferViews used for initializing environment texture image data.
  43707. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  43708. * @param info parameters that determine what views will be created for accessing the underlying buffer
  43709. * @return the views described by info providing access to the underlying buffer
  43710. */
  43711. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  43712. /**
  43713. * Uploads the texture info contained in the env file to the GPU.
  43714. * @param texture defines the internal texture to upload to
  43715. * @param arrayBuffer defines the buffer cotaining the data to load
  43716. * @param info defines the texture info retrieved through the GetEnvInfo method
  43717. * @returns a promise
  43718. */
  43719. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  43720. /**
  43721. * Uploads the levels of image data to the GPU.
  43722. * @param texture defines the internal texture to upload to
  43723. * @param imageData defines the array buffer views of image data [mipmap][face]
  43724. * @returns a promise
  43725. */
  43726. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  43727. /**
  43728. * Uploads spherical polynomials information to the texture.
  43729. * @param texture defines the texture we are trying to upload the information to
  43730. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  43731. */
  43732. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  43733. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  43734. }
  43735. }
  43736. declare module BABYLON {
  43737. /**
  43738. * Contains position and normal vectors for a vertex
  43739. */
  43740. export class PositionNormalVertex {
  43741. /** the position of the vertex (defaut: 0,0,0) */
  43742. position: Vector3;
  43743. /** the normal of the vertex (defaut: 0,1,0) */
  43744. normal: Vector3;
  43745. /**
  43746. * Creates a PositionNormalVertex
  43747. * @param position the position of the vertex (defaut: 0,0,0)
  43748. * @param normal the normal of the vertex (defaut: 0,1,0)
  43749. */
  43750. constructor(
  43751. /** the position of the vertex (defaut: 0,0,0) */
  43752. position?: Vector3,
  43753. /** the normal of the vertex (defaut: 0,1,0) */
  43754. normal?: Vector3);
  43755. /**
  43756. * Clones the PositionNormalVertex
  43757. * @returns the cloned PositionNormalVertex
  43758. */
  43759. clone(): PositionNormalVertex;
  43760. }
  43761. /**
  43762. * Contains position, normal and uv vectors for a vertex
  43763. */
  43764. export class PositionNormalTextureVertex {
  43765. /** the position of the vertex (defaut: 0,0,0) */
  43766. position: Vector3;
  43767. /** the normal of the vertex (defaut: 0,1,0) */
  43768. normal: Vector3;
  43769. /** the uv of the vertex (default: 0,0) */
  43770. uv: Vector2;
  43771. /**
  43772. * Creates a PositionNormalTextureVertex
  43773. * @param position the position of the vertex (defaut: 0,0,0)
  43774. * @param normal the normal of the vertex (defaut: 0,1,0)
  43775. * @param uv the uv of the vertex (default: 0,0)
  43776. */
  43777. constructor(
  43778. /** the position of the vertex (defaut: 0,0,0) */
  43779. position?: Vector3,
  43780. /** the normal of the vertex (defaut: 0,1,0) */
  43781. normal?: Vector3,
  43782. /** the uv of the vertex (default: 0,0) */
  43783. uv?: Vector2);
  43784. /**
  43785. * Clones the PositionNormalTextureVertex
  43786. * @returns the cloned PositionNormalTextureVertex
  43787. */
  43788. clone(): PositionNormalTextureVertex;
  43789. }
  43790. }
  43791. declare module BABYLON {
  43792. /** @hidden */
  43793. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  43794. private _genericAttributeLocation;
  43795. private _varyingLocationCount;
  43796. private _varyingLocationMap;
  43797. private _replacements;
  43798. private _textureCount;
  43799. private _uniforms;
  43800. lineProcessor(line: string): string;
  43801. attributeProcessor(attribute: string): string;
  43802. varyingProcessor(varying: string, isFragment: boolean): string;
  43803. uniformProcessor(uniform: string): string;
  43804. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  43805. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  43806. }
  43807. }
  43808. declare module BABYLON {
  43809. /**
  43810. * Container for accessors for natively-stored mesh data buffers.
  43811. */
  43812. class NativeDataBuffer extends DataBuffer {
  43813. /**
  43814. * Accessor value used to identify/retrieve a natively-stored index buffer.
  43815. */
  43816. nativeIndexBuffer?: any;
  43817. /**
  43818. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  43819. */
  43820. nativeVertexBuffer?: any;
  43821. }
  43822. /** @hidden */
  43823. export class NativeEngine extends Engine {
  43824. private readonly _native;
  43825. getHardwareScalingLevel(): number;
  43826. constructor();
  43827. /**
  43828. * Can be used to override the current requestAnimationFrame requester.
  43829. * @hidden
  43830. */
  43831. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  43832. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43833. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  43834. createVertexBuffer(data: DataArray): NativeDataBuffer;
  43835. recordVertexArrayObject(vertexBuffers: {
  43836. [key: string]: VertexBuffer;
  43837. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  43838. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  43839. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  43840. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43841. /**
  43842. * Draw a list of indexed primitives
  43843. * @param fillMode defines the primitive to use
  43844. * @param indexStart defines the starting index
  43845. * @param indexCount defines the number of index to draw
  43846. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43847. */
  43848. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43849. /**
  43850. * Draw a list of unindexed primitives
  43851. * @param fillMode defines the primitive to use
  43852. * @param verticesStart defines the index of first vertex to draw
  43853. * @param verticesCount defines the count of vertices to draw
  43854. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43855. */
  43856. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43857. createPipelineContext(): IPipelineContext; private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  43858. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  43859. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  43860. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  43861. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  43862. protected _setProgram(program: WebGLProgram): void; private _releaseEffect(effect: Effect): void; private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  43863. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  43864. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  43865. bindSamplers(effect: Effect): void;
  43866. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  43867. getRenderWidth(useScreen?: boolean): number;
  43868. getRenderHeight(useScreen?: boolean): number;
  43869. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  43870. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43871. /**
  43872. * Set the z offset to apply to current rendering
  43873. * @param value defines the offset to apply
  43874. */
  43875. setZOffset(value: number): void;
  43876. /**
  43877. * Gets the current value of the zOffset
  43878. * @returns the current zOffset state
  43879. */
  43880. getZOffset(): number;
  43881. /**
  43882. * Enable or disable depth buffering
  43883. * @param enable defines the state to set
  43884. */
  43885. setDepthBuffer(enable: boolean): void;
  43886. /**
  43887. * Gets a boolean indicating if depth writing is enabled
  43888. * @returns the current depth writing state
  43889. */
  43890. getDepthWrite(): boolean;
  43891. /**
  43892. * Enable or disable depth writing
  43893. * @param enable defines the state to set
  43894. */
  43895. setDepthWrite(enable: boolean): void;
  43896. /**
  43897. * Enable or disable color writing
  43898. * @param enable defines the state to set
  43899. */
  43900. setColorWrite(enable: boolean): void;
  43901. /**
  43902. * Gets a boolean indicating if color writing is enabled
  43903. * @returns the current color writing state
  43904. */
  43905. getColorWrite(): boolean;
  43906. /**
  43907. * Sets alpha constants used by some alpha blending modes
  43908. * @param r defines the red component
  43909. * @param g defines the green component
  43910. * @param b defines the blue component
  43911. * @param a defines the alpha component
  43912. */
  43913. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  43914. /**
  43915. * Sets the current alpha mode
  43916. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  43917. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  43918. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43919. */
  43920. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43921. /**
  43922. * Gets the current alpha mode
  43923. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43924. * @returns the current alpha mode
  43925. */
  43926. getAlphaMode(): number;
  43927. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43928. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43929. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43930. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43931. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43932. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43933. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43934. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43935. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43936. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43937. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43938. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43939. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43940. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43941. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43942. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43943. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43944. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43945. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43946. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43947. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  43948. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  43949. wipeCaches(bruteForce?: boolean): void; private _createTexture(): WebGLTexture;
  43950. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  43951. /**
  43952. * Usually called from BABYLON.Texture.ts.
  43953. * Passed information to create a WebGLTexture
  43954. * @param urlArg defines a value which contains one of the following:
  43955. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  43956. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  43957. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  43958. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  43959. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  43960. * @param scene needed for loading to the correct scene
  43961. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  43962. * @param onLoad optional callback to be called upon successful completion
  43963. * @param onError optional callback to be called upon failure
  43964. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  43965. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  43966. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  43967. * @param forcedExtension defines the extension to use to pick the right loader
  43968. * @returns a InternalTexture for assignment back into BABYLON.Texture
  43969. */
  43970. 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;
  43971. /**
  43972. * Creates a cube texture
  43973. * @param rootUrl defines the url where the files to load is located
  43974. * @param scene defines the current scene
  43975. * @param files defines the list of files to load (1 per face)
  43976. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  43977. * @param onLoad defines an optional callback raised when the texture is loaded
  43978. * @param onError defines an optional callback raised if there is an issue to load the texture
  43979. * @param format defines the format of the data
  43980. * @param forcedExtension defines the extension to use to pick the right loader
  43981. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  43982. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  43983. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  43984. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  43985. * @returns the cube texture as an InternalTexture
  43986. */
  43987. 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;
  43988. private _getSamplingFilter;
  43989. private static _GetNativeTextureFormat;
  43990. createRenderTargetTexture(size: number | {
  43991. width: number;
  43992. height: number;
  43993. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43994. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43995. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43996. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43997. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  43998. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  43999. /**
  44000. * Updates a dynamic vertex buffer.
  44001. * @param vertexBuffer the vertex buffer to update
  44002. * @param data the data used to update the vertex buffer
  44003. * @param byteOffset the byte offset of the data (optional)
  44004. * @param byteLength the byte length of the data (optional)
  44005. */
  44006. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44007. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44008. private _updateAnisotropicLevel;
  44009. private _getAddressMode;
  44010. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  44011. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44012. releaseEffects(): void;
  44013. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44014. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44015. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44016. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44017. }
  44018. }
  44019. declare module BABYLON {
  44020. /**
  44021. * Gather the list of clipboard event types as constants.
  44022. */
  44023. export class ClipboardEventTypes {
  44024. /**
  44025. * The clipboard event is fired when a copy command is active (pressed).
  44026. */
  44027. static readonly COPY: number;
  44028. /**
  44029. * The clipboard event is fired when a cut command is active (pressed).
  44030. */
  44031. static readonly CUT: number;
  44032. /**
  44033. * The clipboard event is fired when a paste command is active (pressed).
  44034. */
  44035. static readonly PASTE: number;
  44036. }
  44037. /**
  44038. * This class is used to store clipboard related info for the onClipboardObservable event.
  44039. */
  44040. export class ClipboardInfo {
  44041. /**
  44042. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44043. */
  44044. type: number;
  44045. /**
  44046. * Defines the related dom event
  44047. */
  44048. event: ClipboardEvent;
  44049. /**
  44050. *Creates an instance of ClipboardInfo.
  44051. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44052. * @param event Defines the related dom event
  44053. */
  44054. constructor(
  44055. /**
  44056. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44057. */
  44058. type: number,
  44059. /**
  44060. * Defines the related dom event
  44061. */
  44062. event: ClipboardEvent);
  44063. /**
  44064. * Get the clipboard event's type from the keycode.
  44065. * @param keyCode Defines the keyCode for the current keyboard event.
  44066. * @return {number}
  44067. */
  44068. static GetTypeFromCharacter(keyCode: number): number;
  44069. }
  44070. }
  44071. declare module BABYLON {
  44072. /**
  44073. * Google Daydream controller
  44074. */
  44075. export class DaydreamController extends WebVRController {
  44076. /**
  44077. * Base Url for the controller model.
  44078. */
  44079. static MODEL_BASE_URL: string;
  44080. /**
  44081. * File name for the controller model.
  44082. */
  44083. static MODEL_FILENAME: string;
  44084. /**
  44085. * Gamepad Id prefix used to identify Daydream Controller.
  44086. */
  44087. static readonly GAMEPAD_ID_PREFIX: string;
  44088. /**
  44089. * Creates a new DaydreamController from a gamepad
  44090. * @param vrGamepad the gamepad that the controller should be created from
  44091. */
  44092. constructor(vrGamepad: any);
  44093. /**
  44094. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44095. * @param scene scene in which to add meshes
  44096. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44097. */
  44098. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44099. /**
  44100. * Called once for each button that changed state since the last frame
  44101. * @param buttonIdx Which button index changed
  44102. * @param state New state of the button
  44103. * @param changes Which properties on the state changed since last frame
  44104. */
  44105. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44106. }
  44107. }
  44108. declare module BABYLON {
  44109. /**
  44110. * Gear VR Controller
  44111. */
  44112. export class GearVRController extends WebVRController {
  44113. /**
  44114. * Base Url for the controller model.
  44115. */
  44116. static MODEL_BASE_URL: string;
  44117. /**
  44118. * File name for the controller model.
  44119. */
  44120. static MODEL_FILENAME: string;
  44121. /**
  44122. * Gamepad Id prefix used to identify this controller.
  44123. */
  44124. static readonly GAMEPAD_ID_PREFIX: string;
  44125. private readonly _buttonIndexToObservableNameMap;
  44126. /**
  44127. * Creates a new GearVRController from a gamepad
  44128. * @param vrGamepad the gamepad that the controller should be created from
  44129. */
  44130. constructor(vrGamepad: any);
  44131. /**
  44132. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44133. * @param scene scene in which to add meshes
  44134. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44135. */
  44136. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44137. /**
  44138. * Called once for each button that changed state since the last frame
  44139. * @param buttonIdx Which button index changed
  44140. * @param state New state of the button
  44141. * @param changes Which properties on the state changed since last frame
  44142. */
  44143. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44144. }
  44145. }
  44146. declare module BABYLON {
  44147. /**
  44148. * Class containing static functions to help procedurally build meshes
  44149. */
  44150. export class PolyhedronBuilder {
  44151. /**
  44152. * Creates a polyhedron mesh
  44153. * * 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
  44154. * * The parameter `size` (positive float, default 1) sets the polygon size
  44155. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44156. * * 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`
  44157. * * 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
  44158. * * 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)`)
  44159. * * 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
  44160. * * 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
  44161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44162. * * 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
  44163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44164. * @param name defines the name of the mesh
  44165. * @param options defines the options used to create the mesh
  44166. * @param scene defines the hosting scene
  44167. * @returns the polyhedron mesh
  44168. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44169. */
  44170. static CreatePolyhedron(name: string, options: {
  44171. type?: number;
  44172. size?: number;
  44173. sizeX?: number;
  44174. sizeY?: number;
  44175. sizeZ?: number;
  44176. custom?: any;
  44177. faceUV?: Vector4[];
  44178. faceColors?: Color4[];
  44179. flat?: boolean;
  44180. updatable?: boolean;
  44181. sideOrientation?: number;
  44182. frontUVs?: Vector4;
  44183. backUVs?: Vector4;
  44184. }, scene?: Nullable<Scene>): Mesh;
  44185. }
  44186. }
  44187. declare module BABYLON {
  44188. /**
  44189. * Gizmo that enables scaling a mesh along 3 axis
  44190. */
  44191. export class ScaleGizmo extends Gizmo {
  44192. /**
  44193. * Internal gizmo used for interactions on the x axis
  44194. */
  44195. xGizmo: AxisScaleGizmo;
  44196. /**
  44197. * Internal gizmo used for interactions on the y axis
  44198. */
  44199. yGizmo: AxisScaleGizmo;
  44200. /**
  44201. * Internal gizmo used for interactions on the z axis
  44202. */
  44203. zGizmo: AxisScaleGizmo;
  44204. /**
  44205. * Internal gizmo used to scale all axis equally
  44206. */
  44207. uniformScaleGizmo: AxisScaleGizmo;
  44208. private _meshAttached;
  44209. private _updateGizmoRotationToMatchAttachedMesh;
  44210. private _snapDistance;
  44211. private _scaleRatio;
  44212. private _uniformScalingMesh;
  44213. private _octahedron;
  44214. /** Fires an event when any of it's sub gizmos are dragged */
  44215. onDragStartObservable: Observable<unknown>;
  44216. /** Fires an event when any of it's sub gizmos are released from dragging */
  44217. onDragEndObservable: Observable<unknown>;
  44218. attachedMesh: Nullable<AbstractMesh>;
  44219. /**
  44220. * Creates a ScaleGizmo
  44221. * @param gizmoLayer The utility layer the gizmo will be added to
  44222. */
  44223. constructor(gizmoLayer?: UtilityLayerRenderer);
  44224. updateGizmoRotationToMatchAttachedMesh: boolean;
  44225. /**
  44226. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44227. */
  44228. snapDistance: number;
  44229. /**
  44230. * Ratio for the scale of the gizmo (Default: 1)
  44231. */
  44232. scaleRatio: number;
  44233. /**
  44234. * Disposes of the gizmo
  44235. */
  44236. dispose(): void;
  44237. }
  44238. }
  44239. declare module BABYLON {
  44240. /**
  44241. * Single axis scale gizmo
  44242. */
  44243. export class AxisScaleGizmo extends Gizmo {
  44244. /**
  44245. * Drag behavior responsible for the gizmos dragging interactions
  44246. */
  44247. dragBehavior: PointerDragBehavior;
  44248. private _pointerObserver;
  44249. /**
  44250. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44251. */
  44252. snapDistance: number;
  44253. /**
  44254. * Event that fires each time the gizmo snaps to a new location.
  44255. * * snapDistance is the the change in distance
  44256. */
  44257. onSnapObservable: Observable<{
  44258. snapDistance: number;
  44259. }>;
  44260. /**
  44261. * If the scaling operation should be done on all axis (default: false)
  44262. */
  44263. uniformScaling: boolean;
  44264. private _isEnabled;
  44265. private _parent;
  44266. private _arrow;
  44267. private _coloredMaterial;
  44268. private _hoverMaterial;
  44269. /**
  44270. * Creates an AxisScaleGizmo
  44271. * @param gizmoLayer The utility layer the gizmo will be added to
  44272. * @param dragAxis The axis which the gizmo will be able to scale on
  44273. * @param color The color of the gizmo
  44274. */
  44275. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44276. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44277. /**
  44278. * If the gizmo is enabled
  44279. */
  44280. isEnabled: boolean;
  44281. /**
  44282. * Disposes of the gizmo
  44283. */
  44284. dispose(): void;
  44285. /**
  44286. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44287. * @param mesh The mesh to replace the default mesh of the gizmo
  44288. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44289. */
  44290. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44291. }
  44292. }
  44293. declare module BABYLON {
  44294. /**
  44295. * Bounding box gizmo
  44296. */
  44297. export class BoundingBoxGizmo extends Gizmo {
  44298. private _lineBoundingBox;
  44299. private _rotateSpheresParent;
  44300. private _scaleBoxesParent;
  44301. private _boundingDimensions;
  44302. private _renderObserver;
  44303. private _pointerObserver;
  44304. private _scaleDragSpeed;
  44305. private _tmpQuaternion;
  44306. private _tmpVector;
  44307. private _tmpRotationMatrix;
  44308. /**
  44309. * 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)
  44310. */
  44311. ignoreChildren: boolean;
  44312. /**
  44313. * 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)
  44314. */
  44315. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44316. /**
  44317. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44318. */
  44319. rotationSphereSize: number;
  44320. /**
  44321. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44322. */
  44323. scaleBoxSize: number;
  44324. /**
  44325. * 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)
  44326. */
  44327. fixedDragMeshScreenSize: boolean;
  44328. /**
  44329. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44330. */
  44331. fixedDragMeshScreenSizeDistanceFactor: number;
  44332. /**
  44333. * Fired when a rotation sphere or scale box is dragged
  44334. */
  44335. onDragStartObservable: Observable<{}>;
  44336. /**
  44337. * Fired when a scale box is dragged
  44338. */
  44339. onScaleBoxDragObservable: Observable<{}>;
  44340. /**
  44341. * Fired when a scale box drag is ended
  44342. */
  44343. onScaleBoxDragEndObservable: Observable<{}>;
  44344. /**
  44345. * Fired when a rotation sphere is dragged
  44346. */
  44347. onRotationSphereDragObservable: Observable<{}>;
  44348. /**
  44349. * Fired when a rotation sphere drag is ended
  44350. */
  44351. onRotationSphereDragEndObservable: Observable<{}>;
  44352. /**
  44353. * 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)
  44354. */
  44355. scalePivot: Nullable<Vector3>;
  44356. /**
  44357. * Mesh used as a pivot to rotate the attached mesh
  44358. */
  44359. private _anchorMesh;
  44360. private _existingMeshScale;
  44361. private _dragMesh;
  44362. private pointerDragBehavior;
  44363. private coloredMaterial;
  44364. private hoverColoredMaterial;
  44365. /**
  44366. * Sets the color of the bounding box gizmo
  44367. * @param color the color to set
  44368. */
  44369. setColor(color: Color3): void;
  44370. /**
  44371. * Creates an BoundingBoxGizmo
  44372. * @param gizmoLayer The utility layer the gizmo will be added to
  44373. * @param color The color of the gizmo
  44374. */
  44375. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44376. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44377. private _selectNode;
  44378. /**
  44379. * Updates the bounding box information for the Gizmo
  44380. */
  44381. updateBoundingBox(): void;
  44382. private _updateRotationSpheres;
  44383. private _updateScaleBoxes;
  44384. /**
  44385. * Enables rotation on the specified axis and disables rotation on the others
  44386. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44387. */
  44388. setEnabledRotationAxis(axis: string): void;
  44389. /**
  44390. * Enables/disables scaling
  44391. * @param enable if scaling should be enabled
  44392. */
  44393. setEnabledScaling(enable: boolean): void;
  44394. private _updateDummy;
  44395. /**
  44396. * Enables a pointer drag behavior on the bounding box of the gizmo
  44397. */
  44398. enableDragBehavior(): void;
  44399. /**
  44400. * Disposes of the gizmo
  44401. */
  44402. dispose(): void;
  44403. /**
  44404. * 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)
  44405. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44406. * @returns the bounding box mesh with the passed in mesh as a child
  44407. */
  44408. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44409. /**
  44410. * CustomMeshes are not supported by this gizmo
  44411. * @param mesh The mesh to replace the default mesh of the gizmo
  44412. */
  44413. setCustomMesh(mesh: Mesh): void;
  44414. }
  44415. }
  44416. declare module BABYLON {
  44417. /**
  44418. * Single plane rotation gizmo
  44419. */
  44420. export class PlaneRotationGizmo extends Gizmo {
  44421. /**
  44422. * Drag behavior responsible for the gizmos dragging interactions
  44423. */
  44424. dragBehavior: PointerDragBehavior;
  44425. private _pointerObserver;
  44426. /**
  44427. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44428. */
  44429. snapDistance: number;
  44430. /**
  44431. * Event that fires each time the gizmo snaps to a new location.
  44432. * * snapDistance is the the change in distance
  44433. */
  44434. onSnapObservable: Observable<{
  44435. snapDistance: number;
  44436. }>;
  44437. private _isEnabled;
  44438. private _parent;
  44439. /**
  44440. * Creates a PlaneRotationGizmo
  44441. * @param gizmoLayer The utility layer the gizmo will be added to
  44442. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44443. * @param color The color of the gizmo
  44444. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44445. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44446. */
  44447. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  44448. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44449. /**
  44450. * If the gizmo is enabled
  44451. */
  44452. isEnabled: boolean;
  44453. /**
  44454. * Disposes of the gizmo
  44455. */
  44456. dispose(): void;
  44457. }
  44458. }
  44459. declare module BABYLON {
  44460. /**
  44461. * Gizmo that enables rotating a mesh along 3 axis
  44462. */
  44463. export class RotationGizmo extends Gizmo {
  44464. /**
  44465. * Internal gizmo used for interactions on the x axis
  44466. */
  44467. xGizmo: PlaneRotationGizmo;
  44468. /**
  44469. * Internal gizmo used for interactions on the y axis
  44470. */
  44471. yGizmo: PlaneRotationGizmo;
  44472. /**
  44473. * Internal gizmo used for interactions on the z axis
  44474. */
  44475. zGizmo: PlaneRotationGizmo;
  44476. /** Fires an event when any of it's sub gizmos are dragged */
  44477. onDragStartObservable: Observable<unknown>;
  44478. /** Fires an event when any of it's sub gizmos are released from dragging */
  44479. onDragEndObservable: Observable<unknown>;
  44480. private _meshAttached;
  44481. attachedMesh: Nullable<AbstractMesh>;
  44482. /**
  44483. * Creates a RotationGizmo
  44484. * @param gizmoLayer The utility layer the gizmo will be added to
  44485. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44486. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44487. */
  44488. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  44489. updateGizmoRotationToMatchAttachedMesh: boolean;
  44490. /**
  44491. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44492. */
  44493. snapDistance: number;
  44494. /**
  44495. * Ratio for the scale of the gizmo (Default: 1)
  44496. */
  44497. scaleRatio: number;
  44498. /**
  44499. * Disposes of the gizmo
  44500. */
  44501. dispose(): void;
  44502. /**
  44503. * CustomMeshes are not supported by this gizmo
  44504. * @param mesh The mesh to replace the default mesh of the gizmo
  44505. */
  44506. setCustomMesh(mesh: Mesh): void;
  44507. }
  44508. }
  44509. declare module BABYLON {
  44510. /**
  44511. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44512. */
  44513. export class GizmoManager implements IDisposable {
  44514. private scene;
  44515. /**
  44516. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44517. */
  44518. gizmos: {
  44519. positionGizmo: Nullable<PositionGizmo>;
  44520. rotationGizmo: Nullable<RotationGizmo>;
  44521. scaleGizmo: Nullable<ScaleGizmo>;
  44522. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44523. };
  44524. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44525. clearGizmoOnEmptyPointerEvent: boolean;
  44526. /** Fires an event when the manager is attached to a mesh */
  44527. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44528. private _gizmosEnabled;
  44529. private _pointerObserver;
  44530. private _attachedMesh;
  44531. private _boundingBoxColor;
  44532. private _defaultUtilityLayer;
  44533. private _defaultKeepDepthUtilityLayer;
  44534. /**
  44535. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44536. */
  44537. boundingBoxDragBehavior: SixDofDragBehavior;
  44538. /**
  44539. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44540. */
  44541. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44542. /**
  44543. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44544. */
  44545. usePointerToAttachGizmos: boolean;
  44546. /**
  44547. * Utility layer that the bounding box gizmo belongs to
  44548. */
  44549. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  44550. /**
  44551. * Utility layer that all gizmos besides bounding box belong to
  44552. */
  44553. readonly utilityLayer: UtilityLayerRenderer;
  44554. /**
  44555. * Instatiates a gizmo manager
  44556. * @param scene the scene to overlay the gizmos on top of
  44557. */
  44558. constructor(scene: Scene);
  44559. /**
  44560. * Attaches a set of gizmos to the specified mesh
  44561. * @param mesh The mesh the gizmo's should be attached to
  44562. */
  44563. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44564. /**
  44565. * If the position gizmo is enabled
  44566. */
  44567. positionGizmoEnabled: boolean;
  44568. /**
  44569. * If the rotation gizmo is enabled
  44570. */
  44571. rotationGizmoEnabled: boolean;
  44572. /**
  44573. * If the scale gizmo is enabled
  44574. */
  44575. scaleGizmoEnabled: boolean;
  44576. /**
  44577. * If the boundingBox gizmo is enabled
  44578. */
  44579. boundingBoxGizmoEnabled: boolean;
  44580. /**
  44581. * Disposes of the gizmo manager
  44582. */
  44583. dispose(): void;
  44584. }
  44585. }
  44586. declare module BABYLON {
  44587. /**
  44588. * A directional light is defined by a direction (what a surprise!).
  44589. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44590. * 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.
  44591. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44592. */
  44593. export class DirectionalLight extends ShadowLight {
  44594. private _shadowFrustumSize;
  44595. /**
  44596. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44597. */
  44598. /**
  44599. * Specifies a fix frustum size for the shadow generation.
  44600. */
  44601. shadowFrustumSize: number;
  44602. private _shadowOrthoScale;
  44603. /**
  44604. * Gets the shadow projection scale against the optimal computed one.
  44605. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44606. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44607. */
  44608. /**
  44609. * Sets the shadow projection scale against the optimal computed one.
  44610. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44611. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44612. */
  44613. shadowOrthoScale: number;
  44614. /**
  44615. * Automatically compute the projection matrix to best fit (including all the casters)
  44616. * on each frame.
  44617. */
  44618. autoUpdateExtends: boolean;
  44619. private _orthoLeft;
  44620. private _orthoRight;
  44621. private _orthoTop;
  44622. private _orthoBottom;
  44623. /**
  44624. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44625. * The directional light is emitted from everywhere in the given direction.
  44626. * It can cast shadows.
  44627. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44628. * @param name The friendly name of the light
  44629. * @param direction The direction of the light
  44630. * @param scene The scene the light belongs to
  44631. */
  44632. constructor(name: string, direction: Vector3, scene: Scene);
  44633. /**
  44634. * Returns the string "DirectionalLight".
  44635. * @return The class name
  44636. */
  44637. getClassName(): string;
  44638. /**
  44639. * Returns the integer 1.
  44640. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44641. */
  44642. getTypeID(): number;
  44643. /**
  44644. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44645. * Returns the DirectionalLight Shadow projection matrix.
  44646. */
  44647. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44648. /**
  44649. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44650. * Returns the DirectionalLight Shadow projection matrix.
  44651. */
  44652. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44653. /**
  44654. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44655. * Returns the DirectionalLight Shadow projection matrix.
  44656. */
  44657. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44658. protected _buildUniformLayout(): void;
  44659. /**
  44660. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44661. * @param effect The effect to update
  44662. * @param lightIndex The index of the light in the effect to update
  44663. * @returns The directional light
  44664. */
  44665. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44666. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  44667. /**
  44668. * Gets the minZ used for shadow according to both the scene and the light.
  44669. *
  44670. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44671. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44672. * @param activeCamera The camera we are returning the min for
  44673. * @returns the depth min z
  44674. */
  44675. getDepthMinZ(activeCamera: Camera): number;
  44676. /**
  44677. * Gets the maxZ used for shadow according to both the scene and the light.
  44678. *
  44679. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44680. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44681. * @param activeCamera The camera we are returning the max for
  44682. * @returns the depth max z
  44683. */
  44684. getDepthMaxZ(activeCamera: Camera): number;
  44685. /**
  44686. * Prepares the list of defines specific to the light type.
  44687. * @param defines the list of defines
  44688. * @param lightIndex defines the index of the light for the effect
  44689. */
  44690. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44691. }
  44692. }
  44693. declare module BABYLON {
  44694. /**
  44695. * Class containing static functions to help procedurally build meshes
  44696. */
  44697. export class HemisphereBuilder {
  44698. /**
  44699. * Creates a hemisphere mesh
  44700. * @param name defines the name of the mesh
  44701. * @param options defines the options used to create the mesh
  44702. * @param scene defines the hosting scene
  44703. * @returns the hemisphere mesh
  44704. */
  44705. static CreateHemisphere(name: string, options: {
  44706. segments?: number;
  44707. diameter?: number;
  44708. sideOrientation?: number;
  44709. }, scene: any): Mesh;
  44710. }
  44711. }
  44712. declare module BABYLON {
  44713. /**
  44714. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44715. * These values define a cone of light starting from the position, emitting toward the direction.
  44716. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44717. * and the exponent defines the speed of the decay of the light with distance (reach).
  44718. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44719. */
  44720. export class SpotLight extends ShadowLight {
  44721. private _angle;
  44722. private _innerAngle;
  44723. private _cosHalfAngle;
  44724. private _lightAngleScale;
  44725. private _lightAngleOffset;
  44726. /**
  44727. * Gets the cone angle of the spot light in Radians.
  44728. */
  44729. /**
  44730. * Sets the cone angle of the spot light in Radians.
  44731. */
  44732. angle: number;
  44733. /**
  44734. * Only used in gltf falloff mode, this defines the angle where
  44735. * the directional falloff will start before cutting at angle which could be seen
  44736. * as outer angle.
  44737. */
  44738. /**
  44739. * Only used in gltf falloff mode, this defines the angle where
  44740. * the directional falloff will start before cutting at angle which could be seen
  44741. * as outer angle.
  44742. */
  44743. innerAngle: number;
  44744. private _shadowAngleScale;
  44745. /**
  44746. * Allows scaling the angle of the light for shadow generation only.
  44747. */
  44748. /**
  44749. * Allows scaling the angle of the light for shadow generation only.
  44750. */
  44751. shadowAngleScale: number;
  44752. /**
  44753. * The light decay speed with the distance from the emission spot.
  44754. */
  44755. exponent: number;
  44756. private _projectionTextureMatrix;
  44757. /**
  44758. * Allows reading the projecton texture
  44759. */
  44760. readonly projectionTextureMatrix: Matrix;
  44761. protected _projectionTextureLightNear: number;
  44762. /**
  44763. * Gets the near clip of the Spotlight for texture projection.
  44764. */
  44765. /**
  44766. * Sets the near clip of the Spotlight for texture projection.
  44767. */
  44768. projectionTextureLightNear: number;
  44769. protected _projectionTextureLightFar: number;
  44770. /**
  44771. * Gets the far clip of the Spotlight for texture projection.
  44772. */
  44773. /**
  44774. * Sets the far clip of the Spotlight for texture projection.
  44775. */
  44776. projectionTextureLightFar: number;
  44777. protected _projectionTextureUpDirection: Vector3;
  44778. /**
  44779. * Gets the Up vector of the Spotlight for texture projection.
  44780. */
  44781. /**
  44782. * Sets the Up vector of the Spotlight for texture projection.
  44783. */
  44784. projectionTextureUpDirection: Vector3;
  44785. private _projectionTexture;
  44786. /**
  44787. * Gets the projection texture of the light.
  44788. */
  44789. /**
  44790. * Sets the projection texture of the light.
  44791. */
  44792. projectionTexture: Nullable<BaseTexture>;
  44793. private _projectionTextureViewLightDirty;
  44794. private _projectionTextureProjectionLightDirty;
  44795. private _projectionTextureDirty;
  44796. private _projectionTextureViewTargetVector;
  44797. private _projectionTextureViewLightMatrix;
  44798. private _projectionTextureProjectionLightMatrix;
  44799. private _projectionTextureScalingMatrix;
  44800. /**
  44801. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44802. * It can cast shadows.
  44803. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44804. * @param name The light friendly name
  44805. * @param position The position of the spot light in the scene
  44806. * @param direction The direction of the light in the scene
  44807. * @param angle The cone angle of the light in Radians
  44808. * @param exponent The light decay speed with the distance from the emission spot
  44809. * @param scene The scene the lights belongs to
  44810. */
  44811. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44812. /**
  44813. * Returns the string "SpotLight".
  44814. * @returns the class name
  44815. */
  44816. getClassName(): string;
  44817. /**
  44818. * Returns the integer 2.
  44819. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44820. */
  44821. getTypeID(): number;
  44822. /**
  44823. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44824. */
  44825. protected _setDirection(value: Vector3): void;
  44826. /**
  44827. * Overrides the position setter to recompute the projection texture view light Matrix.
  44828. */
  44829. protected _setPosition(value: Vector3): void;
  44830. /**
  44831. * 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.
  44832. * Returns the SpotLight.
  44833. */
  44834. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44835. protected _computeProjectionTextureViewLightMatrix(): void;
  44836. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44837. /**
  44838. * Main function for light texture projection matrix computing.
  44839. */
  44840. protected _computeProjectionTextureMatrix(): void;
  44841. protected _buildUniformLayout(): void;
  44842. private _computeAngleValues;
  44843. /**
  44844. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44845. * @param effect The effect to update
  44846. * @param lightIndex The index of the light in the effect to update
  44847. * @returns The spot light
  44848. */
  44849. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44850. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  44851. /**
  44852. * Disposes the light and the associated resources.
  44853. */
  44854. dispose(): void;
  44855. /**
  44856. * Prepares the list of defines specific to the light type.
  44857. * @param defines the list of defines
  44858. * @param lightIndex defines the index of the light for the effect
  44859. */
  44860. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44861. }
  44862. }
  44863. declare module BABYLON {
  44864. /**
  44865. * Gizmo that enables viewing a light
  44866. */
  44867. export class LightGizmo extends Gizmo {
  44868. private _lightMesh;
  44869. private _material;
  44870. private cachedPosition;
  44871. private cachedForward;
  44872. /**
  44873. * Creates a LightGizmo
  44874. * @param gizmoLayer The utility layer the gizmo will be added to
  44875. */
  44876. constructor(gizmoLayer?: UtilityLayerRenderer);
  44877. private _light;
  44878. /**
  44879. * The light that the gizmo is attached to
  44880. */
  44881. light: Nullable<Light>;
  44882. /**
  44883. * Gets the material used to render the light gizmo
  44884. */
  44885. readonly material: StandardMaterial;
  44886. /**
  44887. * @hidden
  44888. * Updates the gizmo to match the attached mesh's position/rotation
  44889. */
  44890. protected _update(): void;
  44891. private static _Scale;
  44892. /**
  44893. * Creates the lines for a light mesh
  44894. */
  44895. private static _createLightLines;
  44896. /**
  44897. * Disposes of the light gizmo
  44898. */
  44899. dispose(): void;
  44900. private static _CreateHemisphericLightMesh;
  44901. private static _CreatePointLightMesh;
  44902. private static _CreateSpotLightMesh;
  44903. private static _CreateDirectionalLightMesh;
  44904. }
  44905. }
  44906. declare module BABYLON {
  44907. /** @hidden */
  44908. export var backgroundFragmentDeclaration: {
  44909. name: string;
  44910. shader: string;
  44911. };
  44912. }
  44913. declare module BABYLON {
  44914. /** @hidden */
  44915. export var backgroundUboDeclaration: {
  44916. name: string;
  44917. shader: string;
  44918. };
  44919. }
  44920. declare module BABYLON {
  44921. /** @hidden */
  44922. export var backgroundPixelShader: {
  44923. name: string;
  44924. shader: string;
  44925. };
  44926. }
  44927. declare module BABYLON {
  44928. /** @hidden */
  44929. export var backgroundVertexDeclaration: {
  44930. name: string;
  44931. shader: string;
  44932. };
  44933. }
  44934. declare module BABYLON {
  44935. /** @hidden */
  44936. export var backgroundVertexShader: {
  44937. name: string;
  44938. shader: string;
  44939. };
  44940. }
  44941. declare module BABYLON {
  44942. /**
  44943. * Background material used to create an efficient environement around your scene.
  44944. */
  44945. export class BackgroundMaterial extends PushMaterial {
  44946. /**
  44947. * Standard reflectance value at parallel view angle.
  44948. */
  44949. static StandardReflectance0: number;
  44950. /**
  44951. * Standard reflectance value at grazing angle.
  44952. */
  44953. static StandardReflectance90: number;
  44954. protected _primaryColor: Color3;
  44955. /**
  44956. * Key light Color (multiply against the environement texture)
  44957. */
  44958. primaryColor: Color3;
  44959. protected __perceptualColor: Nullable<Color3>;
  44960. /**
  44961. * Experimental Internal Use Only.
  44962. *
  44963. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44964. * This acts as a helper to set the primary color to a more "human friendly" value.
  44965. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44966. * output color as close as possible from the chosen value.
  44967. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44968. * part of lighting setup.)
  44969. */ private _perceptualColor: Nullable<Color3>;
  44970. protected _primaryColorShadowLevel: float;
  44971. /**
  44972. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44973. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44974. */
  44975. primaryColorShadowLevel: float;
  44976. protected _primaryColorHighlightLevel: float;
  44977. /**
  44978. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44979. * The primary color is used at the level chosen to define what the white area would look.
  44980. */
  44981. primaryColorHighlightLevel: float;
  44982. protected _reflectionTexture: Nullable<BaseTexture>;
  44983. /**
  44984. * Reflection Texture used in the material.
  44985. * Should be author in a specific way for the best result (refer to the documentation).
  44986. */
  44987. reflectionTexture: Nullable<BaseTexture>;
  44988. protected _reflectionBlur: float;
  44989. /**
  44990. * Reflection Texture level of blur.
  44991. *
  44992. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44993. * texture twice.
  44994. */
  44995. reflectionBlur: float;
  44996. protected _diffuseTexture: Nullable<BaseTexture>;
  44997. /**
  44998. * Diffuse Texture used in the material.
  44999. * Should be author in a specific way for the best result (refer to the documentation).
  45000. */
  45001. diffuseTexture: Nullable<BaseTexture>;
  45002. protected _shadowLights: Nullable<IShadowLight[]>;
  45003. /**
  45004. * Specify the list of lights casting shadow on the material.
  45005. * All scene shadow lights will be included if null.
  45006. */
  45007. shadowLights: Nullable<IShadowLight[]>;
  45008. protected _shadowLevel: float;
  45009. /**
  45010. * Helps adjusting the shadow to a softer level if required.
  45011. * 0 means black shadows and 1 means no shadows.
  45012. */
  45013. shadowLevel: float;
  45014. protected _sceneCenter: Vector3;
  45015. /**
  45016. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45017. * It is usually zero but might be interesting to modify according to your setup.
  45018. */
  45019. sceneCenter: Vector3;
  45020. protected _opacityFresnel: boolean;
  45021. /**
  45022. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45023. * This helps ensuring a nice transition when the camera goes under the ground.
  45024. */
  45025. opacityFresnel: boolean;
  45026. protected _reflectionFresnel: boolean;
  45027. /**
  45028. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45029. * This helps adding a mirror texture on the ground.
  45030. */
  45031. reflectionFresnel: boolean;
  45032. protected _reflectionFalloffDistance: number;
  45033. /**
  45034. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45035. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45036. */
  45037. reflectionFalloffDistance: number;
  45038. protected _reflectionAmount: number;
  45039. /**
  45040. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45041. */
  45042. reflectionAmount: number;
  45043. protected _reflectionReflectance0: number;
  45044. /**
  45045. * This specifies the weight of the reflection at grazing angle.
  45046. */
  45047. reflectionReflectance0: number;
  45048. protected _reflectionReflectance90: number;
  45049. /**
  45050. * This specifies the weight of the reflection at a perpendicular point of view.
  45051. */
  45052. reflectionReflectance90: number;
  45053. /**
  45054. * Sets the reflection reflectance fresnel values according to the default standard
  45055. * empirically know to work well :-)
  45056. */
  45057. reflectionStandardFresnelWeight: number;
  45058. protected _useRGBColor: boolean;
  45059. /**
  45060. * Helps to directly use the maps channels instead of their level.
  45061. */
  45062. useRGBColor: boolean;
  45063. protected _enableNoise: boolean;
  45064. /**
  45065. * This helps reducing the banding effect that could occur on the background.
  45066. */
  45067. enableNoise: boolean;
  45068. /**
  45069. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45070. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45071. * Recommended to be keep at 1.0 except for special cases.
  45072. */
  45073. fovMultiplier: number;
  45074. private _fovMultiplier;
  45075. /**
  45076. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45077. */
  45078. useEquirectangularFOV: boolean;
  45079. private _maxSimultaneousLights;
  45080. /**
  45081. * Number of Simultaneous lights allowed on the material.
  45082. */
  45083. maxSimultaneousLights: int;
  45084. /**
  45085. * Default configuration related to image processing available in the Background Material.
  45086. */
  45087. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45088. /**
  45089. * Keep track of the image processing observer to allow dispose and replace.
  45090. */
  45091. private _imageProcessingObserver;
  45092. /**
  45093. * Attaches a new image processing configuration to the PBR Material.
  45094. * @param configuration (if null the scene configuration will be use)
  45095. */
  45096. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45097. /**
  45098. * Gets the image processing configuration used either in this material.
  45099. */
  45100. /**
  45101. * Sets the Default image processing configuration used either in the this material.
  45102. *
  45103. * If sets to null, the scene one is in use.
  45104. */
  45105. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45106. /**
  45107. * Gets wether the color curves effect is enabled.
  45108. */
  45109. /**
  45110. * Sets wether the color curves effect is enabled.
  45111. */
  45112. cameraColorCurvesEnabled: boolean;
  45113. /**
  45114. * Gets wether the color grading effect is enabled.
  45115. */
  45116. /**
  45117. * Gets wether the color grading effect is enabled.
  45118. */
  45119. cameraColorGradingEnabled: boolean;
  45120. /**
  45121. * Gets wether tonemapping is enabled or not.
  45122. */
  45123. /**
  45124. * Sets wether tonemapping is enabled or not
  45125. */
  45126. cameraToneMappingEnabled: boolean;
  45127. /**
  45128. * The camera exposure used on this material.
  45129. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45130. * This corresponds to a photographic exposure.
  45131. */
  45132. /**
  45133. * The camera exposure used on this material.
  45134. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45135. * This corresponds to a photographic exposure.
  45136. */
  45137. cameraExposure: float;
  45138. /**
  45139. * Gets The camera contrast used on this material.
  45140. */
  45141. /**
  45142. * Sets The camera contrast used on this material.
  45143. */
  45144. cameraContrast: float;
  45145. /**
  45146. * Gets the Color Grading 2D Lookup Texture.
  45147. */
  45148. /**
  45149. * Sets the Color Grading 2D Lookup Texture.
  45150. */
  45151. cameraColorGradingTexture: Nullable<BaseTexture>;
  45152. /**
  45153. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45154. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45155. * 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;
  45156. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45157. */
  45158. /**
  45159. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45160. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45161. * 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;
  45162. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45163. */
  45164. cameraColorCurves: Nullable<ColorCurves>;
  45165. /**
  45166. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45167. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45168. */
  45169. switchToBGR: boolean;
  45170. private _renderTargets;
  45171. private _reflectionControls;
  45172. private _white;
  45173. private _primaryShadowColor;
  45174. private _primaryHighlightColor;
  45175. /**
  45176. * Instantiates a Background Material in the given scene
  45177. * @param name The friendly name of the material
  45178. * @param scene The scene to add the material to
  45179. */
  45180. constructor(name: string, scene: Scene);
  45181. /**
  45182. * Gets a boolean indicating that current material needs to register RTT
  45183. */
  45184. readonly hasRenderTargetTextures: boolean;
  45185. /**
  45186. * The entire material has been created in order to prevent overdraw.
  45187. * @returns false
  45188. */
  45189. needAlphaTesting(): boolean;
  45190. /**
  45191. * The entire material has been created in order to prevent overdraw.
  45192. * @returns true if blending is enable
  45193. */
  45194. needAlphaBlending(): boolean;
  45195. /**
  45196. * Checks wether the material is ready to be rendered for a given mesh.
  45197. * @param mesh The mesh to render
  45198. * @param subMesh The submesh to check against
  45199. * @param useInstances Specify wether or not the material is used with instances
  45200. * @returns true if all the dependencies are ready (Textures, Effects...)
  45201. */
  45202. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45203. /**
  45204. * Compute the primary color according to the chosen perceptual color.
  45205. */
  45206. private _computePrimaryColorFromPerceptualColor;
  45207. /**
  45208. * Compute the highlights and shadow colors according to their chosen levels.
  45209. */
  45210. private _computePrimaryColors;
  45211. /**
  45212. * Build the uniform buffer used in the material.
  45213. */
  45214. buildUniformLayout(): void;
  45215. /**
  45216. * Unbind the material.
  45217. */
  45218. unbind(): void;
  45219. /**
  45220. * Bind only the world matrix to the material.
  45221. * @param world The world matrix to bind.
  45222. */
  45223. bindOnlyWorldMatrix(world: Matrix): void;
  45224. /**
  45225. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45226. * @param world The world matrix to bind.
  45227. * @param subMesh The submesh to bind for.
  45228. */
  45229. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45230. /**
  45231. * Checks to see if a texture is used in the material.
  45232. * @param texture - Base texture to use.
  45233. * @returns - Boolean specifying if a texture is used in the material.
  45234. */
  45235. hasTexture(texture: BaseTexture): boolean;
  45236. /**
  45237. * Dispose the material.
  45238. * @param forceDisposeEffect Force disposal of the associated effect.
  45239. * @param forceDisposeTextures Force disposal of the associated textures.
  45240. */
  45241. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45242. /**
  45243. * Clones the material.
  45244. * @param name The cloned name.
  45245. * @returns The cloned material.
  45246. */
  45247. clone(name: string): BackgroundMaterial;
  45248. /**
  45249. * Serializes the current material to its JSON representation.
  45250. * @returns The JSON representation.
  45251. */
  45252. serialize(): any;
  45253. /**
  45254. * Gets the class name of the material
  45255. * @returns "BackgroundMaterial"
  45256. */
  45257. getClassName(): string;
  45258. /**
  45259. * Parse a JSON input to create back a background material.
  45260. * @param source The JSON data to parse
  45261. * @param scene The scene to create the parsed material in
  45262. * @param rootUrl The root url of the assets the material depends upon
  45263. * @returns the instantiated BackgroundMaterial.
  45264. */
  45265. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45266. }
  45267. }
  45268. declare module BABYLON {
  45269. /**
  45270. * Represents the different options available during the creation of
  45271. * a Environment helper.
  45272. *
  45273. * This can control the default ground, skybox and image processing setup of your scene.
  45274. */
  45275. export interface IEnvironmentHelperOptions {
  45276. /**
  45277. * Specifies wether or not to create a ground.
  45278. * True by default.
  45279. */
  45280. createGround: boolean;
  45281. /**
  45282. * Specifies the ground size.
  45283. * 15 by default.
  45284. */
  45285. groundSize: number;
  45286. /**
  45287. * The texture used on the ground for the main color.
  45288. * Comes from the BabylonJS CDN by default.
  45289. *
  45290. * Remarks: Can be either a texture or a url.
  45291. */
  45292. groundTexture: string | BaseTexture;
  45293. /**
  45294. * The color mixed in the ground texture by default.
  45295. * BabylonJS clearColor by default.
  45296. */
  45297. groundColor: Color3;
  45298. /**
  45299. * Specifies the ground opacity.
  45300. * 1 by default.
  45301. */
  45302. groundOpacity: number;
  45303. /**
  45304. * Enables the ground to receive shadows.
  45305. * True by default.
  45306. */
  45307. enableGroundShadow: boolean;
  45308. /**
  45309. * Helps preventing the shadow to be fully black on the ground.
  45310. * 0.5 by default.
  45311. */
  45312. groundShadowLevel: number;
  45313. /**
  45314. * Creates a mirror texture attach to the ground.
  45315. * false by default.
  45316. */
  45317. enableGroundMirror: boolean;
  45318. /**
  45319. * Specifies the ground mirror size ratio.
  45320. * 0.3 by default as the default kernel is 64.
  45321. */
  45322. groundMirrorSizeRatio: number;
  45323. /**
  45324. * Specifies the ground mirror blur kernel size.
  45325. * 64 by default.
  45326. */
  45327. groundMirrorBlurKernel: number;
  45328. /**
  45329. * Specifies the ground mirror visibility amount.
  45330. * 1 by default
  45331. */
  45332. groundMirrorAmount: number;
  45333. /**
  45334. * Specifies the ground mirror reflectance weight.
  45335. * This uses the standard weight of the background material to setup the fresnel effect
  45336. * of the mirror.
  45337. * 1 by default.
  45338. */
  45339. groundMirrorFresnelWeight: number;
  45340. /**
  45341. * Specifies the ground mirror Falloff distance.
  45342. * This can helps reducing the size of the reflection.
  45343. * 0 by Default.
  45344. */
  45345. groundMirrorFallOffDistance: number;
  45346. /**
  45347. * Specifies the ground mirror texture type.
  45348. * Unsigned Int by Default.
  45349. */
  45350. groundMirrorTextureType: number;
  45351. /**
  45352. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45353. * the shown objects.
  45354. */
  45355. groundYBias: number;
  45356. /**
  45357. * Specifies wether or not to create a skybox.
  45358. * True by default.
  45359. */
  45360. createSkybox: boolean;
  45361. /**
  45362. * Specifies the skybox size.
  45363. * 20 by default.
  45364. */
  45365. skyboxSize: number;
  45366. /**
  45367. * The texture used on the skybox for the main color.
  45368. * Comes from the BabylonJS CDN by default.
  45369. *
  45370. * Remarks: Can be either a texture or a url.
  45371. */
  45372. skyboxTexture: string | BaseTexture;
  45373. /**
  45374. * The color mixed in the skybox texture by default.
  45375. * BabylonJS clearColor by default.
  45376. */
  45377. skyboxColor: Color3;
  45378. /**
  45379. * The background rotation around the Y axis of the scene.
  45380. * This helps aligning the key lights of your scene with the background.
  45381. * 0 by default.
  45382. */
  45383. backgroundYRotation: number;
  45384. /**
  45385. * Compute automatically the size of the elements to best fit with the scene.
  45386. */
  45387. sizeAuto: boolean;
  45388. /**
  45389. * Default position of the rootMesh if autoSize is not true.
  45390. */
  45391. rootPosition: Vector3;
  45392. /**
  45393. * Sets up the image processing in the scene.
  45394. * true by default.
  45395. */
  45396. setupImageProcessing: boolean;
  45397. /**
  45398. * The texture used as your environment texture in the scene.
  45399. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45400. *
  45401. * Remarks: Can be either a texture or a url.
  45402. */
  45403. environmentTexture: string | BaseTexture;
  45404. /**
  45405. * The value of the exposure to apply to the scene.
  45406. * 0.6 by default if setupImageProcessing is true.
  45407. */
  45408. cameraExposure: number;
  45409. /**
  45410. * The value of the contrast to apply to the scene.
  45411. * 1.6 by default if setupImageProcessing is true.
  45412. */
  45413. cameraContrast: number;
  45414. /**
  45415. * Specifies wether or not tonemapping should be enabled in the scene.
  45416. * true by default if setupImageProcessing is true.
  45417. */
  45418. toneMappingEnabled: boolean;
  45419. }
  45420. /**
  45421. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45422. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45423. * It also helps with the default setup of your imageProcessing configuration.
  45424. */
  45425. export class EnvironmentHelper {
  45426. /**
  45427. * Default ground texture URL.
  45428. */
  45429. private static _groundTextureCDNUrl;
  45430. /**
  45431. * Default skybox texture URL.
  45432. */
  45433. private static _skyboxTextureCDNUrl;
  45434. /**
  45435. * Default environment texture URL.
  45436. */
  45437. private static _environmentTextureCDNUrl;
  45438. /**
  45439. * Creates the default options for the helper.
  45440. */
  45441. private static _getDefaultOptions;
  45442. private _rootMesh;
  45443. /**
  45444. * Gets the root mesh created by the helper.
  45445. */
  45446. readonly rootMesh: Mesh;
  45447. private _skybox;
  45448. /**
  45449. * Gets the skybox created by the helper.
  45450. */
  45451. readonly skybox: Nullable<Mesh>;
  45452. private _skyboxTexture;
  45453. /**
  45454. * Gets the skybox texture created by the helper.
  45455. */
  45456. readonly skyboxTexture: Nullable<BaseTexture>;
  45457. private _skyboxMaterial;
  45458. /**
  45459. * Gets the skybox material created by the helper.
  45460. */
  45461. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45462. private _ground;
  45463. /**
  45464. * Gets the ground mesh created by the helper.
  45465. */
  45466. readonly ground: Nullable<Mesh>;
  45467. private _groundTexture;
  45468. /**
  45469. * Gets the ground texture created by the helper.
  45470. */
  45471. readonly groundTexture: Nullable<BaseTexture>;
  45472. private _groundMirror;
  45473. /**
  45474. * Gets the ground mirror created by the helper.
  45475. */
  45476. readonly groundMirror: Nullable<MirrorTexture>;
  45477. /**
  45478. * Gets the ground mirror render list to helps pushing the meshes
  45479. * you wish in the ground reflection.
  45480. */
  45481. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45482. private _groundMaterial;
  45483. /**
  45484. * Gets the ground material created by the helper.
  45485. */
  45486. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45487. /**
  45488. * Stores the creation options.
  45489. */
  45490. private readonly _scene;
  45491. private _options;
  45492. /**
  45493. * This observable will be notified with any error during the creation of the environment,
  45494. * mainly texture creation errors.
  45495. */
  45496. onErrorObservable: Observable<{
  45497. message?: string;
  45498. exception?: any;
  45499. }>;
  45500. /**
  45501. * constructor
  45502. * @param options Defines the options we want to customize the helper
  45503. * @param scene The scene to add the material to
  45504. */
  45505. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45506. /**
  45507. * Updates the background according to the new options
  45508. * @param options
  45509. */
  45510. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45511. /**
  45512. * Sets the primary color of all the available elements.
  45513. * @param color the main color to affect to the ground and the background
  45514. */
  45515. setMainColor(color: Color3): void;
  45516. /**
  45517. * Setup the image processing according to the specified options.
  45518. */
  45519. private _setupImageProcessing;
  45520. /**
  45521. * Setup the environment texture according to the specified options.
  45522. */
  45523. private _setupEnvironmentTexture;
  45524. /**
  45525. * Setup the background according to the specified options.
  45526. */
  45527. private _setupBackground;
  45528. /**
  45529. * Get the scene sizes according to the setup.
  45530. */
  45531. private _getSceneSize;
  45532. /**
  45533. * Setup the ground according to the specified options.
  45534. */
  45535. private _setupGround;
  45536. /**
  45537. * Setup the ground material according to the specified options.
  45538. */
  45539. private _setupGroundMaterial;
  45540. /**
  45541. * Setup the ground diffuse texture according to the specified options.
  45542. */
  45543. private _setupGroundDiffuseTexture;
  45544. /**
  45545. * Setup the ground mirror texture according to the specified options.
  45546. */
  45547. private _setupGroundMirrorTexture;
  45548. /**
  45549. * Setup the ground to receive the mirror texture.
  45550. */
  45551. private _setupMirrorInGroundMaterial;
  45552. /**
  45553. * Setup the skybox according to the specified options.
  45554. */
  45555. private _setupSkybox;
  45556. /**
  45557. * Setup the skybox material according to the specified options.
  45558. */
  45559. private _setupSkyboxMaterial;
  45560. /**
  45561. * Setup the skybox reflection texture according to the specified options.
  45562. */
  45563. private _setupSkyboxReflectionTexture;
  45564. private _errorHandler;
  45565. /**
  45566. * Dispose all the elements created by the Helper.
  45567. */
  45568. dispose(): void;
  45569. }
  45570. }
  45571. declare module BABYLON {
  45572. /**
  45573. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45574. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45575. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45576. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45577. */
  45578. export class PhotoDome extends TransformNode {
  45579. /**
  45580. * Define the image as a Monoscopic panoramic 360 image.
  45581. */
  45582. static readonly MODE_MONOSCOPIC: number;
  45583. /**
  45584. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45585. */
  45586. static readonly MODE_TOPBOTTOM: number;
  45587. /**
  45588. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45589. */
  45590. static readonly MODE_SIDEBYSIDE: number;
  45591. private _useDirectMapping;
  45592. /**
  45593. * The texture being displayed on the sphere
  45594. */
  45595. protected _photoTexture: Texture;
  45596. /**
  45597. * Gets or sets the texture being displayed on the sphere
  45598. */
  45599. photoTexture: Texture;
  45600. /**
  45601. * Observable raised when an error occured while loading the 360 image
  45602. */
  45603. onLoadErrorObservable: Observable<string>;
  45604. /**
  45605. * The skybox material
  45606. */
  45607. protected _material: BackgroundMaterial;
  45608. /**
  45609. * The surface used for the skybox
  45610. */
  45611. protected _mesh: Mesh;
  45612. /**
  45613. * Gets the mesh used for the skybox.
  45614. */
  45615. readonly mesh: Mesh;
  45616. /**
  45617. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45618. * Also see the options.resolution property.
  45619. */
  45620. fovMultiplier: number;
  45621. private _imageMode;
  45622. /**
  45623. * Gets or set the current video mode for the video. It can be:
  45624. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  45625. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45626. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45627. */
  45628. imageMode: number;
  45629. /**
  45630. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45631. * @param name Element's name, child elements will append suffixes for their own names.
  45632. * @param urlsOfPhoto defines the url of the photo to display
  45633. * @param options defines an object containing optional or exposed sub element properties
  45634. * @param onError defines a callback called when an error occured while loading the texture
  45635. */
  45636. constructor(name: string, urlOfPhoto: string, options: {
  45637. resolution?: number;
  45638. size?: number;
  45639. useDirectMapping?: boolean;
  45640. faceForward?: boolean;
  45641. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45642. private _onBeforeCameraRenderObserver;
  45643. private _changeImageMode;
  45644. /**
  45645. * Releases resources associated with this node.
  45646. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45647. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45648. */
  45649. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45650. }
  45651. }
  45652. declare module BABYLON {
  45653. /**
  45654. * Class used to host RGBD texture specific utilities
  45655. */
  45656. export class RGBDTextureTools {
  45657. /**
  45658. * Expand the RGBD Texture from RGBD to Half Float if possible.
  45659. * @param texture the texture to expand.
  45660. */
  45661. static ExpandRGBDTexture(texture: Texture): void;
  45662. }
  45663. }
  45664. declare module BABYLON {
  45665. /**
  45666. * Class used to host texture specific utilities
  45667. */
  45668. export class BRDFTextureTools {
  45669. /**
  45670. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45671. * @param scene defines the hosting scene
  45672. * @returns the environment BRDF texture
  45673. */
  45674. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45675. private static _environmentBRDFBase64Texture;
  45676. }
  45677. }
  45678. declare module BABYLON {
  45679. /**
  45680. * @hidden
  45681. */
  45682. export interface IMaterialClearCoatDefines {
  45683. CLEARCOAT: boolean;
  45684. CLEARCOAT_DEFAULTIOR: boolean;
  45685. CLEARCOAT_TEXTURE: boolean;
  45686. CLEARCOAT_TEXTUREDIRECTUV: number;
  45687. CLEARCOAT_BUMP: boolean;
  45688. CLEARCOAT_BUMPDIRECTUV: number;
  45689. CLEARCOAT_TINT: boolean;
  45690. CLEARCOAT_TINT_TEXTURE: boolean;
  45691. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45692. /** @hidden */ private _areTexturesDirty: boolean;
  45693. }
  45694. /**
  45695. * Define the code related to the clear coat parameters of the pbr material.
  45696. */
  45697. export class PBRClearCoatConfiguration {
  45698. /**
  45699. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45700. * The default fits with a polyurethane material.
  45701. */
  45702. private static readonly _DefaultIndexOfRefraction;
  45703. private _isEnabled;
  45704. /**
  45705. * Defines if the clear coat is enabled in the material.
  45706. */
  45707. isEnabled: boolean;
  45708. /**
  45709. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45710. */
  45711. intensity: number;
  45712. /**
  45713. * Defines the clear coat layer roughness.
  45714. */
  45715. roughness: number;
  45716. private _indexOfRefraction;
  45717. /**
  45718. * Defines the index of refraction of the clear coat.
  45719. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45720. * The default fits with a polyurethane material.
  45721. * Changing the default value is more performance intensive.
  45722. */
  45723. indexOfRefraction: number;
  45724. private _texture;
  45725. /**
  45726. * Stores the clear coat values in a texture.
  45727. */
  45728. texture: Nullable<BaseTexture>;
  45729. private _bumpTexture;
  45730. /**
  45731. * Define the clear coat specific bump texture.
  45732. */
  45733. bumpTexture: Nullable<BaseTexture>;
  45734. private _isTintEnabled;
  45735. /**
  45736. * Defines if the clear coat tint is enabled in the material.
  45737. */
  45738. isTintEnabled: boolean;
  45739. /**
  45740. * Defines the clear coat tint of the material.
  45741. * This is only use if tint is enabled
  45742. */
  45743. tintColor: Color3;
  45744. /**
  45745. * Defines the distance at which the tint color should be found in the
  45746. * clear coat media.
  45747. * This is only use if tint is enabled
  45748. */
  45749. tintColorAtDistance: number;
  45750. /**
  45751. * Defines the clear coat layer thickness.
  45752. * This is only use if tint is enabled
  45753. */
  45754. tintThickness: number;
  45755. private _tintTexture;
  45756. /**
  45757. * Stores the clear tint values in a texture.
  45758. * rgb is tint
  45759. * a is a thickness factor
  45760. */
  45761. tintTexture: Nullable<BaseTexture>;
  45762. /** @hidden */
  45763. private _internalMarkAllSubMeshesAsTexturesDirty;
  45764. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45765. /**
  45766. * Instantiate a new istance of clear coat configuration.
  45767. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45768. */
  45769. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45770. /**
  45771. * Gets wehter the submesh is ready to be used or not.
  45772. * @param defines the list of "defines" to update.
  45773. * @param scene defines the scene the material belongs to.
  45774. * @param engine defines the engine the material belongs to.
  45775. * @param disableBumpMap defines wether the material disables bump or not.
  45776. * @returns - boolean indicating that the submesh is ready or not.
  45777. */
  45778. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45779. /**
  45780. * Checks to see if a texture is used in the material.
  45781. * @param defines the list of "defines" to update.
  45782. * @param scene defines the scene to the material belongs to.
  45783. */
  45784. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45785. /**
  45786. * Binds the material data.
  45787. * @param uniformBuffer defines the Uniform buffer to fill in.
  45788. * @param scene defines the scene the material belongs to.
  45789. * @param engine defines the engine the material belongs to.
  45790. * @param disableBumpMap defines wether the material disables bump or not.
  45791. * @param isFrozen defines wether the material is frozen or not.
  45792. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45793. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45794. */
  45795. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45796. /**
  45797. * Checks to see if a texture is used in the material.
  45798. * @param texture - Base texture to use.
  45799. * @returns - Boolean specifying if a texture is used in the material.
  45800. */
  45801. hasTexture(texture: BaseTexture): boolean;
  45802. /**
  45803. * Returns an array of the actively used textures.
  45804. * @param activeTextures Array of BaseTextures
  45805. */
  45806. getActiveTextures(activeTextures: BaseTexture[]): void;
  45807. /**
  45808. * Returns the animatable textures.
  45809. * @param animatables Array of animatable textures.
  45810. */
  45811. getAnimatables(animatables: IAnimatable[]): void;
  45812. /**
  45813. * Disposes the resources of the material.
  45814. * @param forceDisposeTextures - Forces the disposal of all textures.
  45815. */
  45816. dispose(forceDisposeTextures?: boolean): void;
  45817. /**
  45818. * Get the current class name of the texture useful for serialization or dynamic coding.
  45819. * @returns "PBRClearCoatConfiguration"
  45820. */
  45821. getClassName(): string;
  45822. /**
  45823. * Add fallbacks to the effect fallbacks list.
  45824. * @param defines defines the Base texture to use.
  45825. * @param fallbacks defines the current fallback list.
  45826. * @param currentRank defines the current fallback rank.
  45827. * @returns the new fallback rank.
  45828. */
  45829. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45830. /**
  45831. * Add the required uniforms to the current list.
  45832. * @param uniforms defines the current uniform list.
  45833. */
  45834. static AddUniforms(uniforms: string[]): void;
  45835. /**
  45836. * Add the required samplers to the current list.
  45837. * @param samplers defines the current sampler list.
  45838. */
  45839. static AddSamplers(samplers: string[]): void;
  45840. /**
  45841. * Add the required uniforms to the current buffer.
  45842. * @param uniformBuffer defines the current uniform buffer.
  45843. */
  45844. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45845. /**
  45846. * Makes a duplicate of the current configuration into another one.
  45847. * @param clearCoatConfiguration define the config where to copy the info
  45848. */
  45849. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45850. /**
  45851. * Serializes this clear coat configuration.
  45852. * @returns - An object with the serialized config.
  45853. */
  45854. serialize(): any;
  45855. /**
  45856. * Parses a anisotropy Configuration from a serialized object.
  45857. * @param source - Serialized object.
  45858. * @param scene Defines the scene we are parsing for
  45859. * @param rootUrl Defines the rootUrl to load from
  45860. */
  45861. parse(source: any, scene: Scene, rootUrl: string): void;
  45862. }
  45863. }
  45864. declare module BABYLON {
  45865. /**
  45866. * @hidden
  45867. */
  45868. export interface IMaterialAnisotropicDefines {
  45869. ANISOTROPIC: boolean;
  45870. ANISOTROPIC_TEXTURE: boolean;
  45871. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45872. MAINUV1: boolean; private _areTexturesDirty: boolean; private _needUVs: boolean;
  45873. }
  45874. /**
  45875. * Define the code related to the anisotropic parameters of the pbr material.
  45876. */
  45877. export class PBRAnisotropicConfiguration {
  45878. private _isEnabled;
  45879. /**
  45880. * Defines if the anisotropy is enabled in the material.
  45881. */
  45882. isEnabled: boolean;
  45883. /**
  45884. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45885. */
  45886. intensity: number;
  45887. /**
  45888. * Defines if the effect is along the tangents, bitangents or in between.
  45889. * By default, the effect is "strectching" the highlights along the tangents.
  45890. */
  45891. direction: Vector2;
  45892. private _texture;
  45893. /**
  45894. * Stores the anisotropy values in a texture.
  45895. * rg is direction (like normal from -1 to 1)
  45896. * b is a intensity
  45897. */
  45898. texture: Nullable<BaseTexture>;
  45899. /** @hidden */
  45900. private _internalMarkAllSubMeshesAsTexturesDirty;
  45901. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45902. /**
  45903. * Instantiate a new istance of anisotropy configuration.
  45904. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45905. */
  45906. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45907. /**
  45908. * Specifies that the submesh is ready to be used.
  45909. * @param defines the list of "defines" to update.
  45910. * @param scene defines the scene the material belongs to.
  45911. * @returns - boolean indicating that the submesh is ready or not.
  45912. */
  45913. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45914. /**
  45915. * Checks to see if a texture is used in the material.
  45916. * @param defines the list of "defines" to update.
  45917. * @param mesh the mesh we are preparing the defines for.
  45918. * @param scene defines the scene the material belongs to.
  45919. */
  45920. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45921. /**
  45922. * Binds the material data.
  45923. * @param uniformBuffer defines the Uniform buffer to fill in.
  45924. * @param scene defines the scene the material belongs to.
  45925. * @param isFrozen defines wether the material is frozen or not.
  45926. */
  45927. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45928. /**
  45929. * Checks to see if a texture is used in the material.
  45930. * @param texture - Base texture to use.
  45931. * @returns - Boolean specifying if a texture is used in the material.
  45932. */
  45933. hasTexture(texture: BaseTexture): boolean;
  45934. /**
  45935. * Returns an array of the actively used textures.
  45936. * @param activeTextures Array of BaseTextures
  45937. */
  45938. getActiveTextures(activeTextures: BaseTexture[]): void;
  45939. /**
  45940. * Returns the animatable textures.
  45941. * @param animatables Array of animatable textures.
  45942. */
  45943. getAnimatables(animatables: IAnimatable[]): void;
  45944. /**
  45945. * Disposes the resources of the material.
  45946. * @param forceDisposeTextures - Forces the disposal of all textures.
  45947. */
  45948. dispose(forceDisposeTextures?: boolean): void;
  45949. /**
  45950. * Get the current class name of the texture useful for serialization or dynamic coding.
  45951. * @returns "PBRAnisotropicConfiguration"
  45952. */
  45953. getClassName(): string;
  45954. /**
  45955. * Add fallbacks to the effect fallbacks list.
  45956. * @param defines defines the Base texture to use.
  45957. * @param fallbacks defines the current fallback list.
  45958. * @param currentRank defines the current fallback rank.
  45959. * @returns the new fallback rank.
  45960. */
  45961. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45962. /**
  45963. * Add the required uniforms to the current list.
  45964. * @param uniforms defines the current uniform list.
  45965. */
  45966. static AddUniforms(uniforms: string[]): void;
  45967. /**
  45968. * Add the required uniforms to the current buffer.
  45969. * @param uniformBuffer defines the current uniform buffer.
  45970. */
  45971. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45972. /**
  45973. * Add the required samplers to the current list.
  45974. * @param samplers defines the current sampler list.
  45975. */
  45976. static AddSamplers(samplers: string[]): void;
  45977. /**
  45978. * Makes a duplicate of the current configuration into another one.
  45979. * @param anisotropicConfiguration define the config where to copy the info
  45980. */
  45981. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45982. /**
  45983. * Serializes this anisotropy configuration.
  45984. * @returns - An object with the serialized config.
  45985. */
  45986. serialize(): any;
  45987. /**
  45988. * Parses a anisotropy Configuration from a serialized object.
  45989. * @param source - Serialized object.
  45990. * @param scene Defines the scene we are parsing for
  45991. * @param rootUrl Defines the rootUrl to load from
  45992. */
  45993. parse(source: any, scene: Scene, rootUrl: string): void;
  45994. }
  45995. }
  45996. declare module BABYLON {
  45997. /**
  45998. * @hidden
  45999. */
  46000. export interface IMaterialBRDFDefines {
  46001. BRDF_V_HEIGHT_CORRELATED: boolean;
  46002. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46003. SPHERICAL_HARMONICS: boolean;
  46004. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46005. /** @hidden */ private _areMiscDirty: boolean;
  46006. }
  46007. /**
  46008. * Define the code related to the BRDF parameters of the pbr material.
  46009. */
  46010. export class PBRBRDFConfiguration {
  46011. /**
  46012. * Default value used for the energy conservation.
  46013. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46014. */
  46015. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46016. /**
  46017. * Default value used for the Smith Visibility Height Correlated mode.
  46018. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46019. */
  46020. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46021. /**
  46022. * Default value used for the IBL diffuse part.
  46023. * This can help switching back to the polynomials mode globally which is a tiny bit
  46024. * less GPU intensive at the drawback of a lower quality.
  46025. */
  46026. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46027. /**
  46028. * Default value used for activating energy conservation for the specular workflow.
  46029. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46030. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46031. */
  46032. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  46033. private _useEnergyConservation;
  46034. /**
  46035. * Defines if the material uses energy conservation.
  46036. */
  46037. useEnergyConservation: boolean;
  46038. private _useSmithVisibilityHeightCorrelated;
  46039. /**
  46040. * LEGACY Mode set to false
  46041. * Defines if the material uses height smith correlated visibility term.
  46042. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46043. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46044. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46045. * Not relying on height correlated will also disable energy conservation.
  46046. */
  46047. useSmithVisibilityHeightCorrelated: boolean;
  46048. private _useSphericalHarmonics;
  46049. /**
  46050. * LEGACY Mode set to false
  46051. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46052. * diffuse part of the IBL.
  46053. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46054. * to the ground truth.
  46055. */
  46056. useSphericalHarmonics: boolean;
  46057. private _useSpecularGlossinessInputEnergyConservation;
  46058. /**
  46059. * Defines if the material uses energy conservation, when the specular workflow is active.
  46060. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46061. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46062. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  46063. */
  46064. useSpecularGlossinessInputEnergyConservation: boolean;
  46065. /** @hidden */
  46066. private _internalMarkAllSubMeshesAsMiscDirty;
  46067. /** @hidden */ private _markAllSubMeshesAsMiscDirty(): void;
  46068. /**
  46069. * Instantiate a new istance of clear coat configuration.
  46070. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46071. */
  46072. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46073. /**
  46074. * Checks to see if a texture is used in the material.
  46075. * @param defines the list of "defines" to update.
  46076. */
  46077. prepareDefines(defines: IMaterialBRDFDefines): void;
  46078. /**
  46079. * Get the current class name of the texture useful for serialization or dynamic coding.
  46080. * @returns "PBRClearCoatConfiguration"
  46081. */
  46082. getClassName(): string;
  46083. /**
  46084. * Makes a duplicate of the current configuration into another one.
  46085. * @param brdfConfiguration define the config where to copy the info
  46086. */
  46087. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46088. /**
  46089. * Serializes this BRDF configuration.
  46090. * @returns - An object with the serialized config.
  46091. */
  46092. serialize(): any;
  46093. /**
  46094. * Parses a anisotropy Configuration from a serialized object.
  46095. * @param source - Serialized object.
  46096. * @param scene Defines the scene we are parsing for
  46097. * @param rootUrl Defines the rootUrl to load from
  46098. */
  46099. parse(source: any, scene: Scene, rootUrl: string): void;
  46100. }
  46101. }
  46102. declare module BABYLON {
  46103. /**
  46104. * @hidden
  46105. */
  46106. export interface IMaterialSheenDefines {
  46107. SHEEN: boolean;
  46108. SHEEN_TEXTURE: boolean;
  46109. SHEEN_TEXTUREDIRECTUV: number;
  46110. SHEEN_LINKWITHALBEDO: boolean;
  46111. /** @hidden */ private _areTexturesDirty: boolean;
  46112. }
  46113. /**
  46114. * Define the code related to the Sheen parameters of the pbr material.
  46115. */
  46116. export class PBRSheenConfiguration {
  46117. private _isEnabled;
  46118. /**
  46119. * Defines if the material uses sheen.
  46120. */
  46121. isEnabled: boolean;
  46122. private _linkSheenWithAlbedo;
  46123. /**
  46124. * Defines if the sheen is linked to the sheen color.
  46125. */
  46126. linkSheenWithAlbedo: boolean;
  46127. /**
  46128. * Defines the sheen intensity.
  46129. */
  46130. intensity: number;
  46131. /**
  46132. * Defines the sheen color.
  46133. */
  46134. color: Color3;
  46135. private _texture;
  46136. /**
  46137. * Stores the sheen tint values in a texture.
  46138. * rgb is tint
  46139. * a is a intensity
  46140. */
  46141. texture: Nullable<BaseTexture>;
  46142. /** @hidden */
  46143. private _internalMarkAllSubMeshesAsTexturesDirty;
  46144. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  46145. /**
  46146. * Instantiate a new istance of clear coat configuration.
  46147. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46148. */
  46149. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46150. /**
  46151. * Specifies that the submesh is ready to be used.
  46152. * @param defines the list of "defines" to update.
  46153. * @param scene defines the scene the material belongs to.
  46154. * @returns - boolean indicating that the submesh is ready or not.
  46155. */
  46156. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46157. /**
  46158. * Checks to see if a texture is used in the material.
  46159. * @param defines the list of "defines" to update.
  46160. * @param scene defines the scene the material belongs to.
  46161. */
  46162. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46163. /**
  46164. * Binds the material data.
  46165. * @param uniformBuffer defines the Uniform buffer to fill in.
  46166. * @param scene defines the scene the material belongs to.
  46167. * @param isFrozen defines wether the material is frozen or not.
  46168. */
  46169. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46170. /**
  46171. * Checks to see if a texture is used in the material.
  46172. * @param texture - Base texture to use.
  46173. * @returns - Boolean specifying if a texture is used in the material.
  46174. */
  46175. hasTexture(texture: BaseTexture): boolean;
  46176. /**
  46177. * Returns an array of the actively used textures.
  46178. * @param activeTextures Array of BaseTextures
  46179. */
  46180. getActiveTextures(activeTextures: BaseTexture[]): void;
  46181. /**
  46182. * Returns the animatable textures.
  46183. * @param animatables Array of animatable textures.
  46184. */
  46185. getAnimatables(animatables: IAnimatable[]): void;
  46186. /**
  46187. * Disposes the resources of the material.
  46188. * @param forceDisposeTextures - Forces the disposal of all textures.
  46189. */
  46190. dispose(forceDisposeTextures?: boolean): void;
  46191. /**
  46192. * Get the current class name of the texture useful for serialization or dynamic coding.
  46193. * @returns "PBRSheenConfiguration"
  46194. */
  46195. getClassName(): string;
  46196. /**
  46197. * Add fallbacks to the effect fallbacks list.
  46198. * @param defines defines the Base texture to use.
  46199. * @param fallbacks defines the current fallback list.
  46200. * @param currentRank defines the current fallback rank.
  46201. * @returns the new fallback rank.
  46202. */
  46203. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46204. /**
  46205. * Add the required uniforms to the current list.
  46206. * @param uniforms defines the current uniform list.
  46207. */
  46208. static AddUniforms(uniforms: string[]): void;
  46209. /**
  46210. * Add the required uniforms to the current buffer.
  46211. * @param uniformBuffer defines the current uniform buffer.
  46212. */
  46213. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46214. /**
  46215. * Add the required samplers to the current list.
  46216. * @param samplers defines the current sampler list.
  46217. */
  46218. static AddSamplers(samplers: string[]): void;
  46219. /**
  46220. * Makes a duplicate of the current configuration into another one.
  46221. * @param sheenConfiguration define the config where to copy the info
  46222. */
  46223. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46224. /**
  46225. * Serializes this BRDF configuration.
  46226. * @returns - An object with the serialized config.
  46227. */
  46228. serialize(): any;
  46229. /**
  46230. * Parses a anisotropy Configuration from a serialized object.
  46231. * @param source - Serialized object.
  46232. * @param scene Defines the scene we are parsing for
  46233. * @param rootUrl Defines the rootUrl to load from
  46234. */
  46235. parse(source: any, scene: Scene, rootUrl: string): void;
  46236. }
  46237. }
  46238. declare module BABYLON {
  46239. /**
  46240. * @hidden
  46241. */
  46242. export interface IMaterialSubSurfaceDefines {
  46243. SUBSURFACE: boolean;
  46244. SS_REFRACTION: boolean;
  46245. SS_TRANSLUCENCY: boolean;
  46246. SS_SCATERRING: boolean;
  46247. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46248. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46249. SS_REFRACTIONMAP_3D: boolean;
  46250. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46251. SS_LODINREFRACTIONALPHA: boolean;
  46252. SS_GAMMAREFRACTION: boolean;
  46253. SS_RGBDREFRACTION: boolean;
  46254. SS_LINEARSPECULARREFRACTION: boolean;
  46255. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46256. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46257. /** @hidden */ private _areTexturesDirty: boolean;
  46258. }
  46259. /**
  46260. * Define the code related to the sub surface parameters of the pbr material.
  46261. */
  46262. export class PBRSubSurfaceConfiguration {
  46263. private _isRefractionEnabled;
  46264. /**
  46265. * Defines if the refraction is enabled in the material.
  46266. */
  46267. isRefractionEnabled: boolean;
  46268. private _isTranslucencyEnabled;
  46269. /**
  46270. * Defines if the translucency is enabled in the material.
  46271. */
  46272. isTranslucencyEnabled: boolean;
  46273. private _isScatteringEnabled;
  46274. /**
  46275. * Defines the refraction intensity of the material.
  46276. * The refraction when enabled replaces the Diffuse part of the material.
  46277. * The intensity helps transitionning between diffuse and refraction.
  46278. */
  46279. refractionIntensity: number;
  46280. /**
  46281. * Defines the translucency intensity of the material.
  46282. * When translucency has been enabled, this defines how much of the "translucency"
  46283. * is addded to the diffuse part of the material.
  46284. */
  46285. translucencyIntensity: number;
  46286. /**
  46287. * Defines the scattering intensity of the material.
  46288. * When scattering has been enabled, this defines how much of the "scattered light"
  46289. * is addded to the diffuse part of the material.
  46290. */
  46291. scatteringIntensity: number;
  46292. private _thicknessTexture;
  46293. /**
  46294. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46295. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46296. * 0 would mean minimumThickness
  46297. * 1 would mean maximumThickness
  46298. * The other channels might be use as a mask to vary the different effects intensity.
  46299. */
  46300. thicknessTexture: Nullable<BaseTexture>;
  46301. private _refractionTexture;
  46302. /**
  46303. * Defines the texture to use for refraction.
  46304. */
  46305. refractionTexture: Nullable<BaseTexture>;
  46306. private _indexOfRefraction;
  46307. /**
  46308. * Defines the index of refraction used in the material.
  46309. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46310. */
  46311. indexOfRefraction: number;
  46312. private _invertRefractionY;
  46313. /**
  46314. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46315. */
  46316. invertRefractionY: boolean;
  46317. private _linkRefractionWithTransparency;
  46318. /**
  46319. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46320. * Materials half opaque for instance using refraction could benefit from this control.
  46321. */
  46322. linkRefractionWithTransparency: boolean;
  46323. /**
  46324. * Defines the minimum thickness stored in the thickness map.
  46325. * If no thickness map is defined, this value will be used to simulate thickness.
  46326. */
  46327. minimumThickness: number;
  46328. /**
  46329. * Defines the maximum thickness stored in the thickness map.
  46330. */
  46331. maximumThickness: number;
  46332. /**
  46333. * Defines the volume tint of the material.
  46334. * This is used for both translucency and scattering.
  46335. */
  46336. tintColor: Color3;
  46337. /**
  46338. * Defines the distance at which the tint color should be found in the media.
  46339. * This is used for refraction only.
  46340. */
  46341. tintColorAtDistance: number;
  46342. /**
  46343. * Defines how far each channel transmit through the media.
  46344. * It is defined as a color to simplify it selection.
  46345. */
  46346. diffusionDistance: Color3;
  46347. private _useMaskFromThicknessTexture;
  46348. /**
  46349. * Stores the intensity of the different subsurface effects in the thickness texture.
  46350. * * the green channel is the translucency intensity.
  46351. * * the blue channel is the scattering intensity.
  46352. * * the alpha channel is the refraction intensity.
  46353. */
  46354. useMaskFromThicknessTexture: boolean;
  46355. /** @hidden */
  46356. private _internalMarkAllSubMeshesAsTexturesDirty;
  46357. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  46358. /**
  46359. * Instantiate a new istance of sub surface configuration.
  46360. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46361. */
  46362. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46363. /**
  46364. * Gets wehter the submesh is ready to be used or not.
  46365. * @param defines the list of "defines" to update.
  46366. * @param scene defines the scene the material belongs to.
  46367. * @returns - boolean indicating that the submesh is ready or not.
  46368. */
  46369. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46370. /**
  46371. * Checks to see if a texture is used in the material.
  46372. * @param defines the list of "defines" to update.
  46373. * @param scene defines the scene to the material belongs to.
  46374. */
  46375. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46376. /**
  46377. * Binds the material data.
  46378. * @param uniformBuffer defines the Uniform buffer to fill in.
  46379. * @param scene defines the scene the material belongs to.
  46380. * @param engine defines the engine the material belongs to.
  46381. * @param isFrozen defines wether the material is frozen or not.
  46382. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46383. */
  46384. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46385. /**
  46386. * Unbinds the material from the mesh.
  46387. * @param activeEffect defines the effect that should be unbound from.
  46388. * @returns true if unbound, otherwise false
  46389. */
  46390. unbind(activeEffect: Effect): boolean;
  46391. /**
  46392. * Returns the texture used for refraction or null if none is used.
  46393. * @param scene defines the scene the material belongs to.
  46394. * @returns - Refraction texture if present. If no refraction texture and refraction
  46395. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46396. */
  46397. private _getRefractionTexture;
  46398. /**
  46399. * Returns true if alpha blending should be disabled.
  46400. */
  46401. readonly disableAlphaBlending: boolean;
  46402. /**
  46403. * Fills the list of render target textures.
  46404. * @param renderTargets the list of render targets to update
  46405. */
  46406. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46407. /**
  46408. * Checks to see if a texture is used in the material.
  46409. * @param texture - Base texture to use.
  46410. * @returns - Boolean specifying if a texture is used in the material.
  46411. */
  46412. hasTexture(texture: BaseTexture): boolean;
  46413. /**
  46414. * Gets a boolean indicating that current material needs to register RTT
  46415. * @returns true if this uses a render target otherwise false.
  46416. */
  46417. hasRenderTargetTextures(): boolean;
  46418. /**
  46419. * Returns an array of the actively used textures.
  46420. * @param activeTextures Array of BaseTextures
  46421. */
  46422. getActiveTextures(activeTextures: BaseTexture[]): void;
  46423. /**
  46424. * Returns the animatable textures.
  46425. * @param animatables Array of animatable textures.
  46426. */
  46427. getAnimatables(animatables: IAnimatable[]): void;
  46428. /**
  46429. * Disposes the resources of the material.
  46430. * @param forceDisposeTextures - Forces the disposal of all textures.
  46431. */
  46432. dispose(forceDisposeTextures?: boolean): void;
  46433. /**
  46434. * Get the current class name of the texture useful for serialization or dynamic coding.
  46435. * @returns "PBRSubSurfaceConfiguration"
  46436. */
  46437. getClassName(): string;
  46438. /**
  46439. * Add fallbacks to the effect fallbacks list.
  46440. * @param defines defines the Base texture to use.
  46441. * @param fallbacks defines the current fallback list.
  46442. * @param currentRank defines the current fallback rank.
  46443. * @returns the new fallback rank.
  46444. */
  46445. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46446. /**
  46447. * Add the required uniforms to the current list.
  46448. * @param uniforms defines the current uniform list.
  46449. */
  46450. static AddUniforms(uniforms: string[]): void;
  46451. /**
  46452. * Add the required samplers to the current list.
  46453. * @param samplers defines the current sampler list.
  46454. */
  46455. static AddSamplers(samplers: string[]): void;
  46456. /**
  46457. * Add the required uniforms to the current buffer.
  46458. * @param uniformBuffer defines the current uniform buffer.
  46459. */
  46460. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46461. /**
  46462. * Makes a duplicate of the current configuration into another one.
  46463. * @param configuration define the config where to copy the info
  46464. */
  46465. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46466. /**
  46467. * Serializes this Sub Surface configuration.
  46468. * @returns - An object with the serialized config.
  46469. */
  46470. serialize(): any;
  46471. /**
  46472. * Parses a anisotropy Configuration from a serialized object.
  46473. * @param source - Serialized object.
  46474. * @param scene Defines the scene we are parsing for
  46475. * @param rootUrl Defines the rootUrl to load from
  46476. */
  46477. parse(source: any, scene: Scene, rootUrl: string): void;
  46478. }
  46479. }
  46480. declare module BABYLON {
  46481. /** @hidden */
  46482. export var pbrFragmentDeclaration: {
  46483. name: string;
  46484. shader: string;
  46485. };
  46486. }
  46487. declare module BABYLON {
  46488. /** @hidden */
  46489. export var pbrUboDeclaration: {
  46490. name: string;
  46491. shader: string;
  46492. };
  46493. }
  46494. declare module BABYLON {
  46495. /** @hidden */
  46496. export var pbrFragmentExtraDeclaration: {
  46497. name: string;
  46498. shader: string;
  46499. };
  46500. }
  46501. declare module BABYLON {
  46502. /** @hidden */
  46503. export var pbrFragmentSamplersDeclaration: {
  46504. name: string;
  46505. shader: string;
  46506. };
  46507. }
  46508. declare module BABYLON {
  46509. /** @hidden */
  46510. export var pbrHelperFunctions: {
  46511. name: string;
  46512. shader: string;
  46513. };
  46514. }
  46515. declare module BABYLON {
  46516. /** @hidden */
  46517. export var harmonicsFunctions: {
  46518. name: string;
  46519. shader: string;
  46520. };
  46521. }
  46522. declare module BABYLON {
  46523. /** @hidden */
  46524. export var pbrDirectLightingSetupFunctions: {
  46525. name: string;
  46526. shader: string;
  46527. };
  46528. }
  46529. declare module BABYLON {
  46530. /** @hidden */
  46531. export var pbrDirectLightingFalloffFunctions: {
  46532. name: string;
  46533. shader: string;
  46534. };
  46535. }
  46536. declare module BABYLON {
  46537. /** @hidden */
  46538. export var pbrBRDFFunctions: {
  46539. name: string;
  46540. shader: string;
  46541. };
  46542. }
  46543. declare module BABYLON {
  46544. /** @hidden */
  46545. export var pbrDirectLightingFunctions: {
  46546. name: string;
  46547. shader: string;
  46548. };
  46549. }
  46550. declare module BABYLON {
  46551. /** @hidden */
  46552. export var pbrIBLFunctions: {
  46553. name: string;
  46554. shader: string;
  46555. };
  46556. }
  46557. declare module BABYLON {
  46558. /** @hidden */
  46559. export var pbrDebug: {
  46560. name: string;
  46561. shader: string;
  46562. };
  46563. }
  46564. declare module BABYLON {
  46565. /** @hidden */
  46566. export var pbrPixelShader: {
  46567. name: string;
  46568. shader: string;
  46569. };
  46570. }
  46571. declare module BABYLON {
  46572. /** @hidden */
  46573. export var pbrVertexDeclaration: {
  46574. name: string;
  46575. shader: string;
  46576. };
  46577. }
  46578. declare module BABYLON {
  46579. /** @hidden */
  46580. export var pbrVertexShader: {
  46581. name: string;
  46582. shader: string;
  46583. };
  46584. }
  46585. declare module BABYLON {
  46586. /**
  46587. * Manages the defines for the PBR Material.
  46588. * @hidden
  46589. */
  46590. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46591. PBR: boolean;
  46592. MAINUV1: boolean;
  46593. MAINUV2: boolean;
  46594. UV1: boolean;
  46595. UV2: boolean;
  46596. ALBEDO: boolean;
  46597. ALBEDODIRECTUV: number;
  46598. VERTEXCOLOR: boolean;
  46599. AMBIENT: boolean;
  46600. AMBIENTDIRECTUV: number;
  46601. AMBIENTINGRAYSCALE: boolean;
  46602. OPACITY: boolean;
  46603. VERTEXALPHA: boolean;
  46604. OPACITYDIRECTUV: number;
  46605. OPACITYRGB: boolean;
  46606. ALPHATEST: boolean;
  46607. DEPTHPREPASS: boolean;
  46608. ALPHABLEND: boolean;
  46609. ALPHAFROMALBEDO: boolean;
  46610. ALPHATESTVALUE: string;
  46611. SPECULAROVERALPHA: boolean;
  46612. RADIANCEOVERALPHA: boolean;
  46613. ALPHAFRESNEL: boolean;
  46614. LINEARALPHAFRESNEL: boolean;
  46615. PREMULTIPLYALPHA: boolean;
  46616. EMISSIVE: boolean;
  46617. EMISSIVEDIRECTUV: number;
  46618. REFLECTIVITY: boolean;
  46619. REFLECTIVITYDIRECTUV: number;
  46620. SPECULARTERM: boolean;
  46621. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46622. MICROSURFACEAUTOMATIC: boolean;
  46623. LODBASEDMICROSFURACE: boolean;
  46624. MICROSURFACEMAP: boolean;
  46625. MICROSURFACEMAPDIRECTUV: number;
  46626. METALLICWORKFLOW: boolean;
  46627. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46628. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46629. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46630. AOSTOREINMETALMAPRED: boolean;
  46631. ENVIRONMENTBRDF: boolean;
  46632. ENVIRONMENTBRDF_RGBD: boolean;
  46633. NORMAL: boolean;
  46634. TANGENT: boolean;
  46635. BUMP: boolean;
  46636. BUMPDIRECTUV: number;
  46637. OBJECTSPACE_NORMALMAP: boolean;
  46638. PARALLAX: boolean;
  46639. PARALLAXOCCLUSION: boolean;
  46640. NORMALXYSCALE: boolean;
  46641. LIGHTMAP: boolean;
  46642. LIGHTMAPDIRECTUV: number;
  46643. USELIGHTMAPASSHADOWMAP: boolean;
  46644. GAMMALIGHTMAP: boolean;
  46645. RGBDLIGHTMAP: boolean;
  46646. REFLECTION: boolean;
  46647. REFLECTIONMAP_3D: boolean;
  46648. REFLECTIONMAP_SPHERICAL: boolean;
  46649. REFLECTIONMAP_PLANAR: boolean;
  46650. REFLECTIONMAP_CUBIC: boolean;
  46651. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46652. REFLECTIONMAP_PROJECTION: boolean;
  46653. REFLECTIONMAP_SKYBOX: boolean;
  46654. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46655. REFLECTIONMAP_EXPLICIT: boolean;
  46656. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46657. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46658. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46659. INVERTCUBICMAP: boolean;
  46660. USESPHERICALFROMREFLECTIONMAP: boolean;
  46661. USEIRRADIANCEMAP: boolean;
  46662. SPHERICAL_HARMONICS: boolean;
  46663. USESPHERICALINVERTEX: boolean;
  46664. REFLECTIONMAP_OPPOSITEZ: boolean;
  46665. LODINREFLECTIONALPHA: boolean;
  46666. GAMMAREFLECTION: boolean;
  46667. RGBDREFLECTION: boolean;
  46668. LINEARSPECULARREFLECTION: boolean;
  46669. RADIANCEOCCLUSION: boolean;
  46670. HORIZONOCCLUSION: boolean;
  46671. INSTANCES: boolean;
  46672. NUM_BONE_INFLUENCERS: number;
  46673. BonesPerMesh: number;
  46674. BONETEXTURE: boolean;
  46675. NONUNIFORMSCALING: boolean;
  46676. MORPHTARGETS: boolean;
  46677. MORPHTARGETS_NORMAL: boolean;
  46678. MORPHTARGETS_TANGENT: boolean;
  46679. MORPHTARGETS_UV: boolean;
  46680. NUM_MORPH_INFLUENCERS: number;
  46681. IMAGEPROCESSING: boolean;
  46682. VIGNETTE: boolean;
  46683. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46684. VIGNETTEBLENDMODEOPAQUE: boolean;
  46685. TONEMAPPING: boolean;
  46686. TONEMAPPING_ACES: boolean;
  46687. CONTRAST: boolean;
  46688. COLORCURVES: boolean;
  46689. COLORGRADING: boolean;
  46690. COLORGRADING3D: boolean;
  46691. SAMPLER3DGREENDEPTH: boolean;
  46692. SAMPLER3DBGRMAP: boolean;
  46693. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46694. EXPOSURE: boolean;
  46695. MULTIVIEW: boolean;
  46696. USEPHYSICALLIGHTFALLOFF: boolean;
  46697. USEGLTFLIGHTFALLOFF: boolean;
  46698. TWOSIDEDLIGHTING: boolean;
  46699. SHADOWFLOAT: boolean;
  46700. CLIPPLANE: boolean;
  46701. CLIPPLANE2: boolean;
  46702. CLIPPLANE3: boolean;
  46703. CLIPPLANE4: boolean;
  46704. POINTSIZE: boolean;
  46705. FOG: boolean;
  46706. LOGARITHMICDEPTH: boolean;
  46707. FORCENORMALFORWARD: boolean;
  46708. SPECULARAA: boolean;
  46709. CLEARCOAT: boolean;
  46710. CLEARCOAT_DEFAULTIOR: boolean;
  46711. CLEARCOAT_TEXTURE: boolean;
  46712. CLEARCOAT_TEXTUREDIRECTUV: number;
  46713. CLEARCOAT_BUMP: boolean;
  46714. CLEARCOAT_BUMPDIRECTUV: number;
  46715. CLEARCOAT_TINT: boolean;
  46716. CLEARCOAT_TINT_TEXTURE: boolean;
  46717. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46718. ANISOTROPIC: boolean;
  46719. ANISOTROPIC_TEXTURE: boolean;
  46720. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46721. BRDF_V_HEIGHT_CORRELATED: boolean;
  46722. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46723. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46724. SHEEN: boolean;
  46725. SHEEN_TEXTURE: boolean;
  46726. SHEEN_TEXTUREDIRECTUV: number;
  46727. SHEEN_LINKWITHALBEDO: boolean;
  46728. SUBSURFACE: boolean;
  46729. SS_REFRACTION: boolean;
  46730. SS_TRANSLUCENCY: boolean;
  46731. SS_SCATERRING: boolean;
  46732. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46733. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46734. SS_REFRACTIONMAP_3D: boolean;
  46735. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46736. SS_LODINREFRACTIONALPHA: boolean;
  46737. SS_GAMMAREFRACTION: boolean;
  46738. SS_RGBDREFRACTION: boolean;
  46739. SS_LINEARSPECULARREFRACTION: boolean;
  46740. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46741. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46742. UNLIT: boolean;
  46743. DEBUGMODE: number;
  46744. /**
  46745. * Initializes the PBR Material defines.
  46746. */
  46747. constructor();
  46748. /**
  46749. * Resets the PBR Material defines.
  46750. */
  46751. reset(): void;
  46752. }
  46753. /**
  46754. * The Physically based material base class of BJS.
  46755. *
  46756. * This offers the main features of a standard PBR material.
  46757. * For more information, please refer to the documentation :
  46758. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46759. */
  46760. export abstract class PBRBaseMaterial extends PushMaterial {
  46761. /**
  46762. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46763. */
  46764. static readonly PBRMATERIAL_OPAQUE: number;
  46765. /**
  46766. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46767. */
  46768. static readonly PBRMATERIAL_ALPHATEST: number;
  46769. /**
  46770. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46771. */
  46772. static readonly PBRMATERIAL_ALPHABLEND: number;
  46773. /**
  46774. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46775. * They are also discarded below the alpha cutoff threshold to improve performances.
  46776. */
  46777. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46778. /**
  46779. * Defines the default value of how much AO map is occluding the analytical lights
  46780. * (point spot...).
  46781. */
  46782. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46783. /**
  46784. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46785. */
  46786. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46787. /**
  46788. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46789. * to enhance interoperability with other engines.
  46790. */
  46791. static readonly LIGHTFALLOFF_GLTF: number;
  46792. /**
  46793. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46794. * to enhance interoperability with other materials.
  46795. */
  46796. static readonly LIGHTFALLOFF_STANDARD: number;
  46797. /**
  46798. * Intensity of the direct lights e.g. the four lights available in your scene.
  46799. * This impacts both the direct diffuse and specular highlights.
  46800. */
  46801. protected _directIntensity: number;
  46802. /**
  46803. * Intensity of the emissive part of the material.
  46804. * This helps controlling the emissive effect without modifying the emissive color.
  46805. */
  46806. protected _emissiveIntensity: number;
  46807. /**
  46808. * Intensity of the environment e.g. how much the environment will light the object
  46809. * either through harmonics for rough material or through the refelction for shiny ones.
  46810. */
  46811. protected _environmentIntensity: number;
  46812. /**
  46813. * This is a special control allowing the reduction of the specular highlights coming from the
  46814. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46815. */
  46816. protected _specularIntensity: number;
  46817. /**
  46818. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46819. */
  46820. private _lightingInfos;
  46821. /**
  46822. * Debug Control allowing disabling the bump map on this material.
  46823. */
  46824. protected _disableBumpMap: boolean;
  46825. /**
  46826. * AKA Diffuse Texture in standard nomenclature.
  46827. */
  46828. protected _albedoTexture: Nullable<BaseTexture>;
  46829. /**
  46830. * AKA Occlusion Texture in other nomenclature.
  46831. */
  46832. protected _ambientTexture: Nullable<BaseTexture>;
  46833. /**
  46834. * AKA Occlusion Texture Intensity in other nomenclature.
  46835. */
  46836. protected _ambientTextureStrength: number;
  46837. /**
  46838. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46839. * 1 means it completely occludes it
  46840. * 0 mean it has no impact
  46841. */
  46842. protected _ambientTextureImpactOnAnalyticalLights: number;
  46843. /**
  46844. * Stores the alpha values in a texture.
  46845. */
  46846. protected _opacityTexture: Nullable<BaseTexture>;
  46847. /**
  46848. * Stores the reflection values in a texture.
  46849. */
  46850. protected _reflectionTexture: Nullable<BaseTexture>;
  46851. /**
  46852. * Stores the emissive values in a texture.
  46853. */
  46854. protected _emissiveTexture: Nullable<BaseTexture>;
  46855. /**
  46856. * AKA Specular texture in other nomenclature.
  46857. */
  46858. protected _reflectivityTexture: Nullable<BaseTexture>;
  46859. /**
  46860. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46861. */
  46862. protected _metallicTexture: Nullable<BaseTexture>;
  46863. /**
  46864. * Specifies the metallic scalar of the metallic/roughness workflow.
  46865. * Can also be used to scale the metalness values of the metallic texture.
  46866. */
  46867. protected _metallic: Nullable<number>;
  46868. /**
  46869. * Specifies the roughness scalar of the metallic/roughness workflow.
  46870. * Can also be used to scale the roughness values of the metallic texture.
  46871. */
  46872. protected _roughness: Nullable<number>;
  46873. /**
  46874. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46875. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46876. */
  46877. protected _microSurfaceTexture: Nullable<BaseTexture>;
  46878. /**
  46879. * Stores surface normal data used to displace a mesh in a texture.
  46880. */
  46881. protected _bumpTexture: Nullable<BaseTexture>;
  46882. /**
  46883. * Stores the pre-calculated light information of a mesh in a texture.
  46884. */
  46885. protected _lightmapTexture: Nullable<BaseTexture>;
  46886. /**
  46887. * The color of a material in ambient lighting.
  46888. */
  46889. protected _ambientColor: Color3;
  46890. /**
  46891. * AKA Diffuse Color in other nomenclature.
  46892. */
  46893. protected _albedoColor: Color3;
  46894. /**
  46895. * AKA Specular Color in other nomenclature.
  46896. */
  46897. protected _reflectivityColor: Color3;
  46898. /**
  46899. * The color applied when light is reflected from a material.
  46900. */
  46901. protected _reflectionColor: Color3;
  46902. /**
  46903. * The color applied when light is emitted from a material.
  46904. */
  46905. protected _emissiveColor: Color3;
  46906. /**
  46907. * AKA Glossiness in other nomenclature.
  46908. */
  46909. protected _microSurface: number;
  46910. /**
  46911. * Specifies that the material will use the light map as a show map.
  46912. */
  46913. protected _useLightmapAsShadowmap: boolean;
  46914. /**
  46915. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46916. * makes the reflect vector face the model (under horizon).
  46917. */
  46918. protected _useHorizonOcclusion: boolean;
  46919. /**
  46920. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46921. * too much the area relying on ambient texture to define their ambient occlusion.
  46922. */
  46923. protected _useRadianceOcclusion: boolean;
  46924. /**
  46925. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46926. */
  46927. protected _useAlphaFromAlbedoTexture: boolean;
  46928. /**
  46929. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46930. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46931. */
  46932. protected _useSpecularOverAlpha: boolean;
  46933. /**
  46934. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46935. */
  46936. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46937. /**
  46938. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46939. */
  46940. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46941. /**
  46942. * Specifies if the metallic texture contains the roughness information in its green channel.
  46943. */
  46944. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46945. /**
  46946. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46947. */
  46948. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46949. /**
  46950. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46951. */
  46952. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46953. /**
  46954. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46955. */
  46956. protected _useAmbientInGrayScale: boolean;
  46957. /**
  46958. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46959. * The material will try to infer what glossiness each pixel should be.
  46960. */
  46961. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46962. /**
  46963. * Defines the falloff type used in this material.
  46964. * It by default is Physical.
  46965. */
  46966. protected _lightFalloff: number;
  46967. /**
  46968. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46969. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46970. */
  46971. protected _useRadianceOverAlpha: boolean;
  46972. /**
  46973. * Allows using an object space normal map (instead of tangent space).
  46974. */
  46975. protected _useObjectSpaceNormalMap: boolean;
  46976. /**
  46977. * Allows using the bump map in parallax mode.
  46978. */
  46979. protected _useParallax: boolean;
  46980. /**
  46981. * Allows using the bump map in parallax occlusion mode.
  46982. */
  46983. protected _useParallaxOcclusion: boolean;
  46984. /**
  46985. * Controls the scale bias of the parallax mode.
  46986. */
  46987. protected _parallaxScaleBias: number;
  46988. /**
  46989. * If sets to true, disables all the lights affecting the material.
  46990. */
  46991. protected _disableLighting: boolean;
  46992. /**
  46993. * Number of Simultaneous lights allowed on the material.
  46994. */
  46995. protected _maxSimultaneousLights: number;
  46996. /**
  46997. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46998. */
  46999. protected _invertNormalMapX: boolean;
  47000. /**
  47001. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47002. */
  47003. protected _invertNormalMapY: boolean;
  47004. /**
  47005. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47006. */
  47007. protected _twoSidedLighting: boolean;
  47008. /**
  47009. * Defines the alpha limits in alpha test mode.
  47010. */
  47011. protected _alphaCutOff: number;
  47012. /**
  47013. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47014. */
  47015. protected _forceAlphaTest: boolean;
  47016. /**
  47017. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47018. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47019. */
  47020. protected _useAlphaFresnel: boolean;
  47021. /**
  47022. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47023. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47024. */
  47025. protected _useLinearAlphaFresnel: boolean;
  47026. /**
  47027. * The transparency mode of the material.
  47028. */
  47029. protected _transparencyMode: Nullable<number>;
  47030. /**
  47031. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47032. * from cos thetav and roughness:
  47033. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47034. */
  47035. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47036. /**
  47037. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47038. */
  47039. protected _forceIrradianceInFragment: boolean;
  47040. /**
  47041. * Force normal to face away from face.
  47042. */
  47043. protected _forceNormalForward: boolean;
  47044. /**
  47045. * Enables specular anti aliasing in the PBR shader.
  47046. * It will both interacts on the Geometry for analytical and IBL lighting.
  47047. * It also prefilter the roughness map based on the bump values.
  47048. */
  47049. protected _enableSpecularAntiAliasing: boolean;
  47050. /**
  47051. * Default configuration related to image processing available in the PBR Material.
  47052. */
  47053. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47054. /**
  47055. * Keep track of the image processing observer to allow dispose and replace.
  47056. */
  47057. private _imageProcessingObserver;
  47058. /**
  47059. * Attaches a new image processing configuration to the PBR Material.
  47060. * @param configuration
  47061. */
  47062. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47063. /**
  47064. * Stores the available render targets.
  47065. */
  47066. private _renderTargets;
  47067. /**
  47068. * Sets the global ambient color for the material used in lighting calculations.
  47069. */
  47070. private _globalAmbientColor;
  47071. /**
  47072. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47073. */
  47074. private _useLogarithmicDepth;
  47075. /**
  47076. * If set to true, no lighting calculations will be applied.
  47077. */
  47078. private _unlit;
  47079. private _debugMode;
  47080. /**
  47081. * @hidden
  47082. * This is reserved for the inspector.
  47083. * Defines the material debug mode.
  47084. * It helps seeing only some components of the material while troubleshooting.
  47085. */
  47086. debugMode: number;
  47087. /**
  47088. * @hidden
  47089. * This is reserved for the inspector.
  47090. * Specify from where on screen the debug mode should start.
  47091. * The value goes from -1 (full screen) to 1 (not visible)
  47092. * It helps with side by side comparison against the final render
  47093. * This defaults to -1
  47094. */
  47095. private debugLimit;
  47096. /**
  47097. * @hidden
  47098. * This is reserved for the inspector.
  47099. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47100. * You can use the factor to better multiply the final value.
  47101. */
  47102. private debugFactor;
  47103. /**
  47104. * Defines the clear coat layer parameters for the material.
  47105. */
  47106. readonly clearCoat: PBRClearCoatConfiguration;
  47107. /**
  47108. * Defines the anisotropic parameters for the material.
  47109. */
  47110. readonly anisotropy: PBRAnisotropicConfiguration;
  47111. /**
  47112. * Defines the BRDF parameters for the material.
  47113. */
  47114. readonly brdf: PBRBRDFConfiguration;
  47115. /**
  47116. * Defines the Sheen parameters for the material.
  47117. */
  47118. readonly sheen: PBRSheenConfiguration;
  47119. /**
  47120. * Defines the SubSurface parameters for the material.
  47121. */
  47122. readonly subSurface: PBRSubSurfaceConfiguration;
  47123. /**
  47124. * Custom callback helping to override the default shader used in the material.
  47125. */
  47126. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47127. protected _rebuildInParallel: boolean;
  47128. /**
  47129. * Instantiates a new PBRMaterial instance.
  47130. *
  47131. * @param name The material name
  47132. * @param scene The scene the material will be use in.
  47133. */
  47134. constructor(name: string, scene: Scene);
  47135. /**
  47136. * Gets a boolean indicating that current material needs to register RTT
  47137. */
  47138. readonly hasRenderTargetTextures: boolean;
  47139. /**
  47140. * Gets the name of the material class.
  47141. */
  47142. getClassName(): string;
  47143. /**
  47144. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47145. */
  47146. /**
  47147. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47148. */
  47149. useLogarithmicDepth: boolean;
  47150. /**
  47151. * Gets the current transparency mode.
  47152. */
  47153. /**
  47154. * Sets the transparency mode of the material.
  47155. *
  47156. * | Value | Type | Description |
  47157. * | ----- | ----------------------------------- | ----------- |
  47158. * | 0 | OPAQUE | |
  47159. * | 1 | ALPHATEST | |
  47160. * | 2 | ALPHABLEND | |
  47161. * | 3 | ALPHATESTANDBLEND | |
  47162. *
  47163. */
  47164. transparencyMode: Nullable<number>;
  47165. /**
  47166. * Returns true if alpha blending should be disabled.
  47167. */
  47168. private readonly _disableAlphaBlending;
  47169. /**
  47170. * Specifies whether or not this material should be rendered in alpha blend mode.
  47171. */
  47172. needAlphaBlending(): boolean;
  47173. /**
  47174. * Specifies if the mesh will require alpha blending.
  47175. * @param mesh - BJS mesh.
  47176. */
  47177. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47178. /**
  47179. * Specifies whether or not this material should be rendered in alpha test mode.
  47180. */
  47181. needAlphaTesting(): boolean;
  47182. /**
  47183. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47184. */
  47185. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47186. /**
  47187. * Gets the texture used for the alpha test.
  47188. */
  47189. getAlphaTestTexture(): Nullable<BaseTexture>;
  47190. /**
  47191. * Specifies that the submesh is ready to be used.
  47192. * @param mesh - BJS mesh.
  47193. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47194. * @param useInstances - Specifies that instances should be used.
  47195. * @returns - boolean indicating that the submesh is ready or not.
  47196. */
  47197. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47198. /**
  47199. * Specifies if the material uses metallic roughness workflow.
  47200. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47201. */
  47202. isMetallicWorkflow(): boolean;
  47203. private _prepareEffect;
  47204. private _prepareDefines;
  47205. /**
  47206. * Force shader compilation
  47207. */
  47208. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47209. clipPlane: boolean;
  47210. }>): void;
  47211. /**
  47212. * Initializes the uniform buffer layout for the shader.
  47213. */
  47214. buildUniformLayout(): void;
  47215. /**
  47216. * Unbinds the material from the mesh
  47217. */
  47218. unbind(): void;
  47219. /**
  47220. * Binds the submesh data.
  47221. * @param world - The world matrix.
  47222. * @param mesh - The BJS mesh.
  47223. * @param subMesh - A submesh of the BJS mesh.
  47224. */
  47225. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47226. /**
  47227. * Returns the animatable textures.
  47228. * @returns - Array of animatable textures.
  47229. */
  47230. getAnimatables(): IAnimatable[];
  47231. /**
  47232. * Returns the texture used for reflections.
  47233. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47234. */
  47235. private _getReflectionTexture;
  47236. /**
  47237. * Returns an array of the actively used textures.
  47238. * @returns - Array of BaseTextures
  47239. */
  47240. getActiveTextures(): BaseTexture[];
  47241. /**
  47242. * Checks to see if a texture is used in the material.
  47243. * @param texture - Base texture to use.
  47244. * @returns - Boolean specifying if a texture is used in the material.
  47245. */
  47246. hasTexture(texture: BaseTexture): boolean;
  47247. /**
  47248. * Disposes the resources of the material.
  47249. * @param forceDisposeEffect - Forces the disposal of effects.
  47250. * @param forceDisposeTextures - Forces the disposal of all textures.
  47251. */
  47252. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47253. }
  47254. }
  47255. declare module BABYLON {
  47256. /**
  47257. * The Physically based material of BJS.
  47258. *
  47259. * This offers the main features of a standard PBR material.
  47260. * For more information, please refer to the documentation :
  47261. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47262. */
  47263. export class PBRMaterial extends PBRBaseMaterial {
  47264. /**
  47265. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47266. */
  47267. static readonly PBRMATERIAL_OPAQUE: number;
  47268. /**
  47269. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47270. */
  47271. static readonly PBRMATERIAL_ALPHATEST: number;
  47272. /**
  47273. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47274. */
  47275. static readonly PBRMATERIAL_ALPHABLEND: number;
  47276. /**
  47277. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47278. * They are also discarded below the alpha cutoff threshold to improve performances.
  47279. */
  47280. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47281. /**
  47282. * Defines the default value of how much AO map is occluding the analytical lights
  47283. * (point spot...).
  47284. */
  47285. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47286. /**
  47287. * Intensity of the direct lights e.g. the four lights available in your scene.
  47288. * This impacts both the direct diffuse and specular highlights.
  47289. */
  47290. directIntensity: number;
  47291. /**
  47292. * Intensity of the emissive part of the material.
  47293. * This helps controlling the emissive effect without modifying the emissive color.
  47294. */
  47295. emissiveIntensity: number;
  47296. /**
  47297. * Intensity of the environment e.g. how much the environment will light the object
  47298. * either through harmonics for rough material or through the refelction for shiny ones.
  47299. */
  47300. environmentIntensity: number;
  47301. /**
  47302. * This is a special control allowing the reduction of the specular highlights coming from the
  47303. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47304. */
  47305. specularIntensity: number;
  47306. /**
  47307. * Debug Control allowing disabling the bump map on this material.
  47308. */
  47309. disableBumpMap: boolean;
  47310. /**
  47311. * AKA Diffuse Texture in standard nomenclature.
  47312. */
  47313. albedoTexture: BaseTexture;
  47314. /**
  47315. * AKA Occlusion Texture in other nomenclature.
  47316. */
  47317. ambientTexture: BaseTexture;
  47318. /**
  47319. * AKA Occlusion Texture Intensity in other nomenclature.
  47320. */
  47321. ambientTextureStrength: number;
  47322. /**
  47323. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47324. * 1 means it completely occludes it
  47325. * 0 mean it has no impact
  47326. */
  47327. ambientTextureImpactOnAnalyticalLights: number;
  47328. /**
  47329. * Stores the alpha values in a texture.
  47330. */
  47331. opacityTexture: BaseTexture;
  47332. /**
  47333. * Stores the reflection values in a texture.
  47334. */
  47335. reflectionTexture: Nullable<BaseTexture>;
  47336. /**
  47337. * Stores the emissive values in a texture.
  47338. */
  47339. emissiveTexture: BaseTexture;
  47340. /**
  47341. * AKA Specular texture in other nomenclature.
  47342. */
  47343. reflectivityTexture: BaseTexture;
  47344. /**
  47345. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47346. */
  47347. metallicTexture: BaseTexture;
  47348. /**
  47349. * Specifies the metallic scalar of the metallic/roughness workflow.
  47350. * Can also be used to scale the metalness values of the metallic texture.
  47351. */
  47352. metallic: Nullable<number>;
  47353. /**
  47354. * Specifies the roughness scalar of the metallic/roughness workflow.
  47355. * Can also be used to scale the roughness values of the metallic texture.
  47356. */
  47357. roughness: Nullable<number>;
  47358. /**
  47359. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47360. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47361. */
  47362. microSurfaceTexture: BaseTexture;
  47363. /**
  47364. * Stores surface normal data used to displace a mesh in a texture.
  47365. */
  47366. bumpTexture: BaseTexture;
  47367. /**
  47368. * Stores the pre-calculated light information of a mesh in a texture.
  47369. */
  47370. lightmapTexture: BaseTexture;
  47371. /**
  47372. * Stores the refracted light information in a texture.
  47373. */
  47374. refractionTexture: Nullable<BaseTexture>;
  47375. /**
  47376. * The color of a material in ambient lighting.
  47377. */
  47378. ambientColor: Color3;
  47379. /**
  47380. * AKA Diffuse Color in other nomenclature.
  47381. */
  47382. albedoColor: Color3;
  47383. /**
  47384. * AKA Specular Color in other nomenclature.
  47385. */
  47386. reflectivityColor: Color3;
  47387. /**
  47388. * The color reflected from the material.
  47389. */
  47390. reflectionColor: Color3;
  47391. /**
  47392. * The color emitted from the material.
  47393. */
  47394. emissiveColor: Color3;
  47395. /**
  47396. * AKA Glossiness in other nomenclature.
  47397. */
  47398. microSurface: number;
  47399. /**
  47400. * source material index of refraction (IOR)' / 'destination material IOR.
  47401. */
  47402. indexOfRefraction: number;
  47403. /**
  47404. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47405. */
  47406. invertRefractionY: boolean;
  47407. /**
  47408. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47409. * Materials half opaque for instance using refraction could benefit from this control.
  47410. */
  47411. linkRefractionWithTransparency: boolean;
  47412. /**
  47413. * If true, the light map contains occlusion information instead of lighting info.
  47414. */
  47415. useLightmapAsShadowmap: boolean;
  47416. /**
  47417. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47418. */
  47419. useAlphaFromAlbedoTexture: boolean;
  47420. /**
  47421. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47422. */
  47423. forceAlphaTest: boolean;
  47424. /**
  47425. * Defines the alpha limits in alpha test mode.
  47426. */
  47427. alphaCutOff: number;
  47428. /**
  47429. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47430. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47431. */
  47432. useSpecularOverAlpha: boolean;
  47433. /**
  47434. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47435. */
  47436. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47437. /**
  47438. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47439. */
  47440. useRoughnessFromMetallicTextureAlpha: boolean;
  47441. /**
  47442. * Specifies if the metallic texture contains the roughness information in its green channel.
  47443. */
  47444. useRoughnessFromMetallicTextureGreen: boolean;
  47445. /**
  47446. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47447. */
  47448. useMetallnessFromMetallicTextureBlue: boolean;
  47449. /**
  47450. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47451. */
  47452. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47453. /**
  47454. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47455. */
  47456. useAmbientInGrayScale: boolean;
  47457. /**
  47458. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47459. * The material will try to infer what glossiness each pixel should be.
  47460. */
  47461. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47462. /**
  47463. * BJS is using an harcoded light falloff based on a manually sets up range.
  47464. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47465. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47466. */
  47467. /**
  47468. * BJS is using an harcoded light falloff based on a manually sets up range.
  47469. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47470. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47471. */
  47472. usePhysicalLightFalloff: boolean;
  47473. /**
  47474. * In order to support the falloff compatibility with gltf, a special mode has been added
  47475. * to reproduce the gltf light falloff.
  47476. */
  47477. /**
  47478. * In order to support the falloff compatibility with gltf, a special mode has been added
  47479. * to reproduce the gltf light falloff.
  47480. */
  47481. useGLTFLightFalloff: boolean;
  47482. /**
  47483. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47484. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47485. */
  47486. useRadianceOverAlpha: boolean;
  47487. /**
  47488. * Allows using an object space normal map (instead of tangent space).
  47489. */
  47490. useObjectSpaceNormalMap: boolean;
  47491. /**
  47492. * Allows using the bump map in parallax mode.
  47493. */
  47494. useParallax: boolean;
  47495. /**
  47496. * Allows using the bump map in parallax occlusion mode.
  47497. */
  47498. useParallaxOcclusion: boolean;
  47499. /**
  47500. * Controls the scale bias of the parallax mode.
  47501. */
  47502. parallaxScaleBias: number;
  47503. /**
  47504. * If sets to true, disables all the lights affecting the material.
  47505. */
  47506. disableLighting: boolean;
  47507. /**
  47508. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47509. */
  47510. forceIrradianceInFragment: boolean;
  47511. /**
  47512. * Number of Simultaneous lights allowed on the material.
  47513. */
  47514. maxSimultaneousLights: number;
  47515. /**
  47516. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47517. */
  47518. invertNormalMapX: boolean;
  47519. /**
  47520. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47521. */
  47522. invertNormalMapY: boolean;
  47523. /**
  47524. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47525. */
  47526. twoSidedLighting: boolean;
  47527. /**
  47528. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47529. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47530. */
  47531. useAlphaFresnel: boolean;
  47532. /**
  47533. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47534. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47535. */
  47536. useLinearAlphaFresnel: boolean;
  47537. /**
  47538. * Let user defines the brdf lookup texture used for IBL.
  47539. * A default 8bit version is embedded but you could point at :
  47540. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  47541. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47542. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  47543. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47544. */
  47545. environmentBRDFTexture: Nullable<BaseTexture>;
  47546. /**
  47547. * Force normal to face away from face.
  47548. */
  47549. forceNormalForward: boolean;
  47550. /**
  47551. * Enables specular anti aliasing in the PBR shader.
  47552. * It will both interacts on the Geometry for analytical and IBL lighting.
  47553. * It also prefilter the roughness map based on the bump values.
  47554. */
  47555. enableSpecularAntiAliasing: boolean;
  47556. /**
  47557. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47558. * makes the reflect vector face the model (under horizon).
  47559. */
  47560. useHorizonOcclusion: boolean;
  47561. /**
  47562. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47563. * too much the area relying on ambient texture to define their ambient occlusion.
  47564. */
  47565. useRadianceOcclusion: boolean;
  47566. /**
  47567. * If set to true, no lighting calculations will be applied.
  47568. */
  47569. unlit: boolean;
  47570. /**
  47571. * Gets the image processing configuration used either in this material.
  47572. */
  47573. /**
  47574. * Sets the Default image processing configuration used either in the this material.
  47575. *
  47576. * If sets to null, the scene one is in use.
  47577. */
  47578. imageProcessingConfiguration: ImageProcessingConfiguration;
  47579. /**
  47580. * Gets wether the color curves effect is enabled.
  47581. */
  47582. /**
  47583. * Sets wether the color curves effect is enabled.
  47584. */
  47585. cameraColorCurvesEnabled: boolean;
  47586. /**
  47587. * Gets wether the color grading effect is enabled.
  47588. */
  47589. /**
  47590. * Gets wether the color grading effect is enabled.
  47591. */
  47592. cameraColorGradingEnabled: boolean;
  47593. /**
  47594. * Gets wether tonemapping is enabled or not.
  47595. */
  47596. /**
  47597. * Sets wether tonemapping is enabled or not
  47598. */
  47599. cameraToneMappingEnabled: boolean;
  47600. /**
  47601. * The camera exposure used on this material.
  47602. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47603. * This corresponds to a photographic exposure.
  47604. */
  47605. /**
  47606. * The camera exposure used on this material.
  47607. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47608. * This corresponds to a photographic exposure.
  47609. */
  47610. cameraExposure: number;
  47611. /**
  47612. * Gets The camera contrast used on this material.
  47613. */
  47614. /**
  47615. * Sets The camera contrast used on this material.
  47616. */
  47617. cameraContrast: number;
  47618. /**
  47619. * Gets the Color Grading 2D Lookup Texture.
  47620. */
  47621. /**
  47622. * Sets the Color Grading 2D Lookup Texture.
  47623. */
  47624. cameraColorGradingTexture: Nullable<BaseTexture>;
  47625. /**
  47626. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47627. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47628. * 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;
  47629. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47630. */
  47631. /**
  47632. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47633. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47634. * 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;
  47635. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47636. */
  47637. cameraColorCurves: Nullable<ColorCurves>;
  47638. /**
  47639. * Instantiates a new PBRMaterial instance.
  47640. *
  47641. * @param name The material name
  47642. * @param scene The scene the material will be use in.
  47643. */
  47644. constructor(name: string, scene: Scene);
  47645. /**
  47646. * Returns the name of this material class.
  47647. */
  47648. getClassName(): string;
  47649. /**
  47650. * Makes a duplicate of the current material.
  47651. * @param name - name to use for the new material.
  47652. */
  47653. clone(name: string): PBRMaterial;
  47654. /**
  47655. * Serializes this PBR Material.
  47656. * @returns - An object with the serialized material.
  47657. */
  47658. serialize(): any;
  47659. /**
  47660. * Parses a PBR Material from a serialized object.
  47661. * @param source - Serialized object.
  47662. * @param scene - BJS scene instance.
  47663. * @param rootUrl - url for the scene object
  47664. * @returns - PBRMaterial
  47665. */
  47666. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47667. }
  47668. }
  47669. declare module BABYLON {
  47670. /**
  47671. * Direct draw surface info
  47672. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47673. */
  47674. export interface DDSInfo {
  47675. /**
  47676. * Width of the texture
  47677. */
  47678. width: number;
  47679. /**
  47680. * Width of the texture
  47681. */
  47682. height: number;
  47683. /**
  47684. * Number of Mipmaps for the texture
  47685. * @see https://en.wikipedia.org/wiki/Mipmap
  47686. */
  47687. mipmapCount: number;
  47688. /**
  47689. * If the textures format is a known fourCC format
  47690. * @see https://www.fourcc.org/
  47691. */
  47692. isFourCC: boolean;
  47693. /**
  47694. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47695. */
  47696. isRGB: boolean;
  47697. /**
  47698. * If the texture is a lumincance format
  47699. */
  47700. isLuminance: boolean;
  47701. /**
  47702. * If this is a cube texture
  47703. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47704. */
  47705. isCube: boolean;
  47706. /**
  47707. * If the texture is a compressed format eg. FOURCC_DXT1
  47708. */
  47709. isCompressed: boolean;
  47710. /**
  47711. * The dxgiFormat of the texture
  47712. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47713. */
  47714. dxgiFormat: number;
  47715. /**
  47716. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47717. */
  47718. textureType: number;
  47719. /**
  47720. * Sphericle polynomial created for the dds texture
  47721. */
  47722. sphericalPolynomial?: SphericalPolynomial;
  47723. }
  47724. /**
  47725. * Class used to provide DDS decompression tools
  47726. */
  47727. export class DDSTools {
  47728. /**
  47729. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47730. */
  47731. static StoreLODInAlphaChannel: boolean;
  47732. /**
  47733. * Gets DDS information from an array buffer
  47734. * @param arrayBuffer defines the array buffer to read data from
  47735. * @returns the DDS information
  47736. */
  47737. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47738. private static _FloatView;
  47739. private static _Int32View;
  47740. private static _ToHalfFloat;
  47741. private static _FromHalfFloat;
  47742. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47743. private static _GetHalfFloatRGBAArrayBuffer;
  47744. private static _GetFloatRGBAArrayBuffer;
  47745. private static _GetFloatAsUIntRGBAArrayBuffer;
  47746. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47747. private static _GetRGBAArrayBuffer;
  47748. private static _ExtractLongWordOrder;
  47749. private static _GetRGBArrayBuffer;
  47750. private static _GetLuminanceArrayBuffer;
  47751. /**
  47752. * Uploads DDS Levels to a Babylon Texture
  47753. * @hidden
  47754. */
  47755. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47756. }
  47757. interface ThinEngine {
  47758. /**
  47759. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47760. * @param rootUrl defines the url where the file to load is located
  47761. * @param scene defines the current scene
  47762. * @param lodScale defines scale to apply to the mip map selection
  47763. * @param lodOffset defines offset to apply to the mip map selection
  47764. * @param onLoad defines an optional callback raised when the texture is loaded
  47765. * @param onError defines an optional callback raised if there is an issue to load the texture
  47766. * @param format defines the format of the data
  47767. * @param forcedExtension defines the extension to use to pick the right loader
  47768. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47769. * @returns the cube texture as an InternalTexture
  47770. */
  47771. 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;
  47772. }
  47773. }
  47774. declare module BABYLON {
  47775. /**
  47776. * Implementation of the DDS Texture Loader.
  47777. * @hidden
  47778. */
  47779. export class _DDSTextureLoader implements IInternalTextureLoader {
  47780. /**
  47781. * Defines wether the loader supports cascade loading the different faces.
  47782. */
  47783. readonly supportCascades: boolean;
  47784. /**
  47785. * This returns if the loader support the current file information.
  47786. * @param extension defines the file extension of the file being loaded
  47787. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47788. * @param fallback defines the fallback internal texture if any
  47789. * @param isBase64 defines whether the texture is encoded as a base64
  47790. * @param isBuffer defines whether the texture data are stored as a buffer
  47791. * @returns true if the loader can load the specified file
  47792. */
  47793. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47794. /**
  47795. * Transform the url before loading if required.
  47796. * @param rootUrl the url of the texture
  47797. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47798. * @returns the transformed texture
  47799. */
  47800. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47801. /**
  47802. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47803. * @param rootUrl the url of the texture
  47804. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47805. * @returns the fallback texture
  47806. */
  47807. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47808. /**
  47809. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47810. * @param data contains the texture data
  47811. * @param texture defines the BabylonJS internal texture
  47812. * @param createPolynomials will be true if polynomials have been requested
  47813. * @param onLoad defines the callback to trigger once the texture is ready
  47814. * @param onError defines the callback to trigger in case of error
  47815. */
  47816. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47817. /**
  47818. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47819. * @param data contains the texture data
  47820. * @param texture defines the BabylonJS internal texture
  47821. * @param callback defines the method to call once ready to upload
  47822. */
  47823. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47824. }
  47825. }
  47826. declare module BABYLON {
  47827. /**
  47828. * Implementation of the ENV Texture Loader.
  47829. * @hidden
  47830. */
  47831. export class _ENVTextureLoader implements IInternalTextureLoader {
  47832. /**
  47833. * Defines wether the loader supports cascade loading the different faces.
  47834. */
  47835. readonly supportCascades: boolean;
  47836. /**
  47837. * This returns if the loader support the current file information.
  47838. * @param extension defines the file extension of the file being loaded
  47839. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47840. * @param fallback defines the fallback internal texture if any
  47841. * @param isBase64 defines whether the texture is encoded as a base64
  47842. * @param isBuffer defines whether the texture data are stored as a buffer
  47843. * @returns true if the loader can load the specified file
  47844. */
  47845. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47846. /**
  47847. * Transform the url before loading if required.
  47848. * @param rootUrl the url of the texture
  47849. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47850. * @returns the transformed texture
  47851. */
  47852. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47853. /**
  47854. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47855. * @param rootUrl the url of the texture
  47856. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47857. * @returns the fallback texture
  47858. */
  47859. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47860. /**
  47861. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47862. * @param data contains the texture data
  47863. * @param texture defines the BabylonJS internal texture
  47864. * @param createPolynomials will be true if polynomials have been requested
  47865. * @param onLoad defines the callback to trigger once the texture is ready
  47866. * @param onError defines the callback to trigger in case of error
  47867. */
  47868. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47869. /**
  47870. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47871. * @param data contains the texture data
  47872. * @param texture defines the BabylonJS internal texture
  47873. * @param callback defines the method to call once ready to upload
  47874. */
  47875. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47876. }
  47877. }
  47878. declare module BABYLON {
  47879. /**
  47880. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47881. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47882. */
  47883. export class KhronosTextureContainer {
  47884. /** contents of the KTX container file */
  47885. arrayBuffer: any;
  47886. private static HEADER_LEN;
  47887. private static COMPRESSED_2D;
  47888. private static COMPRESSED_3D;
  47889. private static TEX_2D;
  47890. private static TEX_3D;
  47891. /**
  47892. * Gets the openGL type
  47893. */
  47894. glType: number;
  47895. /**
  47896. * Gets the openGL type size
  47897. */
  47898. glTypeSize: number;
  47899. /**
  47900. * Gets the openGL format
  47901. */
  47902. glFormat: number;
  47903. /**
  47904. * Gets the openGL internal format
  47905. */
  47906. glInternalFormat: number;
  47907. /**
  47908. * Gets the base internal format
  47909. */
  47910. glBaseInternalFormat: number;
  47911. /**
  47912. * Gets image width in pixel
  47913. */
  47914. pixelWidth: number;
  47915. /**
  47916. * Gets image height in pixel
  47917. */
  47918. pixelHeight: number;
  47919. /**
  47920. * Gets image depth in pixels
  47921. */
  47922. pixelDepth: number;
  47923. /**
  47924. * Gets the number of array elements
  47925. */
  47926. numberOfArrayElements: number;
  47927. /**
  47928. * Gets the number of faces
  47929. */
  47930. numberOfFaces: number;
  47931. /**
  47932. * Gets the number of mipmap levels
  47933. */
  47934. numberOfMipmapLevels: number;
  47935. /**
  47936. * Gets the bytes of key value data
  47937. */
  47938. bytesOfKeyValueData: number;
  47939. /**
  47940. * Gets the load type
  47941. */
  47942. loadType: number;
  47943. /**
  47944. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47945. */
  47946. isInvalid: boolean;
  47947. /**
  47948. * Creates a new KhronosTextureContainer
  47949. * @param arrayBuffer contents of the KTX container file
  47950. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47951. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47952. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47953. */
  47954. constructor(
  47955. /** contents of the KTX container file */
  47956. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47957. /**
  47958. * Uploads KTX content to a Babylon Texture.
  47959. * It is assumed that the texture has already been created & is currently bound
  47960. * @hidden
  47961. */
  47962. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47963. private _upload2DCompressedLevels;
  47964. }
  47965. }
  47966. declare module BABYLON {
  47967. /**
  47968. * Implementation of the KTX Texture Loader.
  47969. * @hidden
  47970. */
  47971. export class _KTXTextureLoader implements IInternalTextureLoader {
  47972. /**
  47973. * Defines wether the loader supports cascade loading the different faces.
  47974. */
  47975. readonly supportCascades: boolean;
  47976. /**
  47977. * This returns if the loader support the current file information.
  47978. * @param extension defines the file extension of the file being loaded
  47979. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47980. * @param fallback defines the fallback internal texture if any
  47981. * @param isBase64 defines whether the texture is encoded as a base64
  47982. * @param isBuffer defines whether the texture data are stored as a buffer
  47983. * @returns true if the loader can load the specified file
  47984. */
  47985. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47986. /**
  47987. * Transform the url before loading if required.
  47988. * @param rootUrl the url of the texture
  47989. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47990. * @returns the transformed texture
  47991. */
  47992. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47993. /**
  47994. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47995. * @param rootUrl the url of the texture
  47996. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47997. * @returns the fallback texture
  47998. */
  47999. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48000. /**
  48001. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48002. * @param data contains the texture data
  48003. * @param texture defines the BabylonJS internal texture
  48004. * @param createPolynomials will be true if polynomials have been requested
  48005. * @param onLoad defines the callback to trigger once the texture is ready
  48006. * @param onError defines the callback to trigger in case of error
  48007. */
  48008. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48009. /**
  48010. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48011. * @param data contains the texture data
  48012. * @param texture defines the BabylonJS internal texture
  48013. * @param callback defines the method to call once ready to upload
  48014. */
  48015. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48016. }
  48017. }
  48018. declare module BABYLON {
  48019. /**
  48020. * Options for the default xr helper
  48021. */
  48022. export class WebXRDefaultExperienceOptions {
  48023. /**
  48024. * Floor meshes that should be used for teleporting
  48025. */
  48026. floorMeshes: Array<AbstractMesh>;
  48027. }
  48028. /**
  48029. * Default experience which provides a similar setup to the previous webVRExperience
  48030. */
  48031. export class WebXRDefaultExperience {
  48032. /**
  48033. * Base experience
  48034. */
  48035. baseExperience: WebXRExperienceHelper;
  48036. /**
  48037. * Input experience extension
  48038. */
  48039. input: WebXRInput;
  48040. /**
  48041. * Loads the controller models
  48042. */
  48043. controllerModelLoader: WebXRControllerModelLoader;
  48044. /**
  48045. * Enables laser pointer and selection
  48046. */
  48047. pointerSelection: WebXRControllerPointerSelection;
  48048. /**
  48049. * Enables teleportation
  48050. */
  48051. teleportation: WebXRControllerTeleportation;
  48052. /**
  48053. * Enables ui for enetering/exiting xr
  48054. */
  48055. enterExitUI: WebXREnterExitUI;
  48056. /**
  48057. * Default output canvas xr should render to
  48058. */
  48059. outputCanvas: WebXRManagedOutputCanvas;
  48060. /**
  48061. * Creates the default xr experience
  48062. * @param scene scene
  48063. * @param options options for basic configuration
  48064. * @returns resulting WebXRDefaultExperience
  48065. */
  48066. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48067. private constructor();
  48068. /**
  48069. * DIsposes of the experience helper
  48070. */
  48071. dispose(): void;
  48072. }
  48073. }
  48074. declare module BABYLON {
  48075. /** @hidden */
  48076. export var _forceSceneHelpersToBundle: boolean;
  48077. interface Scene {
  48078. /**
  48079. * Creates a default light for the scene.
  48080. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48081. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48082. */
  48083. createDefaultLight(replace?: boolean): void;
  48084. /**
  48085. * Creates a default camera for the scene.
  48086. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48087. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48088. * @param replace has default false, when true replaces the active camera in the scene
  48089. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48090. */
  48091. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48092. /**
  48093. * Creates a default camera and a default light.
  48094. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48095. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48096. * @param replace has the default false, when true replaces the active camera/light in the scene
  48097. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48098. */
  48099. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48100. /**
  48101. * Creates a new sky box
  48102. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48103. * @param environmentTexture defines the texture to use as environment texture
  48104. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48105. * @param scale defines the overall scale of the skybox
  48106. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48107. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48108. * @returns a new mesh holding the sky box
  48109. */
  48110. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48111. /**
  48112. * Creates a new environment
  48113. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48114. * @param options defines the options you can use to configure the environment
  48115. * @returns the new EnvironmentHelper
  48116. */
  48117. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48118. /**
  48119. * Creates a new VREXperienceHelper
  48120. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48121. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48122. * @returns a new VREXperienceHelper
  48123. */
  48124. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48125. /**
  48126. * Creates a new WebXRDefaultExperience
  48127. * @see http://doc.babylonjs.com/how_to/webxr
  48128. * @param options experience options
  48129. * @returns a promise for a new WebXRDefaultExperience
  48130. */
  48131. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48132. }
  48133. }
  48134. declare module BABYLON {
  48135. /**
  48136. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48137. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48138. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48139. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48140. */
  48141. export class VideoDome extends TransformNode {
  48142. /**
  48143. * Define the video source as a Monoscopic panoramic 360 video.
  48144. */
  48145. static readonly MODE_MONOSCOPIC: number;
  48146. /**
  48147. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48148. */
  48149. static readonly MODE_TOPBOTTOM: number;
  48150. /**
  48151. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48152. */
  48153. static readonly MODE_SIDEBYSIDE: number;
  48154. private _halfDome;
  48155. private _useDirectMapping;
  48156. /**
  48157. * The video texture being displayed on the sphere
  48158. */
  48159. protected _videoTexture: VideoTexture;
  48160. /**
  48161. * Gets the video texture being displayed on the sphere
  48162. */
  48163. readonly videoTexture: VideoTexture;
  48164. /**
  48165. * The skybox material
  48166. */
  48167. protected _material: BackgroundMaterial;
  48168. /**
  48169. * The surface used for the skybox
  48170. */
  48171. protected _mesh: Mesh;
  48172. /**
  48173. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48174. */
  48175. private _halfDomeMask;
  48176. /**
  48177. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48178. * Also see the options.resolution property.
  48179. */
  48180. fovMultiplier: number;
  48181. private _videoMode;
  48182. /**
  48183. * Gets or set the current video mode for the video. It can be:
  48184. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48185. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48186. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48187. */
  48188. videoMode: number;
  48189. /**
  48190. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48191. *
  48192. */
  48193. /**
  48194. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48195. */
  48196. halfDome: boolean;
  48197. /**
  48198. * Oberserver used in Stereoscopic VR Mode.
  48199. */
  48200. private _onBeforeCameraRenderObserver;
  48201. /**
  48202. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48203. * @param name Element's name, child elements will append suffixes for their own names.
  48204. * @param urlsOrVideo defines the url(s) or the video element to use
  48205. * @param options An object containing optional or exposed sub element properties
  48206. */
  48207. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48208. resolution?: number;
  48209. clickToPlay?: boolean;
  48210. autoPlay?: boolean;
  48211. loop?: boolean;
  48212. size?: number;
  48213. poster?: string;
  48214. faceForward?: boolean;
  48215. useDirectMapping?: boolean;
  48216. halfDomeMode?: boolean;
  48217. }, scene: Scene);
  48218. private _changeVideoMode;
  48219. /**
  48220. * Releases resources associated with this node.
  48221. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48222. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48223. */
  48224. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48225. }
  48226. }
  48227. declare module BABYLON {
  48228. /**
  48229. * This class can be used to get instrumentation data from a Babylon engine
  48230. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48231. */
  48232. export class EngineInstrumentation implements IDisposable {
  48233. /**
  48234. * Define the instrumented engine.
  48235. */
  48236. engine: Engine;
  48237. private _captureGPUFrameTime;
  48238. private _gpuFrameTimeToken;
  48239. private _gpuFrameTime;
  48240. private _captureShaderCompilationTime;
  48241. private _shaderCompilationTime;
  48242. private _onBeginFrameObserver;
  48243. private _onEndFrameObserver;
  48244. private _onBeforeShaderCompilationObserver;
  48245. private _onAfterShaderCompilationObserver;
  48246. /**
  48247. * Gets the perf counter used for GPU frame time
  48248. */
  48249. readonly gpuFrameTimeCounter: PerfCounter;
  48250. /**
  48251. * Gets the GPU frame time capture status
  48252. */
  48253. /**
  48254. * Enable or disable the GPU frame time capture
  48255. */
  48256. captureGPUFrameTime: boolean;
  48257. /**
  48258. * Gets the perf counter used for shader compilation time
  48259. */
  48260. readonly shaderCompilationTimeCounter: PerfCounter;
  48261. /**
  48262. * Gets the shader compilation time capture status
  48263. */
  48264. /**
  48265. * Enable or disable the shader compilation time capture
  48266. */
  48267. captureShaderCompilationTime: boolean;
  48268. /**
  48269. * Instantiates a new engine instrumentation.
  48270. * This class can be used to get instrumentation data from a Babylon engine
  48271. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48272. * @param engine Defines the engine to instrument
  48273. */
  48274. constructor(
  48275. /**
  48276. * Define the instrumented engine.
  48277. */
  48278. engine: Engine);
  48279. /**
  48280. * Dispose and release associated resources.
  48281. */
  48282. dispose(): void;
  48283. }
  48284. }
  48285. declare module BABYLON {
  48286. /**
  48287. * This class can be used to get instrumentation data from a Babylon engine
  48288. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48289. */
  48290. export class SceneInstrumentation implements IDisposable {
  48291. /**
  48292. * Defines the scene to instrument
  48293. */
  48294. scene: Scene;
  48295. private _captureActiveMeshesEvaluationTime;
  48296. private _activeMeshesEvaluationTime;
  48297. private _captureRenderTargetsRenderTime;
  48298. private _renderTargetsRenderTime;
  48299. private _captureFrameTime;
  48300. private _frameTime;
  48301. private _captureRenderTime;
  48302. private _renderTime;
  48303. private _captureInterFrameTime;
  48304. private _interFrameTime;
  48305. private _captureParticlesRenderTime;
  48306. private _particlesRenderTime;
  48307. private _captureSpritesRenderTime;
  48308. private _spritesRenderTime;
  48309. private _capturePhysicsTime;
  48310. private _physicsTime;
  48311. private _captureAnimationsTime;
  48312. private _animationsTime;
  48313. private _captureCameraRenderTime;
  48314. private _cameraRenderTime;
  48315. private _onBeforeActiveMeshesEvaluationObserver;
  48316. private _onAfterActiveMeshesEvaluationObserver;
  48317. private _onBeforeRenderTargetsRenderObserver;
  48318. private _onAfterRenderTargetsRenderObserver;
  48319. private _onAfterRenderObserver;
  48320. private _onBeforeDrawPhaseObserver;
  48321. private _onAfterDrawPhaseObserver;
  48322. private _onBeforeAnimationsObserver;
  48323. private _onBeforeParticlesRenderingObserver;
  48324. private _onAfterParticlesRenderingObserver;
  48325. private _onBeforeSpritesRenderingObserver;
  48326. private _onAfterSpritesRenderingObserver;
  48327. private _onBeforePhysicsObserver;
  48328. private _onAfterPhysicsObserver;
  48329. private _onAfterAnimationsObserver;
  48330. private _onBeforeCameraRenderObserver;
  48331. private _onAfterCameraRenderObserver;
  48332. /**
  48333. * Gets the perf counter used for active meshes evaluation time
  48334. */
  48335. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48336. /**
  48337. * Gets the active meshes evaluation time capture status
  48338. */
  48339. /**
  48340. * Enable or disable the active meshes evaluation time capture
  48341. */
  48342. captureActiveMeshesEvaluationTime: boolean;
  48343. /**
  48344. * Gets the perf counter used for render targets render time
  48345. */
  48346. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48347. /**
  48348. * Gets the render targets render time capture status
  48349. */
  48350. /**
  48351. * Enable or disable the render targets render time capture
  48352. */
  48353. captureRenderTargetsRenderTime: boolean;
  48354. /**
  48355. * Gets the perf counter used for particles render time
  48356. */
  48357. readonly particlesRenderTimeCounter: PerfCounter;
  48358. /**
  48359. * Gets the particles render time capture status
  48360. */
  48361. /**
  48362. * Enable or disable the particles render time capture
  48363. */
  48364. captureParticlesRenderTime: boolean;
  48365. /**
  48366. * Gets the perf counter used for sprites render time
  48367. */
  48368. readonly spritesRenderTimeCounter: PerfCounter;
  48369. /**
  48370. * Gets the sprites render time capture status
  48371. */
  48372. /**
  48373. * Enable or disable the sprites render time capture
  48374. */
  48375. captureSpritesRenderTime: boolean;
  48376. /**
  48377. * Gets the perf counter used for physics time
  48378. */
  48379. readonly physicsTimeCounter: PerfCounter;
  48380. /**
  48381. * Gets the physics time capture status
  48382. */
  48383. /**
  48384. * Enable or disable the physics time capture
  48385. */
  48386. capturePhysicsTime: boolean;
  48387. /**
  48388. * Gets the perf counter used for animations time
  48389. */
  48390. readonly animationsTimeCounter: PerfCounter;
  48391. /**
  48392. * Gets the animations time capture status
  48393. */
  48394. /**
  48395. * Enable or disable the animations time capture
  48396. */
  48397. captureAnimationsTime: boolean;
  48398. /**
  48399. * Gets the perf counter used for frame time capture
  48400. */
  48401. readonly frameTimeCounter: PerfCounter;
  48402. /**
  48403. * Gets the frame time capture status
  48404. */
  48405. /**
  48406. * Enable or disable the frame time capture
  48407. */
  48408. captureFrameTime: boolean;
  48409. /**
  48410. * Gets the perf counter used for inter-frames time capture
  48411. */
  48412. readonly interFrameTimeCounter: PerfCounter;
  48413. /**
  48414. * Gets the inter-frames time capture status
  48415. */
  48416. /**
  48417. * Enable or disable the inter-frames time capture
  48418. */
  48419. captureInterFrameTime: boolean;
  48420. /**
  48421. * Gets the perf counter used for render time capture
  48422. */
  48423. readonly renderTimeCounter: PerfCounter;
  48424. /**
  48425. * Gets the render time capture status
  48426. */
  48427. /**
  48428. * Enable or disable the render time capture
  48429. */
  48430. captureRenderTime: boolean;
  48431. /**
  48432. * Gets the perf counter used for camera render time capture
  48433. */
  48434. readonly cameraRenderTimeCounter: PerfCounter;
  48435. /**
  48436. * Gets the camera render time capture status
  48437. */
  48438. /**
  48439. * Enable or disable the camera render time capture
  48440. */
  48441. captureCameraRenderTime: boolean;
  48442. /**
  48443. * Gets the perf counter used for draw calls
  48444. */
  48445. readonly drawCallsCounter: PerfCounter;
  48446. /**
  48447. * Instantiates a new scene instrumentation.
  48448. * This class can be used to get instrumentation data from a Babylon engine
  48449. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48450. * @param scene Defines the scene to instrument
  48451. */
  48452. constructor(
  48453. /**
  48454. * Defines the scene to instrument
  48455. */
  48456. scene: Scene);
  48457. /**
  48458. * Dispose and release associated resources.
  48459. */
  48460. dispose(): void;
  48461. }
  48462. }
  48463. declare module BABYLON {
  48464. /** @hidden */
  48465. export var glowMapGenerationPixelShader: {
  48466. name: string;
  48467. shader: string;
  48468. };
  48469. }
  48470. declare module BABYLON {
  48471. /** @hidden */
  48472. export var glowMapGenerationVertexShader: {
  48473. name: string;
  48474. shader: string;
  48475. };
  48476. }
  48477. declare module BABYLON {
  48478. /**
  48479. * Effect layer options. This helps customizing the behaviour
  48480. * of the effect layer.
  48481. */
  48482. export interface IEffectLayerOptions {
  48483. /**
  48484. * Multiplication factor apply to the canvas size to compute the render target size
  48485. * used to generated the objects (the smaller the faster).
  48486. */
  48487. mainTextureRatio: number;
  48488. /**
  48489. * Enforces a fixed size texture to ensure effect stability across devices.
  48490. */
  48491. mainTextureFixedSize?: number;
  48492. /**
  48493. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48494. */
  48495. alphaBlendingMode: number;
  48496. /**
  48497. * The camera attached to the layer.
  48498. */
  48499. camera: Nullable<Camera>;
  48500. /**
  48501. * The rendering group to draw the layer in.
  48502. */
  48503. renderingGroupId: number;
  48504. }
  48505. /**
  48506. * The effect layer Helps adding post process effect blended with the main pass.
  48507. *
  48508. * This can be for instance use to generate glow or higlight effects on the scene.
  48509. *
  48510. * The effect layer class can not be used directly and is intented to inherited from to be
  48511. * customized per effects.
  48512. */
  48513. export abstract class EffectLayer {
  48514. private _vertexBuffers;
  48515. private _indexBuffer;
  48516. private _cachedDefines;
  48517. private _effectLayerMapGenerationEffect;
  48518. private _effectLayerOptions;
  48519. private _mergeEffect;
  48520. protected _scene: Scene;
  48521. protected _engine: Engine;
  48522. protected _maxSize: number;
  48523. protected _mainTextureDesiredSize: ISize;
  48524. protected _mainTexture: RenderTargetTexture;
  48525. protected _shouldRender: boolean;
  48526. protected _postProcesses: PostProcess[];
  48527. protected _textures: BaseTexture[];
  48528. protected _emissiveTextureAndColor: {
  48529. texture: Nullable<BaseTexture>;
  48530. color: Color4;
  48531. };
  48532. /**
  48533. * The name of the layer
  48534. */
  48535. name: string;
  48536. /**
  48537. * The clear color of the texture used to generate the glow map.
  48538. */
  48539. neutralColor: Color4;
  48540. /**
  48541. * Specifies wether the highlight layer is enabled or not.
  48542. */
  48543. isEnabled: boolean;
  48544. /**
  48545. * Gets the camera attached to the layer.
  48546. */
  48547. readonly camera: Nullable<Camera>;
  48548. /**
  48549. * Gets the rendering group id the layer should render in.
  48550. */
  48551. renderingGroupId: number;
  48552. /**
  48553. * An event triggered when the effect layer has been disposed.
  48554. */
  48555. onDisposeObservable: Observable<EffectLayer>;
  48556. /**
  48557. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48558. */
  48559. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48560. /**
  48561. * An event triggered when the generated texture is being merged in the scene.
  48562. */
  48563. onBeforeComposeObservable: Observable<EffectLayer>;
  48564. /**
  48565. * An event triggered when the generated texture has been merged in the scene.
  48566. */
  48567. onAfterComposeObservable: Observable<EffectLayer>;
  48568. /**
  48569. * An event triggered when the efffect layer changes its size.
  48570. */
  48571. onSizeChangedObservable: Observable<EffectLayer>;
  48572. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  48573. /**
  48574. * Instantiates a new effect Layer and references it in the scene.
  48575. * @param name The name of the layer
  48576. * @param scene The scene to use the layer in
  48577. */
  48578. constructor(
  48579. /** The Friendly of the effect in the scene */
  48580. name: string, scene: Scene);
  48581. /**
  48582. * Get the effect name of the layer.
  48583. * @return The effect name
  48584. */
  48585. abstract getEffectName(): string;
  48586. /**
  48587. * Checks for the readiness of the element composing the layer.
  48588. * @param subMesh the mesh to check for
  48589. * @param useInstances specify wether or not to use instances to render the mesh
  48590. * @return true if ready otherwise, false
  48591. */
  48592. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48593. /**
  48594. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48595. * @returns true if the effect requires stencil during the main canvas render pass.
  48596. */
  48597. abstract needStencil(): boolean;
  48598. /**
  48599. * Create the merge effect. This is the shader use to blit the information back
  48600. * to the main canvas at the end of the scene rendering.
  48601. * @returns The effect containing the shader used to merge the effect on the main canvas
  48602. */
  48603. protected abstract _createMergeEffect(): Effect;
  48604. /**
  48605. * Creates the render target textures and post processes used in the effect layer.
  48606. */
  48607. protected abstract _createTextureAndPostProcesses(): void;
  48608. /**
  48609. * Implementation specific of rendering the generating effect on the main canvas.
  48610. * @param effect The effect used to render through
  48611. */
  48612. protected abstract _internalRender(effect: Effect): void;
  48613. /**
  48614. * Sets the required values for both the emissive texture and and the main color.
  48615. */
  48616. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48617. /**
  48618. * Free any resources and references associated to a mesh.
  48619. * Internal use
  48620. * @param mesh The mesh to free.
  48621. */
  48622. abstract _disposeMesh(mesh: Mesh): void;
  48623. /**
  48624. * Serializes this layer (Glow or Highlight for example)
  48625. * @returns a serialized layer object
  48626. */
  48627. abstract serialize?(): any;
  48628. /**
  48629. * Initializes the effect layer with the required options.
  48630. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48631. */
  48632. protected _init(options: Partial<IEffectLayerOptions>): void;
  48633. /**
  48634. * Generates the index buffer of the full screen quad blending to the main canvas.
  48635. */
  48636. private _generateIndexBuffer;
  48637. /**
  48638. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48639. */
  48640. private _generateVertexBuffer;
  48641. /**
  48642. * Sets the main texture desired size which is the closest power of two
  48643. * of the engine canvas size.
  48644. */
  48645. private _setMainTextureSize;
  48646. /**
  48647. * Creates the main texture for the effect layer.
  48648. */
  48649. protected _createMainTexture(): void;
  48650. /**
  48651. * Adds specific effects defines.
  48652. * @param defines The defines to add specifics to.
  48653. */
  48654. protected _addCustomEffectDefines(defines: string[]): void;
  48655. /**
  48656. * Checks for the readiness of the element composing the layer.
  48657. * @param subMesh the mesh to check for
  48658. * @param useInstances specify wether or not to use instances to render the mesh
  48659. * @param emissiveTexture the associated emissive texture used to generate the glow
  48660. * @return true if ready otherwise, false
  48661. */
  48662. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48663. /**
  48664. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48665. */
  48666. render(): void;
  48667. /**
  48668. * Determine if a given mesh will be used in the current effect.
  48669. * @param mesh mesh to test
  48670. * @returns true if the mesh will be used
  48671. */
  48672. hasMesh(mesh: AbstractMesh): boolean;
  48673. /**
  48674. * Returns true if the layer contains information to display, otherwise false.
  48675. * @returns true if the glow layer should be rendered
  48676. */
  48677. shouldRender(): boolean;
  48678. /**
  48679. * Returns true if the mesh should render, otherwise false.
  48680. * @param mesh The mesh to render
  48681. * @returns true if it should render otherwise false
  48682. */
  48683. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48684. /**
  48685. * Returns true if the mesh can be rendered, otherwise false.
  48686. * @param mesh The mesh to render
  48687. * @param material The material used on the mesh
  48688. * @returns true if it can be rendered otherwise false
  48689. */
  48690. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48691. /**
  48692. * Returns true if the mesh should render, otherwise false.
  48693. * @param mesh The mesh to render
  48694. * @returns true if it should render otherwise false
  48695. */
  48696. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48697. /**
  48698. * Renders the submesh passed in parameter to the generation map.
  48699. */
  48700. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48701. /**
  48702. * Rebuild the required buffers.
  48703. * @hidden Internal use only.
  48704. */ private _rebuild(): void;
  48705. /**
  48706. * Dispose only the render target textures and post process.
  48707. */
  48708. private _disposeTextureAndPostProcesses;
  48709. /**
  48710. * Dispose the highlight layer and free resources.
  48711. */
  48712. dispose(): void;
  48713. /**
  48714. * Gets the class name of the effect layer
  48715. * @returns the string with the class name of the effect layer
  48716. */
  48717. getClassName(): string;
  48718. /**
  48719. * Creates an effect layer from parsed effect layer data
  48720. * @param parsedEffectLayer defines effect layer data
  48721. * @param scene defines the current scene
  48722. * @param rootUrl defines the root URL containing the effect layer information
  48723. * @returns a parsed effect Layer
  48724. */
  48725. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48726. }
  48727. }
  48728. declare module BABYLON {
  48729. interface AbstractScene {
  48730. /**
  48731. * The list of effect layers (highlights/glow) added to the scene
  48732. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48733. * @see http://doc.babylonjs.com/how_to/glow_layer
  48734. */
  48735. effectLayers: Array<EffectLayer>;
  48736. /**
  48737. * Removes the given effect layer from this scene.
  48738. * @param toRemove defines the effect layer to remove
  48739. * @returns the index of the removed effect layer
  48740. */
  48741. removeEffectLayer(toRemove: EffectLayer): number;
  48742. /**
  48743. * Adds the given effect layer to this scene
  48744. * @param newEffectLayer defines the effect layer to add
  48745. */
  48746. addEffectLayer(newEffectLayer: EffectLayer): void;
  48747. }
  48748. /**
  48749. * Defines the layer scene component responsible to manage any effect layers
  48750. * in a given scene.
  48751. */
  48752. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48753. /**
  48754. * The component name helpfull to identify the component in the list of scene components.
  48755. */
  48756. readonly name: string;
  48757. /**
  48758. * The scene the component belongs to.
  48759. */
  48760. scene: Scene;
  48761. private _engine;
  48762. private _renderEffects;
  48763. private _needStencil;
  48764. private _previousStencilState;
  48765. /**
  48766. * Creates a new instance of the component for the given scene
  48767. * @param scene Defines the scene to register the component in
  48768. */
  48769. constructor(scene: Scene);
  48770. /**
  48771. * Registers the component in a given scene
  48772. */
  48773. register(): void;
  48774. /**
  48775. * Rebuilds the elements related to this component in case of
  48776. * context lost for instance.
  48777. */
  48778. rebuild(): void;
  48779. /**
  48780. * Serializes the component data to the specified json object
  48781. * @param serializationObject The object to serialize to
  48782. */
  48783. serialize(serializationObject: any): void;
  48784. /**
  48785. * Adds all the elements from the container to the scene
  48786. * @param container the container holding the elements
  48787. */
  48788. addFromContainer(container: AbstractScene): void;
  48789. /**
  48790. * Removes all the elements in the container from the scene
  48791. * @param container contains the elements to remove
  48792. * @param dispose if the removed element should be disposed (default: false)
  48793. */
  48794. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48795. /**
  48796. * Disposes the component and the associated ressources.
  48797. */
  48798. dispose(): void;
  48799. private _isReadyForMesh;
  48800. private _renderMainTexture;
  48801. private _setStencil;
  48802. private _setStencilBack;
  48803. private _draw;
  48804. private _drawCamera;
  48805. private _drawRenderingGroup;
  48806. }
  48807. }
  48808. declare module BABYLON {
  48809. /** @hidden */
  48810. export var glowMapMergePixelShader: {
  48811. name: string;
  48812. shader: string;
  48813. };
  48814. }
  48815. declare module BABYLON {
  48816. /** @hidden */
  48817. export var glowMapMergeVertexShader: {
  48818. name: string;
  48819. shader: string;
  48820. };
  48821. }
  48822. declare module BABYLON {
  48823. interface AbstractScene {
  48824. /**
  48825. * Return a the first highlight layer of the scene with a given name.
  48826. * @param name The name of the highlight layer to look for.
  48827. * @return The highlight layer if found otherwise null.
  48828. */
  48829. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48830. }
  48831. /**
  48832. * Glow layer options. This helps customizing the behaviour
  48833. * of the glow layer.
  48834. */
  48835. export interface IGlowLayerOptions {
  48836. /**
  48837. * Multiplication factor apply to the canvas size to compute the render target size
  48838. * used to generated the glowing objects (the smaller the faster).
  48839. */
  48840. mainTextureRatio: number;
  48841. /**
  48842. * Enforces a fixed size texture to ensure resize independant blur.
  48843. */
  48844. mainTextureFixedSize?: number;
  48845. /**
  48846. * How big is the kernel of the blur texture.
  48847. */
  48848. blurKernelSize: number;
  48849. /**
  48850. * The camera attached to the layer.
  48851. */
  48852. camera: Nullable<Camera>;
  48853. /**
  48854. * Enable MSAA by chosing the number of samples.
  48855. */
  48856. mainTextureSamples?: number;
  48857. /**
  48858. * The rendering group to draw the layer in.
  48859. */
  48860. renderingGroupId: number;
  48861. }
  48862. /**
  48863. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48864. *
  48865. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48866. * glowy meshes to your scene.
  48867. *
  48868. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48869. */
  48870. export class GlowLayer extends EffectLayer {
  48871. /**
  48872. * Effect Name of the layer.
  48873. */
  48874. static readonly EffectName: string;
  48875. /**
  48876. * The default blur kernel size used for the glow.
  48877. */
  48878. static DefaultBlurKernelSize: number;
  48879. /**
  48880. * The default texture size ratio used for the glow.
  48881. */
  48882. static DefaultTextureRatio: number;
  48883. /**
  48884. * Sets the kernel size of the blur.
  48885. */
  48886. /**
  48887. * Gets the kernel size of the blur.
  48888. */
  48889. blurKernelSize: number;
  48890. /**
  48891. * Sets the glow intensity.
  48892. */
  48893. /**
  48894. * Gets the glow intensity.
  48895. */
  48896. intensity: number;
  48897. private _options;
  48898. private _intensity;
  48899. private _horizontalBlurPostprocess1;
  48900. private _verticalBlurPostprocess1;
  48901. private _horizontalBlurPostprocess2;
  48902. private _verticalBlurPostprocess2;
  48903. private _blurTexture1;
  48904. private _blurTexture2;
  48905. private _postProcesses1;
  48906. private _postProcesses2;
  48907. private _includedOnlyMeshes;
  48908. private _excludedMeshes;
  48909. /**
  48910. * Callback used to let the user override the color selection on a per mesh basis
  48911. */
  48912. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48913. /**
  48914. * Callback used to let the user override the texture selection on a per mesh basis
  48915. */
  48916. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48917. /**
  48918. * Instantiates a new glow Layer and references it to the scene.
  48919. * @param name The name of the layer
  48920. * @param scene The scene to use the layer in
  48921. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48922. */
  48923. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48924. /**
  48925. * Get the effect name of the layer.
  48926. * @return The effect name
  48927. */
  48928. getEffectName(): string;
  48929. /**
  48930. * Create the merge effect. This is the shader use to blit the information back
  48931. * to the main canvas at the end of the scene rendering.
  48932. */
  48933. protected _createMergeEffect(): Effect;
  48934. /**
  48935. * Creates the render target textures and post processes used in the glow layer.
  48936. */
  48937. protected _createTextureAndPostProcesses(): void;
  48938. /**
  48939. * Checks for the readiness of the element composing the layer.
  48940. * @param subMesh the mesh to check for
  48941. * @param useInstances specify wether or not to use instances to render the mesh
  48942. * @param emissiveTexture the associated emissive texture used to generate the glow
  48943. * @return true if ready otherwise, false
  48944. */
  48945. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48946. /**
  48947. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48948. */
  48949. needStencil(): boolean;
  48950. /**
  48951. * Returns true if the mesh can be rendered, otherwise false.
  48952. * @param mesh The mesh to render
  48953. * @param material The material used on the mesh
  48954. * @returns true if it can be rendered otherwise false
  48955. */
  48956. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48957. /**
  48958. * Implementation specific of rendering the generating effect on the main canvas.
  48959. * @param effect The effect used to render through
  48960. */
  48961. protected _internalRender(effect: Effect): void;
  48962. /**
  48963. * Sets the required values for both the emissive texture and and the main color.
  48964. */
  48965. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48966. /**
  48967. * Returns true if the mesh should render, otherwise false.
  48968. * @param mesh The mesh to render
  48969. * @returns true if it should render otherwise false
  48970. */
  48971. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48972. /**
  48973. * Adds specific effects defines.
  48974. * @param defines The defines to add specifics to.
  48975. */
  48976. protected _addCustomEffectDefines(defines: string[]): void;
  48977. /**
  48978. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48979. * @param mesh The mesh to exclude from the glow layer
  48980. */
  48981. addExcludedMesh(mesh: Mesh): void;
  48982. /**
  48983. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48984. * @param mesh The mesh to remove
  48985. */
  48986. removeExcludedMesh(mesh: Mesh): void;
  48987. /**
  48988. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48989. * @param mesh The mesh to include in the glow layer
  48990. */
  48991. addIncludedOnlyMesh(mesh: Mesh): void;
  48992. /**
  48993. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48994. * @param mesh The mesh to remove
  48995. */
  48996. removeIncludedOnlyMesh(mesh: Mesh): void;
  48997. /**
  48998. * Determine if a given mesh will be used in the glow layer
  48999. * @param mesh The mesh to test
  49000. * @returns true if the mesh will be highlighted by the current glow layer
  49001. */
  49002. hasMesh(mesh: AbstractMesh): boolean;
  49003. /**
  49004. * Free any resources and references associated to a mesh.
  49005. * Internal use
  49006. * @param mesh The mesh to free.
  49007. * @hidden
  49008. */ private _disposeMesh(mesh: Mesh): void;
  49009. /**
  49010. * Gets the class name of the effect layer
  49011. * @returns the string with the class name of the effect layer
  49012. */
  49013. getClassName(): string;
  49014. /**
  49015. * Serializes this glow layer
  49016. * @returns a serialized glow layer object
  49017. */
  49018. serialize(): any;
  49019. /**
  49020. * Creates a Glow Layer from parsed glow layer data
  49021. * @param parsedGlowLayer defines glow layer data
  49022. * @param scene defines the current scene
  49023. * @param rootUrl defines the root URL containing the glow layer information
  49024. * @returns a parsed Glow Layer
  49025. */
  49026. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49027. }
  49028. }
  49029. declare module BABYLON {
  49030. /** @hidden */
  49031. export var glowBlurPostProcessPixelShader: {
  49032. name: string;
  49033. shader: string;
  49034. };
  49035. }
  49036. declare module BABYLON {
  49037. interface AbstractScene {
  49038. /**
  49039. * Return a the first highlight layer of the scene with a given name.
  49040. * @param name The name of the highlight layer to look for.
  49041. * @return The highlight layer if found otherwise null.
  49042. */
  49043. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49044. }
  49045. /**
  49046. * Highlight layer options. This helps customizing the behaviour
  49047. * of the highlight layer.
  49048. */
  49049. export interface IHighlightLayerOptions {
  49050. /**
  49051. * Multiplication factor apply to the canvas size to compute the render target size
  49052. * used to generated the glowing objects (the smaller the faster).
  49053. */
  49054. mainTextureRatio: number;
  49055. /**
  49056. * Enforces a fixed size texture to ensure resize independant blur.
  49057. */
  49058. mainTextureFixedSize?: number;
  49059. /**
  49060. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49061. * of the picture to blur (the smaller the faster).
  49062. */
  49063. blurTextureSizeRatio: number;
  49064. /**
  49065. * How big in texel of the blur texture is the vertical blur.
  49066. */
  49067. blurVerticalSize: number;
  49068. /**
  49069. * How big in texel of the blur texture is the horizontal blur.
  49070. */
  49071. blurHorizontalSize: number;
  49072. /**
  49073. * Alpha blending mode used to apply the blur. Default is combine.
  49074. */
  49075. alphaBlendingMode: number;
  49076. /**
  49077. * The camera attached to the layer.
  49078. */
  49079. camera: Nullable<Camera>;
  49080. /**
  49081. * Should we display highlight as a solid stroke?
  49082. */
  49083. isStroke?: boolean;
  49084. /**
  49085. * The rendering group to draw the layer in.
  49086. */
  49087. renderingGroupId: number;
  49088. }
  49089. /**
  49090. * The highlight layer Helps adding a glow effect around a mesh.
  49091. *
  49092. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49093. * glowy meshes to your scene.
  49094. *
  49095. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49096. */
  49097. export class HighlightLayer extends EffectLayer {
  49098. name: string;
  49099. /**
  49100. * Effect Name of the highlight layer.
  49101. */
  49102. static readonly EffectName: string;
  49103. /**
  49104. * The neutral color used during the preparation of the glow effect.
  49105. * This is black by default as the blend operation is a blend operation.
  49106. */
  49107. static NeutralColor: Color4;
  49108. /**
  49109. * Stencil value used for glowing meshes.
  49110. */
  49111. static GlowingMeshStencilReference: number;
  49112. /**
  49113. * Stencil value used for the other meshes in the scene.
  49114. */
  49115. static NormalMeshStencilReference: number;
  49116. /**
  49117. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49118. */
  49119. innerGlow: boolean;
  49120. /**
  49121. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49122. */
  49123. outerGlow: boolean;
  49124. /**
  49125. * Specifies the horizontal size of the blur.
  49126. */
  49127. /**
  49128. * Gets the horizontal size of the blur.
  49129. */
  49130. blurHorizontalSize: number;
  49131. /**
  49132. * Specifies the vertical size of the blur.
  49133. */
  49134. /**
  49135. * Gets the vertical size of the blur.
  49136. */
  49137. blurVerticalSize: number;
  49138. /**
  49139. * An event triggered when the highlight layer is being blurred.
  49140. */
  49141. onBeforeBlurObservable: Observable<HighlightLayer>;
  49142. /**
  49143. * An event triggered when the highlight layer has been blurred.
  49144. */
  49145. onAfterBlurObservable: Observable<HighlightLayer>;
  49146. private _instanceGlowingMeshStencilReference;
  49147. private _options;
  49148. private _downSamplePostprocess;
  49149. private _horizontalBlurPostprocess;
  49150. private _verticalBlurPostprocess;
  49151. private _blurTexture;
  49152. private _meshes;
  49153. private _excludedMeshes;
  49154. /**
  49155. * Instantiates a new highlight Layer and references it to the scene..
  49156. * @param name The name of the layer
  49157. * @param scene The scene to use the layer in
  49158. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49159. */
  49160. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49161. /**
  49162. * Get the effect name of the layer.
  49163. * @return The effect name
  49164. */
  49165. getEffectName(): string;
  49166. /**
  49167. * Create the merge effect. This is the shader use to blit the information back
  49168. * to the main canvas at the end of the scene rendering.
  49169. */
  49170. protected _createMergeEffect(): Effect;
  49171. /**
  49172. * Creates the render target textures and post processes used in the highlight layer.
  49173. */
  49174. protected _createTextureAndPostProcesses(): void;
  49175. /**
  49176. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49177. */
  49178. needStencil(): boolean;
  49179. /**
  49180. * Checks for the readiness of the element composing the layer.
  49181. * @param subMesh the mesh to check for
  49182. * @param useInstances specify wether or not to use instances to render the mesh
  49183. * @param emissiveTexture the associated emissive texture used to generate the glow
  49184. * @return true if ready otherwise, false
  49185. */
  49186. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49187. /**
  49188. * Implementation specific of rendering the generating effect on the main canvas.
  49189. * @param effect The effect used to render through
  49190. */
  49191. protected _internalRender(effect: Effect): void;
  49192. /**
  49193. * Returns true if the layer contains information to display, otherwise false.
  49194. */
  49195. shouldRender(): boolean;
  49196. /**
  49197. * Returns true if the mesh should render, otherwise false.
  49198. * @param mesh The mesh to render
  49199. * @returns true if it should render otherwise false
  49200. */
  49201. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49202. /**
  49203. * Sets the required values for both the emissive texture and and the main color.
  49204. */
  49205. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49206. /**
  49207. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49208. * @param mesh The mesh to exclude from the highlight layer
  49209. */
  49210. addExcludedMesh(mesh: Mesh): void;
  49211. /**
  49212. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49213. * @param mesh The mesh to highlight
  49214. */
  49215. removeExcludedMesh(mesh: Mesh): void;
  49216. /**
  49217. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49218. * @param mesh mesh to test
  49219. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49220. */
  49221. hasMesh(mesh: AbstractMesh): boolean;
  49222. /**
  49223. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49224. * @param mesh The mesh to highlight
  49225. * @param color The color of the highlight
  49226. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49227. */
  49228. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49229. /**
  49230. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49231. * @param mesh The mesh to highlight
  49232. */
  49233. removeMesh(mesh: Mesh): void;
  49234. /**
  49235. * Force the stencil to the normal expected value for none glowing parts
  49236. */
  49237. private _defaultStencilReference;
  49238. /**
  49239. * Free any resources and references associated to a mesh.
  49240. * Internal use
  49241. * @param mesh The mesh to free.
  49242. * @hidden
  49243. */ private _disposeMesh(mesh: Mesh): void;
  49244. /**
  49245. * Dispose the highlight layer and free resources.
  49246. */
  49247. dispose(): void;
  49248. /**
  49249. * Gets the class name of the effect layer
  49250. * @returns the string with the class name of the effect layer
  49251. */
  49252. getClassName(): string;
  49253. /**
  49254. * Serializes this Highlight layer
  49255. * @returns a serialized Highlight layer object
  49256. */
  49257. serialize(): any;
  49258. /**
  49259. * Creates a Highlight layer from parsed Highlight layer data
  49260. * @param parsedHightlightLayer defines the Highlight layer data
  49261. * @param scene defines the current scene
  49262. * @param rootUrl defines the root URL containing the Highlight layer information
  49263. * @returns a parsed Highlight layer
  49264. */
  49265. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49266. }
  49267. }
  49268. declare module BABYLON {
  49269. interface AbstractScene {
  49270. /**
  49271. * The list of layers (background and foreground) of the scene
  49272. */
  49273. layers: Array<Layer>;
  49274. }
  49275. /**
  49276. * Defines the layer scene component responsible to manage any layers
  49277. * in a given scene.
  49278. */
  49279. export class LayerSceneComponent implements ISceneComponent {
  49280. /**
  49281. * The component name helpfull to identify the component in the list of scene components.
  49282. */
  49283. readonly name: string;
  49284. /**
  49285. * The scene the component belongs to.
  49286. */
  49287. scene: Scene;
  49288. private _engine;
  49289. /**
  49290. * Creates a new instance of the component for the given scene
  49291. * @param scene Defines the scene to register the component in
  49292. */
  49293. constructor(scene: Scene);
  49294. /**
  49295. * Registers the component in a given scene
  49296. */
  49297. register(): void;
  49298. /**
  49299. * Rebuilds the elements related to this component in case of
  49300. * context lost for instance.
  49301. */
  49302. rebuild(): void;
  49303. /**
  49304. * Disposes the component and the associated ressources.
  49305. */
  49306. dispose(): void;
  49307. private _draw;
  49308. private _drawCameraPredicate;
  49309. private _drawCameraBackground;
  49310. private _drawCameraForeground;
  49311. private _drawRenderTargetPredicate;
  49312. private _drawRenderTargetBackground;
  49313. private _drawRenderTargetForeground;
  49314. /**
  49315. * Adds all the elements from the container to the scene
  49316. * @param container the container holding the elements
  49317. */
  49318. addFromContainer(container: AbstractScene): void;
  49319. /**
  49320. * Removes all the elements in the container from the scene
  49321. * @param container contains the elements to remove
  49322. * @param dispose if the removed element should be disposed (default: false)
  49323. */
  49324. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49325. }
  49326. }
  49327. declare module BABYLON {
  49328. /** @hidden */
  49329. export var layerPixelShader: {
  49330. name: string;
  49331. shader: string;
  49332. };
  49333. }
  49334. declare module BABYLON {
  49335. /** @hidden */
  49336. export var layerVertexShader: {
  49337. name: string;
  49338. shader: string;
  49339. };
  49340. }
  49341. declare module BABYLON {
  49342. /**
  49343. * This represents a full screen 2d layer.
  49344. * This can be useful to display a picture in the background of your scene for instance.
  49345. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49346. */
  49347. export class Layer {
  49348. /**
  49349. * Define the name of the layer.
  49350. */
  49351. name: string;
  49352. /**
  49353. * Define the texture the layer should display.
  49354. */
  49355. texture: Nullable<Texture>;
  49356. /**
  49357. * Is the layer in background or foreground.
  49358. */
  49359. isBackground: boolean;
  49360. /**
  49361. * Define the color of the layer (instead of texture).
  49362. */
  49363. color: Color4;
  49364. /**
  49365. * Define the scale of the layer in order to zoom in out of the texture.
  49366. */
  49367. scale: Vector2;
  49368. /**
  49369. * Define an offset for the layer in order to shift the texture.
  49370. */
  49371. offset: Vector2;
  49372. /**
  49373. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  49374. */
  49375. alphaBlendingMode: number;
  49376. /**
  49377. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  49378. * Alpha test will not mix with the background color in case of transparency.
  49379. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  49380. */
  49381. alphaTest: boolean;
  49382. /**
  49383. * Define a mask to restrict the layer to only some of the scene cameras.
  49384. */
  49385. layerMask: number;
  49386. /**
  49387. * Define the list of render target the layer is visible into.
  49388. */
  49389. renderTargetTextures: RenderTargetTexture[];
  49390. /**
  49391. * Define if the layer is only used in renderTarget or if it also
  49392. * renders in the main frame buffer of the canvas.
  49393. */
  49394. renderOnlyInRenderTargetTextures: boolean;
  49395. private _scene;
  49396. private _vertexBuffers;
  49397. private _indexBuffer;
  49398. private _effect;
  49399. private _alphaTestEffect;
  49400. /**
  49401. * An event triggered when the layer is disposed.
  49402. */
  49403. onDisposeObservable: Observable<Layer>;
  49404. private _onDisposeObserver;
  49405. /**
  49406. * Back compatibility with callback before the onDisposeObservable existed.
  49407. * The set callback will be triggered when the layer has been disposed.
  49408. */
  49409. onDispose: () => void;
  49410. /**
  49411. * An event triggered before rendering the scene
  49412. */
  49413. onBeforeRenderObservable: Observable<Layer>;
  49414. private _onBeforeRenderObserver;
  49415. /**
  49416. * Back compatibility with callback before the onBeforeRenderObservable existed.
  49417. * The set callback will be triggered just before rendering the layer.
  49418. */
  49419. onBeforeRender: () => void;
  49420. /**
  49421. * An event triggered after rendering the scene
  49422. */
  49423. onAfterRenderObservable: Observable<Layer>;
  49424. private _onAfterRenderObserver;
  49425. /**
  49426. * Back compatibility with callback before the onAfterRenderObservable existed.
  49427. * The set callback will be triggered just after rendering the layer.
  49428. */
  49429. onAfterRender: () => void;
  49430. /**
  49431. * Instantiates a new layer.
  49432. * This represents a full screen 2d layer.
  49433. * This can be useful to display a picture in the background of your scene for instance.
  49434. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49435. * @param name Define the name of the layer in the scene
  49436. * @param imgUrl Define the url of the texture to display in the layer
  49437. * @param scene Define the scene the layer belongs to
  49438. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  49439. * @param color Defines a color for the layer
  49440. */
  49441. constructor(
  49442. /**
  49443. * Define the name of the layer.
  49444. */
  49445. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  49446. private _createIndexBuffer;
  49447. /** @hidden */ private _rebuild(): void;
  49448. /**
  49449. * Renders the layer in the scene.
  49450. */
  49451. render(): void;
  49452. /**
  49453. * Disposes and releases the associated ressources.
  49454. */
  49455. dispose(): void;
  49456. }
  49457. }
  49458. declare module BABYLON {
  49459. /** @hidden */
  49460. export var lensFlarePixelShader: {
  49461. name: string;
  49462. shader: string;
  49463. };
  49464. }
  49465. declare module BABYLON {
  49466. /** @hidden */
  49467. export var lensFlareVertexShader: {
  49468. name: string;
  49469. shader: string;
  49470. };
  49471. }
  49472. declare module BABYLON {
  49473. /**
  49474. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49475. * It is usually composed of several `lensFlare`.
  49476. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49477. */
  49478. export class LensFlareSystem {
  49479. /**
  49480. * Define the name of the lens flare system
  49481. */
  49482. name: string;
  49483. /**
  49484. * List of lens flares used in this system.
  49485. */
  49486. lensFlares: LensFlare[];
  49487. /**
  49488. * Define a limit from the border the lens flare can be visible.
  49489. */
  49490. borderLimit: number;
  49491. /**
  49492. * Define a viewport border we do not want to see the lens flare in.
  49493. */
  49494. viewportBorder: number;
  49495. /**
  49496. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49497. */
  49498. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49499. /**
  49500. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49501. */
  49502. layerMask: number;
  49503. /**
  49504. * Define the id of the lens flare system in the scene.
  49505. * (equal to name by default)
  49506. */
  49507. id: string;
  49508. private _scene;
  49509. private _emitter;
  49510. private _vertexBuffers;
  49511. private _indexBuffer;
  49512. private _effect;
  49513. private _positionX;
  49514. private _positionY;
  49515. private _isEnabled;
  49516. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  49517. /**
  49518. * Instantiates a lens flare system.
  49519. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49520. * It is usually composed of several `lensFlare`.
  49521. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49522. * @param name Define the name of the lens flare system in the scene
  49523. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49524. * @param scene Define the scene the lens flare system belongs to
  49525. */
  49526. constructor(
  49527. /**
  49528. * Define the name of the lens flare system
  49529. */
  49530. name: string, emitter: any, scene: Scene);
  49531. /**
  49532. * Define if the lens flare system is enabled.
  49533. */
  49534. isEnabled: boolean;
  49535. /**
  49536. * Get the scene the effects belongs to.
  49537. * @returns the scene holding the lens flare system
  49538. */
  49539. getScene(): Scene;
  49540. /**
  49541. * Get the emitter of the lens flare system.
  49542. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49543. * @returns the emitter of the lens flare system
  49544. */
  49545. getEmitter(): any;
  49546. /**
  49547. * Set the emitter of the lens flare system.
  49548. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49549. * @param newEmitter Define the new emitter of the system
  49550. */
  49551. setEmitter(newEmitter: any): void;
  49552. /**
  49553. * Get the lens flare system emitter position.
  49554. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49555. * @returns the position
  49556. */
  49557. getEmitterPosition(): Vector3;
  49558. /**
  49559. * @hidden
  49560. */
  49561. computeEffectivePosition(globalViewport: Viewport): boolean;
  49562. /** @hidden */ private _isVisible(): boolean;
  49563. /**
  49564. * @hidden
  49565. */
  49566. render(): boolean;
  49567. /**
  49568. * Dispose and release the lens flare with its associated resources.
  49569. */
  49570. dispose(): void;
  49571. /**
  49572. * Parse a lens flare system from a JSON repressentation
  49573. * @param parsedLensFlareSystem Define the JSON to parse
  49574. * @param scene Define the scene the parsed system should be instantiated in
  49575. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49576. * @returns the parsed system
  49577. */
  49578. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49579. /**
  49580. * Serialize the current Lens Flare System into a JSON representation.
  49581. * @returns the serialized JSON
  49582. */
  49583. serialize(): any;
  49584. }
  49585. }
  49586. declare module BABYLON {
  49587. /**
  49588. * This represents one of the lens effect in a `lensFlareSystem`.
  49589. * It controls one of the indiviual texture used in the effect.
  49590. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49591. */
  49592. export class LensFlare {
  49593. /**
  49594. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49595. */
  49596. size: number;
  49597. /**
  49598. * 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.
  49599. */
  49600. position: number;
  49601. /**
  49602. * Define the lens color.
  49603. */
  49604. color: Color3;
  49605. /**
  49606. * Define the lens texture.
  49607. */
  49608. texture: Nullable<Texture>;
  49609. /**
  49610. * Define the alpha mode to render this particular lens.
  49611. */
  49612. alphaMode: number;
  49613. private _system;
  49614. /**
  49615. * Creates a new Lens Flare.
  49616. * This represents one of the lens effect in a `lensFlareSystem`.
  49617. * It controls one of the indiviual texture used in the effect.
  49618. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49619. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49620. * @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.
  49621. * @param color Define the lens color
  49622. * @param imgUrl Define the lens texture url
  49623. * @param system Define the `lensFlareSystem` this flare is part of
  49624. * @returns The newly created Lens Flare
  49625. */
  49626. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49627. /**
  49628. * Instantiates a new Lens Flare.
  49629. * This represents one of the lens effect in a `lensFlareSystem`.
  49630. * It controls one of the indiviual texture used in the effect.
  49631. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49632. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49633. * @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.
  49634. * @param color Define the lens color
  49635. * @param imgUrl Define the lens texture url
  49636. * @param system Define the `lensFlareSystem` this flare is part of
  49637. */
  49638. constructor(
  49639. /**
  49640. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49641. */
  49642. size: number,
  49643. /**
  49644. * 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.
  49645. */
  49646. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49647. /**
  49648. * Dispose and release the lens flare with its associated resources.
  49649. */
  49650. dispose(): void;
  49651. }
  49652. }
  49653. declare module BABYLON {
  49654. interface AbstractScene {
  49655. /**
  49656. * The list of lens flare system added to the scene
  49657. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49658. */
  49659. lensFlareSystems: Array<LensFlareSystem>;
  49660. /**
  49661. * Removes the given lens flare system from this scene.
  49662. * @param toRemove The lens flare system to remove
  49663. * @returns The index of the removed lens flare system
  49664. */
  49665. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49666. /**
  49667. * Adds the given lens flare system to this scene
  49668. * @param newLensFlareSystem The lens flare system to add
  49669. */
  49670. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49671. /**
  49672. * Gets a lens flare system using its name
  49673. * @param name defines the name to look for
  49674. * @returns the lens flare system or null if not found
  49675. */
  49676. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49677. /**
  49678. * Gets a lens flare system using its id
  49679. * @param id defines the id to look for
  49680. * @returns the lens flare system or null if not found
  49681. */
  49682. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49683. }
  49684. /**
  49685. * Defines the lens flare scene component responsible to manage any lens flares
  49686. * in a given scene.
  49687. */
  49688. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49689. /**
  49690. * The component name helpfull to identify the component in the list of scene components.
  49691. */
  49692. readonly name: string;
  49693. /**
  49694. * The scene the component belongs to.
  49695. */
  49696. scene: Scene;
  49697. /**
  49698. * Creates a new instance of the component for the given scene
  49699. * @param scene Defines the scene to register the component in
  49700. */
  49701. constructor(scene: Scene);
  49702. /**
  49703. * Registers the component in a given scene
  49704. */
  49705. register(): void;
  49706. /**
  49707. * Rebuilds the elements related to this component in case of
  49708. * context lost for instance.
  49709. */
  49710. rebuild(): void;
  49711. /**
  49712. * Adds all the elements from the container to the scene
  49713. * @param container the container holding the elements
  49714. */
  49715. addFromContainer(container: AbstractScene): void;
  49716. /**
  49717. * Removes all the elements in the container from the scene
  49718. * @param container contains the elements to remove
  49719. * @param dispose if the removed element should be disposed (default: false)
  49720. */
  49721. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49722. /**
  49723. * Serializes the component data to the specified json object
  49724. * @param serializationObject The object to serialize to
  49725. */
  49726. serialize(serializationObject: any): void;
  49727. /**
  49728. * Disposes the component and the associated ressources.
  49729. */
  49730. dispose(): void;
  49731. private _draw;
  49732. }
  49733. }
  49734. declare module BABYLON {
  49735. /**
  49736. * Defines the shadow generator component responsible to manage any shadow generators
  49737. * in a given scene.
  49738. */
  49739. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49740. /**
  49741. * The component name helpfull to identify the component in the list of scene components.
  49742. */
  49743. readonly name: string;
  49744. /**
  49745. * The scene the component belongs to.
  49746. */
  49747. scene: Scene;
  49748. /**
  49749. * Creates a new instance of the component for the given scene
  49750. * @param scene Defines the scene to register the component in
  49751. */
  49752. constructor(scene: Scene);
  49753. /**
  49754. * Registers the component in a given scene
  49755. */
  49756. register(): void;
  49757. /**
  49758. * Rebuilds the elements related to this component in case of
  49759. * context lost for instance.
  49760. */
  49761. rebuild(): void;
  49762. /**
  49763. * Serializes the component data to the specified json object
  49764. * @param serializationObject The object to serialize to
  49765. */
  49766. serialize(serializationObject: any): void;
  49767. /**
  49768. * Adds all the elements from the container to the scene
  49769. * @param container the container holding the elements
  49770. */
  49771. addFromContainer(container: AbstractScene): void;
  49772. /**
  49773. * Removes all the elements in the container from the scene
  49774. * @param container contains the elements to remove
  49775. * @param dispose if the removed element should be disposed (default: false)
  49776. */
  49777. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49778. /**
  49779. * Rebuilds the elements related to this component in case of
  49780. * context lost for instance.
  49781. */
  49782. dispose(): void;
  49783. private _gatherRenderTargets;
  49784. }
  49785. }
  49786. declare module BABYLON {
  49787. /**
  49788. * A point light is a light defined by an unique point in world space.
  49789. * The light is emitted in every direction from this point.
  49790. * A good example of a point light is a standard light bulb.
  49791. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49792. */
  49793. export class PointLight extends ShadowLight {
  49794. private _shadowAngle;
  49795. /**
  49796. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49797. * This specifies what angle the shadow will use to be created.
  49798. *
  49799. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49800. */
  49801. /**
  49802. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49803. * This specifies what angle the shadow will use to be created.
  49804. *
  49805. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49806. */
  49807. shadowAngle: number;
  49808. /**
  49809. * Gets the direction if it has been set.
  49810. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49811. */
  49812. /**
  49813. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49814. */
  49815. direction: Vector3;
  49816. /**
  49817. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49818. * A PointLight emits the light in every direction.
  49819. * It can cast shadows.
  49820. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49821. * ```javascript
  49822. * var pointLight = new PointLight("pl", camera.position, scene);
  49823. * ```
  49824. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49825. * @param name The light friendly name
  49826. * @param position The position of the point light in the scene
  49827. * @param scene The scene the lights belongs to
  49828. */
  49829. constructor(name: string, position: Vector3, scene: Scene);
  49830. /**
  49831. * Returns the string "PointLight"
  49832. * @returns the class name
  49833. */
  49834. getClassName(): string;
  49835. /**
  49836. * Returns the integer 0.
  49837. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49838. */
  49839. getTypeID(): number;
  49840. /**
  49841. * Specifies wether or not the shadowmap should be a cube texture.
  49842. * @returns true if the shadowmap needs to be a cube texture.
  49843. */
  49844. needCube(): boolean;
  49845. /**
  49846. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49847. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49848. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49849. */
  49850. getShadowDirection(faceIndex?: number): Vector3;
  49851. /**
  49852. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49853. * - fov = PI / 2
  49854. * - aspect ratio : 1.0
  49855. * - z-near and far equal to the active camera minZ and maxZ.
  49856. * Returns the PointLight.
  49857. */
  49858. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49859. protected _buildUniformLayout(): void;
  49860. /**
  49861. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49862. * @param effect The effect to update
  49863. * @param lightIndex The index of the light in the effect to update
  49864. * @returns The point light
  49865. */
  49866. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49867. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49868. /**
  49869. * Prepares the list of defines specific to the light type.
  49870. * @param defines the list of defines
  49871. * @param lightIndex defines the index of the light for the effect
  49872. */
  49873. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49874. }
  49875. }
  49876. declare module BABYLON {
  49877. /**
  49878. * Header information of HDR texture files.
  49879. */
  49880. export interface HDRInfo {
  49881. /**
  49882. * The height of the texture in pixels.
  49883. */
  49884. height: number;
  49885. /**
  49886. * The width of the texture in pixels.
  49887. */
  49888. width: number;
  49889. /**
  49890. * The index of the beginning of the data in the binary file.
  49891. */
  49892. dataPosition: number;
  49893. }
  49894. /**
  49895. * This groups tools to convert HDR texture to native colors array.
  49896. */
  49897. export class HDRTools {
  49898. private static Ldexp;
  49899. private static Rgbe2float;
  49900. private static readStringLine;
  49901. /**
  49902. * Reads header information from an RGBE texture stored in a native array.
  49903. * More information on this format are available here:
  49904. * https://en.wikipedia.org/wiki/RGBE_image_format
  49905. *
  49906. * @param uint8array The binary file stored in native array.
  49907. * @return The header information.
  49908. */
  49909. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49910. /**
  49911. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49912. * This RGBE texture needs to store the information as a panorama.
  49913. *
  49914. * More information on this format are available here:
  49915. * https://en.wikipedia.org/wiki/RGBE_image_format
  49916. *
  49917. * @param buffer The binary file stored in an array buffer.
  49918. * @param size The expected size of the extracted cubemap.
  49919. * @return The Cube Map information.
  49920. */
  49921. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49922. /**
  49923. * Returns the pixels data extracted from an RGBE texture.
  49924. * This pixels will be stored left to right up to down in the R G B order in one array.
  49925. *
  49926. * More information on this format are available here:
  49927. * https://en.wikipedia.org/wiki/RGBE_image_format
  49928. *
  49929. * @param uint8array The binary file stored in an array buffer.
  49930. * @param hdrInfo The header information of the file.
  49931. * @return The pixels data in RGB right to left up to down order.
  49932. */
  49933. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49934. private static RGBE_ReadPixels_RLE;
  49935. }
  49936. }
  49937. declare module BABYLON {
  49938. /**
  49939. * This represents a texture coming from an HDR input.
  49940. *
  49941. * The only supported format is currently panorama picture stored in RGBE format.
  49942. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49943. */
  49944. export class HDRCubeTexture extends BaseTexture {
  49945. private static _facesMapping;
  49946. private _generateHarmonics;
  49947. private _noMipmap;
  49948. private _textureMatrix;
  49949. private _size;
  49950. private _onLoad;
  49951. private _onError;
  49952. /**
  49953. * The texture URL.
  49954. */
  49955. url: string;
  49956. /**
  49957. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49958. */
  49959. coordinatesMode: number;
  49960. protected _isBlocking: boolean;
  49961. /**
  49962. * Sets wether or not the texture is blocking during loading.
  49963. */
  49964. /**
  49965. * Gets wether or not the texture is blocking during loading.
  49966. */
  49967. isBlocking: boolean;
  49968. protected _rotationY: number;
  49969. /**
  49970. * Sets texture matrix rotation angle around Y axis in radians.
  49971. */
  49972. /**
  49973. * Gets texture matrix rotation angle around Y axis radians.
  49974. */
  49975. rotationY: number;
  49976. /**
  49977. * Gets or sets the center of the bounding box associated with the cube texture
  49978. * It must define where the camera used to render the texture was set
  49979. */
  49980. boundingBoxPosition: Vector3;
  49981. private _boundingBoxSize;
  49982. /**
  49983. * Gets or sets the size of the bounding box associated with the cube texture
  49984. * When defined, the cubemap will switch to local mode
  49985. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49986. * @example https://www.babylonjs-playground.com/#RNASML
  49987. */
  49988. boundingBoxSize: Vector3;
  49989. /**
  49990. * Instantiates an HDRTexture from the following parameters.
  49991. *
  49992. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49993. * @param scene The scene the texture will be used in
  49994. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49995. * @param noMipmap Forces to not generate the mipmap if true
  49996. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49997. * @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)
  49998. * @param reserved Reserved flag for internal use.
  49999. */
  50000. 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>);
  50001. /**
  50002. * Get the current class name of the texture useful for serialization or dynamic coding.
  50003. * @returns "HDRCubeTexture"
  50004. */
  50005. getClassName(): string;
  50006. /**
  50007. * Occurs when the file is raw .hdr file.
  50008. */
  50009. private loadTexture;
  50010. clone(): HDRCubeTexture;
  50011. delayLoad(): void;
  50012. /**
  50013. * Get the texture reflection matrix used to rotate/transform the reflection.
  50014. * @returns the reflection matrix
  50015. */
  50016. getReflectionTextureMatrix(): Matrix;
  50017. /**
  50018. * Set the texture reflection matrix used to rotate/transform the reflection.
  50019. * @param value Define the reflection matrix to set
  50020. */
  50021. setReflectionTextureMatrix(value: Matrix): void;
  50022. /**
  50023. * Parses a JSON representation of an HDR Texture in order to create the texture
  50024. * @param parsedTexture Define the JSON representation
  50025. * @param scene Define the scene the texture should be created in
  50026. * @param rootUrl Define the root url in case we need to load relative dependencies
  50027. * @returns the newly created texture after parsing
  50028. */
  50029. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50030. serialize(): any;
  50031. }
  50032. }
  50033. declare module BABYLON {
  50034. /**
  50035. * Class used to control physics engine
  50036. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50037. */
  50038. export class PhysicsEngine implements IPhysicsEngine {
  50039. private _physicsPlugin;
  50040. /**
  50041. * Global value used to control the smallest number supported by the simulation
  50042. */
  50043. static Epsilon: number;
  50044. private _impostors;
  50045. private _joints;
  50046. /**
  50047. * Gets the gravity vector used by the simulation
  50048. */
  50049. gravity: Vector3;
  50050. /**
  50051. * Factory used to create the default physics plugin.
  50052. * @returns The default physics plugin
  50053. */
  50054. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50055. /**
  50056. * Creates a new Physics Engine
  50057. * @param gravity defines the gravity vector used by the simulation
  50058. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50059. */
  50060. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50061. /**
  50062. * Sets the gravity vector used by the simulation
  50063. * @param gravity defines the gravity vector to use
  50064. */
  50065. setGravity(gravity: Vector3): void;
  50066. /**
  50067. * Set the time step of the physics engine.
  50068. * Default is 1/60.
  50069. * To slow it down, enter 1/600 for example.
  50070. * To speed it up, 1/30
  50071. * @param newTimeStep defines the new timestep to apply to this world.
  50072. */
  50073. setTimeStep(newTimeStep?: number): void;
  50074. /**
  50075. * Get the time step of the physics engine.
  50076. * @returns the current time step
  50077. */
  50078. getTimeStep(): number;
  50079. /**
  50080. * Release all resources
  50081. */
  50082. dispose(): void;
  50083. /**
  50084. * Gets the name of the current physics plugin
  50085. * @returns the name of the plugin
  50086. */
  50087. getPhysicsPluginName(): string;
  50088. /**
  50089. * Adding a new impostor for the impostor tracking.
  50090. * This will be done by the impostor itself.
  50091. * @param impostor the impostor to add
  50092. */
  50093. addImpostor(impostor: PhysicsImpostor): void;
  50094. /**
  50095. * Remove an impostor from the engine.
  50096. * This impostor and its mesh will not longer be updated by the physics engine.
  50097. * @param impostor the impostor to remove
  50098. */
  50099. removeImpostor(impostor: PhysicsImpostor): void;
  50100. /**
  50101. * Add a joint to the physics engine
  50102. * @param mainImpostor defines the main impostor to which the joint is added.
  50103. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50104. * @param joint defines the joint that will connect both impostors.
  50105. */
  50106. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50107. /**
  50108. * Removes a joint from the simulation
  50109. * @param mainImpostor defines the impostor used with the joint
  50110. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50111. * @param joint defines the joint to remove
  50112. */
  50113. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50114. /**
  50115. * Called by the scene. No need to call it.
  50116. * @param delta defines the timespam between frames
  50117. */ private _step(delta: number): void;
  50118. /**
  50119. * Gets the current plugin used to run the simulation
  50120. * @returns current plugin
  50121. */
  50122. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50123. /**
  50124. * Gets the list of physic impostors
  50125. * @returns an array of PhysicsImpostor
  50126. */
  50127. getImpostors(): Array<PhysicsImpostor>;
  50128. /**
  50129. * Gets the impostor for a physics enabled object
  50130. * @param object defines the object impersonated by the impostor
  50131. * @returns the PhysicsImpostor or null if not found
  50132. */
  50133. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50134. /**
  50135. * Gets the impostor for a physics body object
  50136. * @param body defines physics body used by the impostor
  50137. * @returns the PhysicsImpostor or null if not found
  50138. */
  50139. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50140. /**
  50141. * Does a raycast in the physics world
  50142. * @param from when should the ray start?
  50143. * @param to when should the ray end?
  50144. * @returns PhysicsRaycastResult
  50145. */
  50146. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50147. }
  50148. }
  50149. declare module BABYLON {
  50150. /** @hidden */
  50151. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50152. private _useDeltaForWorldStep;
  50153. world: any;
  50154. name: string;
  50155. private _physicsMaterials;
  50156. private _fixedTimeStep;
  50157. private _cannonRaycastResult;
  50158. private _raycastResult;
  50159. private _physicsBodysToRemoveAfterStep;
  50160. BJSCANNON: any;
  50161. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50162. setGravity(gravity: Vector3): void;
  50163. setTimeStep(timeStep: number): void;
  50164. getTimeStep(): number;
  50165. executeStep(delta: number): void;
  50166. private _removeMarkedPhysicsBodiesFromWorld;
  50167. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50168. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50169. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50170. private _processChildMeshes;
  50171. removePhysicsBody(impostor: PhysicsImpostor): void;
  50172. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50173. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50174. private _addMaterial;
  50175. private _checkWithEpsilon;
  50176. private _createShape;
  50177. private _createHeightmap;
  50178. private _minus90X;
  50179. private _plus90X;
  50180. private _tmpPosition;
  50181. private _tmpDeltaPosition;
  50182. private _tmpUnityRotation;
  50183. private _updatePhysicsBodyTransformation;
  50184. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50185. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50186. isSupported(): boolean;
  50187. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50188. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50189. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50190. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50191. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50192. getBodyMass(impostor: PhysicsImpostor): number;
  50193. getBodyFriction(impostor: PhysicsImpostor): number;
  50194. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50195. getBodyRestitution(impostor: PhysicsImpostor): number;
  50196. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50197. sleepBody(impostor: PhysicsImpostor): void;
  50198. wakeUpBody(impostor: PhysicsImpostor): void;
  50199. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50200. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50201. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50202. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50203. getRadius(impostor: PhysicsImpostor): number;
  50204. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50205. dispose(): void;
  50206. private _extendNamespace;
  50207. /**
  50208. * Does a raycast in the physics world
  50209. * @param from when should the ray start?
  50210. * @param to when should the ray end?
  50211. * @returns PhysicsRaycastResult
  50212. */
  50213. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50214. }
  50215. }
  50216. declare module BABYLON {
  50217. /** @hidden */
  50218. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50219. world: any;
  50220. name: string;
  50221. BJSOIMO: any;
  50222. private _raycastResult;
  50223. constructor(iterations?: number, oimoInjection?: any);
  50224. setGravity(gravity: Vector3): void;
  50225. setTimeStep(timeStep: number): void;
  50226. getTimeStep(): number;
  50227. private _tmpImpostorsArray;
  50228. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50229. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50230. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50231. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50232. private _tmpPositionVector;
  50233. removePhysicsBody(impostor: PhysicsImpostor): void;
  50234. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50235. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50236. isSupported(): boolean;
  50237. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50238. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50239. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50240. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50241. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50242. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50243. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50244. getBodyMass(impostor: PhysicsImpostor): number;
  50245. getBodyFriction(impostor: PhysicsImpostor): number;
  50246. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50247. getBodyRestitution(impostor: PhysicsImpostor): number;
  50248. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50249. sleepBody(impostor: PhysicsImpostor): void;
  50250. wakeUpBody(impostor: PhysicsImpostor): void;
  50251. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50252. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50253. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50254. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50255. getRadius(impostor: PhysicsImpostor): number;
  50256. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50257. dispose(): void;
  50258. /**
  50259. * Does a raycast in the physics world
  50260. * @param from when should the ray start?
  50261. * @param to when should the ray end?
  50262. * @returns PhysicsRaycastResult
  50263. */
  50264. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50265. }
  50266. }
  50267. declare module BABYLON {
  50268. /**
  50269. * Class containing static functions to help procedurally build meshes
  50270. */
  50271. export class RibbonBuilder {
  50272. /**
  50273. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50274. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50275. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50276. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50277. * * 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
  50278. * * 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
  50279. * * 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
  50280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50281. * * 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
  50282. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50283. * * 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
  50284. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50285. * * 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
  50286. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50288. * @param name defines the name of the mesh
  50289. * @param options defines the options used to create the mesh
  50290. * @param scene defines the hosting scene
  50291. * @returns the ribbon mesh
  50292. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50293. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50294. */
  50295. static CreateRibbon(name: string, options: {
  50296. pathArray: Vector3[][];
  50297. closeArray?: boolean;
  50298. closePath?: boolean;
  50299. offset?: number;
  50300. updatable?: boolean;
  50301. sideOrientation?: number;
  50302. frontUVs?: Vector4;
  50303. backUVs?: Vector4;
  50304. instance?: Mesh;
  50305. invertUV?: boolean;
  50306. uvs?: Vector2[];
  50307. colors?: Color4[];
  50308. }, scene?: Nullable<Scene>): Mesh;
  50309. }
  50310. }
  50311. declare module BABYLON {
  50312. /**
  50313. * Class containing static functions to help procedurally build meshes
  50314. */
  50315. export class ShapeBuilder {
  50316. /**
  50317. * 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.
  50318. * * 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.
  50319. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50320. * * 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.
  50321. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50322. * * 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
  50323. * * 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
  50324. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50325. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50326. * * 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
  50327. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50329. * @param name defines the name of the mesh
  50330. * @param options defines the options used to create the mesh
  50331. * @param scene defines the hosting scene
  50332. * @returns the extruded shape mesh
  50333. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50334. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50335. */
  50336. static ExtrudeShape(name: string, options: {
  50337. shape: Vector3[];
  50338. path: Vector3[];
  50339. scale?: number;
  50340. rotation?: number;
  50341. cap?: number;
  50342. updatable?: boolean;
  50343. sideOrientation?: number;
  50344. frontUVs?: Vector4;
  50345. backUVs?: Vector4;
  50346. instance?: Mesh;
  50347. invertUV?: boolean;
  50348. }, scene?: Nullable<Scene>): Mesh;
  50349. /**
  50350. * Creates an custom extruded shape mesh.
  50351. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50352. * * 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.
  50353. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50354. * * 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
  50355. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50356. * * 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
  50357. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50358. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50359. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50360. * * 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
  50361. * * 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
  50362. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50363. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50364. * * 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
  50365. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50367. * @param name defines the name of the mesh
  50368. * @param options defines the options used to create the mesh
  50369. * @param scene defines the hosting scene
  50370. * @returns the custom extruded shape mesh
  50371. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50372. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50373. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50374. */
  50375. static ExtrudeShapeCustom(name: string, options: {
  50376. shape: Vector3[];
  50377. path: Vector3[];
  50378. scaleFunction?: any;
  50379. rotationFunction?: any;
  50380. ribbonCloseArray?: boolean;
  50381. ribbonClosePath?: boolean;
  50382. cap?: number;
  50383. updatable?: boolean;
  50384. sideOrientation?: number;
  50385. frontUVs?: Vector4;
  50386. backUVs?: Vector4;
  50387. instance?: Mesh;
  50388. invertUV?: boolean;
  50389. }, scene?: Nullable<Scene>): Mesh;
  50390. private static _ExtrudeShapeGeneric;
  50391. }
  50392. }
  50393. declare module BABYLON {
  50394. /**
  50395. * AmmoJS Physics plugin
  50396. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50397. * @see https://github.com/kripken/ammo.js/
  50398. */
  50399. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50400. private _useDeltaForWorldStep;
  50401. /**
  50402. * Reference to the Ammo library
  50403. */
  50404. bjsAMMO: any;
  50405. /**
  50406. * Created ammoJS world which physics bodies are added to
  50407. */
  50408. world: any;
  50409. /**
  50410. * Name of the plugin
  50411. */
  50412. name: string;
  50413. private _timeStep;
  50414. private _fixedTimeStep;
  50415. private _maxSteps;
  50416. private _tmpQuaternion;
  50417. private _tmpAmmoTransform;
  50418. private _tmpAmmoQuaternion;
  50419. private _tmpAmmoConcreteContactResultCallback;
  50420. private _collisionConfiguration;
  50421. private _dispatcher;
  50422. private _overlappingPairCache;
  50423. private _solver;
  50424. private _softBodySolver;
  50425. private _tmpAmmoVectorA;
  50426. private _tmpAmmoVectorB;
  50427. private _tmpAmmoVectorC;
  50428. private _tmpAmmoVectorD;
  50429. private _tmpContactCallbackResult;
  50430. private _tmpAmmoVectorRCA;
  50431. private _tmpAmmoVectorRCB;
  50432. private _raycastResult;
  50433. private static readonly DISABLE_COLLISION_FLAG;
  50434. private static readonly KINEMATIC_FLAG;
  50435. private static readonly DISABLE_DEACTIVATION_FLAG;
  50436. /**
  50437. * Initializes the ammoJS plugin
  50438. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50439. * @param ammoInjection can be used to inject your own ammo reference
  50440. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  50441. */
  50442. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  50443. /**
  50444. * Sets the gravity of the physics world (m/(s^2))
  50445. * @param gravity Gravity to set
  50446. */
  50447. setGravity(gravity: Vector3): void;
  50448. /**
  50449. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50450. * @param timeStep timestep to use in seconds
  50451. */
  50452. setTimeStep(timeStep: number): void;
  50453. /**
  50454. * 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)
  50455. * @param fixedTimeStep fixedTimeStep to use in seconds
  50456. */
  50457. setFixedTimeStep(fixedTimeStep: number): void;
  50458. /**
  50459. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50460. * @param maxSteps the maximum number of steps by the physics engine per frame
  50461. */
  50462. setMaxSteps(maxSteps: number): void;
  50463. /**
  50464. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50465. * @returns the current timestep in seconds
  50466. */
  50467. getTimeStep(): number;
  50468. private _isImpostorInContact;
  50469. private _isImpostorPairInContact;
  50470. private _stepSimulation;
  50471. /**
  50472. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50473. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50474. * After the step the babylon meshes are set to the position of the physics imposters
  50475. * @param delta amount of time to step forward
  50476. * @param impostors array of imposters to update before/after the step
  50477. */
  50478. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50479. /**
  50480. * Update babylon mesh to match physics world object
  50481. * @param impostor imposter to match
  50482. */
  50483. private _afterSoftStep;
  50484. /**
  50485. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50486. * @param impostor imposter to match
  50487. */
  50488. private _ropeStep;
  50489. /**
  50490. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50491. * @param impostor imposter to match
  50492. */
  50493. private _softbodyOrClothStep;
  50494. private _tmpVector;
  50495. private _tmpMatrix;
  50496. /**
  50497. * Applies an impulse on the imposter
  50498. * @param impostor imposter to apply impulse to
  50499. * @param force amount of force to be applied to the imposter
  50500. * @param contactPoint the location to apply the impulse on the imposter
  50501. */
  50502. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50503. /**
  50504. * Applies a force on the imposter
  50505. * @param impostor imposter to apply force
  50506. * @param force amount of force to be applied to the imposter
  50507. * @param contactPoint the location to apply the force on the imposter
  50508. */
  50509. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50510. /**
  50511. * Creates a physics body using the plugin
  50512. * @param impostor the imposter to create the physics body on
  50513. */
  50514. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50515. /**
  50516. * Removes the physics body from the imposter and disposes of the body's memory
  50517. * @param impostor imposter to remove the physics body from
  50518. */
  50519. removePhysicsBody(impostor: PhysicsImpostor): void;
  50520. /**
  50521. * Generates a joint
  50522. * @param impostorJoint the imposter joint to create the joint with
  50523. */
  50524. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50525. /**
  50526. * Removes a joint
  50527. * @param impostorJoint the imposter joint to remove the joint from
  50528. */
  50529. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50530. private _addMeshVerts;
  50531. /**
  50532. * Initialise the soft body vertices to match its object's (mesh) vertices
  50533. * Softbody vertices (nodes) are in world space and to match this
  50534. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50535. * @param impostor to create the softbody for
  50536. */
  50537. private _softVertexData;
  50538. /**
  50539. * Create an impostor's soft body
  50540. * @param impostor to create the softbody for
  50541. */
  50542. private _createSoftbody;
  50543. /**
  50544. * Create cloth for an impostor
  50545. * @param impostor to create the softbody for
  50546. */
  50547. private _createCloth;
  50548. /**
  50549. * Create rope for an impostor
  50550. * @param impostor to create the softbody for
  50551. */
  50552. private _createRope;
  50553. private _addHullVerts;
  50554. private _createShape;
  50555. /**
  50556. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50557. * @param impostor imposter containing the physics body and babylon object
  50558. */
  50559. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50560. /**
  50561. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50562. * @param impostor imposter containing the physics body and babylon object
  50563. * @param newPosition new position
  50564. * @param newRotation new rotation
  50565. */
  50566. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50567. /**
  50568. * If this plugin is supported
  50569. * @returns true if its supported
  50570. */
  50571. isSupported(): boolean;
  50572. /**
  50573. * Sets the linear velocity of the physics body
  50574. * @param impostor imposter to set the velocity on
  50575. * @param velocity velocity to set
  50576. */
  50577. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50578. /**
  50579. * Sets the angular velocity of the physics body
  50580. * @param impostor imposter to set the velocity on
  50581. * @param velocity velocity to set
  50582. */
  50583. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50584. /**
  50585. * gets the linear velocity
  50586. * @param impostor imposter to get linear velocity from
  50587. * @returns linear velocity
  50588. */
  50589. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50590. /**
  50591. * gets the angular velocity
  50592. * @param impostor imposter to get angular velocity from
  50593. * @returns angular velocity
  50594. */
  50595. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50596. /**
  50597. * Sets the mass of physics body
  50598. * @param impostor imposter to set the mass on
  50599. * @param mass mass to set
  50600. */
  50601. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50602. /**
  50603. * Gets the mass of the physics body
  50604. * @param impostor imposter to get the mass from
  50605. * @returns mass
  50606. */
  50607. getBodyMass(impostor: PhysicsImpostor): number;
  50608. /**
  50609. * Gets friction of the impostor
  50610. * @param impostor impostor to get friction from
  50611. * @returns friction value
  50612. */
  50613. getBodyFriction(impostor: PhysicsImpostor): number;
  50614. /**
  50615. * Sets friction of the impostor
  50616. * @param impostor impostor to set friction on
  50617. * @param friction friction value
  50618. */
  50619. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50620. /**
  50621. * Gets restitution of the impostor
  50622. * @param impostor impostor to get restitution from
  50623. * @returns restitution value
  50624. */
  50625. getBodyRestitution(impostor: PhysicsImpostor): number;
  50626. /**
  50627. * Sets resitution of the impostor
  50628. * @param impostor impostor to set resitution on
  50629. * @param restitution resitution value
  50630. */
  50631. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50632. /**
  50633. * Gets pressure inside the impostor
  50634. * @param impostor impostor to get pressure from
  50635. * @returns pressure value
  50636. */
  50637. getBodyPressure(impostor: PhysicsImpostor): number;
  50638. /**
  50639. * Sets pressure inside a soft body impostor
  50640. * Cloth and rope must remain 0 pressure
  50641. * @param impostor impostor to set pressure on
  50642. * @param pressure pressure value
  50643. */
  50644. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50645. /**
  50646. * Gets stiffness of the impostor
  50647. * @param impostor impostor to get stiffness from
  50648. * @returns pressure value
  50649. */
  50650. getBodyStiffness(impostor: PhysicsImpostor): number;
  50651. /**
  50652. * Sets stiffness of the impostor
  50653. * @param impostor impostor to set stiffness on
  50654. * @param stiffness stiffness value from 0 to 1
  50655. */
  50656. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50657. /**
  50658. * Gets velocityIterations of the impostor
  50659. * @param impostor impostor to get velocity iterations from
  50660. * @returns velocityIterations value
  50661. */
  50662. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50663. /**
  50664. * Sets velocityIterations of the impostor
  50665. * @param impostor impostor to set velocity iterations on
  50666. * @param velocityIterations velocityIterations value
  50667. */
  50668. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50669. /**
  50670. * Gets positionIterations of the impostor
  50671. * @param impostor impostor to get position iterations from
  50672. * @returns positionIterations value
  50673. */
  50674. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50675. /**
  50676. * Sets positionIterations of the impostor
  50677. * @param impostor impostor to set position on
  50678. * @param positionIterations positionIterations value
  50679. */
  50680. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50681. /**
  50682. * Append an anchor to a cloth object
  50683. * @param impostor is the cloth impostor to add anchor to
  50684. * @param otherImpostor is the rigid impostor to anchor to
  50685. * @param width ratio across width from 0 to 1
  50686. * @param height ratio up height from 0 to 1
  50687. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50688. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50689. */
  50690. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50691. /**
  50692. * Append an hook to a rope object
  50693. * @param impostor is the rope impostor to add hook to
  50694. * @param otherImpostor is the rigid impostor to hook to
  50695. * @param length ratio along the rope from 0 to 1
  50696. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50697. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50698. */
  50699. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50700. /**
  50701. * Sleeps the physics body and stops it from being active
  50702. * @param impostor impostor to sleep
  50703. */
  50704. sleepBody(impostor: PhysicsImpostor): void;
  50705. /**
  50706. * Activates the physics body
  50707. * @param impostor impostor to activate
  50708. */
  50709. wakeUpBody(impostor: PhysicsImpostor): void;
  50710. /**
  50711. * Updates the distance parameters of the joint
  50712. * @param joint joint to update
  50713. * @param maxDistance maximum distance of the joint
  50714. * @param minDistance minimum distance of the joint
  50715. */
  50716. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50717. /**
  50718. * Sets a motor on the joint
  50719. * @param joint joint to set motor on
  50720. * @param speed speed of the motor
  50721. * @param maxForce maximum force of the motor
  50722. * @param motorIndex index of the motor
  50723. */
  50724. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50725. /**
  50726. * Sets the motors limit
  50727. * @param joint joint to set limit on
  50728. * @param upperLimit upper limit
  50729. * @param lowerLimit lower limit
  50730. */
  50731. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50732. /**
  50733. * Syncs the position and rotation of a mesh with the impostor
  50734. * @param mesh mesh to sync
  50735. * @param impostor impostor to update the mesh with
  50736. */
  50737. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50738. /**
  50739. * Gets the radius of the impostor
  50740. * @param impostor impostor to get radius from
  50741. * @returns the radius
  50742. */
  50743. getRadius(impostor: PhysicsImpostor): number;
  50744. /**
  50745. * Gets the box size of the impostor
  50746. * @param impostor impostor to get box size from
  50747. * @param result the resulting box size
  50748. */
  50749. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50750. /**
  50751. * Disposes of the impostor
  50752. */
  50753. dispose(): void;
  50754. /**
  50755. * Does a raycast in the physics world
  50756. * @param from when should the ray start?
  50757. * @param to when should the ray end?
  50758. * @returns PhysicsRaycastResult
  50759. */
  50760. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50761. }
  50762. }
  50763. declare module BABYLON {
  50764. interface AbstractScene {
  50765. /**
  50766. * The list of reflection probes added to the scene
  50767. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50768. */
  50769. reflectionProbes: Array<ReflectionProbe>;
  50770. /**
  50771. * Removes the given reflection probe from this scene.
  50772. * @param toRemove The reflection probe to remove
  50773. * @returns The index of the removed reflection probe
  50774. */
  50775. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50776. /**
  50777. * Adds the given reflection probe to this scene.
  50778. * @param newReflectionProbe The reflection probe to add
  50779. */
  50780. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50781. }
  50782. /**
  50783. * Class used to generate realtime reflection / refraction cube textures
  50784. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50785. */
  50786. export class ReflectionProbe {
  50787. /** defines the name of the probe */
  50788. name: string;
  50789. private _scene;
  50790. private _renderTargetTexture;
  50791. private _projectionMatrix;
  50792. private _viewMatrix;
  50793. private _target;
  50794. private _add;
  50795. private _attachedMesh;
  50796. private _invertYAxis;
  50797. /** Gets or sets probe position (center of the cube map) */
  50798. position: Vector3;
  50799. /**
  50800. * Creates a new reflection probe
  50801. * @param name defines the name of the probe
  50802. * @param size defines the texture resolution (for each face)
  50803. * @param scene defines the hosting scene
  50804. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50805. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50806. */
  50807. constructor(
  50808. /** defines the name of the probe */
  50809. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50810. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50811. samples: number;
  50812. /** Gets or sets the refresh rate to use (on every frame by default) */
  50813. refreshRate: number;
  50814. /**
  50815. * Gets the hosting scene
  50816. * @returns a Scene
  50817. */
  50818. getScene(): Scene;
  50819. /** Gets the internal CubeTexture used to render to */
  50820. readonly cubeTexture: RenderTargetTexture;
  50821. /** Gets the list of meshes to render */
  50822. readonly renderList: Nullable<AbstractMesh[]>;
  50823. /**
  50824. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50825. * @param mesh defines the mesh to attach to
  50826. */
  50827. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50828. /**
  50829. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50830. * @param renderingGroupId The rendering group id corresponding to its index
  50831. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50832. */
  50833. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50834. /**
  50835. * Clean all associated resources
  50836. */
  50837. dispose(): void;
  50838. /**
  50839. * Converts the reflection probe information to a readable string for debug purpose.
  50840. * @param fullDetails Supports for multiple levels of logging within scene loading
  50841. * @returns the human readable reflection probe info
  50842. */
  50843. toString(fullDetails?: boolean): string;
  50844. /**
  50845. * Get the class name of the relfection probe.
  50846. * @returns "ReflectionProbe"
  50847. */
  50848. getClassName(): string;
  50849. /**
  50850. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50851. * @returns The JSON representation of the texture
  50852. */
  50853. serialize(): any;
  50854. /**
  50855. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50856. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50857. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50858. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50859. * @returns The parsed reflection probe if successful
  50860. */
  50861. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50862. }
  50863. }
  50864. declare module BABYLON {
  50865. /** @hidden */
  50866. export var _BabylonLoaderRegistered: boolean;
  50867. }
  50868. declare module BABYLON {
  50869. /**
  50870. * The Physically based simple base material of BJS.
  50871. *
  50872. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50873. * It is used as the base class for both the specGloss and metalRough conventions.
  50874. */
  50875. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50876. /**
  50877. * Number of Simultaneous lights allowed on the material.
  50878. */
  50879. maxSimultaneousLights: number;
  50880. /**
  50881. * If sets to true, disables all the lights affecting the material.
  50882. */
  50883. disableLighting: boolean;
  50884. /**
  50885. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50886. */
  50887. environmentTexture: BaseTexture;
  50888. /**
  50889. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50890. */
  50891. invertNormalMapX: boolean;
  50892. /**
  50893. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50894. */
  50895. invertNormalMapY: boolean;
  50896. /**
  50897. * Normal map used in the model.
  50898. */
  50899. normalTexture: BaseTexture;
  50900. /**
  50901. * Emissivie color used to self-illuminate the model.
  50902. */
  50903. emissiveColor: Color3;
  50904. /**
  50905. * Emissivie texture used to self-illuminate the model.
  50906. */
  50907. emissiveTexture: BaseTexture;
  50908. /**
  50909. * Occlusion Channel Strenght.
  50910. */
  50911. occlusionStrength: number;
  50912. /**
  50913. * Occlusion Texture of the material (adding extra occlusion effects).
  50914. */
  50915. occlusionTexture: BaseTexture;
  50916. /**
  50917. * Defines the alpha limits in alpha test mode.
  50918. */
  50919. alphaCutOff: number;
  50920. /**
  50921. * Gets the current double sided mode.
  50922. */
  50923. /**
  50924. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50925. */
  50926. doubleSided: boolean;
  50927. /**
  50928. * Stores the pre-calculated light information of a mesh in a texture.
  50929. */
  50930. lightmapTexture: BaseTexture;
  50931. /**
  50932. * If true, the light map contains occlusion information instead of lighting info.
  50933. */
  50934. useLightmapAsShadowmap: boolean;
  50935. /**
  50936. * Instantiates a new PBRMaterial instance.
  50937. *
  50938. * @param name The material name
  50939. * @param scene The scene the material will be use in.
  50940. */
  50941. constructor(name: string, scene: Scene);
  50942. getClassName(): string;
  50943. }
  50944. }
  50945. declare module BABYLON {
  50946. /**
  50947. * The PBR material of BJS following the metal roughness convention.
  50948. *
  50949. * This fits to the PBR convention in the GLTF definition:
  50950. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50951. */
  50952. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50953. /**
  50954. * The base color has two different interpretations depending on the value of metalness.
  50955. * When the material is a metal, the base color is the specific measured reflectance value
  50956. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50957. * of the material.
  50958. */
  50959. baseColor: Color3;
  50960. /**
  50961. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50962. * well as opacity information in the alpha channel.
  50963. */
  50964. baseTexture: BaseTexture;
  50965. /**
  50966. * Specifies the metallic scalar value of the material.
  50967. * Can also be used to scale the metalness values of the metallic texture.
  50968. */
  50969. metallic: number;
  50970. /**
  50971. * Specifies the roughness scalar value of the material.
  50972. * Can also be used to scale the roughness values of the metallic texture.
  50973. */
  50974. roughness: number;
  50975. /**
  50976. * Texture containing both the metallic value in the B channel and the
  50977. * roughness value in the G channel to keep better precision.
  50978. */
  50979. metallicRoughnessTexture: BaseTexture;
  50980. /**
  50981. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50982. *
  50983. * @param name The material name
  50984. * @param scene The scene the material will be use in.
  50985. */
  50986. constructor(name: string, scene: Scene);
  50987. /**
  50988. * Return the currrent class name of the material.
  50989. */
  50990. getClassName(): string;
  50991. /**
  50992. * Makes a duplicate of the current material.
  50993. * @param name - name to use for the new material.
  50994. */
  50995. clone(name: string): PBRMetallicRoughnessMaterial;
  50996. /**
  50997. * Serialize the material to a parsable JSON object.
  50998. */
  50999. serialize(): any;
  51000. /**
  51001. * Parses a JSON object correponding to the serialize function.
  51002. */
  51003. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51004. }
  51005. }
  51006. declare module BABYLON {
  51007. /**
  51008. * The PBR material of BJS following the specular glossiness convention.
  51009. *
  51010. * This fits to the PBR convention in the GLTF definition:
  51011. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51012. */
  51013. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51014. /**
  51015. * Specifies the diffuse color of the material.
  51016. */
  51017. diffuseColor: Color3;
  51018. /**
  51019. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51020. * channel.
  51021. */
  51022. diffuseTexture: BaseTexture;
  51023. /**
  51024. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51025. */
  51026. specularColor: Color3;
  51027. /**
  51028. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51029. */
  51030. glossiness: number;
  51031. /**
  51032. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51033. */
  51034. specularGlossinessTexture: BaseTexture;
  51035. /**
  51036. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51037. *
  51038. * @param name The material name
  51039. * @param scene The scene the material will be use in.
  51040. */
  51041. constructor(name: string, scene: Scene);
  51042. /**
  51043. * Return the currrent class name of the material.
  51044. */
  51045. getClassName(): string;
  51046. /**
  51047. * Makes a duplicate of the current material.
  51048. * @param name - name to use for the new material.
  51049. */
  51050. clone(name: string): PBRSpecularGlossinessMaterial;
  51051. /**
  51052. * Serialize the material to a parsable JSON object.
  51053. */
  51054. serialize(): any;
  51055. /**
  51056. * Parses a JSON object correponding to the serialize function.
  51057. */
  51058. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51059. }
  51060. }
  51061. declare module BABYLON {
  51062. /**
  51063. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51064. * It can help converting any input color in a desired output one. This can then be used to create effects
  51065. * from sepia, black and white to sixties or futuristic rendering...
  51066. *
  51067. * The only supported format is currently 3dl.
  51068. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51069. */
  51070. export class ColorGradingTexture extends BaseTexture {
  51071. /**
  51072. * The current texture matrix. (will always be identity in color grading texture)
  51073. */
  51074. private _textureMatrix;
  51075. /**
  51076. * The texture URL.
  51077. */
  51078. url: string;
  51079. /**
  51080. * Empty line regex stored for GC.
  51081. */
  51082. private static _noneEmptyLineRegex;
  51083. private _engine;
  51084. /**
  51085. * Instantiates a ColorGradingTexture from the following parameters.
  51086. *
  51087. * @param url The location of the color gradind data (currently only supporting 3dl)
  51088. * @param scene The scene the texture will be used in
  51089. */
  51090. constructor(url: string, scene: Scene);
  51091. /**
  51092. * Returns the texture matrix used in most of the material.
  51093. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51094. */
  51095. getTextureMatrix(): Matrix;
  51096. /**
  51097. * Occurs when the file being loaded is a .3dl LUT file.
  51098. */
  51099. private load3dlTexture;
  51100. /**
  51101. * Starts the loading process of the texture.
  51102. */
  51103. private loadTexture;
  51104. /**
  51105. * Clones the color gradind texture.
  51106. */
  51107. clone(): ColorGradingTexture;
  51108. /**
  51109. * Called during delayed load for textures.
  51110. */
  51111. delayLoad(): void;
  51112. /**
  51113. * Parses a color grading texture serialized by Babylon.
  51114. * @param parsedTexture The texture information being parsedTexture
  51115. * @param scene The scene to load the texture in
  51116. * @param rootUrl The root url of the data assets to load
  51117. * @return A color gradind texture
  51118. */
  51119. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51120. /**
  51121. * Serializes the LUT texture to json format.
  51122. */
  51123. serialize(): any;
  51124. }
  51125. }
  51126. declare module BABYLON {
  51127. /**
  51128. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51129. */
  51130. export class EquiRectangularCubeTexture extends BaseTexture {
  51131. /** The six faces of the cube. */
  51132. private static _FacesMapping;
  51133. private _noMipmap;
  51134. private _onLoad;
  51135. private _onError;
  51136. /** The size of the cubemap. */
  51137. private _size;
  51138. /** The buffer of the image. */
  51139. private _buffer;
  51140. /** The width of the input image. */
  51141. private _width;
  51142. /** The height of the input image. */
  51143. private _height;
  51144. /** The URL to the image. */
  51145. url: string;
  51146. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51147. coordinatesMode: number;
  51148. /**
  51149. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51150. * @param url The location of the image
  51151. * @param scene The scene the texture will be used in
  51152. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51153. * @param noMipmap Forces to not generate the mipmap if true
  51154. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51155. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51156. * @param onLoad — defines a callback called when texture is loaded
  51157. * @param onError — defines a callback called if there is an error
  51158. */
  51159. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51160. /**
  51161. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51162. */
  51163. private loadImage;
  51164. /**
  51165. * Convert the image buffer into a cubemap and create a CubeTexture.
  51166. */
  51167. private loadTexture;
  51168. /**
  51169. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51170. * @param buffer The ArrayBuffer that should be converted.
  51171. * @returns The buffer as Float32Array.
  51172. */
  51173. private getFloat32ArrayFromArrayBuffer;
  51174. /**
  51175. * Get the current class name of the texture useful for serialization or dynamic coding.
  51176. * @returns "EquiRectangularCubeTexture"
  51177. */
  51178. getClassName(): string;
  51179. /**
  51180. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51181. * @returns A clone of the current EquiRectangularCubeTexture.
  51182. */
  51183. clone(): EquiRectangularCubeTexture;
  51184. }
  51185. }
  51186. declare module BABYLON {
  51187. /**
  51188. * Based on jsTGALoader - Javascript loader for TGA file
  51189. * By Vincent Thibault
  51190. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51191. */
  51192. export class TGATools {
  51193. private static _TYPE_INDEXED;
  51194. private static _TYPE_RGB;
  51195. private static _TYPE_GREY;
  51196. private static _TYPE_RLE_INDEXED;
  51197. private static _TYPE_RLE_RGB;
  51198. private static _TYPE_RLE_GREY;
  51199. private static _ORIGIN_MASK;
  51200. private static _ORIGIN_SHIFT;
  51201. private static _ORIGIN_BL;
  51202. private static _ORIGIN_BR;
  51203. private static _ORIGIN_UL;
  51204. private static _ORIGIN_UR;
  51205. /**
  51206. * Gets the header of a TGA file
  51207. * @param data defines the TGA data
  51208. * @returns the header
  51209. */
  51210. static GetTGAHeader(data: Uint8Array): any;
  51211. /**
  51212. * Uploads TGA content to a Babylon Texture
  51213. * @hidden
  51214. */
  51215. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51216. /** @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;
  51217. /** @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;
  51218. /** @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;
  51219. /** @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;
  51220. /** @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;
  51221. /** @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;
  51222. }
  51223. }
  51224. declare module BABYLON {
  51225. /**
  51226. * Implementation of the TGA Texture Loader.
  51227. * @hidden
  51228. */
  51229. export class _TGATextureLoader implements IInternalTextureLoader {
  51230. /**
  51231. * Defines wether the loader supports cascade loading the different faces.
  51232. */
  51233. readonly supportCascades: boolean;
  51234. /**
  51235. * This returns if the loader support the current file information.
  51236. * @param extension defines the file extension of the file being loaded
  51237. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51238. * @param fallback defines the fallback internal texture if any
  51239. * @param isBase64 defines whether the texture is encoded as a base64
  51240. * @param isBuffer defines whether the texture data are stored as a buffer
  51241. * @returns true if the loader can load the specified file
  51242. */
  51243. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51244. /**
  51245. * Transform the url before loading if required.
  51246. * @param rootUrl the url of the texture
  51247. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51248. * @returns the transformed texture
  51249. */
  51250. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51251. /**
  51252. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51253. * @param rootUrl the url of the texture
  51254. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51255. * @returns the fallback texture
  51256. */
  51257. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51258. /**
  51259. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51260. * @param data contains the texture data
  51261. * @param texture defines the BabylonJS internal texture
  51262. * @param createPolynomials will be true if polynomials have been requested
  51263. * @param onLoad defines the callback to trigger once the texture is ready
  51264. * @param onError defines the callback to trigger in case of error
  51265. */
  51266. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51267. /**
  51268. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51269. * @param data contains the texture data
  51270. * @param texture defines the BabylonJS internal texture
  51271. * @param callback defines the method to call once ready to upload
  51272. */
  51273. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51274. }
  51275. }
  51276. declare module BABYLON {
  51277. /**
  51278. * Info about the .basis files
  51279. */
  51280. class BasisFileInfo {
  51281. /**
  51282. * If the file has alpha
  51283. */
  51284. hasAlpha: boolean;
  51285. /**
  51286. * Info about each image of the basis file
  51287. */
  51288. images: Array<{
  51289. levels: Array<{
  51290. width: number;
  51291. height: number;
  51292. transcodedPixels: ArrayBufferView;
  51293. }>;
  51294. }>;
  51295. }
  51296. /**
  51297. * Result of transcoding a basis file
  51298. */
  51299. class TranscodeResult {
  51300. /**
  51301. * Info about the .basis file
  51302. */
  51303. fileInfo: BasisFileInfo;
  51304. /**
  51305. * Format to use when loading the file
  51306. */
  51307. format: number;
  51308. }
  51309. /**
  51310. * Configuration options for the Basis transcoder
  51311. */
  51312. export class BasisTranscodeConfiguration {
  51313. /**
  51314. * Supported compression formats used to determine the supported output format of the transcoder
  51315. */
  51316. supportedCompressionFormats?: {
  51317. /**
  51318. * etc1 compression format
  51319. */
  51320. etc1?: boolean;
  51321. /**
  51322. * s3tc compression format
  51323. */
  51324. s3tc?: boolean;
  51325. /**
  51326. * pvrtc compression format
  51327. */
  51328. pvrtc?: boolean;
  51329. /**
  51330. * etc2 compression format
  51331. */
  51332. etc2?: boolean;
  51333. };
  51334. /**
  51335. * If mipmap levels should be loaded for transcoded images (Default: true)
  51336. */
  51337. loadMipmapLevels?: boolean;
  51338. /**
  51339. * Index of a single image to load (Default: all images)
  51340. */
  51341. loadSingleImage?: number;
  51342. }
  51343. /**
  51344. * Used to load .Basis files
  51345. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  51346. */
  51347. export class BasisTools {
  51348. private static _IgnoreSupportedFormats;
  51349. /**
  51350. * URL to use when loading the basis transcoder
  51351. */
  51352. static JSModuleURL: string;
  51353. /**
  51354. * URL to use when loading the wasm module for the transcoder
  51355. */
  51356. static WasmModuleURL: string;
  51357. /**
  51358. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  51359. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  51360. * @returns internal format corresponding to the Basis format
  51361. */
  51362. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  51363. private static _WorkerPromise;
  51364. private static _Worker;
  51365. private static _actionId;
  51366. private static _CreateWorkerAsync;
  51367. /**
  51368. * Transcodes a loaded image file to compressed pixel data
  51369. * @param imageData image data to transcode
  51370. * @param config configuration options for the transcoding
  51371. * @returns a promise resulting in the transcoded image
  51372. */
  51373. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  51374. /**
  51375. * Loads a texture from the transcode result
  51376. * @param texture texture load to
  51377. * @param transcodeResult the result of transcoding the basis file to load from
  51378. */
  51379. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  51380. }
  51381. }
  51382. declare module BABYLON {
  51383. /**
  51384. * Loader for .basis file format
  51385. */
  51386. export class _BasisTextureLoader implements IInternalTextureLoader {
  51387. /**
  51388. * Defines whether the loader supports cascade loading the different faces.
  51389. */
  51390. readonly supportCascades: boolean;
  51391. /**
  51392. * This returns if the loader support the current file information.
  51393. * @param extension defines the file extension of the file being loaded
  51394. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51395. * @param fallback defines the fallback internal texture if any
  51396. * @param isBase64 defines whether the texture is encoded as a base64
  51397. * @param isBuffer defines whether the texture data are stored as a buffer
  51398. * @returns true if the loader can load the specified file
  51399. */
  51400. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51401. /**
  51402. * Transform the url before loading if required.
  51403. * @param rootUrl the url of the texture
  51404. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51405. * @returns the transformed texture
  51406. */
  51407. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51408. /**
  51409. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51410. * @param rootUrl the url of the texture
  51411. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51412. * @returns the fallback texture
  51413. */
  51414. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51415. /**
  51416. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  51417. * @param data contains the texture data
  51418. * @param texture defines the BabylonJS internal texture
  51419. * @param createPolynomials will be true if polynomials have been requested
  51420. * @param onLoad defines the callback to trigger once the texture is ready
  51421. * @param onError defines the callback to trigger in case of error
  51422. */
  51423. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51424. /**
  51425. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51426. * @param data contains the texture data
  51427. * @param texture defines the BabylonJS internal texture
  51428. * @param callback defines the method to call once ready to upload
  51429. */
  51430. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51431. }
  51432. }
  51433. declare module BABYLON {
  51434. /**
  51435. * 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.
  51436. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51437. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51438. */
  51439. export class CustomProceduralTexture extends ProceduralTexture {
  51440. private _animate;
  51441. private _time;
  51442. private _config;
  51443. private _texturePath;
  51444. /**
  51445. * Instantiates a new Custom Procedural Texture.
  51446. * 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.
  51447. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51448. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51449. * @param name Define the name of the texture
  51450. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51451. * @param size Define the size of the texture to create
  51452. * @param scene Define the scene the texture belongs to
  51453. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51454. * @param generateMipMaps Define if the texture should creates mip maps or not
  51455. */
  51456. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51457. private _loadJson;
  51458. /**
  51459. * Is the texture ready to be used ? (rendered at least once)
  51460. * @returns true if ready, otherwise, false.
  51461. */
  51462. isReady(): boolean;
  51463. /**
  51464. * Render the texture to its associated render target.
  51465. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51466. */
  51467. render(useCameraPostProcess?: boolean): void;
  51468. /**
  51469. * Update the list of dependant textures samplers in the shader.
  51470. */
  51471. updateTextures(): void;
  51472. /**
  51473. * Update the uniform values of the procedural texture in the shader.
  51474. */
  51475. updateShaderUniforms(): void;
  51476. /**
  51477. * Define if the texture animates or not.
  51478. */
  51479. animate: boolean;
  51480. }
  51481. }
  51482. declare module BABYLON {
  51483. /** @hidden */
  51484. export var noisePixelShader: {
  51485. name: string;
  51486. shader: string;
  51487. };
  51488. }
  51489. declare module BABYLON {
  51490. /**
  51491. * Class used to generate noise procedural textures
  51492. */
  51493. export class NoiseProceduralTexture extends ProceduralTexture {
  51494. private _time;
  51495. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51496. brightness: number;
  51497. /** Defines the number of octaves to process */
  51498. octaves: number;
  51499. /** Defines the level of persistence (0.8 by default) */
  51500. persistence: number;
  51501. /** Gets or sets animation speed factor (default is 1) */
  51502. animationSpeedFactor: number;
  51503. /**
  51504. * Creates a new NoiseProceduralTexture
  51505. * @param name defines the name fo the texture
  51506. * @param size defines the size of the texture (default is 256)
  51507. * @param scene defines the hosting scene
  51508. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51509. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51510. */
  51511. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51512. private _updateShaderUniforms;
  51513. protected _getDefines(): string;
  51514. /** Generate the current state of the procedural texture */
  51515. render(useCameraPostProcess?: boolean): void;
  51516. /**
  51517. * Serializes this noise procedural texture
  51518. * @returns a serialized noise procedural texture object
  51519. */
  51520. serialize(): any;
  51521. /**
  51522. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51523. * @param parsedTexture defines parsed texture data
  51524. * @param scene defines the current scene
  51525. * @param rootUrl defines the root URL containing noise procedural texture information
  51526. * @returns a parsed NoiseProceduralTexture
  51527. */
  51528. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51529. }
  51530. }
  51531. declare module BABYLON {
  51532. /**
  51533. * Raw cube texture where the raw buffers are passed in
  51534. */
  51535. export class RawCubeTexture extends CubeTexture {
  51536. /**
  51537. * Creates a cube texture where the raw buffers are passed in.
  51538. * @param scene defines the scene the texture is attached to
  51539. * @param data defines the array of data to use to create each face
  51540. * @param size defines the size of the textures
  51541. * @param format defines the format of the data
  51542. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51543. * @param generateMipMaps defines if the engine should generate the mip levels
  51544. * @param invertY defines if data must be stored with Y axis inverted
  51545. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51546. * @param compression defines the compression used (null by default)
  51547. */
  51548. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51549. /**
  51550. * Updates the raw cube texture.
  51551. * @param data defines the data to store
  51552. * @param format defines the data format
  51553. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51554. * @param invertY defines if data must be stored with Y axis inverted
  51555. * @param compression defines the compression used (null by default)
  51556. * @param level defines which level of the texture to update
  51557. */
  51558. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51559. /**
  51560. * Updates a raw cube texture with RGBD encoded data.
  51561. * @param data defines the array of data [mipmap][face] to use to create each face
  51562. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51563. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51564. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51565. * @returns a promsie that resolves when the operation is complete
  51566. */
  51567. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51568. /**
  51569. * Clones the raw cube texture.
  51570. * @return a new cube texture
  51571. */
  51572. clone(): CubeTexture;
  51573. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51574. }
  51575. }
  51576. declare module BABYLON {
  51577. /**
  51578. * Class used to store 3D textures containing user data
  51579. */
  51580. export class RawTexture3D extends Texture {
  51581. /** Gets or sets the texture format to use */
  51582. format: number;
  51583. private _engine;
  51584. /**
  51585. * Create a new RawTexture3D
  51586. * @param data defines the data of the texture
  51587. * @param width defines the width of the texture
  51588. * @param height defines the height of the texture
  51589. * @param depth defines the depth of the texture
  51590. * @param format defines the texture format to use
  51591. * @param scene defines the hosting scene
  51592. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51593. * @param invertY defines if texture must be stored with Y axis inverted
  51594. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51595. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51596. */
  51597. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51598. /** Gets or sets the texture format to use */
  51599. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51600. /**
  51601. * Update the texture with new data
  51602. * @param data defines the data to store in the texture
  51603. */
  51604. update(data: ArrayBufferView): void;
  51605. }
  51606. }
  51607. declare module BABYLON {
  51608. /**
  51609. * Creates a refraction texture used by refraction channel of the standard material.
  51610. * It is like a mirror but to see through a material.
  51611. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51612. */
  51613. export class RefractionTexture extends RenderTargetTexture {
  51614. /**
  51615. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51616. * 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.
  51617. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51618. */
  51619. refractionPlane: Plane;
  51620. /**
  51621. * Define how deep under the surface we should see.
  51622. */
  51623. depth: number;
  51624. /**
  51625. * Creates a refraction texture used by refraction channel of the standard material.
  51626. * It is like a mirror but to see through a material.
  51627. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51628. * @param name Define the texture name
  51629. * @param size Define the size of the underlying texture
  51630. * @param scene Define the scene the refraction belongs to
  51631. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51632. */
  51633. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51634. /**
  51635. * Clone the refraction texture.
  51636. * @returns the cloned texture
  51637. */
  51638. clone(): RefractionTexture;
  51639. /**
  51640. * Serialize the texture to a JSON representation you could use in Parse later on
  51641. * @returns the serialized JSON representation
  51642. */
  51643. serialize(): any;
  51644. }
  51645. }
  51646. declare module BABYLON {
  51647. /**
  51648. * Defines the options related to the creation of an HtmlElementTexture
  51649. */
  51650. export interface IHtmlElementTextureOptions {
  51651. /**
  51652. * Defines wether mip maps should be created or not.
  51653. */
  51654. generateMipMaps?: boolean;
  51655. /**
  51656. * Defines the sampling mode of the texture.
  51657. */
  51658. samplingMode?: number;
  51659. /**
  51660. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51661. */
  51662. engine: Nullable<ThinEngine>;
  51663. /**
  51664. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51665. */
  51666. scene: Nullable<Scene>;
  51667. }
  51668. /**
  51669. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51670. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51671. * is automatically managed.
  51672. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51673. * in your application.
  51674. *
  51675. * As the update is not automatic, you need to call them manually.
  51676. */
  51677. export class HtmlElementTexture extends BaseTexture {
  51678. /**
  51679. * The texture URL.
  51680. */
  51681. element: HTMLVideoElement | HTMLCanvasElement;
  51682. private static readonly DefaultOptions;
  51683. private _textureMatrix;
  51684. private _engine;
  51685. private _isVideo;
  51686. private _generateMipMaps;
  51687. private _samplingMode;
  51688. /**
  51689. * Instantiates a HtmlElementTexture from the following parameters.
  51690. *
  51691. * @param name Defines the name of the texture
  51692. * @param element Defines the video or canvas the texture is filled with
  51693. * @param options Defines the other none mandatory texture creation options
  51694. */
  51695. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51696. private _createInternalTexture;
  51697. /**
  51698. * Returns the texture matrix used in most of the material.
  51699. */
  51700. getTextureMatrix(): Matrix;
  51701. /**
  51702. * Updates the content of the texture.
  51703. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51704. */
  51705. update(invertY?: Nullable<boolean>): void;
  51706. }
  51707. }
  51708. declare module BABYLON {
  51709. /**
  51710. * Enum used to define the target of a block
  51711. */
  51712. export enum NodeMaterialBlockTargets {
  51713. /** Vertex shader */
  51714. Vertex = 1,
  51715. /** Fragment shader */
  51716. Fragment = 2,
  51717. /** Neutral */
  51718. Neutral = 4,
  51719. /** Vertex and Fragment */
  51720. VertexAndFragment = 3
  51721. }
  51722. }
  51723. declare module BABYLON {
  51724. /**
  51725. * Defines the kind of connection point for node based material
  51726. */
  51727. export enum NodeMaterialBlockConnectionPointTypes {
  51728. /** Float */
  51729. Float = 1,
  51730. /** Int */
  51731. Int = 2,
  51732. /** Vector2 */
  51733. Vector2 = 4,
  51734. /** Vector3 */
  51735. Vector3 = 8,
  51736. /** Vector4 */
  51737. Vector4 = 16,
  51738. /** Color3 */
  51739. Color3 = 32,
  51740. /** Color4 */
  51741. Color4 = 64,
  51742. /** Matrix */
  51743. Matrix = 128,
  51744. /** Detect type based on connection */
  51745. AutoDetect = 1024,
  51746. /** Output type that will be defined by input type */
  51747. BasedOnInput = 2048
  51748. }
  51749. }
  51750. declare module BABYLON {
  51751. /**
  51752. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  51753. */
  51754. export enum NodeMaterialBlockConnectionPointMode {
  51755. /** Value is an uniform */
  51756. Uniform = 0,
  51757. /** Value is a mesh attribute */
  51758. Attribute = 1,
  51759. /** Value is a varying between vertex and fragment shaders */
  51760. Varying = 2,
  51761. /** Mode is undefined */
  51762. Undefined = 3
  51763. }
  51764. }
  51765. declare module BABYLON {
  51766. /**
  51767. * Enum used to define system values e.g. values automatically provided by the system
  51768. */
  51769. export enum NodeMaterialSystemValues {
  51770. /** World */
  51771. World = 1,
  51772. /** View */
  51773. View = 2,
  51774. /** Projection */
  51775. Projection = 3,
  51776. /** ViewProjection */
  51777. ViewProjection = 4,
  51778. /** WorldView */
  51779. WorldView = 5,
  51780. /** WorldViewProjection */
  51781. WorldViewProjection = 6,
  51782. /** CameraPosition */
  51783. CameraPosition = 7,
  51784. /** Fog Color */
  51785. FogColor = 8,
  51786. /** Delta time */
  51787. DeltaTime = 9
  51788. }
  51789. }
  51790. declare module BABYLON {
  51791. /**
  51792. * Root class for all node material optimizers
  51793. */
  51794. export class NodeMaterialOptimizer {
  51795. /**
  51796. * Function used to optimize a NodeMaterial graph
  51797. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  51798. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  51799. */
  51800. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  51801. }
  51802. }
  51803. declare module BABYLON {
  51804. /**
  51805. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  51806. */
  51807. export class TransformBlock extends NodeMaterialBlock {
  51808. /**
  51809. * Defines the value to use to complement W value to transform it to a Vector4
  51810. */
  51811. complementW: number;
  51812. /**
  51813. * Defines the value to use to complement z value to transform it to a Vector4
  51814. */
  51815. complementZ: number;
  51816. /**
  51817. * Creates a new TransformBlock
  51818. * @param name defines the block name
  51819. */
  51820. constructor(name: string);
  51821. /**
  51822. * Gets the current class name
  51823. * @returns the class name
  51824. */
  51825. getClassName(): string;
  51826. /**
  51827. * Gets the vector input
  51828. */
  51829. readonly vector: NodeMaterialConnectionPoint;
  51830. /**
  51831. * Gets the output component
  51832. */
  51833. readonly output: NodeMaterialConnectionPoint;
  51834. /**
  51835. * Gets the matrix transform input
  51836. */
  51837. readonly transform: NodeMaterialConnectionPoint;
  51838. protected _buildBlock(state: NodeMaterialBuildState): this;
  51839. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51840. protected _dumpPropertiesCode(): string;
  51841. }
  51842. }
  51843. declare module BABYLON {
  51844. /**
  51845. * Block used to output the vertex position
  51846. */
  51847. export class VertexOutputBlock extends NodeMaterialBlock {
  51848. /**
  51849. * Creates a new VertexOutputBlock
  51850. * @param name defines the block name
  51851. */
  51852. constructor(name: string);
  51853. /**
  51854. * Gets the current class name
  51855. * @returns the class name
  51856. */
  51857. getClassName(): string;
  51858. /**
  51859. * Gets the vector input component
  51860. */
  51861. readonly vector: NodeMaterialConnectionPoint;
  51862. protected _buildBlock(state: NodeMaterialBuildState): this;
  51863. }
  51864. }
  51865. declare module BABYLON {
  51866. /**
  51867. * Block used to output the final color
  51868. */
  51869. export class FragmentOutputBlock extends NodeMaterialBlock {
  51870. /**
  51871. * Create a new FragmentOutputBlock
  51872. * @param name defines the block name
  51873. */
  51874. constructor(name: string);
  51875. /**
  51876. * Gets the current class name
  51877. * @returns the class name
  51878. */
  51879. getClassName(): string;
  51880. /**
  51881. * Gets the rgba input component
  51882. */
  51883. readonly rgba: NodeMaterialConnectionPoint;
  51884. /**
  51885. * Gets the rgb input component
  51886. */
  51887. readonly rgb: NodeMaterialConnectionPoint;
  51888. /**
  51889. * Gets the a input component
  51890. */
  51891. readonly a: NodeMaterialConnectionPoint;
  51892. protected _buildBlock(state: NodeMaterialBuildState): this;
  51893. }
  51894. }
  51895. declare module BABYLON {
  51896. /**
  51897. * Block used to read a reflection texture from a sampler
  51898. */
  51899. export class ReflectionTextureBlock extends NodeMaterialBlock {
  51900. private _define3DName;
  51901. private _defineCubicName;
  51902. private _defineExplicitName;
  51903. private _defineProjectionName;
  51904. private _defineLocalCubicName;
  51905. private _defineSphericalName;
  51906. private _definePlanarName;
  51907. private _defineEquirectangularName;
  51908. private _defineMirroredEquirectangularFixedName;
  51909. private _defineEquirectangularFixedName;
  51910. private _defineSkyboxName;
  51911. private _cubeSamplerName;
  51912. private _2DSamplerName;
  51913. private _positionUVWName;
  51914. private _directionWName;
  51915. private _reflectionCoordsName;
  51916. private _reflection2DCoordsName;
  51917. private _reflectionColorName;
  51918. private _reflectionMatrixName;
  51919. /**
  51920. * Gets or sets the texture associated with the node
  51921. */
  51922. texture: Nullable<BaseTexture>;
  51923. /**
  51924. * Create a new TextureBlock
  51925. * @param name defines the block name
  51926. */
  51927. constructor(name: string);
  51928. /**
  51929. * Gets the current class name
  51930. * @returns the class name
  51931. */
  51932. getClassName(): string;
  51933. /**
  51934. * Gets the world position input component
  51935. */
  51936. readonly position: NodeMaterialConnectionPoint;
  51937. /**
  51938. * Gets the world position input component
  51939. */
  51940. readonly worldPosition: NodeMaterialConnectionPoint;
  51941. /**
  51942. * Gets the world normal input component
  51943. */
  51944. readonly worldNormal: NodeMaterialConnectionPoint;
  51945. /**
  51946. * Gets the world input component
  51947. */
  51948. readonly world: NodeMaterialConnectionPoint;
  51949. /**
  51950. * Gets the camera (or eye) position component
  51951. */
  51952. readonly cameraPosition: NodeMaterialConnectionPoint;
  51953. /**
  51954. * Gets the view input component
  51955. */
  51956. readonly view: NodeMaterialConnectionPoint;
  51957. /**
  51958. * Gets the rgb output component
  51959. */
  51960. readonly rgb: NodeMaterialConnectionPoint;
  51961. /**
  51962. * Gets the r output component
  51963. */
  51964. readonly r: NodeMaterialConnectionPoint;
  51965. /**
  51966. * Gets the g output component
  51967. */
  51968. readonly g: NodeMaterialConnectionPoint;
  51969. /**
  51970. * Gets the b output component
  51971. */
  51972. readonly b: NodeMaterialConnectionPoint;
  51973. autoConfigure(material: NodeMaterial): void;
  51974. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51975. isReady(): boolean;
  51976. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51977. private _injectVertexCode;
  51978. private _writeOutput;
  51979. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51980. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51981. }
  51982. }
  51983. declare module BABYLON {
  51984. /**
  51985. * Interface used to configure the node material editor
  51986. */
  51987. export interface INodeMaterialEditorOptions {
  51988. /** Define the URl to load node editor script */
  51989. editorURL?: string;
  51990. }
  51991. /** @hidden */
  51992. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  51993. /** BONES */
  51994. NUM_BONE_INFLUENCERS: number;
  51995. BonesPerMesh: number;
  51996. BONETEXTURE: boolean;
  51997. /** MORPH TARGETS */
  51998. MORPHTARGETS: boolean;
  51999. MORPHTARGETS_NORMAL: boolean;
  52000. MORPHTARGETS_TANGENT: boolean;
  52001. MORPHTARGETS_UV: boolean;
  52002. NUM_MORPH_INFLUENCERS: number;
  52003. /** IMAGE PROCESSING */
  52004. IMAGEPROCESSING: boolean;
  52005. VIGNETTE: boolean;
  52006. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52007. VIGNETTEBLENDMODEOPAQUE: boolean;
  52008. TONEMAPPING: boolean;
  52009. TONEMAPPING_ACES: boolean;
  52010. CONTRAST: boolean;
  52011. EXPOSURE: boolean;
  52012. COLORCURVES: boolean;
  52013. COLORGRADING: boolean;
  52014. COLORGRADING3D: boolean;
  52015. SAMPLER3DGREENDEPTH: boolean;
  52016. SAMPLER3DBGRMAP: boolean;
  52017. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52018. /** MISC. */
  52019. BUMPDIRECTUV: number;
  52020. constructor();
  52021. setValue(name: string, value: boolean): void;
  52022. }
  52023. /**
  52024. * Class used to configure NodeMaterial
  52025. */
  52026. export interface INodeMaterialOptions {
  52027. /**
  52028. * Defines if blocks should emit comments
  52029. */
  52030. emitComments: boolean;
  52031. }
  52032. /**
  52033. * Class used to create a node based material built by assembling shader blocks
  52034. */
  52035. export class NodeMaterial extends PushMaterial {
  52036. private static _BuildIdGenerator;
  52037. private _options;
  52038. private _vertexCompilationState;
  52039. private _fragmentCompilationState;
  52040. private _sharedData;
  52041. private _buildId;
  52042. private _buildWasSuccessful;
  52043. private _cachedWorldViewMatrix;
  52044. private _cachedWorldViewProjectionMatrix;
  52045. private _optimizers;
  52046. private _animationFrame;
  52047. /** Define the URl to load node editor script */
  52048. static EditorURL: string;
  52049. private BJSNODEMATERIALEDITOR;
  52050. /** Get the inspector from bundle or global */
  52051. private _getGlobalNodeMaterialEditor;
  52052. /**
  52053. * 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)
  52054. */
  52055. ignoreAlpha: boolean;
  52056. /**
  52057. * Defines the maximum number of lights that can be used in the material
  52058. */
  52059. maxSimultaneousLights: number;
  52060. /**
  52061. * Observable raised when the material is built
  52062. */
  52063. onBuildObservable: Observable<NodeMaterial>;
  52064. /**
  52065. * Gets or sets the root nodes of the material vertex shader
  52066. */ private _vertexOutputNodes: NodeMaterialBlock[];
  52067. /**
  52068. * Gets or sets the root nodes of the material fragment (pixel) shader
  52069. */ private _fragmentOutputNodes: NodeMaterialBlock[];
  52070. /** Gets or sets options to control the node material overall behavior */
  52071. options: INodeMaterialOptions;
  52072. /**
  52073. * Default configuration related to image processing available in the standard Material.
  52074. */
  52075. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52076. /**
  52077. * Gets the image processing configuration used either in this material.
  52078. */
  52079. /**
  52080. * Sets the Default image processing configuration used either in the this material.
  52081. *
  52082. * If sets to null, the scene one is in use.
  52083. */
  52084. imageProcessingConfiguration: ImageProcessingConfiguration;
  52085. /**
  52086. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52087. */
  52088. attachedBlocks: NodeMaterialBlock[];
  52089. /**
  52090. * Create a new node based material
  52091. * @param name defines the material name
  52092. * @param scene defines the hosting scene
  52093. * @param options defines creation option
  52094. */
  52095. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52096. /**
  52097. * Gets the current class name of the material e.g. "NodeMaterial"
  52098. * @returns the class name
  52099. */
  52100. getClassName(): string;
  52101. /**
  52102. * Keep track of the image processing observer to allow dispose and replace.
  52103. */
  52104. private _imageProcessingObserver;
  52105. /**
  52106. * Attaches a new image processing configuration to the Standard Material.
  52107. * @param configuration
  52108. */
  52109. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52110. /**
  52111. * Get a block by its name
  52112. * @param name defines the name of the block to retrieve
  52113. * @returns the required block or null if not found
  52114. */
  52115. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52116. /**
  52117. * Get a block by its name
  52118. * @param predicate defines the predicate used to find the good candidate
  52119. * @returns the required block or null if not found
  52120. */
  52121. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52122. /**
  52123. * Get an input block by its name
  52124. * @param predicate defines the predicate used to find the good candidate
  52125. * @returns the required input block or null if not found
  52126. */
  52127. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52128. /**
  52129. * Gets the list of input blocks attached to this material
  52130. * @returns an array of InputBlocks
  52131. */
  52132. getInputBlocks(): InputBlock[];
  52133. /**
  52134. * Adds a new optimizer to the list of optimizers
  52135. * @param optimizer defines the optimizers to add
  52136. * @returns the current material
  52137. */
  52138. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52139. /**
  52140. * Remove an optimizer from the list of optimizers
  52141. * @param optimizer defines the optimizers to remove
  52142. * @returns the current material
  52143. */
  52144. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52145. /**
  52146. * Add a new block to the list of output nodes
  52147. * @param node defines the node to add
  52148. * @returns the current material
  52149. */
  52150. addOutputNode(node: NodeMaterialBlock): this;
  52151. /**
  52152. * Remove a block from the list of root nodes
  52153. * @param node defines the node to remove
  52154. * @returns the current material
  52155. */
  52156. removeOutputNode(node: NodeMaterialBlock): this;
  52157. private _addVertexOutputNode;
  52158. private _removeVertexOutputNode;
  52159. private _addFragmentOutputNode;
  52160. private _removeFragmentOutputNode;
  52161. /**
  52162. * Specifies if the material will require alpha blending
  52163. * @returns a boolean specifying if alpha blending is needed
  52164. */
  52165. needAlphaBlending(): boolean;
  52166. /**
  52167. * Specifies if this material should be rendered in alpha test mode
  52168. * @returns a boolean specifying if an alpha test is needed.
  52169. */
  52170. needAlphaTesting(): boolean;
  52171. private _initializeBlock;
  52172. private _resetDualBlocks;
  52173. /**
  52174. * Build the material and generates the inner effect
  52175. * @param verbose defines if the build should log activity
  52176. */
  52177. build(verbose?: boolean): void;
  52178. /**
  52179. * Runs an otpimization phase to try to improve the shader code
  52180. */
  52181. optimize(): void;
  52182. private _prepareDefinesForAttributes;
  52183. /**
  52184. * Get if the submesh is ready to be used and all its information available.
  52185. * Child classes can use it to update shaders
  52186. * @param mesh defines the mesh to check
  52187. * @param subMesh defines which submesh to check
  52188. * @param useInstances specifies that instances should be used
  52189. * @returns a boolean indicating that the submesh is ready or not
  52190. */
  52191. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52192. /**
  52193. * Get a string representing the shaders built by the current node graph
  52194. */
  52195. readonly compiledShaders: string;
  52196. /**
  52197. * Binds the world matrix to the material
  52198. * @param world defines the world transformation matrix
  52199. */
  52200. bindOnlyWorldMatrix(world: Matrix): void;
  52201. /**
  52202. * Binds the submesh to this material by preparing the effect and shader to draw
  52203. * @param world defines the world transformation matrix
  52204. * @param mesh defines the mesh containing the submesh
  52205. * @param subMesh defines the submesh to bind the material to
  52206. */
  52207. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52208. /**
  52209. * Gets the active textures from the material
  52210. * @returns an array of textures
  52211. */
  52212. getActiveTextures(): BaseTexture[];
  52213. /**
  52214. * Gets the list of texture blocks
  52215. * @returns an array of texture blocks
  52216. */
  52217. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  52218. /**
  52219. * Specifies if the material uses a texture
  52220. * @param texture defines the texture to check against the material
  52221. * @returns a boolean specifying if the material uses the texture
  52222. */
  52223. hasTexture(texture: BaseTexture): boolean;
  52224. /**
  52225. * Disposes the material
  52226. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52227. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52228. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52229. */
  52230. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  52231. /** Creates the node editor window. */
  52232. private _createNodeEditor;
  52233. /**
  52234. * Launch the node material editor
  52235. * @param config Define the configuration of the editor
  52236. * @return a promise fulfilled when the node editor is visible
  52237. */
  52238. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  52239. /**
  52240. * Clear the current material
  52241. */
  52242. clear(): void;
  52243. /**
  52244. * Clear the current material and set it to a default state
  52245. */
  52246. setToDefault(): void;
  52247. /**
  52248. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  52249. * @param url defines the url to load from
  52250. * @returns a promise that will fullfil when the material is fully loaded
  52251. */
  52252. loadAsync(url: string): Promise<unknown>;
  52253. private _gatherBlocks;
  52254. /**
  52255. * Generate a string containing the code declaration required to create an equivalent of this material
  52256. * @returns a string
  52257. */
  52258. generateCode(): string;
  52259. /**
  52260. * Serializes this material in a JSON representation
  52261. * @returns the serialized material object
  52262. */
  52263. serialize(): any;
  52264. private _restoreConnections;
  52265. /**
  52266. * Clear the current graph and load a new one from a serialization object
  52267. * @param source defines the JSON representation of the material
  52268. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52269. */
  52270. loadFromSerialization(source: any, rootUrl?: string): void;
  52271. /**
  52272. * Creates a node material from parsed material data
  52273. * @param source defines the JSON representation of the material
  52274. * @param scene defines the hosting scene
  52275. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52276. * @returns a new node material
  52277. */
  52278. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  52279. /**
  52280. * Creates a new node material set to default basic configuration
  52281. * @param name defines the name of the material
  52282. * @param scene defines the hosting scene
  52283. * @returns a new NodeMaterial
  52284. */
  52285. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  52286. }
  52287. }
  52288. declare module BABYLON {
  52289. /**
  52290. * Block used to read a texture from a sampler
  52291. */
  52292. export class TextureBlock extends NodeMaterialBlock {
  52293. private _defineName;
  52294. private _linearDefineName;
  52295. private _samplerName;
  52296. private _transformedUVName;
  52297. private _textureTransformName;
  52298. private _textureInfoName;
  52299. private _mainUVName;
  52300. private _mainUVDefineName;
  52301. /**
  52302. * Gets or sets the texture associated with the node
  52303. */
  52304. texture: Nullable<Texture>;
  52305. /**
  52306. * Create a new TextureBlock
  52307. * @param name defines the block name
  52308. */
  52309. constructor(name: string);
  52310. /**
  52311. * Gets the current class name
  52312. * @returns the class name
  52313. */
  52314. getClassName(): string;
  52315. /**
  52316. * Gets the uv input component
  52317. */
  52318. readonly uv: NodeMaterialConnectionPoint;
  52319. /**
  52320. * Gets the rgba output component
  52321. */
  52322. readonly rgba: NodeMaterialConnectionPoint;
  52323. /**
  52324. * Gets the rgb output component
  52325. */
  52326. readonly rgb: NodeMaterialConnectionPoint;
  52327. /**
  52328. * Gets the r output component
  52329. */
  52330. readonly r: NodeMaterialConnectionPoint;
  52331. /**
  52332. * Gets the g output component
  52333. */
  52334. readonly g: NodeMaterialConnectionPoint;
  52335. /**
  52336. * Gets the b output component
  52337. */
  52338. readonly b: NodeMaterialConnectionPoint;
  52339. /**
  52340. * Gets the a output component
  52341. */
  52342. readonly a: NodeMaterialConnectionPoint;
  52343. readonly target: NodeMaterialBlockTargets;
  52344. autoConfigure(material: NodeMaterial): void;
  52345. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52346. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52347. isReady(): boolean;
  52348. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52349. private readonly _isMixed;
  52350. private _injectVertexCode;
  52351. private _writeOutput;
  52352. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52353. protected _dumpPropertiesCode(): string;
  52354. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52355. }
  52356. }
  52357. declare module BABYLON {
  52358. /**
  52359. * Class used to store shared data between 2 NodeMaterialBuildState
  52360. */
  52361. export class NodeMaterialBuildStateSharedData {
  52362. /**
  52363. * Gets the list of emitted varyings
  52364. */
  52365. temps: string[];
  52366. /**
  52367. * Gets the list of emitted varyings
  52368. */
  52369. varyings: string[];
  52370. /**
  52371. * Gets the varying declaration string
  52372. */
  52373. varyingDeclaration: string;
  52374. /**
  52375. * Input blocks
  52376. */
  52377. inputBlocks: InputBlock[];
  52378. /**
  52379. * Input blocks
  52380. */
  52381. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  52382. /**
  52383. * Bindable blocks (Blocks that need to set data to the effect)
  52384. */
  52385. bindableBlocks: NodeMaterialBlock[];
  52386. /**
  52387. * List of blocks that can provide a compilation fallback
  52388. */
  52389. blocksWithFallbacks: NodeMaterialBlock[];
  52390. /**
  52391. * List of blocks that can provide a define update
  52392. */
  52393. blocksWithDefines: NodeMaterialBlock[];
  52394. /**
  52395. * List of blocks that can provide a repeatable content
  52396. */
  52397. repeatableContentBlocks: NodeMaterialBlock[];
  52398. /**
  52399. * List of blocks that can provide a dynamic list of uniforms
  52400. */
  52401. dynamicUniformBlocks: NodeMaterialBlock[];
  52402. /**
  52403. * List of blocks that can block the isReady function for the material
  52404. */
  52405. blockingBlocks: NodeMaterialBlock[];
  52406. /**
  52407. * Gets the list of animated inputs
  52408. */
  52409. animatedInputs: InputBlock[];
  52410. /**
  52411. * Build Id used to avoid multiple recompilations
  52412. */
  52413. buildId: number;
  52414. /** List of emitted variables */
  52415. variableNames: {
  52416. [key: string]: number;
  52417. };
  52418. /** List of emitted defines */
  52419. defineNames: {
  52420. [key: string]: number;
  52421. };
  52422. /** Should emit comments? */
  52423. emitComments: boolean;
  52424. /** Emit build activity */
  52425. verbose: boolean;
  52426. /** Gets or sets the hosting scene */
  52427. scene: Scene;
  52428. /**
  52429. * Gets the compilation hints emitted at compilation time
  52430. */
  52431. hints: {
  52432. needWorldViewMatrix: boolean;
  52433. needWorldViewProjectionMatrix: boolean;
  52434. needAlphaBlending: boolean;
  52435. needAlphaTesting: boolean;
  52436. };
  52437. /**
  52438. * List of compilation checks
  52439. */
  52440. checks: {
  52441. emitVertex: boolean;
  52442. emitFragment: boolean;
  52443. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52444. };
  52445. /** Creates a new shared data */
  52446. constructor();
  52447. /**
  52448. * Emits console errors and exceptions if there is a failing check
  52449. */
  52450. emitErrors(): void;
  52451. }
  52452. }
  52453. declare module BABYLON {
  52454. /**
  52455. * Class used to store node based material build state
  52456. */
  52457. export class NodeMaterialBuildState {
  52458. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  52459. supportUniformBuffers: boolean;
  52460. /**
  52461. * Gets the list of emitted attributes
  52462. */
  52463. attributes: string[];
  52464. /**
  52465. * Gets the list of emitted uniforms
  52466. */
  52467. uniforms: string[];
  52468. /**
  52469. * Gets the list of emitted constants
  52470. */
  52471. constants: string[];
  52472. /**
  52473. * Gets the list of emitted uniform buffers
  52474. */
  52475. uniformBuffers: string[];
  52476. /**
  52477. * Gets the list of emitted samplers
  52478. */
  52479. samplers: string[];
  52480. /**
  52481. * Gets the list of emitted functions
  52482. */
  52483. functions: {
  52484. [key: string]: string;
  52485. };
  52486. /**
  52487. * Gets the list of emitted extensions
  52488. */
  52489. extensions: {
  52490. [key: string]: string;
  52491. };
  52492. /**
  52493. * Gets the target of the compilation state
  52494. */
  52495. target: NodeMaterialBlockTargets;
  52496. /**
  52497. * Gets the list of emitted counters
  52498. */
  52499. counters: {
  52500. [key: string]: number;
  52501. };
  52502. /**
  52503. * Shared data between multiple NodeMaterialBuildState instances
  52504. */
  52505. sharedData: NodeMaterialBuildStateSharedData;
  52506. /** @hidden */ private _vertexState: NodeMaterialBuildState;
  52507. /** @hidden */ private _attributeDeclaration: string;
  52508. /** @hidden */ private _uniformDeclaration: string;
  52509. /** @hidden */ private _constantDeclaration: string;
  52510. /** @hidden */ private _samplerDeclaration: string;
  52511. /** @hidden */ private _varyingTransfer: string;
  52512. private _repeatableContentAnchorIndex;
  52513. /** @hidden */ private _builtCompilationString: string;
  52514. /**
  52515. * Gets the emitted compilation strings
  52516. */
  52517. compilationString: string;
  52518. /**
  52519. * Finalize the compilation strings
  52520. * @param state defines the current compilation state
  52521. */
  52522. finalize(state: NodeMaterialBuildState): void;
  52523. /** @hidden */ protected readonly _repeatableContentAnchor: string;
  52524. /** @hidden */ private _getFreeVariableName(prefix: string): string;
  52525. /** @hidden */ private _getFreeDefineName(prefix: string): string;
  52526. /** @hidden */ private _excludeVariableName(name: string): void;
  52527. /** @hidden */ private _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52528. /** @hidden */ private _emitExtension(name: string, extension: string): void;
  52529. /** @hidden */ private _emitFunction(name: string, code: string, comments: string): void;
  52530. /** @hidden */ private _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52531. replaceStrings?: {
  52532. search: RegExp;
  52533. replace: string;
  52534. }[];
  52535. repeatKey?: string;
  52536. }): string;
  52537. /** @hidden */ private _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52538. repeatKey?: string;
  52539. removeAttributes?: boolean;
  52540. removeUniforms?: boolean;
  52541. removeVaryings?: boolean;
  52542. removeIfDef?: boolean;
  52543. replaceStrings?: {
  52544. search: RegExp;
  52545. replace: string;
  52546. }[];
  52547. }, storeKey?: string): void;
  52548. /** @hidden */ private _registerTempVariable(name: string): boolean;
  52549. /** @hidden */ private _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  52550. /** @hidden */ private _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  52551. /** @hidden */ private _emitFloat(value: number): string;
  52552. }
  52553. }
  52554. declare module BABYLON {
  52555. /**
  52556. * Defines a block that can be used inside a node based material
  52557. */
  52558. export class NodeMaterialBlock {
  52559. private _buildId;
  52560. private _buildTarget;
  52561. private _target;
  52562. private _isFinalMerger;
  52563. private _isInput;
  52564. /** @hidden */ private _codeVariableName: string;
  52565. /** @hidden */ private _inputs: NodeMaterialConnectionPoint[];
  52566. /** @hidden */ private _outputs: NodeMaterialConnectionPoint[];
  52567. /** @hidden */ private _preparationId: number;
  52568. /**
  52569. * Gets or sets the name of the block
  52570. */
  52571. name: string;
  52572. /**
  52573. * Gets or sets the unique id of the node
  52574. */
  52575. uniqueId: number;
  52576. /**
  52577. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  52578. */
  52579. readonly isFinalMerger: boolean;
  52580. /**
  52581. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  52582. */
  52583. readonly isInput: boolean;
  52584. /**
  52585. * Gets or sets the build Id
  52586. */
  52587. buildId: number;
  52588. /**
  52589. * Gets or sets the target of the block
  52590. */
  52591. target: NodeMaterialBlockTargets;
  52592. /**
  52593. * Gets the list of input points
  52594. */
  52595. readonly inputs: NodeMaterialConnectionPoint[];
  52596. /** Gets the list of output points */
  52597. readonly outputs: NodeMaterialConnectionPoint[];
  52598. /**
  52599. * Find an input by its name
  52600. * @param name defines the name of the input to look for
  52601. * @returns the input or null if not found
  52602. */
  52603. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52604. /**
  52605. * Find an output by its name
  52606. * @param name defines the name of the outputto look for
  52607. * @returns the output or null if not found
  52608. */
  52609. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52610. /**
  52611. * Creates a new NodeMaterialBlock
  52612. * @param name defines the block name
  52613. * @param target defines the target of that block (Vertex by default)
  52614. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  52615. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  52616. */
  52617. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  52618. /**
  52619. * Initialize the block and prepare the context for build
  52620. * @param state defines the state that will be used for the build
  52621. */
  52622. initialize(state: NodeMaterialBuildState): void;
  52623. /**
  52624. * Bind data to effect. Will only be called for blocks with isBindable === true
  52625. * @param effect defines the effect to bind data to
  52626. * @param nodeMaterial defines the hosting NodeMaterial
  52627. * @param mesh defines the mesh that will be rendered
  52628. */
  52629. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52630. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  52631. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  52632. protected _writeFloat(value: number): string;
  52633. /**
  52634. * Gets the current class name e.g. "NodeMaterialBlock"
  52635. * @returns the class name
  52636. */
  52637. getClassName(): string;
  52638. /**
  52639. * Register a new input. Must be called inside a block constructor
  52640. * @param name defines the connection point name
  52641. * @param type defines the connection point type
  52642. * @param isOptional defines a boolean indicating that this input can be omitted
  52643. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52644. * @returns the current block
  52645. */
  52646. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  52647. /**
  52648. * Register a new output. Must be called inside a block constructor
  52649. * @param name defines the connection point name
  52650. * @param type defines the connection point type
  52651. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52652. * @returns the current block
  52653. */
  52654. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  52655. /**
  52656. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  52657. * @param forOutput defines an optional connection point to check compatibility with
  52658. * @returns the first available input or null
  52659. */
  52660. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  52661. /**
  52662. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  52663. * @param forBlock defines an optional block to check compatibility with
  52664. * @returns the first available input or null
  52665. */
  52666. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  52667. /**
  52668. * Gets the sibling of the given output
  52669. * @param current defines the current output
  52670. * @returns the next output in the list or null
  52671. */
  52672. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  52673. /**
  52674. * Connect current block with another block
  52675. * @param other defines the block to connect with
  52676. * @param options define the various options to help pick the right connections
  52677. * @returns the current block
  52678. */
  52679. connectTo(other: NodeMaterialBlock, options?: {
  52680. input?: string;
  52681. output?: string;
  52682. outputSwizzle?: string;
  52683. }): this | undefined;
  52684. protected _buildBlock(state: NodeMaterialBuildState): void;
  52685. /**
  52686. * Add uniforms, samplers and uniform buffers at compilation time
  52687. * @param state defines the state to update
  52688. * @param nodeMaterial defines the node material requesting the update
  52689. * @param defines defines the material defines to update
  52690. */
  52691. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52692. /**
  52693. * Add potential fallbacks if shader compilation fails
  52694. * @param mesh defines the mesh to be rendered
  52695. * @param fallbacks defines the current prioritized list of fallbacks
  52696. */
  52697. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52698. /**
  52699. * Initialize defines for shader compilation
  52700. * @param mesh defines the mesh to be rendered
  52701. * @param nodeMaterial defines the node material requesting the update
  52702. * @param defines defines the material defines to update
  52703. * @param useInstances specifies that instances should be used
  52704. */
  52705. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52706. /**
  52707. * Update defines for shader compilation
  52708. * @param mesh defines the mesh to be rendered
  52709. * @param nodeMaterial defines the node material requesting the update
  52710. * @param defines defines the material defines to update
  52711. * @param useInstances specifies that instances should be used
  52712. */
  52713. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52714. /**
  52715. * Lets the block try to connect some inputs automatically
  52716. * @param material defines the hosting NodeMaterial
  52717. */
  52718. autoConfigure(material: NodeMaterial): void;
  52719. /**
  52720. * Function called when a block is declared as repeatable content generator
  52721. * @param vertexShaderState defines the current compilation state for the vertex shader
  52722. * @param fragmentShaderState defines the current compilation state for the fragment shader
  52723. * @param mesh defines the mesh to be rendered
  52724. * @param defines defines the material defines to update
  52725. */
  52726. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52727. /**
  52728. * Checks if the block is ready
  52729. * @param mesh defines the mesh to be rendered
  52730. * @param nodeMaterial defines the node material requesting the update
  52731. * @param defines defines the material defines to update
  52732. * @param useInstances specifies that instances should be used
  52733. * @returns true if the block is ready
  52734. */
  52735. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  52736. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  52737. private _processBuild;
  52738. /**
  52739. * Compile the current node and generate the shader code
  52740. * @param state defines the current compilation state (uniforms, samplers, current string)
  52741. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  52742. * @returns true if already built
  52743. */
  52744. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  52745. protected _inputRename(name: string): string;
  52746. protected _outputRename(name: string): string;
  52747. protected _dumpPropertiesCode(): string;
  52748. /** @hidden */ private _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  52749. /**
  52750. * Clone the current block to a new identical block
  52751. * @param scene defines the hosting scene
  52752. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52753. * @returns a copy of the current block
  52754. */
  52755. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  52756. /**
  52757. * Serializes this block in a JSON representation
  52758. * @returns the serialized block object
  52759. */
  52760. serialize(): any;
  52761. /** @hidden */ private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52762. }
  52763. }
  52764. declare module BABYLON {
  52765. /**
  52766. * Enum defining the type of animations supported by InputBlock
  52767. */
  52768. export enum AnimatedInputBlockTypes {
  52769. /** No animation */
  52770. None = 0,
  52771. /** Time based animation. Will only work for floats */
  52772. Time = 1
  52773. }
  52774. }
  52775. declare module BABYLON {
  52776. /**
  52777. * Block used to expose an input value
  52778. */
  52779. export class InputBlock extends NodeMaterialBlock {
  52780. private _mode;
  52781. private _associatedVariableName;
  52782. private _storedValue;
  52783. private _valueCallback;
  52784. private _type;
  52785. private _animationType;
  52786. /** Gets or set a value used to limit the range of float values */
  52787. min: number;
  52788. /** Gets or set a value used to limit the range of float values */
  52789. max: number;
  52790. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  52791. matrixMode: number;
  52792. /** @hidden */ private _systemValue: Nullable<NodeMaterialSystemValues>;
  52793. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  52794. visibleInInspector: boolean;
  52795. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  52796. isConstant: boolean;
  52797. /**
  52798. * Gets or sets the connection point type (default is float)
  52799. */
  52800. readonly type: NodeMaterialBlockConnectionPointTypes;
  52801. /**
  52802. * Creates a new InputBlock
  52803. * @param name defines the block name
  52804. * @param target defines the target of that block (Vertex by default)
  52805. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  52806. */
  52807. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  52808. /**
  52809. * Gets the output component
  52810. */
  52811. readonly output: NodeMaterialConnectionPoint;
  52812. /**
  52813. * Set the source of this connection point to a vertex attribute
  52814. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  52815. * @returns the current connection point
  52816. */
  52817. setAsAttribute(attributeName?: string): InputBlock;
  52818. /**
  52819. * Set the source of this connection point to a system value
  52820. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  52821. * @returns the current connection point
  52822. */
  52823. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  52824. /**
  52825. * Gets or sets the value of that point.
  52826. * Please note that this value will be ignored if valueCallback is defined
  52827. */
  52828. value: any;
  52829. /**
  52830. * Gets or sets a callback used to get the value of that point.
  52831. * Please note that setting this value will force the connection point to ignore the value property
  52832. */
  52833. valueCallback: () => any;
  52834. /**
  52835. * Gets or sets the associated variable name in the shader
  52836. */
  52837. associatedVariableName: string;
  52838. /** Gets or sets the type of animation applied to the input */
  52839. animationType: AnimatedInputBlockTypes;
  52840. /**
  52841. * Gets a boolean indicating that this connection point not defined yet
  52842. */
  52843. readonly isUndefined: boolean;
  52844. /**
  52845. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  52846. * In this case the connection point name must be the name of the uniform to use.
  52847. * Can only be set on inputs
  52848. */
  52849. isUniform: boolean;
  52850. /**
  52851. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  52852. * In this case the connection point name must be the name of the attribute to use
  52853. * Can only be set on inputs
  52854. */
  52855. isAttribute: boolean;
  52856. /**
  52857. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  52858. * Can only be set on exit points
  52859. */
  52860. isVarying: boolean;
  52861. /**
  52862. * Gets a boolean indicating that the current connection point is a system value
  52863. */
  52864. readonly isSystemValue: boolean;
  52865. /**
  52866. * Gets or sets the current well known value or null if not defined as a system value
  52867. */
  52868. systemValue: Nullable<NodeMaterialSystemValues>;
  52869. /**
  52870. * Gets the current class name
  52871. * @returns the class name
  52872. */
  52873. getClassName(): string;
  52874. /**
  52875. * Animate the input if animationType !== None
  52876. * @param scene defines the rendering scene
  52877. */
  52878. animate(scene: Scene): void;
  52879. private _emitDefine;
  52880. initialize(state: NodeMaterialBuildState): void;
  52881. /**
  52882. * Set the input block to its default value (based on its type)
  52883. */
  52884. setDefaultValue(): void;
  52885. private _emitConstant;
  52886. private _emit;
  52887. /** @hidden */ private _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  52888. /** @hidden */ private _transmit(effect: Effect, scene: Scene): void;
  52889. protected _buildBlock(state: NodeMaterialBuildState): void;
  52890. protected _dumpPropertiesCode(): string;
  52891. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52892. }
  52893. }
  52894. declare module BABYLON {
  52895. /**
  52896. * Defines a connection point for a block
  52897. */
  52898. export class NodeMaterialConnectionPoint {
  52899. /** @hidden */ private _ownerBlock: NodeMaterialBlock;
  52900. /** @hidden */ private _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52901. private _endpoints;
  52902. private _associatedVariableName;
  52903. /** @hidden */ private _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  52904. /** @hidden */ private _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  52905. private _type;
  52906. /** @hidden */ private _enforceAssociatedVariableName: boolean;
  52907. /**
  52908. * Gets or sets the additional types supported by this connection point
  52909. */
  52910. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  52911. /**
  52912. * Gets or sets the additional types excluded by this connection point
  52913. */
  52914. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  52915. /**
  52916. * Gets or sets the associated variable name in the shader
  52917. */
  52918. associatedVariableName: string;
  52919. /**
  52920. * Gets or sets the connection point type (default is float)
  52921. */
  52922. type: NodeMaterialBlockConnectionPointTypes;
  52923. /**
  52924. * Gets or sets the connection point name
  52925. */
  52926. name: string;
  52927. /**
  52928. * Gets or sets a boolean indicating that this connection point can be omitted
  52929. */
  52930. isOptional: boolean;
  52931. /**
  52932. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  52933. */
  52934. define: string;
  52935. /** Gets or sets the target of that connection point */
  52936. target: NodeMaterialBlockTargets;
  52937. /**
  52938. * Gets a boolean indicating that the current point is connected
  52939. */
  52940. readonly isConnected: boolean;
  52941. /**
  52942. * Gets a boolean indicating that the current point is connected to an input block
  52943. */
  52944. readonly isConnectedToInputBlock: boolean;
  52945. /**
  52946. * Gets a the connected input block (if any)
  52947. */
  52948. readonly connectInputBlock: Nullable<InputBlock>;
  52949. /** Get the other side of the connection (if any) */
  52950. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52951. /** Get the block that owns this connection point */
  52952. readonly ownerBlock: NodeMaterialBlock;
  52953. /** Get the block connected on the other side of this connection (if any) */
  52954. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  52955. /** Get the block connected on the endpoints of this connection (if any) */
  52956. readonly connectedBlocks: Array<NodeMaterialBlock>;
  52957. /** Gets the list of connected endpoints */
  52958. readonly endpoints: NodeMaterialConnectionPoint[];
  52959. /** Gets a boolean indicating if that output point is connected to at least one input */
  52960. readonly hasEndpoints: boolean;
  52961. /**
  52962. * Creates a new connection point
  52963. * @param name defines the connection point name
  52964. * @param ownerBlock defines the block hosting this connection point
  52965. */
  52966. constructor(name: string, ownerBlock: NodeMaterialBlock);
  52967. /**
  52968. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  52969. * @returns the class name
  52970. */
  52971. getClassName(): string;
  52972. /**
  52973. * Gets an boolean indicating if the current point can be connected to another point
  52974. * @param connectionPoint defines the other connection point
  52975. * @returns true if the connection is possible
  52976. */
  52977. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  52978. /**
  52979. * Connect this point to another connection point
  52980. * @param connectionPoint defines the other connection point
  52981. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  52982. * @returns the current connection point
  52983. */
  52984. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  52985. /**
  52986. * Disconnect this point from one of his endpoint
  52987. * @param endpoint defines the other connection point
  52988. * @returns the current connection point
  52989. */
  52990. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52991. /**
  52992. * Serializes this point in a JSON representation
  52993. * @returns the serialized point object
  52994. */
  52995. serialize(): any;
  52996. }
  52997. }
  52998. declare module BABYLON {
  52999. /**
  53000. * Block used to add support for vertex skinning (bones)
  53001. */
  53002. export class BonesBlock extends NodeMaterialBlock {
  53003. /**
  53004. * Creates a new BonesBlock
  53005. * @param name defines the block name
  53006. */
  53007. constructor(name: string);
  53008. /**
  53009. * Initialize the block and prepare the context for build
  53010. * @param state defines the state that will be used for the build
  53011. */
  53012. initialize(state: NodeMaterialBuildState): void;
  53013. /**
  53014. * Gets the current class name
  53015. * @returns the class name
  53016. */
  53017. getClassName(): string;
  53018. /**
  53019. * Gets the matrix indices input component
  53020. */
  53021. readonly matricesIndices: NodeMaterialConnectionPoint;
  53022. /**
  53023. * Gets the matrix weights input component
  53024. */
  53025. readonly matricesWeights: NodeMaterialConnectionPoint;
  53026. /**
  53027. * Gets the extra matrix indices input component
  53028. */
  53029. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53030. /**
  53031. * Gets the extra matrix weights input component
  53032. */
  53033. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53034. /**
  53035. * Gets the world input component
  53036. */
  53037. readonly world: NodeMaterialConnectionPoint;
  53038. /**
  53039. * Gets the output component
  53040. */
  53041. readonly output: NodeMaterialConnectionPoint;
  53042. autoConfigure(material: NodeMaterial): void;
  53043. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53044. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53045. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53046. protected _buildBlock(state: NodeMaterialBuildState): this;
  53047. }
  53048. }
  53049. declare module BABYLON {
  53050. /**
  53051. * Block used to add support for instances
  53052. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53053. */
  53054. export class InstancesBlock extends NodeMaterialBlock {
  53055. /**
  53056. * Creates a new InstancesBlock
  53057. * @param name defines the block name
  53058. */
  53059. constructor(name: string);
  53060. /**
  53061. * Gets the current class name
  53062. * @returns the class name
  53063. */
  53064. getClassName(): string;
  53065. /**
  53066. * Gets the first world row input component
  53067. */
  53068. readonly world0: NodeMaterialConnectionPoint;
  53069. /**
  53070. * Gets the second world row input component
  53071. */
  53072. readonly world1: NodeMaterialConnectionPoint;
  53073. /**
  53074. * Gets the third world row input component
  53075. */
  53076. readonly world2: NodeMaterialConnectionPoint;
  53077. /**
  53078. * Gets the forth world row input component
  53079. */
  53080. readonly world3: NodeMaterialConnectionPoint;
  53081. /**
  53082. * Gets the world input component
  53083. */
  53084. readonly world: NodeMaterialConnectionPoint;
  53085. /**
  53086. * Gets the output component
  53087. */
  53088. readonly output: NodeMaterialConnectionPoint;
  53089. autoConfigure(material: NodeMaterial): void;
  53090. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53091. protected _buildBlock(state: NodeMaterialBuildState): this;
  53092. }
  53093. }
  53094. declare module BABYLON {
  53095. /**
  53096. * Block used to add morph targets support to vertex shader
  53097. */
  53098. export class MorphTargetsBlock extends NodeMaterialBlock {
  53099. private _repeatableContentAnchor;
  53100. private _repeatebleContentGenerated;
  53101. /**
  53102. * Create a new MorphTargetsBlock
  53103. * @param name defines the block name
  53104. */
  53105. constructor(name: string);
  53106. /**
  53107. * Gets the current class name
  53108. * @returns the class name
  53109. */
  53110. getClassName(): string;
  53111. /**
  53112. * Gets the position input component
  53113. */
  53114. readonly position: NodeMaterialConnectionPoint;
  53115. /**
  53116. * Gets the normal input component
  53117. */
  53118. readonly normal: NodeMaterialConnectionPoint;
  53119. /**
  53120. * Gets the tangent input component
  53121. */
  53122. readonly tangent: NodeMaterialConnectionPoint;
  53123. /**
  53124. * Gets the tangent input component
  53125. */
  53126. readonly uv: NodeMaterialConnectionPoint;
  53127. /**
  53128. * Gets the position output component
  53129. */
  53130. readonly positionOutput: NodeMaterialConnectionPoint;
  53131. /**
  53132. * Gets the normal output component
  53133. */
  53134. readonly normalOutput: NodeMaterialConnectionPoint;
  53135. /**
  53136. * Gets the tangent output component
  53137. */
  53138. readonly tangentOutput: NodeMaterialConnectionPoint;
  53139. /**
  53140. * Gets the tangent output component
  53141. */
  53142. readonly uvOutput: NodeMaterialConnectionPoint;
  53143. initialize(state: NodeMaterialBuildState): void;
  53144. autoConfigure(material: NodeMaterial): void;
  53145. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53146. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53147. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53148. protected _buildBlock(state: NodeMaterialBuildState): this;
  53149. }
  53150. }
  53151. declare module BABYLON {
  53152. /**
  53153. * Block used to get data information from a light
  53154. */
  53155. export class LightInformationBlock extends NodeMaterialBlock {
  53156. private _lightDataUniformName;
  53157. private _lightColorUniformName;
  53158. private _lightTypeDefineName;
  53159. /**
  53160. * Gets or sets the light associated with this block
  53161. */
  53162. light: Nullable<Light>;
  53163. /**
  53164. * Creates a new LightInformationBlock
  53165. * @param name defines the block name
  53166. */
  53167. constructor(name: string);
  53168. /**
  53169. * Gets the current class name
  53170. * @returns the class name
  53171. */
  53172. getClassName(): string;
  53173. /**
  53174. * Gets the world position input component
  53175. */
  53176. readonly worldPosition: NodeMaterialConnectionPoint;
  53177. /**
  53178. * Gets the direction output component
  53179. */
  53180. readonly direction: NodeMaterialConnectionPoint;
  53181. /**
  53182. * Gets the direction output component
  53183. */
  53184. readonly color: NodeMaterialConnectionPoint;
  53185. /**
  53186. * Gets the direction output component
  53187. */
  53188. readonly intensity: NodeMaterialConnectionPoint;
  53189. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53190. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53191. protected _buildBlock(state: NodeMaterialBuildState): this;
  53192. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53193. }
  53194. }
  53195. declare module BABYLON {
  53196. /**
  53197. * Block used to add image processing support to fragment shader
  53198. */
  53199. export class ImageProcessingBlock extends NodeMaterialBlock {
  53200. /**
  53201. * Create a new ImageProcessingBlock
  53202. * @param name defines the block name
  53203. */
  53204. constructor(name: string);
  53205. /**
  53206. * Gets the current class name
  53207. * @returns the class name
  53208. */
  53209. getClassName(): string;
  53210. /**
  53211. * Gets the color input component
  53212. */
  53213. readonly color: NodeMaterialConnectionPoint;
  53214. /**
  53215. * Gets the output component
  53216. */
  53217. readonly output: NodeMaterialConnectionPoint;
  53218. /**
  53219. * Initialize the block and prepare the context for build
  53220. * @param state defines the state that will be used for the build
  53221. */
  53222. initialize(state: NodeMaterialBuildState): void;
  53223. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53224. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53225. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53226. protected _buildBlock(state: NodeMaterialBuildState): this;
  53227. }
  53228. }
  53229. declare module BABYLON {
  53230. /**
  53231. * Block used to pertub normals based on a normal map
  53232. */
  53233. export class PerturbNormalBlock extends NodeMaterialBlock {
  53234. private _tangentSpaceParameterName;
  53235. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  53236. invertX: boolean;
  53237. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  53238. invertY: boolean;
  53239. /**
  53240. * Create a new PerturbNormalBlock
  53241. * @param name defines the block name
  53242. */
  53243. constructor(name: string);
  53244. /**
  53245. * Gets the current class name
  53246. * @returns the class name
  53247. */
  53248. getClassName(): string;
  53249. /**
  53250. * Gets the world position input component
  53251. */
  53252. readonly worldPosition: NodeMaterialConnectionPoint;
  53253. /**
  53254. * Gets the world normal input component
  53255. */
  53256. readonly worldNormal: NodeMaterialConnectionPoint;
  53257. /**
  53258. * Gets the uv input component
  53259. */
  53260. readonly uv: NodeMaterialConnectionPoint;
  53261. /**
  53262. * Gets the normal map color input component
  53263. */
  53264. readonly normalMapColor: NodeMaterialConnectionPoint;
  53265. /**
  53266. * Gets the strength input component
  53267. */
  53268. readonly strength: NodeMaterialConnectionPoint;
  53269. /**
  53270. * Gets the output component
  53271. */
  53272. readonly output: NodeMaterialConnectionPoint;
  53273. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53274. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53275. autoConfigure(material: NodeMaterial): void;
  53276. protected _buildBlock(state: NodeMaterialBuildState): this;
  53277. protected _dumpPropertiesCode(): string;
  53278. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53279. }
  53280. }
  53281. declare module BABYLON {
  53282. /**
  53283. * Block used to discard a pixel if a value is smaller than a cutoff
  53284. */
  53285. export class DiscardBlock extends NodeMaterialBlock {
  53286. /**
  53287. * Create a new DiscardBlock
  53288. * @param name defines the block name
  53289. */
  53290. constructor(name: string);
  53291. /**
  53292. * Gets the current class name
  53293. * @returns the class name
  53294. */
  53295. getClassName(): string;
  53296. /**
  53297. * Gets the color input component
  53298. */
  53299. readonly value: NodeMaterialConnectionPoint;
  53300. /**
  53301. * Gets the cutoff input component
  53302. */
  53303. readonly cutoff: NodeMaterialConnectionPoint;
  53304. protected _buildBlock(state: NodeMaterialBuildState): this;
  53305. }
  53306. }
  53307. declare module BABYLON {
  53308. /**
  53309. * Block used to add support for scene fog
  53310. */
  53311. export class FogBlock extends NodeMaterialBlock {
  53312. private _fogDistanceName;
  53313. private _fogParameters;
  53314. /**
  53315. * Create a new FogBlock
  53316. * @param name defines the block name
  53317. */
  53318. constructor(name: string);
  53319. /**
  53320. * Gets the current class name
  53321. * @returns the class name
  53322. */
  53323. getClassName(): string;
  53324. /**
  53325. * Gets the world position input component
  53326. */
  53327. readonly worldPosition: NodeMaterialConnectionPoint;
  53328. /**
  53329. * Gets the view input component
  53330. */
  53331. readonly view: NodeMaterialConnectionPoint;
  53332. /**
  53333. * Gets the color input component
  53334. */
  53335. readonly input: NodeMaterialConnectionPoint;
  53336. /**
  53337. * Gets the fog color input component
  53338. */
  53339. readonly fogColor: NodeMaterialConnectionPoint;
  53340. /**
  53341. * Gets the output component
  53342. */
  53343. readonly output: NodeMaterialConnectionPoint;
  53344. autoConfigure(material: NodeMaterial): void;
  53345. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53346. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53347. protected _buildBlock(state: NodeMaterialBuildState): this;
  53348. }
  53349. }
  53350. declare module BABYLON {
  53351. /**
  53352. * Block used to add light in the fragment shader
  53353. */
  53354. export class LightBlock extends NodeMaterialBlock {
  53355. private _lightId;
  53356. /**
  53357. * Gets or sets the light associated with this block
  53358. */
  53359. light: Nullable<Light>;
  53360. /**
  53361. * Create a new LightBlock
  53362. * @param name defines the block name
  53363. */
  53364. constructor(name: string);
  53365. /**
  53366. * Gets the current class name
  53367. * @returns the class name
  53368. */
  53369. getClassName(): string;
  53370. /**
  53371. * Gets the world position input component
  53372. */
  53373. readonly worldPosition: NodeMaterialConnectionPoint;
  53374. /**
  53375. * Gets the world normal input component
  53376. */
  53377. readonly worldNormal: NodeMaterialConnectionPoint;
  53378. /**
  53379. * Gets the camera (or eye) position component
  53380. */
  53381. readonly cameraPosition: NodeMaterialConnectionPoint;
  53382. /**
  53383. * Gets the glossiness component
  53384. */
  53385. readonly glossiness: NodeMaterialConnectionPoint;
  53386. /**
  53387. * Gets the glossinness power component
  53388. */
  53389. readonly glossPower: NodeMaterialConnectionPoint;
  53390. /**
  53391. * Gets the diffuse color component
  53392. */
  53393. readonly diffuseColor: NodeMaterialConnectionPoint;
  53394. /**
  53395. * Gets the specular color component
  53396. */
  53397. readonly specularColor: NodeMaterialConnectionPoint;
  53398. /**
  53399. * Gets the diffuse output component
  53400. */
  53401. readonly diffuseOutput: NodeMaterialConnectionPoint;
  53402. /**
  53403. * Gets the specular output component
  53404. */
  53405. readonly specularOutput: NodeMaterialConnectionPoint;
  53406. autoConfigure(material: NodeMaterial): void;
  53407. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53408. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53409. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53410. private _injectVertexCode;
  53411. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53412. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53413. }
  53414. }
  53415. declare module BABYLON {
  53416. /**
  53417. * Block used to multiply 2 values
  53418. */
  53419. export class MultiplyBlock extends NodeMaterialBlock {
  53420. /**
  53421. * Creates a new MultiplyBlock
  53422. * @param name defines the block name
  53423. */
  53424. constructor(name: string);
  53425. /**
  53426. * Gets the current class name
  53427. * @returns the class name
  53428. */
  53429. getClassName(): string;
  53430. /**
  53431. * Gets the left operand input component
  53432. */
  53433. readonly left: NodeMaterialConnectionPoint;
  53434. /**
  53435. * Gets the right operand input component
  53436. */
  53437. readonly right: NodeMaterialConnectionPoint;
  53438. /**
  53439. * Gets the output component
  53440. */
  53441. readonly output: NodeMaterialConnectionPoint;
  53442. protected _buildBlock(state: NodeMaterialBuildState): this;
  53443. }
  53444. }
  53445. declare module BABYLON {
  53446. /**
  53447. * Block used to add 2 vectors
  53448. */
  53449. export class AddBlock extends NodeMaterialBlock {
  53450. /**
  53451. * Creates a new AddBlock
  53452. * @param name defines the block name
  53453. */
  53454. constructor(name: string);
  53455. /**
  53456. * Gets the current class name
  53457. * @returns the class name
  53458. */
  53459. getClassName(): string;
  53460. /**
  53461. * Gets the left operand input component
  53462. */
  53463. readonly left: NodeMaterialConnectionPoint;
  53464. /**
  53465. * Gets the right operand input component
  53466. */
  53467. readonly right: NodeMaterialConnectionPoint;
  53468. /**
  53469. * Gets the output component
  53470. */
  53471. readonly output: NodeMaterialConnectionPoint;
  53472. protected _buildBlock(state: NodeMaterialBuildState): this;
  53473. }
  53474. }
  53475. declare module BABYLON {
  53476. /**
  53477. * Block used to scale a vector by a float
  53478. */
  53479. export class ScaleBlock extends NodeMaterialBlock {
  53480. /**
  53481. * Creates a new ScaleBlock
  53482. * @param name defines the block name
  53483. */
  53484. constructor(name: string);
  53485. /**
  53486. * Gets the current class name
  53487. * @returns the class name
  53488. */
  53489. getClassName(): string;
  53490. /**
  53491. * Gets the input component
  53492. */
  53493. readonly input: NodeMaterialConnectionPoint;
  53494. /**
  53495. * Gets the factor input component
  53496. */
  53497. readonly factor: NodeMaterialConnectionPoint;
  53498. /**
  53499. * Gets the output component
  53500. */
  53501. readonly output: NodeMaterialConnectionPoint;
  53502. protected _buildBlock(state: NodeMaterialBuildState): this;
  53503. }
  53504. }
  53505. declare module BABYLON {
  53506. /**
  53507. * Block used to clamp a float
  53508. */
  53509. export class ClampBlock extends NodeMaterialBlock {
  53510. /** Gets or sets the minimum range */
  53511. minimum: number;
  53512. /** Gets or sets the maximum range */
  53513. maximum: number;
  53514. /**
  53515. * Creates a new ClampBlock
  53516. * @param name defines the block name
  53517. */
  53518. constructor(name: string);
  53519. /**
  53520. * Gets the current class name
  53521. * @returns the class name
  53522. */
  53523. getClassName(): string;
  53524. /**
  53525. * Gets the value input component
  53526. */
  53527. readonly value: NodeMaterialConnectionPoint;
  53528. /**
  53529. * Gets the output component
  53530. */
  53531. readonly output: NodeMaterialConnectionPoint;
  53532. protected _buildBlock(state: NodeMaterialBuildState): this;
  53533. protected _dumpPropertiesCode(): string;
  53534. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53535. }
  53536. }
  53537. declare module BABYLON {
  53538. /**
  53539. * Block used to apply a cross product between 2 vectors
  53540. */
  53541. export class CrossBlock extends NodeMaterialBlock {
  53542. /**
  53543. * Creates a new CrossBlock
  53544. * @param name defines the block name
  53545. */
  53546. constructor(name: string);
  53547. /**
  53548. * Gets the current class name
  53549. * @returns the class name
  53550. */
  53551. getClassName(): string;
  53552. /**
  53553. * Gets the left operand input component
  53554. */
  53555. readonly left: NodeMaterialConnectionPoint;
  53556. /**
  53557. * Gets the right operand input component
  53558. */
  53559. readonly right: NodeMaterialConnectionPoint;
  53560. /**
  53561. * Gets the output component
  53562. */
  53563. readonly output: NodeMaterialConnectionPoint;
  53564. protected _buildBlock(state: NodeMaterialBuildState): this;
  53565. }
  53566. }
  53567. declare module BABYLON {
  53568. /**
  53569. * Block used to apply a dot product between 2 vectors
  53570. */
  53571. export class DotBlock extends NodeMaterialBlock {
  53572. /**
  53573. * Creates a new DotBlock
  53574. * @param name defines the block name
  53575. */
  53576. constructor(name: string);
  53577. /**
  53578. * Gets the current class name
  53579. * @returns the class name
  53580. */
  53581. getClassName(): string;
  53582. /**
  53583. * Gets the left operand input component
  53584. */
  53585. readonly left: NodeMaterialConnectionPoint;
  53586. /**
  53587. * Gets the right operand input component
  53588. */
  53589. readonly right: NodeMaterialConnectionPoint;
  53590. /**
  53591. * Gets the output component
  53592. */
  53593. readonly output: NodeMaterialConnectionPoint;
  53594. protected _buildBlock(state: NodeMaterialBuildState): this;
  53595. }
  53596. }
  53597. declare module BABYLON {
  53598. /**
  53599. * Block used to remap a float from a range to a new one
  53600. */
  53601. export class RemapBlock extends NodeMaterialBlock {
  53602. /**
  53603. * Gets or sets the source range
  53604. */
  53605. sourceRange: Vector2;
  53606. /**
  53607. * Gets or sets the target range
  53608. */
  53609. targetRange: Vector2;
  53610. /**
  53611. * Creates a new RemapBlock
  53612. * @param name defines the block name
  53613. */
  53614. constructor(name: string);
  53615. /**
  53616. * Gets the current class name
  53617. * @returns the class name
  53618. */
  53619. getClassName(): string;
  53620. /**
  53621. * Gets the input component
  53622. */
  53623. readonly input: NodeMaterialConnectionPoint;
  53624. /**
  53625. * Gets the source min input component
  53626. */
  53627. readonly sourceMin: NodeMaterialConnectionPoint;
  53628. /**
  53629. * Gets the source max input component
  53630. */
  53631. readonly sourceMax: NodeMaterialConnectionPoint;
  53632. /**
  53633. * Gets the target min input component
  53634. */
  53635. readonly targetMin: NodeMaterialConnectionPoint;
  53636. /**
  53637. * Gets the target max input component
  53638. */
  53639. readonly targetMax: NodeMaterialConnectionPoint;
  53640. /**
  53641. * Gets the output component
  53642. */
  53643. readonly output: NodeMaterialConnectionPoint;
  53644. protected _buildBlock(state: NodeMaterialBuildState): this;
  53645. protected _dumpPropertiesCode(): string;
  53646. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53647. }
  53648. }
  53649. declare module BABYLON {
  53650. /**
  53651. * Block used to normalize a vector
  53652. */
  53653. export class NormalizeBlock extends NodeMaterialBlock {
  53654. /**
  53655. * Creates a new NormalizeBlock
  53656. * @param name defines the block name
  53657. */
  53658. constructor(name: string);
  53659. /**
  53660. * Gets the current class name
  53661. * @returns the class name
  53662. */
  53663. getClassName(): string;
  53664. /**
  53665. * Gets the input component
  53666. */
  53667. readonly input: NodeMaterialConnectionPoint;
  53668. /**
  53669. * Gets the output component
  53670. */
  53671. readonly output: NodeMaterialConnectionPoint;
  53672. protected _buildBlock(state: NodeMaterialBuildState): this;
  53673. }
  53674. }
  53675. declare module BABYLON {
  53676. /**
  53677. * Operations supported by the Trigonometry block
  53678. */
  53679. export enum TrigonometryBlockOperations {
  53680. /** Cos */
  53681. Cos = 0,
  53682. /** Sin */
  53683. Sin = 1,
  53684. /** Abs */
  53685. Abs = 2,
  53686. /** Exp */
  53687. Exp = 3,
  53688. /** Exp2 */
  53689. Exp2 = 4,
  53690. /** Round */
  53691. Round = 5,
  53692. /** Floor */
  53693. Floor = 6,
  53694. /** Ceiling */
  53695. Ceiling = 7,
  53696. /** Square root */
  53697. Sqrt = 8,
  53698. /** Log */
  53699. Log = 9,
  53700. /** Tangent */
  53701. Tan = 10,
  53702. /** Arc tangent */
  53703. ArcTan = 11,
  53704. /** Arc cosinus */
  53705. ArcCos = 12,
  53706. /** Arc sinus */
  53707. ArcSin = 13,
  53708. /** Fraction */
  53709. Fract = 14,
  53710. /** Sign */
  53711. Sign = 15,
  53712. /** To radians (from degrees) */
  53713. Radians = 16,
  53714. /** To degrees (from radians) */
  53715. Degrees = 17
  53716. }
  53717. /**
  53718. * Block used to apply trigonometry operation to floats
  53719. */
  53720. export class TrigonometryBlock extends NodeMaterialBlock {
  53721. /**
  53722. * Gets or sets the operation applied by the block
  53723. */
  53724. operation: TrigonometryBlockOperations;
  53725. /**
  53726. * Creates a new TrigonometryBlock
  53727. * @param name defines the block name
  53728. */
  53729. constructor(name: string);
  53730. /**
  53731. * Gets the current class name
  53732. * @returns the class name
  53733. */
  53734. getClassName(): string;
  53735. /**
  53736. * Gets the input component
  53737. */
  53738. readonly input: NodeMaterialConnectionPoint;
  53739. /**
  53740. * Gets the output component
  53741. */
  53742. readonly output: NodeMaterialConnectionPoint;
  53743. protected _buildBlock(state: NodeMaterialBuildState): this;
  53744. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53745. }
  53746. }
  53747. declare module BABYLON {
  53748. /**
  53749. * Block used to create a Color3/4 out of individual inputs (one for each component)
  53750. */
  53751. export class ColorMergerBlock extends NodeMaterialBlock {
  53752. /**
  53753. * Create a new ColorMergerBlock
  53754. * @param name defines the block name
  53755. */
  53756. constructor(name: string);
  53757. /**
  53758. * Gets the current class name
  53759. * @returns the class name
  53760. */
  53761. getClassName(): string;
  53762. /**
  53763. * Gets the r component (input)
  53764. */
  53765. readonly r: NodeMaterialConnectionPoint;
  53766. /**
  53767. * Gets the g component (input)
  53768. */
  53769. readonly g: NodeMaterialConnectionPoint;
  53770. /**
  53771. * Gets the b component (input)
  53772. */
  53773. readonly b: NodeMaterialConnectionPoint;
  53774. /**
  53775. * Gets the a component (input)
  53776. */
  53777. readonly a: NodeMaterialConnectionPoint;
  53778. /**
  53779. * Gets the rgba component (output)
  53780. */
  53781. readonly rgba: NodeMaterialConnectionPoint;
  53782. /**
  53783. * Gets the rgb component (output)
  53784. */
  53785. readonly rgb: NodeMaterialConnectionPoint;
  53786. protected _buildBlock(state: NodeMaterialBuildState): this;
  53787. }
  53788. }
  53789. declare module BABYLON {
  53790. /**
  53791. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  53792. */
  53793. export class VectorMergerBlock extends NodeMaterialBlock {
  53794. /**
  53795. * Create a new VectorMergerBlock
  53796. * @param name defines the block name
  53797. */
  53798. constructor(name: string);
  53799. /**
  53800. * Gets the current class name
  53801. * @returns the class name
  53802. */
  53803. getClassName(): string;
  53804. /**
  53805. * Gets the x component (input)
  53806. */
  53807. readonly x: NodeMaterialConnectionPoint;
  53808. /**
  53809. * Gets the y component (input)
  53810. */
  53811. readonly y: NodeMaterialConnectionPoint;
  53812. /**
  53813. * Gets the z component (input)
  53814. */
  53815. readonly z: NodeMaterialConnectionPoint;
  53816. /**
  53817. * Gets the w component (input)
  53818. */
  53819. readonly w: NodeMaterialConnectionPoint;
  53820. /**
  53821. * Gets the xyzw component (output)
  53822. */
  53823. readonly xyzw: NodeMaterialConnectionPoint;
  53824. /**
  53825. * Gets the xyz component (output)
  53826. */
  53827. readonly xyz: NodeMaterialConnectionPoint;
  53828. /**
  53829. * Gets the xy component (output)
  53830. */
  53831. readonly xy: NodeMaterialConnectionPoint;
  53832. protected _buildBlock(state: NodeMaterialBuildState): this;
  53833. }
  53834. }
  53835. declare module BABYLON {
  53836. /**
  53837. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  53838. */
  53839. export class ColorSplitterBlock extends NodeMaterialBlock {
  53840. /**
  53841. * Create a new ColorSplitterBlock
  53842. * @param name defines the block name
  53843. */
  53844. constructor(name: string);
  53845. /**
  53846. * Gets the current class name
  53847. * @returns the class name
  53848. */
  53849. getClassName(): string;
  53850. /**
  53851. * Gets the rgba component (input)
  53852. */
  53853. readonly rgba: NodeMaterialConnectionPoint;
  53854. /**
  53855. * Gets the rgb component (input)
  53856. */
  53857. readonly rgbIn: NodeMaterialConnectionPoint;
  53858. /**
  53859. * Gets the rgb component (output)
  53860. */
  53861. readonly rgbOut: NodeMaterialConnectionPoint;
  53862. /**
  53863. * Gets the r component (output)
  53864. */
  53865. readonly r: NodeMaterialConnectionPoint;
  53866. /**
  53867. * Gets the g component (output)
  53868. */
  53869. readonly g: NodeMaterialConnectionPoint;
  53870. /**
  53871. * Gets the b component (output)
  53872. */
  53873. readonly b: NodeMaterialConnectionPoint;
  53874. /**
  53875. * Gets the a component (output)
  53876. */
  53877. readonly a: NodeMaterialConnectionPoint;
  53878. protected _inputRename(name: string): string;
  53879. protected _outputRename(name: string): string;
  53880. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53881. }
  53882. }
  53883. declare module BABYLON {
  53884. /**
  53885. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  53886. */
  53887. export class VectorSplitterBlock extends NodeMaterialBlock {
  53888. /**
  53889. * Create a new VectorSplitterBlock
  53890. * @param name defines the block name
  53891. */
  53892. constructor(name: string);
  53893. /**
  53894. * Gets the current class name
  53895. * @returns the class name
  53896. */
  53897. getClassName(): string;
  53898. /**
  53899. * Gets the xyzw component (input)
  53900. */
  53901. readonly xyzw: NodeMaterialConnectionPoint;
  53902. /**
  53903. * Gets the xyz component (input)
  53904. */
  53905. readonly xyzIn: NodeMaterialConnectionPoint;
  53906. /**
  53907. * Gets the xy component (input)
  53908. */
  53909. readonly xyIn: NodeMaterialConnectionPoint;
  53910. /**
  53911. * Gets the xyz component (output)
  53912. */
  53913. readonly xyzOut: NodeMaterialConnectionPoint;
  53914. /**
  53915. * Gets the xy component (output)
  53916. */
  53917. readonly xyOut: NodeMaterialConnectionPoint;
  53918. /**
  53919. * Gets the x component (output)
  53920. */
  53921. readonly x: NodeMaterialConnectionPoint;
  53922. /**
  53923. * Gets the y component (output)
  53924. */
  53925. readonly y: NodeMaterialConnectionPoint;
  53926. /**
  53927. * Gets the z component (output)
  53928. */
  53929. readonly z: NodeMaterialConnectionPoint;
  53930. /**
  53931. * Gets the w component (output)
  53932. */
  53933. readonly w: NodeMaterialConnectionPoint;
  53934. protected _inputRename(name: string): string;
  53935. protected _outputRename(name: string): string;
  53936. protected _buildBlock(state: NodeMaterialBuildState): this;
  53937. }
  53938. }
  53939. declare module BABYLON {
  53940. /**
  53941. * Block used to lerp between 2 values
  53942. */
  53943. export class LerpBlock extends NodeMaterialBlock {
  53944. /**
  53945. * Creates a new LerpBlock
  53946. * @param name defines the block name
  53947. */
  53948. constructor(name: string);
  53949. /**
  53950. * Gets the current class name
  53951. * @returns the class name
  53952. */
  53953. getClassName(): string;
  53954. /**
  53955. * Gets the left operand input component
  53956. */
  53957. readonly left: NodeMaterialConnectionPoint;
  53958. /**
  53959. * Gets the right operand input component
  53960. */
  53961. readonly right: NodeMaterialConnectionPoint;
  53962. /**
  53963. * Gets the gradient operand input component
  53964. */
  53965. readonly gradient: NodeMaterialConnectionPoint;
  53966. /**
  53967. * Gets the output component
  53968. */
  53969. readonly output: NodeMaterialConnectionPoint;
  53970. protected _buildBlock(state: NodeMaterialBuildState): this;
  53971. }
  53972. }
  53973. declare module BABYLON {
  53974. /**
  53975. * Block used to divide 2 vectors
  53976. */
  53977. export class DivideBlock extends NodeMaterialBlock {
  53978. /**
  53979. * Creates a new DivideBlock
  53980. * @param name defines the block name
  53981. */
  53982. constructor(name: string);
  53983. /**
  53984. * Gets the current class name
  53985. * @returns the class name
  53986. */
  53987. getClassName(): string;
  53988. /**
  53989. * Gets the left operand input component
  53990. */
  53991. readonly left: NodeMaterialConnectionPoint;
  53992. /**
  53993. * Gets the right operand input component
  53994. */
  53995. readonly right: NodeMaterialConnectionPoint;
  53996. /**
  53997. * Gets the output component
  53998. */
  53999. readonly output: NodeMaterialConnectionPoint;
  54000. protected _buildBlock(state: NodeMaterialBuildState): this;
  54001. }
  54002. }
  54003. declare module BABYLON {
  54004. /**
  54005. * Block used to subtract 2 vectors
  54006. */
  54007. export class SubtractBlock extends NodeMaterialBlock {
  54008. /**
  54009. * Creates a new SubtractBlock
  54010. * @param name defines the block name
  54011. */
  54012. constructor(name: string);
  54013. /**
  54014. * Gets the current class name
  54015. * @returns the class name
  54016. */
  54017. getClassName(): string;
  54018. /**
  54019. * Gets the left operand input component
  54020. */
  54021. readonly left: NodeMaterialConnectionPoint;
  54022. /**
  54023. * Gets the right operand input component
  54024. */
  54025. readonly right: NodeMaterialConnectionPoint;
  54026. /**
  54027. * Gets the output component
  54028. */
  54029. readonly output: NodeMaterialConnectionPoint;
  54030. protected _buildBlock(state: NodeMaterialBuildState): this;
  54031. }
  54032. }
  54033. declare module BABYLON {
  54034. /**
  54035. * Block used to step a value
  54036. */
  54037. export class StepBlock extends NodeMaterialBlock {
  54038. /**
  54039. * Creates a new StepBlock
  54040. * @param name defines the block name
  54041. */
  54042. constructor(name: string);
  54043. /**
  54044. * Gets the current class name
  54045. * @returns the class name
  54046. */
  54047. getClassName(): string;
  54048. /**
  54049. * Gets the value operand input component
  54050. */
  54051. readonly value: NodeMaterialConnectionPoint;
  54052. /**
  54053. * Gets the edge operand input component
  54054. */
  54055. readonly edge: NodeMaterialConnectionPoint;
  54056. /**
  54057. * Gets the output component
  54058. */
  54059. readonly output: NodeMaterialConnectionPoint;
  54060. protected _buildBlock(state: NodeMaterialBuildState): this;
  54061. }
  54062. }
  54063. declare module BABYLON {
  54064. /**
  54065. * Block used to get the opposite (1 - x) of a value
  54066. */
  54067. export class OneMinusBlock extends NodeMaterialBlock {
  54068. /**
  54069. * Creates a new OneMinusBlock
  54070. * @param name defines the block name
  54071. */
  54072. constructor(name: string);
  54073. /**
  54074. * Gets the current class name
  54075. * @returns the class name
  54076. */
  54077. getClassName(): string;
  54078. /**
  54079. * Gets the input component
  54080. */
  54081. readonly input: NodeMaterialConnectionPoint;
  54082. /**
  54083. * Gets the output component
  54084. */
  54085. readonly output: NodeMaterialConnectionPoint;
  54086. protected _buildBlock(state: NodeMaterialBuildState): this;
  54087. }
  54088. }
  54089. declare module BABYLON {
  54090. /**
  54091. * Block used to get the view direction
  54092. */
  54093. export class ViewDirectionBlock extends NodeMaterialBlock {
  54094. /**
  54095. * Creates a new ViewDirectionBlock
  54096. * @param name defines the block name
  54097. */
  54098. constructor(name: string);
  54099. /**
  54100. * Gets the current class name
  54101. * @returns the class name
  54102. */
  54103. getClassName(): string;
  54104. /**
  54105. * Gets the world position component
  54106. */
  54107. readonly worldPosition: NodeMaterialConnectionPoint;
  54108. /**
  54109. * Gets the camera position component
  54110. */
  54111. readonly cameraPosition: NodeMaterialConnectionPoint;
  54112. /**
  54113. * Gets the output component
  54114. */
  54115. readonly output: NodeMaterialConnectionPoint;
  54116. autoConfigure(material: NodeMaterial): void;
  54117. protected _buildBlock(state: NodeMaterialBuildState): this;
  54118. }
  54119. }
  54120. declare module BABYLON {
  54121. /**
  54122. * Block used to compute fresnel value
  54123. */
  54124. export class FresnelBlock extends NodeMaterialBlock {
  54125. /**
  54126. * Create a new FresnelBlock
  54127. * @param name defines the block name
  54128. */
  54129. constructor(name: string);
  54130. /**
  54131. * Gets the current class name
  54132. * @returns the class name
  54133. */
  54134. getClassName(): string;
  54135. /**
  54136. * Gets the world normal input component
  54137. */
  54138. readonly worldNormal: NodeMaterialConnectionPoint;
  54139. /**
  54140. * Gets the view direction input component
  54141. */
  54142. readonly viewDirection: NodeMaterialConnectionPoint;
  54143. /**
  54144. * Gets the bias input component
  54145. */
  54146. readonly bias: NodeMaterialConnectionPoint;
  54147. /**
  54148. * Gets the camera (or eye) position component
  54149. */
  54150. readonly power: NodeMaterialConnectionPoint;
  54151. /**
  54152. * Gets the fresnel output component
  54153. */
  54154. readonly fresnel: NodeMaterialConnectionPoint;
  54155. autoConfigure(material: NodeMaterial): void;
  54156. protected _buildBlock(state: NodeMaterialBuildState): this;
  54157. }
  54158. }
  54159. declare module BABYLON {
  54160. /**
  54161. * Block used to get the max of 2 values
  54162. */
  54163. export class MaxBlock extends NodeMaterialBlock {
  54164. /**
  54165. * Creates a new MaxBlock
  54166. * @param name defines the block name
  54167. */
  54168. constructor(name: string);
  54169. /**
  54170. * Gets the current class name
  54171. * @returns the class name
  54172. */
  54173. getClassName(): string;
  54174. /**
  54175. * Gets the left operand input component
  54176. */
  54177. readonly left: NodeMaterialConnectionPoint;
  54178. /**
  54179. * Gets the right operand input component
  54180. */
  54181. readonly right: NodeMaterialConnectionPoint;
  54182. /**
  54183. * Gets the output component
  54184. */
  54185. readonly output: NodeMaterialConnectionPoint;
  54186. protected _buildBlock(state: NodeMaterialBuildState): this;
  54187. }
  54188. }
  54189. declare module BABYLON {
  54190. /**
  54191. * Block used to get the min of 2 values
  54192. */
  54193. export class MinBlock extends NodeMaterialBlock {
  54194. /**
  54195. * Creates a new MinBlock
  54196. * @param name defines the block name
  54197. */
  54198. constructor(name: string);
  54199. /**
  54200. * Gets the current class name
  54201. * @returns the class name
  54202. */
  54203. getClassName(): string;
  54204. /**
  54205. * Gets the left operand input component
  54206. */
  54207. readonly left: NodeMaterialConnectionPoint;
  54208. /**
  54209. * Gets the right operand input component
  54210. */
  54211. readonly right: NodeMaterialConnectionPoint;
  54212. /**
  54213. * Gets the output component
  54214. */
  54215. readonly output: NodeMaterialConnectionPoint;
  54216. protected _buildBlock(state: NodeMaterialBuildState): this;
  54217. }
  54218. }
  54219. declare module BABYLON {
  54220. /**
  54221. * Block used to get the distance between 2 values
  54222. */
  54223. export class DistanceBlock extends NodeMaterialBlock {
  54224. /**
  54225. * Creates a new DistanceBlock
  54226. * @param name defines the block name
  54227. */
  54228. constructor(name: string);
  54229. /**
  54230. * Gets the current class name
  54231. * @returns the class name
  54232. */
  54233. getClassName(): string;
  54234. /**
  54235. * Gets the left operand input component
  54236. */
  54237. readonly left: NodeMaterialConnectionPoint;
  54238. /**
  54239. * Gets the right operand input component
  54240. */
  54241. readonly right: NodeMaterialConnectionPoint;
  54242. /**
  54243. * Gets the output component
  54244. */
  54245. readonly output: NodeMaterialConnectionPoint;
  54246. protected _buildBlock(state: NodeMaterialBuildState): this;
  54247. }
  54248. }
  54249. declare module BABYLON {
  54250. /**
  54251. * Block used to get the length of a vector
  54252. */
  54253. export class LengthBlock extends NodeMaterialBlock {
  54254. /**
  54255. * Creates a new LengthBlock
  54256. * @param name defines the block name
  54257. */
  54258. constructor(name: string);
  54259. /**
  54260. * Gets the current class name
  54261. * @returns the class name
  54262. */
  54263. getClassName(): string;
  54264. /**
  54265. * Gets the value input component
  54266. */
  54267. readonly value: NodeMaterialConnectionPoint;
  54268. /**
  54269. * Gets the output component
  54270. */
  54271. readonly output: NodeMaterialConnectionPoint;
  54272. protected _buildBlock(state: NodeMaterialBuildState): this;
  54273. }
  54274. }
  54275. declare module BABYLON {
  54276. /**
  54277. * Block used to get negative version of a value (i.e. x * -1)
  54278. */
  54279. export class NegateBlock extends NodeMaterialBlock {
  54280. /**
  54281. * Creates a new NegateBlock
  54282. * @param name defines the block name
  54283. */
  54284. constructor(name: string);
  54285. /**
  54286. * Gets the current class name
  54287. * @returns the class name
  54288. */
  54289. getClassName(): string;
  54290. /**
  54291. * Gets the value input component
  54292. */
  54293. readonly value: NodeMaterialConnectionPoint;
  54294. /**
  54295. * Gets the output component
  54296. */
  54297. readonly output: NodeMaterialConnectionPoint;
  54298. protected _buildBlock(state: NodeMaterialBuildState): this;
  54299. }
  54300. }
  54301. declare module BABYLON {
  54302. /**
  54303. * Block used to get the value of the first parameter raised to the power of the second
  54304. */
  54305. export class PowBlock extends NodeMaterialBlock {
  54306. /**
  54307. * Creates a new PowBlock
  54308. * @param name defines the block name
  54309. */
  54310. constructor(name: string);
  54311. /**
  54312. * Gets the current class name
  54313. * @returns the class name
  54314. */
  54315. getClassName(): string;
  54316. /**
  54317. * Gets the value operand input component
  54318. */
  54319. readonly value: NodeMaterialConnectionPoint;
  54320. /**
  54321. * Gets the power operand input component
  54322. */
  54323. readonly power: NodeMaterialConnectionPoint;
  54324. /**
  54325. * Gets the output component
  54326. */
  54327. readonly output: NodeMaterialConnectionPoint;
  54328. protected _buildBlock(state: NodeMaterialBuildState): this;
  54329. }
  54330. }
  54331. declare module BABYLON {
  54332. /**
  54333. * Block used to get a random number
  54334. */
  54335. export class RandomNumberBlock extends NodeMaterialBlock {
  54336. /**
  54337. * Creates a new RandomNumberBlock
  54338. * @param name defines the block name
  54339. */
  54340. constructor(name: string);
  54341. /**
  54342. * Gets the current class name
  54343. * @returns the class name
  54344. */
  54345. getClassName(): string;
  54346. /**
  54347. * Gets the seed input component
  54348. */
  54349. readonly seed: NodeMaterialConnectionPoint;
  54350. /**
  54351. * Gets the output component
  54352. */
  54353. readonly output: NodeMaterialConnectionPoint;
  54354. protected _buildBlock(state: NodeMaterialBuildState): this;
  54355. }
  54356. }
  54357. declare module BABYLON {
  54358. /**
  54359. * Block used to compute arc tangent of 2 values
  54360. */
  54361. export class ArcTan2Block extends NodeMaterialBlock {
  54362. /**
  54363. * Creates a new ArcTan2Block
  54364. * @param name defines the block name
  54365. */
  54366. constructor(name: string);
  54367. /**
  54368. * Gets the current class name
  54369. * @returns the class name
  54370. */
  54371. getClassName(): string;
  54372. /**
  54373. * Gets the x operand input component
  54374. */
  54375. readonly x: NodeMaterialConnectionPoint;
  54376. /**
  54377. * Gets the y operand input component
  54378. */
  54379. readonly y: NodeMaterialConnectionPoint;
  54380. /**
  54381. * Gets the output component
  54382. */
  54383. readonly output: NodeMaterialConnectionPoint;
  54384. protected _buildBlock(state: NodeMaterialBuildState): this;
  54385. }
  54386. }
  54387. declare module BABYLON {
  54388. /**
  54389. * Block used to smooth step a value
  54390. */
  54391. export class SmoothStepBlock extends NodeMaterialBlock {
  54392. /**
  54393. * Creates a new SmoothStepBlock
  54394. * @param name defines the block name
  54395. */
  54396. constructor(name: string);
  54397. /**
  54398. * Gets the current class name
  54399. * @returns the class name
  54400. */
  54401. getClassName(): string;
  54402. /**
  54403. * Gets the value operand input component
  54404. */
  54405. readonly value: NodeMaterialConnectionPoint;
  54406. /**
  54407. * Gets the first edge operand input component
  54408. */
  54409. readonly edge0: NodeMaterialConnectionPoint;
  54410. /**
  54411. * Gets the second edge operand input component
  54412. */
  54413. readonly edge1: NodeMaterialConnectionPoint;
  54414. /**
  54415. * Gets the output component
  54416. */
  54417. readonly output: NodeMaterialConnectionPoint;
  54418. protected _buildBlock(state: NodeMaterialBuildState): this;
  54419. }
  54420. }
  54421. declare module BABYLON {
  54422. /**
  54423. * Block used to get the reciprocal (1 / x) of a value
  54424. */
  54425. export class ReciprocalBlock extends NodeMaterialBlock {
  54426. /**
  54427. * Creates a new ReciprocalBlock
  54428. * @param name defines the block name
  54429. */
  54430. constructor(name: string);
  54431. /**
  54432. * Gets the current class name
  54433. * @returns the class name
  54434. */
  54435. getClassName(): string;
  54436. /**
  54437. * Gets the input component
  54438. */
  54439. readonly input: NodeMaterialConnectionPoint;
  54440. /**
  54441. * Gets the output component
  54442. */
  54443. readonly output: NodeMaterialConnectionPoint;
  54444. protected _buildBlock(state: NodeMaterialBuildState): this;
  54445. }
  54446. }
  54447. declare module BABYLON {
  54448. /**
  54449. * Block used to replace a color by another one
  54450. */
  54451. export class ReplaceColorBlock extends NodeMaterialBlock {
  54452. /**
  54453. * Creates a new ReplaceColorBlock
  54454. * @param name defines the block name
  54455. */
  54456. constructor(name: string);
  54457. /**
  54458. * Gets the current class name
  54459. * @returns the class name
  54460. */
  54461. getClassName(): string;
  54462. /**
  54463. * Gets the value input component
  54464. */
  54465. readonly value: NodeMaterialConnectionPoint;
  54466. /**
  54467. * Gets the reference input component
  54468. */
  54469. readonly reference: NodeMaterialConnectionPoint;
  54470. /**
  54471. * Gets the distance input component
  54472. */
  54473. readonly distance: NodeMaterialConnectionPoint;
  54474. /**
  54475. * Gets the replacement input component
  54476. */
  54477. readonly replacement: NodeMaterialConnectionPoint;
  54478. /**
  54479. * Gets the output component
  54480. */
  54481. readonly output: NodeMaterialConnectionPoint;
  54482. protected _buildBlock(state: NodeMaterialBuildState): this;
  54483. }
  54484. }
  54485. declare module BABYLON {
  54486. /**
  54487. * Block used to posterize a value
  54488. * @see https://en.wikipedia.org/wiki/Posterization
  54489. */
  54490. export class PosterizeBlock extends NodeMaterialBlock {
  54491. /**
  54492. * Creates a new PosterizeBlock
  54493. * @param name defines the block name
  54494. */
  54495. constructor(name: string);
  54496. /**
  54497. * Gets the current class name
  54498. * @returns the class name
  54499. */
  54500. getClassName(): string;
  54501. /**
  54502. * Gets the value input component
  54503. */
  54504. readonly value: NodeMaterialConnectionPoint;
  54505. /**
  54506. * Gets the steps input component
  54507. */
  54508. readonly steps: NodeMaterialConnectionPoint;
  54509. /**
  54510. * Gets the output component
  54511. */
  54512. readonly output: NodeMaterialConnectionPoint;
  54513. protected _buildBlock(state: NodeMaterialBuildState): this;
  54514. }
  54515. }
  54516. declare module BABYLON {
  54517. /**
  54518. * Operations supported by the Wave block
  54519. */
  54520. export enum WaveBlockKind {
  54521. /** SawTooth */
  54522. SawTooth = 0,
  54523. /** Square */
  54524. Square = 1,
  54525. /** Triangle */
  54526. Triangle = 2
  54527. }
  54528. /**
  54529. * Block used to apply wave operation to floats
  54530. */
  54531. export class WaveBlock extends NodeMaterialBlock {
  54532. /**
  54533. * Gets or sets the kibnd of wave to be applied by the block
  54534. */
  54535. kind: WaveBlockKind;
  54536. /**
  54537. * Creates a new WaveBlock
  54538. * @param name defines the block name
  54539. */
  54540. constructor(name: string);
  54541. /**
  54542. * Gets the current class name
  54543. * @returns the class name
  54544. */
  54545. getClassName(): string;
  54546. /**
  54547. * Gets the input component
  54548. */
  54549. readonly input: NodeMaterialConnectionPoint;
  54550. /**
  54551. * Gets the output component
  54552. */
  54553. readonly output: NodeMaterialConnectionPoint;
  54554. protected _buildBlock(state: NodeMaterialBuildState): this;
  54555. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54556. }
  54557. }
  54558. declare module BABYLON {
  54559. /**
  54560. * Class used to store a color step for the GradientBlock
  54561. */
  54562. export class GradientBlockColorStep {
  54563. /**
  54564. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  54565. */
  54566. step: number;
  54567. /**
  54568. * Gets or sets the color associated with this step
  54569. */
  54570. color: Color3;
  54571. /**
  54572. * Creates a new GradientBlockColorStep
  54573. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  54574. * @param color defines the color associated with this step
  54575. */
  54576. constructor(
  54577. /**
  54578. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  54579. */
  54580. step: number,
  54581. /**
  54582. * Gets or sets the color associated with this step
  54583. */
  54584. color: Color3);
  54585. }
  54586. /**
  54587. * Block used to return a color from a gradient based on an input value between 0 and 1
  54588. */
  54589. export class GradientBlock extends NodeMaterialBlock {
  54590. /**
  54591. * Gets or sets the list of color steps
  54592. */
  54593. colorSteps: GradientBlockColorStep[];
  54594. /**
  54595. * Creates a new GradientBlock
  54596. * @param name defines the block name
  54597. */
  54598. constructor(name: string);
  54599. /**
  54600. * Gets the current class name
  54601. * @returns the class name
  54602. */
  54603. getClassName(): string;
  54604. /**
  54605. * Gets the gradient input component
  54606. */
  54607. readonly gradient: NodeMaterialConnectionPoint;
  54608. /**
  54609. * Gets the output component
  54610. */
  54611. readonly output: NodeMaterialConnectionPoint;
  54612. private _writeColorConstant;
  54613. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54614. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54615. protected _dumpPropertiesCode(): string;
  54616. }
  54617. }
  54618. declare module BABYLON {
  54619. /**
  54620. * Block used to normalize lerp between 2 values
  54621. */
  54622. export class NLerpBlock extends NodeMaterialBlock {
  54623. /**
  54624. * Creates a new NLerpBlock
  54625. * @param name defines the block name
  54626. */
  54627. constructor(name: string);
  54628. /**
  54629. * Gets the current class name
  54630. * @returns the class name
  54631. */
  54632. getClassName(): string;
  54633. /**
  54634. * Gets the left operand input component
  54635. */
  54636. readonly left: NodeMaterialConnectionPoint;
  54637. /**
  54638. * Gets the right operand input component
  54639. */
  54640. readonly right: NodeMaterialConnectionPoint;
  54641. /**
  54642. * Gets the gradient operand input component
  54643. */
  54644. readonly gradient: NodeMaterialConnectionPoint;
  54645. /**
  54646. * Gets the output component
  54647. */
  54648. readonly output: NodeMaterialConnectionPoint;
  54649. protected _buildBlock(state: NodeMaterialBuildState): this;
  54650. }
  54651. }
  54652. declare module BABYLON {
  54653. /**
  54654. * Effect Render Options
  54655. */
  54656. export interface IEffectRendererOptions {
  54657. /**
  54658. * Defines the vertices positions.
  54659. */
  54660. positions?: number[];
  54661. /**
  54662. * Defines the indices.
  54663. */
  54664. indices?: number[];
  54665. }
  54666. /**
  54667. * Helper class to render one or more effects
  54668. */
  54669. export class EffectRenderer {
  54670. private engine;
  54671. private static _DefaultOptions;
  54672. private _vertexBuffers;
  54673. private _indexBuffer;
  54674. private _ringBufferIndex;
  54675. private _ringScreenBuffer;
  54676. private _fullscreenViewport;
  54677. private _getNextFrameBuffer;
  54678. /**
  54679. * Creates an effect renderer
  54680. * @param engine the engine to use for rendering
  54681. * @param options defines the options of the effect renderer
  54682. */
  54683. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  54684. /**
  54685. * Sets the current viewport in normalized coordinates 0-1
  54686. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  54687. */
  54688. setViewport(viewport?: Viewport): void;
  54689. /**
  54690. * Binds the embedded attributes buffer to the effect.
  54691. * @param effect Defines the effect to bind the attributes for
  54692. */
  54693. bindBuffers(effect: Effect): void;
  54694. /**
  54695. * Sets the current effect wrapper to use during draw.
  54696. * The effect needs to be ready before calling this api.
  54697. * This also sets the default full screen position attribute.
  54698. * @param effectWrapper Defines the effect to draw with
  54699. */
  54700. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  54701. /**
  54702. * Draws a full screen quad.
  54703. */
  54704. draw(): void;
  54705. /**
  54706. * renders one or more effects to a specified texture
  54707. * @param effectWrappers list of effects to renderer
  54708. * @param outputTexture texture to draw to, if null it will render to the screen
  54709. */
  54710. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  54711. /**
  54712. * Disposes of the effect renderer
  54713. */
  54714. dispose(): void;
  54715. }
  54716. /**
  54717. * Options to create an EffectWrapper
  54718. */
  54719. interface EffectWrapperCreationOptions {
  54720. /**
  54721. * Engine to use to create the effect
  54722. */
  54723. engine: ThinEngine;
  54724. /**
  54725. * Fragment shader for the effect
  54726. */
  54727. fragmentShader: string;
  54728. /**
  54729. * Vertex shader for the effect
  54730. */
  54731. vertexShader?: string;
  54732. /**
  54733. * Attributes to use in the shader
  54734. */
  54735. attributeNames?: Array<string>;
  54736. /**
  54737. * Uniforms to use in the shader
  54738. */
  54739. uniformNames?: Array<string>;
  54740. /**
  54741. * Texture sampler names to use in the shader
  54742. */
  54743. samplerNames?: Array<string>;
  54744. /**
  54745. * The friendly name of the effect displayed in Spector.
  54746. */
  54747. name?: string;
  54748. }
  54749. /**
  54750. * Wraps an effect to be used for rendering
  54751. */
  54752. export class EffectWrapper {
  54753. /**
  54754. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  54755. */
  54756. onApplyObservable: Observable<{}>;
  54757. /**
  54758. * The underlying effect
  54759. */
  54760. effect: Effect;
  54761. /**
  54762. * Creates an effect to be renderer
  54763. * @param creationOptions options to create the effect
  54764. */
  54765. constructor(creationOptions: EffectWrapperCreationOptions);
  54766. /**
  54767. * Disposes of the effect wrapper
  54768. */
  54769. dispose(): void;
  54770. }
  54771. }
  54772. declare module BABYLON {
  54773. /**
  54774. * Helper class to push actions to a pool of workers.
  54775. */
  54776. export class WorkerPool implements IDisposable {
  54777. private _workerInfos;
  54778. private _pendingActions;
  54779. /**
  54780. * Constructor
  54781. * @param workers Array of workers to use for actions
  54782. */
  54783. constructor(workers: Array<Worker>);
  54784. /**
  54785. * Terminates all workers and clears any pending actions.
  54786. */
  54787. dispose(): void;
  54788. /**
  54789. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54790. * pended until a worker has completed its action.
  54791. * @param action The action to perform. Call onComplete when the action is complete.
  54792. */
  54793. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54794. private _execute;
  54795. }
  54796. }
  54797. declare module BABYLON {
  54798. /**
  54799. * Configuration for Draco compression
  54800. */
  54801. export interface IDracoCompressionConfiguration {
  54802. /**
  54803. * Configuration for the decoder.
  54804. */
  54805. decoder: {
  54806. /**
  54807. * The url to the WebAssembly module.
  54808. */
  54809. wasmUrl?: string;
  54810. /**
  54811. * The url to the WebAssembly binary.
  54812. */
  54813. wasmBinaryUrl?: string;
  54814. /**
  54815. * The url to the fallback JavaScript module.
  54816. */
  54817. fallbackUrl?: string;
  54818. };
  54819. }
  54820. /**
  54821. * Draco compression (https://google.github.io/draco/)
  54822. *
  54823. * This class wraps the Draco module.
  54824. *
  54825. * **Encoder**
  54826. *
  54827. * The encoder is not currently implemented.
  54828. *
  54829. * **Decoder**
  54830. *
  54831. * 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.
  54832. *
  54833. * To update the configuration, use the following code:
  54834. * ```javascript
  54835. * DracoCompression.Configuration = {
  54836. * decoder: {
  54837. * wasmUrl: "<url to the WebAssembly library>",
  54838. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54839. * fallbackUrl: "<url to the fallback JavaScript library>",
  54840. * }
  54841. * };
  54842. * ```
  54843. *
  54844. * 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.
  54845. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54846. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54847. *
  54848. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54849. * ```javascript
  54850. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54851. * ```
  54852. *
  54853. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54854. */
  54855. export class DracoCompression implements IDisposable {
  54856. private _workerPoolPromise?;
  54857. private _decoderModulePromise?;
  54858. /**
  54859. * The configuration. Defaults to the following urls:
  54860. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54861. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54862. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54863. */
  54864. static Configuration: IDracoCompressionConfiguration;
  54865. /**
  54866. * Returns true if the decoder configuration is available.
  54867. */
  54868. static readonly DecoderAvailable: boolean;
  54869. /**
  54870. * Default number of workers to create when creating the draco compression object.
  54871. */
  54872. static DefaultNumWorkers: number;
  54873. private static GetDefaultNumWorkers;
  54874. private static _Default;
  54875. /**
  54876. * Default instance for the draco compression object.
  54877. */
  54878. static readonly Default: DracoCompression;
  54879. /**
  54880. * Constructor
  54881. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54882. */
  54883. constructor(numWorkers?: number);
  54884. /**
  54885. * Stop all async operations and release resources.
  54886. */
  54887. dispose(): void;
  54888. /**
  54889. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54890. * @returns a promise that resolves when ready
  54891. */
  54892. whenReadyAsync(): Promise<void>;
  54893. /**
  54894. * Decode Draco compressed mesh data to vertex data.
  54895. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54896. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54897. * @returns A promise that resolves with the decoded vertex data
  54898. */
  54899. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54900. [kind: string]: number;
  54901. }): Promise<VertexData>;
  54902. }
  54903. }
  54904. declare module BABYLON {
  54905. /**
  54906. * Class for building Constructive Solid Geometry
  54907. */
  54908. export class CSG {
  54909. private polygons;
  54910. /**
  54911. * The world matrix
  54912. */
  54913. matrix: Matrix;
  54914. /**
  54915. * Stores the position
  54916. */
  54917. position: Vector3;
  54918. /**
  54919. * Stores the rotation
  54920. */
  54921. rotation: Vector3;
  54922. /**
  54923. * Stores the rotation quaternion
  54924. */
  54925. rotationQuaternion: Nullable<Quaternion>;
  54926. /**
  54927. * Stores the scaling vector
  54928. */
  54929. scaling: Vector3;
  54930. /**
  54931. * Convert the Mesh to CSG
  54932. * @param mesh The Mesh to convert to CSG
  54933. * @returns A new CSG from the Mesh
  54934. */
  54935. static FromMesh(mesh: Mesh): CSG;
  54936. /**
  54937. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54938. * @param polygons Polygons used to construct a CSG solid
  54939. */
  54940. private static FromPolygons;
  54941. /**
  54942. * Clones, or makes a deep copy, of the CSG
  54943. * @returns A new CSG
  54944. */
  54945. clone(): CSG;
  54946. /**
  54947. * Unions this CSG with another CSG
  54948. * @param csg The CSG to union against this CSG
  54949. * @returns The unioned CSG
  54950. */
  54951. union(csg: CSG): CSG;
  54952. /**
  54953. * Unions this CSG with another CSG in place
  54954. * @param csg The CSG to union against this CSG
  54955. */
  54956. unionInPlace(csg: CSG): void;
  54957. /**
  54958. * Subtracts this CSG with another CSG
  54959. * @param csg The CSG to subtract against this CSG
  54960. * @returns A new CSG
  54961. */
  54962. subtract(csg: CSG): CSG;
  54963. /**
  54964. * Subtracts this CSG with another CSG in place
  54965. * @param csg The CSG to subtact against this CSG
  54966. */
  54967. subtractInPlace(csg: CSG): void;
  54968. /**
  54969. * Intersect this CSG with another CSG
  54970. * @param csg The CSG to intersect against this CSG
  54971. * @returns A new CSG
  54972. */
  54973. intersect(csg: CSG): CSG;
  54974. /**
  54975. * Intersects this CSG with another CSG in place
  54976. * @param csg The CSG to intersect against this CSG
  54977. */
  54978. intersectInPlace(csg: CSG): void;
  54979. /**
  54980. * Return a new CSG solid with solid and empty space switched. This solid is
  54981. * not modified.
  54982. * @returns A new CSG solid with solid and empty space switched
  54983. */
  54984. inverse(): CSG;
  54985. /**
  54986. * Inverses the CSG in place
  54987. */
  54988. inverseInPlace(): void;
  54989. /**
  54990. * This is used to keep meshes transformations so they can be restored
  54991. * when we build back a Babylon Mesh
  54992. * NB : All CSG operations are performed in world coordinates
  54993. * @param csg The CSG to copy the transform attributes from
  54994. * @returns This CSG
  54995. */
  54996. copyTransformAttributes(csg: CSG): CSG;
  54997. /**
  54998. * Build Raw mesh from CSG
  54999. * Coordinates here are in world space
  55000. * @param name The name of the mesh geometry
  55001. * @param scene The Scene
  55002. * @param keepSubMeshes Specifies if the submeshes should be kept
  55003. * @returns A new Mesh
  55004. */
  55005. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55006. /**
  55007. * Build Mesh from CSG taking material and transforms into account
  55008. * @param name The name of the Mesh
  55009. * @param material The material of the Mesh
  55010. * @param scene The Scene
  55011. * @param keepSubMeshes Specifies if submeshes should be kept
  55012. * @returns The new Mesh
  55013. */
  55014. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55015. }
  55016. }
  55017. declare module BABYLON {
  55018. /**
  55019. * Class used to create a trail following a mesh
  55020. */
  55021. export class TrailMesh extends Mesh {
  55022. private _generator;
  55023. private _autoStart;
  55024. private _running;
  55025. private _diameter;
  55026. private _length;
  55027. private _sectionPolygonPointsCount;
  55028. private _sectionVectors;
  55029. private _sectionNormalVectors;
  55030. private _beforeRenderObserver;
  55031. /**
  55032. * @constructor
  55033. * @param name The value used by scene.getMeshByName() to do a lookup.
  55034. * @param generator The mesh to generate a trail.
  55035. * @param scene The scene to add this mesh to.
  55036. * @param diameter Diameter of trailing mesh. Default is 1.
  55037. * @param length Length of trailing mesh. Default is 60.
  55038. * @param autoStart Automatically start trailing mesh. Default true.
  55039. */
  55040. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55041. /**
  55042. * "TrailMesh"
  55043. * @returns "TrailMesh"
  55044. */
  55045. getClassName(): string;
  55046. private _createMesh;
  55047. /**
  55048. * Start trailing mesh.
  55049. */
  55050. start(): void;
  55051. /**
  55052. * Stop trailing mesh.
  55053. */
  55054. stop(): void;
  55055. /**
  55056. * Update trailing mesh geometry.
  55057. */
  55058. update(): void;
  55059. /**
  55060. * Returns a new TrailMesh object.
  55061. * @param name is a string, the name given to the new mesh
  55062. * @param newGenerator use new generator object for cloned trail mesh
  55063. * @returns a new mesh
  55064. */
  55065. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55066. /**
  55067. * Serializes this trail mesh
  55068. * @param serializationObject object to write serialization to
  55069. */
  55070. serialize(serializationObject: any): void;
  55071. /**
  55072. * Parses a serialized trail mesh
  55073. * @param parsedMesh the serialized mesh
  55074. * @param scene the scene to create the trail mesh in
  55075. * @returns the created trail mesh
  55076. */
  55077. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55078. }
  55079. }
  55080. declare module BABYLON {
  55081. /**
  55082. * Class containing static functions to help procedurally build meshes
  55083. */
  55084. export class TiledBoxBuilder {
  55085. /**
  55086. * Creates a box mesh
  55087. * 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)
  55088. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55089. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55090. * * 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
  55091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55092. * @param name defines the name of the mesh
  55093. * @param options defines the options used to create the mesh
  55094. * @param scene defines the hosting scene
  55095. * @returns the box mesh
  55096. */
  55097. static CreateTiledBox(name: string, options: {
  55098. pattern?: number;
  55099. width?: number;
  55100. height?: number;
  55101. depth?: number;
  55102. tileSize?: number;
  55103. tileWidth?: number;
  55104. tileHeight?: number;
  55105. alignHorizontal?: number;
  55106. alignVertical?: number;
  55107. faceUV?: Vector4[];
  55108. faceColors?: Color4[];
  55109. sideOrientation?: number;
  55110. updatable?: boolean;
  55111. }, scene?: Nullable<Scene>): Mesh;
  55112. }
  55113. }
  55114. declare module BABYLON {
  55115. /**
  55116. * Class containing static functions to help procedurally build meshes
  55117. */
  55118. export class TorusKnotBuilder {
  55119. /**
  55120. * Creates a torus knot mesh
  55121. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55122. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55123. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55124. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55126. * * 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
  55127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55128. * @param name defines the name of the mesh
  55129. * @param options defines the options used to create the mesh
  55130. * @param scene defines the hosting scene
  55131. * @returns the torus knot mesh
  55132. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55133. */
  55134. static CreateTorusKnot(name: string, options: {
  55135. radius?: number;
  55136. tube?: number;
  55137. radialSegments?: number;
  55138. tubularSegments?: number;
  55139. p?: number;
  55140. q?: number;
  55141. updatable?: boolean;
  55142. sideOrientation?: number;
  55143. frontUVs?: Vector4;
  55144. backUVs?: Vector4;
  55145. }, scene: any): Mesh;
  55146. }
  55147. }
  55148. declare module BABYLON {
  55149. /**
  55150. * Polygon
  55151. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55152. */
  55153. export class Polygon {
  55154. /**
  55155. * Creates a rectangle
  55156. * @param xmin bottom X coord
  55157. * @param ymin bottom Y coord
  55158. * @param xmax top X coord
  55159. * @param ymax top Y coord
  55160. * @returns points that make the resulting rectation
  55161. */
  55162. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55163. /**
  55164. * Creates a circle
  55165. * @param radius radius of circle
  55166. * @param cx scale in x
  55167. * @param cy scale in y
  55168. * @param numberOfSides number of sides that make up the circle
  55169. * @returns points that make the resulting circle
  55170. */
  55171. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55172. /**
  55173. * Creates a polygon from input string
  55174. * @param input Input polygon data
  55175. * @returns the parsed points
  55176. */
  55177. static Parse(input: string): Vector2[];
  55178. /**
  55179. * Starts building a polygon from x and y coordinates
  55180. * @param x x coordinate
  55181. * @param y y coordinate
  55182. * @returns the started path2
  55183. */
  55184. static StartingAt(x: number, y: number): Path2;
  55185. }
  55186. /**
  55187. * Builds a polygon
  55188. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55189. */
  55190. export class PolygonMeshBuilder {
  55191. private _points;
  55192. private _outlinepoints;
  55193. private _holes;
  55194. private _name;
  55195. private _scene;
  55196. private _epoints;
  55197. private _eholes;
  55198. private _addToepoint;
  55199. /**
  55200. * Babylon reference to the earcut plugin.
  55201. */
  55202. bjsEarcut: any;
  55203. /**
  55204. * Creates a PolygonMeshBuilder
  55205. * @param name name of the builder
  55206. * @param contours Path of the polygon
  55207. * @param scene scene to add to when creating the mesh
  55208. * @param earcutInjection can be used to inject your own earcut reference
  55209. */
  55210. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55211. /**
  55212. * Adds a whole within the polygon
  55213. * @param hole Array of points defining the hole
  55214. * @returns this
  55215. */
  55216. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55217. /**
  55218. * Creates the polygon
  55219. * @param updatable If the mesh should be updatable
  55220. * @param depth The depth of the mesh created
  55221. * @returns the created mesh
  55222. */
  55223. build(updatable?: boolean, depth?: number): Mesh;
  55224. /**
  55225. * Creates the polygon
  55226. * @param depth The depth of the mesh created
  55227. * @returns the created VertexData
  55228. */
  55229. buildVertexData(depth?: number): VertexData;
  55230. /**
  55231. * Adds a side to the polygon
  55232. * @param positions points that make the polygon
  55233. * @param normals normals of the polygon
  55234. * @param uvs uvs of the polygon
  55235. * @param indices indices of the polygon
  55236. * @param bounds bounds of the polygon
  55237. * @param points points of the polygon
  55238. * @param depth depth of the polygon
  55239. * @param flip flip of the polygon
  55240. */
  55241. private addSide;
  55242. }
  55243. }
  55244. declare module BABYLON {
  55245. /**
  55246. * Class containing static functions to help procedurally build meshes
  55247. */
  55248. export class PolygonBuilder {
  55249. /**
  55250. * Creates a polygon mesh
  55251. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55252. * * 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
  55253. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55255. * * 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)
  55256. * * Remember you can only change the shape positions, not their number when updating a polygon
  55257. * @param name defines the name of the mesh
  55258. * @param options defines the options used to create the mesh
  55259. * @param scene defines the hosting scene
  55260. * @param earcutInjection can be used to inject your own earcut reference
  55261. * @returns the polygon mesh
  55262. */
  55263. static CreatePolygon(name: string, options: {
  55264. shape: Vector3[];
  55265. holes?: Vector3[][];
  55266. depth?: number;
  55267. faceUV?: Vector4[];
  55268. faceColors?: Color4[];
  55269. updatable?: boolean;
  55270. sideOrientation?: number;
  55271. frontUVs?: Vector4;
  55272. backUVs?: Vector4;
  55273. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55274. /**
  55275. * Creates an extruded polygon mesh, with depth in the Y direction.
  55276. * * 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)
  55277. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55278. * @param name defines the name of the mesh
  55279. * @param options defines the options used to create the mesh
  55280. * @param scene defines the hosting scene
  55281. * @param earcutInjection can be used to inject your own earcut reference
  55282. * @returns the polygon mesh
  55283. */
  55284. static ExtrudePolygon(name: string, options: {
  55285. shape: Vector3[];
  55286. holes?: Vector3[][];
  55287. depth?: number;
  55288. faceUV?: Vector4[];
  55289. faceColors?: Color4[];
  55290. updatable?: boolean;
  55291. sideOrientation?: number;
  55292. frontUVs?: Vector4;
  55293. backUVs?: Vector4;
  55294. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55295. }
  55296. }
  55297. declare module BABYLON {
  55298. /**
  55299. * Class containing static functions to help procedurally build meshes
  55300. */
  55301. export class LatheBuilder {
  55302. /**
  55303. * Creates lathe mesh.
  55304. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55305. * * 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
  55306. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55307. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55308. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55309. * * 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
  55310. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55311. * * 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
  55312. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55313. * * 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
  55314. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55316. * @param name defines the name of the mesh
  55317. * @param options defines the options used to create the mesh
  55318. * @param scene defines the hosting scene
  55319. * @returns the lathe mesh
  55320. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55321. */
  55322. static CreateLathe(name: string, options: {
  55323. shape: Vector3[];
  55324. radius?: number;
  55325. tessellation?: number;
  55326. clip?: number;
  55327. arc?: number;
  55328. closed?: boolean;
  55329. updatable?: boolean;
  55330. sideOrientation?: number;
  55331. frontUVs?: Vector4;
  55332. backUVs?: Vector4;
  55333. cap?: number;
  55334. invertUV?: boolean;
  55335. }, scene?: Nullable<Scene>): Mesh;
  55336. }
  55337. }
  55338. declare module BABYLON {
  55339. /**
  55340. * Class containing static functions to help procedurally build meshes
  55341. */
  55342. export class TiledPlaneBuilder {
  55343. /**
  55344. * Creates a tiled plane mesh
  55345. * * The parameter `pattern` will, depending on value, do nothing or
  55346. * * * flip (reflect about central vertical) alternate tiles across and up
  55347. * * * flip every tile on alternate rows
  55348. * * * rotate (180 degs) alternate tiles across and up
  55349. * * * rotate every tile on alternate rows
  55350. * * * flip and rotate alternate tiles across and up
  55351. * * * flip and rotate every tile on alternate rows
  55352. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55353. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55354. * * 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
  55355. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55356. * * 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)
  55357. * * 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)
  55358. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55359. * @param name defines the name of the mesh
  55360. * @param options defines the options used to create the mesh
  55361. * @param scene defines the hosting scene
  55362. * @returns the box mesh
  55363. */
  55364. static CreateTiledPlane(name: string, options: {
  55365. pattern?: number;
  55366. tileSize?: number;
  55367. tileWidth?: number;
  55368. tileHeight?: number;
  55369. size?: number;
  55370. width?: number;
  55371. height?: number;
  55372. alignHorizontal?: number;
  55373. alignVertical?: number;
  55374. sideOrientation?: number;
  55375. frontUVs?: Vector4;
  55376. backUVs?: Vector4;
  55377. updatable?: boolean;
  55378. }, scene?: Nullable<Scene>): Mesh;
  55379. }
  55380. }
  55381. declare module BABYLON {
  55382. /**
  55383. * Class containing static functions to help procedurally build meshes
  55384. */
  55385. export class TubeBuilder {
  55386. /**
  55387. * Creates a tube mesh.
  55388. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55389. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55390. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55391. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55392. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55393. * * 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)
  55394. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55395. * * 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
  55396. * * 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
  55397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55398. * * 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
  55399. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55401. * @param name defines the name of the mesh
  55402. * @param options defines the options used to create the mesh
  55403. * @param scene defines the hosting scene
  55404. * @returns the tube mesh
  55405. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55406. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55407. */
  55408. static CreateTube(name: string, options: {
  55409. path: Vector3[];
  55410. radius?: number;
  55411. tessellation?: number;
  55412. radiusFunction?: {
  55413. (i: number, distance: number): number;
  55414. };
  55415. cap?: number;
  55416. arc?: number;
  55417. updatable?: boolean;
  55418. sideOrientation?: number;
  55419. frontUVs?: Vector4;
  55420. backUVs?: Vector4;
  55421. instance?: Mesh;
  55422. invertUV?: boolean;
  55423. }, scene?: Nullable<Scene>): Mesh;
  55424. }
  55425. }
  55426. declare module BABYLON {
  55427. /**
  55428. * Class containing static functions to help procedurally build meshes
  55429. */
  55430. export class IcoSphereBuilder {
  55431. /**
  55432. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55433. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55434. * * 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`)
  55435. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55436. * * 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
  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 icosahedron mesh
  55444. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55445. */
  55446. static CreateIcoSphere(name: string, options: {
  55447. radius?: number;
  55448. radiusX?: number;
  55449. radiusY?: number;
  55450. radiusZ?: number;
  55451. flat?: boolean;
  55452. subdivisions?: number;
  55453. sideOrientation?: number;
  55454. frontUVs?: Vector4;
  55455. backUVs?: Vector4;
  55456. updatable?: boolean;
  55457. }, scene?: Nullable<Scene>): Mesh;
  55458. }
  55459. }
  55460. declare module BABYLON {
  55461. /**
  55462. * Class containing static functions to help procedurally build meshes
  55463. */
  55464. export class DecalBuilder {
  55465. /**
  55466. * Creates a decal mesh.
  55467. * 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
  55468. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55469. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55470. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55471. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55472. * @param name defines the name of the mesh
  55473. * @param sourceMesh defines the mesh where the decal must be applied
  55474. * @param options defines the options used to create the mesh
  55475. * @param scene defines the hosting scene
  55476. * @returns the decal mesh
  55477. * @see https://doc.babylonjs.com/how_to/decals
  55478. */
  55479. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55480. position?: Vector3;
  55481. normal?: Vector3;
  55482. size?: Vector3;
  55483. angle?: number;
  55484. }): Mesh;
  55485. }
  55486. }
  55487. declare module BABYLON {
  55488. /**
  55489. * Class containing static functions to help procedurally build meshes
  55490. */
  55491. export class MeshBuilder {
  55492. /**
  55493. * Creates a box mesh
  55494. * * The parameter `size` sets the size (float) of each box side (default 1)
  55495. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55496. * * 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)
  55497. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55499. * * 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
  55500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55501. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55502. * @param name defines the name of the mesh
  55503. * @param options defines the options used to create the mesh
  55504. * @param scene defines the hosting scene
  55505. * @returns the box mesh
  55506. */
  55507. static CreateBox(name: string, options: {
  55508. size?: number;
  55509. width?: number;
  55510. height?: number;
  55511. depth?: number;
  55512. faceUV?: Vector4[];
  55513. faceColors?: Color4[];
  55514. sideOrientation?: number;
  55515. frontUVs?: Vector4;
  55516. backUVs?: Vector4;
  55517. updatable?: boolean;
  55518. }, scene?: Nullable<Scene>): Mesh;
  55519. /**
  55520. * Creates a tiled box mesh
  55521. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55523. * @param name defines the name of the mesh
  55524. * @param options defines the options used to create the mesh
  55525. * @param scene defines the hosting scene
  55526. * @returns the tiled box mesh
  55527. */
  55528. static CreateTiledBox(name: string, options: {
  55529. pattern?: number;
  55530. size?: number;
  55531. width?: number;
  55532. height?: number;
  55533. depth: number;
  55534. tileSize?: number;
  55535. tileWidth?: number;
  55536. tileHeight?: number;
  55537. faceUV?: Vector4[];
  55538. faceColors?: Color4[];
  55539. alignHorizontal?: number;
  55540. alignVertical?: number;
  55541. sideOrientation?: number;
  55542. updatable?: boolean;
  55543. }, scene?: Nullable<Scene>): Mesh;
  55544. /**
  55545. * Creates a sphere mesh
  55546. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55547. * * 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`)
  55548. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55549. * * 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
  55550. * * 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)
  55551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55552. * * 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
  55553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55554. * @param name defines the name of the mesh
  55555. * @param options defines the options used to create the mesh
  55556. * @param scene defines the hosting scene
  55557. * @returns the sphere mesh
  55558. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55559. */
  55560. static CreateSphere(name: string, options: {
  55561. segments?: number;
  55562. diameter?: number;
  55563. diameterX?: number;
  55564. diameterY?: number;
  55565. diameterZ?: number;
  55566. arc?: number;
  55567. slice?: number;
  55568. sideOrientation?: number;
  55569. frontUVs?: Vector4;
  55570. backUVs?: Vector4;
  55571. updatable?: boolean;
  55572. }, scene?: Nullable<Scene>): Mesh;
  55573. /**
  55574. * Creates a plane polygonal mesh. By default, this is a disc
  55575. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55576. * * 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
  55577. * * 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
  55578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55579. * * 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
  55580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55581. * @param name defines the name of the mesh
  55582. * @param options defines the options used to create the mesh
  55583. * @param scene defines the hosting scene
  55584. * @returns the plane polygonal mesh
  55585. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55586. */
  55587. static CreateDisc(name: string, options: {
  55588. radius?: number;
  55589. tessellation?: number;
  55590. arc?: number;
  55591. updatable?: boolean;
  55592. sideOrientation?: number;
  55593. frontUVs?: Vector4;
  55594. backUVs?: Vector4;
  55595. }, scene?: Nullable<Scene>): Mesh;
  55596. /**
  55597. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55598. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55599. * * 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`)
  55600. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55601. * * 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
  55602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55603. * * 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
  55604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55605. * @param name defines the name of the mesh
  55606. * @param options defines the options used to create the mesh
  55607. * @param scene defines the hosting scene
  55608. * @returns the icosahedron mesh
  55609. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55610. */
  55611. static CreateIcoSphere(name: string, options: {
  55612. radius?: number;
  55613. radiusX?: number;
  55614. radiusY?: number;
  55615. radiusZ?: number;
  55616. flat?: boolean;
  55617. subdivisions?: number;
  55618. sideOrientation?: number;
  55619. frontUVs?: Vector4;
  55620. backUVs?: Vector4;
  55621. updatable?: boolean;
  55622. }, scene?: Nullable<Scene>): Mesh;
  55623. /**
  55624. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55625. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55626. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55627. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55628. * * 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
  55629. * * 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
  55630. * * 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
  55631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55632. * * 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
  55633. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55634. * * 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
  55635. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55636. * * 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
  55637. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55639. * @param name defines the name of the mesh
  55640. * @param options defines the options used to create the mesh
  55641. * @param scene defines the hosting scene
  55642. * @returns the ribbon mesh
  55643. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55644. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55645. */
  55646. static CreateRibbon(name: string, options: {
  55647. pathArray: Vector3[][];
  55648. closeArray?: boolean;
  55649. closePath?: boolean;
  55650. offset?: number;
  55651. updatable?: boolean;
  55652. sideOrientation?: number;
  55653. frontUVs?: Vector4;
  55654. backUVs?: Vector4;
  55655. instance?: Mesh;
  55656. invertUV?: boolean;
  55657. uvs?: Vector2[];
  55658. colors?: Color4[];
  55659. }, scene?: Nullable<Scene>): Mesh;
  55660. /**
  55661. * Creates a cylinder or a cone mesh
  55662. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55663. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55664. * * 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.
  55665. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55666. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55667. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55668. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55669. * * 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).
  55670. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55671. * * 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).
  55672. * * 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
  55673. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55674. * * 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
  55675. * * 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.
  55676. * * If `enclose` is false, a ring surface is one element.
  55677. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55678. * * 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
  55679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55680. * * 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
  55681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55682. * @param name defines the name of the mesh
  55683. * @param options defines the options used to create the mesh
  55684. * @param scene defines the hosting scene
  55685. * @returns the cylinder mesh
  55686. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55687. */
  55688. static CreateCylinder(name: string, options: {
  55689. height?: number;
  55690. diameterTop?: number;
  55691. diameterBottom?: number;
  55692. diameter?: number;
  55693. tessellation?: number;
  55694. subdivisions?: number;
  55695. arc?: number;
  55696. faceColors?: Color4[];
  55697. faceUV?: Vector4[];
  55698. updatable?: boolean;
  55699. hasRings?: boolean;
  55700. enclose?: boolean;
  55701. cap?: number;
  55702. sideOrientation?: number;
  55703. frontUVs?: Vector4;
  55704. backUVs?: Vector4;
  55705. }, scene?: Nullable<Scene>): Mesh;
  55706. /**
  55707. * Creates a torus mesh
  55708. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55709. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55710. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55712. * * 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
  55713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55714. * @param name defines the name of the mesh
  55715. * @param options defines the options used to create the mesh
  55716. * @param scene defines the hosting scene
  55717. * @returns the torus mesh
  55718. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55719. */
  55720. static CreateTorus(name: string, options: {
  55721. diameter?: number;
  55722. thickness?: number;
  55723. tessellation?: number;
  55724. updatable?: boolean;
  55725. sideOrientation?: number;
  55726. frontUVs?: Vector4;
  55727. backUVs?: Vector4;
  55728. }, scene?: Nullable<Scene>): Mesh;
  55729. /**
  55730. * Creates a torus knot mesh
  55731. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55732. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55733. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55734. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55736. * * 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
  55737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55738. * @param name defines the name of the mesh
  55739. * @param options defines the options used to create the mesh
  55740. * @param scene defines the hosting scene
  55741. * @returns the torus knot mesh
  55742. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55743. */
  55744. static CreateTorusKnot(name: string, options: {
  55745. radius?: number;
  55746. tube?: number;
  55747. radialSegments?: number;
  55748. tubularSegments?: number;
  55749. p?: number;
  55750. q?: number;
  55751. updatable?: boolean;
  55752. sideOrientation?: number;
  55753. frontUVs?: Vector4;
  55754. backUVs?: Vector4;
  55755. }, scene?: Nullable<Scene>): Mesh;
  55756. /**
  55757. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55758. * * 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
  55759. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55760. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55761. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55762. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55763. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55764. * * 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
  55765. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55767. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55768. * @param name defines the name of the new line system
  55769. * @param options defines the options used to create the line system
  55770. * @param scene defines the hosting scene
  55771. * @returns a new line system mesh
  55772. */
  55773. static CreateLineSystem(name: string, options: {
  55774. lines: Vector3[][];
  55775. updatable?: boolean;
  55776. instance?: Nullable<LinesMesh>;
  55777. colors?: Nullable<Color4[][]>;
  55778. useVertexAlpha?: boolean;
  55779. }, scene: Nullable<Scene>): LinesMesh;
  55780. /**
  55781. * Creates a line mesh
  55782. * 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
  55783. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55784. * * The parameter `points` is an array successive Vector3
  55785. * * 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
  55786. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55787. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55788. * * When updating an instance, remember that only point positions can change, not the number of points
  55789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55790. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55791. * @param name defines the name of the new line system
  55792. * @param options defines the options used to create the line system
  55793. * @param scene defines the hosting scene
  55794. * @returns a new line mesh
  55795. */
  55796. static CreateLines(name: string, options: {
  55797. points: Vector3[];
  55798. updatable?: boolean;
  55799. instance?: Nullable<LinesMesh>;
  55800. colors?: Color4[];
  55801. useVertexAlpha?: boolean;
  55802. }, scene?: Nullable<Scene>): LinesMesh;
  55803. /**
  55804. * Creates a dashed line mesh
  55805. * * 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
  55806. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55807. * * The parameter `points` is an array successive Vector3
  55808. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55809. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55810. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55811. * * 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
  55812. * * When updating an instance, remember that only point positions can change, not the number of points
  55813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55814. * @param name defines the name of the mesh
  55815. * @param options defines the options used to create the mesh
  55816. * @param scene defines the hosting scene
  55817. * @returns the dashed line mesh
  55818. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55819. */
  55820. static CreateDashedLines(name: string, options: {
  55821. points: Vector3[];
  55822. dashSize?: number;
  55823. gapSize?: number;
  55824. dashNb?: number;
  55825. updatable?: boolean;
  55826. instance?: LinesMesh;
  55827. }, scene?: Nullable<Scene>): LinesMesh;
  55828. /**
  55829. * 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.
  55830. * * 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.
  55831. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55832. * * 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.
  55833. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55834. * * 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
  55835. * * 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
  55836. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55838. * * 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
  55839. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55841. * @param name defines the name of the mesh
  55842. * @param options defines the options used to create the mesh
  55843. * @param scene defines the hosting scene
  55844. * @returns the extruded shape mesh
  55845. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55846. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55847. */
  55848. static ExtrudeShape(name: string, options: {
  55849. shape: Vector3[];
  55850. path: Vector3[];
  55851. scale?: number;
  55852. rotation?: number;
  55853. cap?: number;
  55854. updatable?: boolean;
  55855. sideOrientation?: number;
  55856. frontUVs?: Vector4;
  55857. backUVs?: Vector4;
  55858. instance?: Mesh;
  55859. invertUV?: boolean;
  55860. }, scene?: Nullable<Scene>): Mesh;
  55861. /**
  55862. * Creates an custom extruded shape mesh.
  55863. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55864. * * 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.
  55865. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55866. * * 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
  55867. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55868. * * 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
  55869. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55870. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55871. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55872. * * 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
  55873. * * 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
  55874. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55875. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55876. * * 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
  55877. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55879. * @param name defines the name of the mesh
  55880. * @param options defines the options used to create the mesh
  55881. * @param scene defines the hosting scene
  55882. * @returns the custom extruded shape mesh
  55883. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55884. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55885. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55886. */
  55887. static ExtrudeShapeCustom(name: string, options: {
  55888. shape: Vector3[];
  55889. path: Vector3[];
  55890. scaleFunction?: any;
  55891. rotationFunction?: any;
  55892. ribbonCloseArray?: boolean;
  55893. ribbonClosePath?: boolean;
  55894. cap?: number;
  55895. updatable?: boolean;
  55896. sideOrientation?: number;
  55897. frontUVs?: Vector4;
  55898. backUVs?: Vector4;
  55899. instance?: Mesh;
  55900. invertUV?: boolean;
  55901. }, scene?: Nullable<Scene>): Mesh;
  55902. /**
  55903. * Creates lathe mesh.
  55904. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55905. * * 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
  55906. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55907. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55908. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55909. * * 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
  55910. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55911. * * 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
  55912. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55913. * * 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
  55914. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55916. * @param name defines the name of the mesh
  55917. * @param options defines the options used to create the mesh
  55918. * @param scene defines the hosting scene
  55919. * @returns the lathe mesh
  55920. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55921. */
  55922. static CreateLathe(name: string, options: {
  55923. shape: Vector3[];
  55924. radius?: number;
  55925. tessellation?: number;
  55926. clip?: number;
  55927. arc?: number;
  55928. closed?: boolean;
  55929. updatable?: boolean;
  55930. sideOrientation?: number;
  55931. frontUVs?: Vector4;
  55932. backUVs?: Vector4;
  55933. cap?: number;
  55934. invertUV?: boolean;
  55935. }, scene?: Nullable<Scene>): Mesh;
  55936. /**
  55937. * Creates a tiled plane mesh
  55938. * * You can set a limited pattern arrangement with the tiles
  55939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55940. * * 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
  55941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55942. * @param name defines the name of the mesh
  55943. * @param options defines the options used to create the mesh
  55944. * @param scene defines the hosting scene
  55945. * @returns the plane mesh
  55946. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55947. */
  55948. static CreateTiledPlane(name: string, options: {
  55949. pattern?: number;
  55950. tileSize?: number;
  55951. tileWidth?: number;
  55952. tileHeight?: number;
  55953. size?: number;
  55954. width?: number;
  55955. height?: number;
  55956. alignHorizontal?: number;
  55957. alignVertical?: number;
  55958. sideOrientation?: number;
  55959. frontUVs?: Vector4;
  55960. backUVs?: Vector4;
  55961. updatable?: boolean;
  55962. }, scene?: Nullable<Scene>): Mesh;
  55963. /**
  55964. * Creates a plane mesh
  55965. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55966. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55967. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55969. * * 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
  55970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55971. * @param name defines the name of the mesh
  55972. * @param options defines the options used to create the mesh
  55973. * @param scene defines the hosting scene
  55974. * @returns the plane mesh
  55975. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55976. */
  55977. static CreatePlane(name: string, options: {
  55978. size?: number;
  55979. width?: number;
  55980. height?: number;
  55981. sideOrientation?: number;
  55982. frontUVs?: Vector4;
  55983. backUVs?: Vector4;
  55984. updatable?: boolean;
  55985. sourcePlane?: Plane;
  55986. }, scene?: Nullable<Scene>): Mesh;
  55987. /**
  55988. * Creates a ground mesh
  55989. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55990. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55992. * @param name defines the name of the mesh
  55993. * @param options defines the options used to create the mesh
  55994. * @param scene defines the hosting scene
  55995. * @returns the ground mesh
  55996. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55997. */
  55998. static CreateGround(name: string, options: {
  55999. width?: number;
  56000. height?: number;
  56001. subdivisions?: number;
  56002. subdivisionsX?: number;
  56003. subdivisionsY?: number;
  56004. updatable?: boolean;
  56005. }, scene?: Nullable<Scene>): Mesh;
  56006. /**
  56007. * Creates a tiled ground mesh
  56008. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56009. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56010. * * 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
  56011. * * 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
  56012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56013. * @param name defines the name of the mesh
  56014. * @param options defines the options used to create the mesh
  56015. * @param scene defines the hosting scene
  56016. * @returns the tiled ground mesh
  56017. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56018. */
  56019. static CreateTiledGround(name: string, options: {
  56020. xmin: number;
  56021. zmin: number;
  56022. xmax: number;
  56023. zmax: number;
  56024. subdivisions?: {
  56025. w: number;
  56026. h: number;
  56027. };
  56028. precision?: {
  56029. w: number;
  56030. h: number;
  56031. };
  56032. updatable?: boolean;
  56033. }, scene?: Nullable<Scene>): Mesh;
  56034. /**
  56035. * Creates a ground mesh from a height map
  56036. * * The parameter `url` sets the URL of the height map image resource.
  56037. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56038. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56039. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56040. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56041. * * 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.
  56042. * * 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).
  56043. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56045. * @param name defines the name of the mesh
  56046. * @param url defines the url to the height map
  56047. * @param options defines the options used to create the mesh
  56048. * @param scene defines the hosting scene
  56049. * @returns the ground mesh
  56050. * @see https://doc.babylonjs.com/babylon101/height_map
  56051. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56052. */
  56053. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56054. width?: number;
  56055. height?: number;
  56056. subdivisions?: number;
  56057. minHeight?: number;
  56058. maxHeight?: number;
  56059. colorFilter?: Color3;
  56060. alphaFilter?: number;
  56061. updatable?: boolean;
  56062. onReady?: (mesh: GroundMesh) => void;
  56063. }, scene?: Nullable<Scene>): GroundMesh;
  56064. /**
  56065. * Creates a polygon mesh
  56066. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56067. * * 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
  56068. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56070. * * 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)
  56071. * * Remember you can only change the shape positions, not their number when updating a polygon
  56072. * @param name defines the name of the mesh
  56073. * @param options defines the options used to create the mesh
  56074. * @param scene defines the hosting scene
  56075. * @param earcutInjection can be used to inject your own earcut reference
  56076. * @returns the polygon mesh
  56077. */
  56078. static CreatePolygon(name: string, options: {
  56079. shape: Vector3[];
  56080. holes?: Vector3[][];
  56081. depth?: number;
  56082. faceUV?: Vector4[];
  56083. faceColors?: Color4[];
  56084. updatable?: boolean;
  56085. sideOrientation?: number;
  56086. frontUVs?: Vector4;
  56087. backUVs?: Vector4;
  56088. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56089. /**
  56090. * Creates an extruded polygon mesh, with depth in the Y direction.
  56091. * * 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)
  56092. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56093. * @param name defines the name of the mesh
  56094. * @param options defines the options used to create the mesh
  56095. * @param scene defines the hosting scene
  56096. * @param earcutInjection can be used to inject your own earcut reference
  56097. * @returns the polygon mesh
  56098. */
  56099. static ExtrudePolygon(name: string, options: {
  56100. shape: Vector3[];
  56101. holes?: Vector3[][];
  56102. depth?: number;
  56103. faceUV?: Vector4[];
  56104. faceColors?: Color4[];
  56105. updatable?: boolean;
  56106. sideOrientation?: number;
  56107. frontUVs?: Vector4;
  56108. backUVs?: Vector4;
  56109. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56110. /**
  56111. * Creates a tube mesh.
  56112. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56113. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56114. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56115. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56116. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56117. * * 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)
  56118. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56119. * * 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
  56120. * * 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
  56121. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56122. * * 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
  56123. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56125. * @param name defines the name of the mesh
  56126. * @param options defines the options used to create the mesh
  56127. * @param scene defines the hosting scene
  56128. * @returns the tube mesh
  56129. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56130. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56131. */
  56132. static CreateTube(name: string, options: {
  56133. path: Vector3[];
  56134. radius?: number;
  56135. tessellation?: number;
  56136. radiusFunction?: {
  56137. (i: number, distance: number): number;
  56138. };
  56139. cap?: number;
  56140. arc?: number;
  56141. updatable?: boolean;
  56142. sideOrientation?: number;
  56143. frontUVs?: Vector4;
  56144. backUVs?: Vector4;
  56145. instance?: Mesh;
  56146. invertUV?: boolean;
  56147. }, scene?: Nullable<Scene>): Mesh;
  56148. /**
  56149. * Creates a polyhedron mesh
  56150. * * 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
  56151. * * The parameter `size` (positive float, default 1) sets the polygon size
  56152. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56153. * * 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`
  56154. * * 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
  56155. * * 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)`)
  56156. * * 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
  56157. * * 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
  56158. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56159. * * 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
  56160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56161. * @param name defines the name of the mesh
  56162. * @param options defines the options used to create the mesh
  56163. * @param scene defines the hosting scene
  56164. * @returns the polyhedron mesh
  56165. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56166. */
  56167. static CreatePolyhedron(name: string, options: {
  56168. type?: number;
  56169. size?: number;
  56170. sizeX?: number;
  56171. sizeY?: number;
  56172. sizeZ?: number;
  56173. custom?: any;
  56174. faceUV?: Vector4[];
  56175. faceColors?: Color4[];
  56176. flat?: boolean;
  56177. updatable?: boolean;
  56178. sideOrientation?: number;
  56179. frontUVs?: Vector4;
  56180. backUVs?: Vector4;
  56181. }, scene?: Nullable<Scene>): Mesh;
  56182. /**
  56183. * Creates a decal mesh.
  56184. * 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
  56185. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56186. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56187. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56188. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56189. * @param name defines the name of the mesh
  56190. * @param sourceMesh defines the mesh where the decal must be applied
  56191. * @param options defines the options used to create the mesh
  56192. * @param scene defines the hosting scene
  56193. * @returns the decal mesh
  56194. * @see https://doc.babylonjs.com/how_to/decals
  56195. */
  56196. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56197. position?: Vector3;
  56198. normal?: Vector3;
  56199. size?: Vector3;
  56200. angle?: number;
  56201. }): Mesh;
  56202. }
  56203. }
  56204. declare module BABYLON {
  56205. /**
  56206. * A simplifier interface for future simplification implementations
  56207. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56208. */
  56209. export interface ISimplifier {
  56210. /**
  56211. * Simplification of a given mesh according to the given settings.
  56212. * Since this requires computation, it is assumed that the function runs async.
  56213. * @param settings The settings of the simplification, including quality and distance
  56214. * @param successCallback A callback that will be called after the mesh was simplified.
  56215. * @param errorCallback in case of an error, this callback will be called. optional.
  56216. */
  56217. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56218. }
  56219. /**
  56220. * Expected simplification settings.
  56221. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56222. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56223. */
  56224. export interface ISimplificationSettings {
  56225. /**
  56226. * Gets or sets the expected quality
  56227. */
  56228. quality: number;
  56229. /**
  56230. * Gets or sets the distance when this optimized version should be used
  56231. */
  56232. distance: number;
  56233. /**
  56234. * Gets an already optimized mesh
  56235. */
  56236. optimizeMesh?: boolean;
  56237. }
  56238. /**
  56239. * Class used to specify simplification options
  56240. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56241. */
  56242. export class SimplificationSettings implements ISimplificationSettings {
  56243. /** expected quality */
  56244. quality: number;
  56245. /** distance when this optimized version should be used */
  56246. distance: number;
  56247. /** already optimized mesh */
  56248. optimizeMesh?: boolean | undefined;
  56249. /**
  56250. * Creates a SimplificationSettings
  56251. * @param quality expected quality
  56252. * @param distance distance when this optimized version should be used
  56253. * @param optimizeMesh already optimized mesh
  56254. */
  56255. constructor(
  56256. /** expected quality */
  56257. quality: number,
  56258. /** distance when this optimized version should be used */
  56259. distance: number,
  56260. /** already optimized mesh */
  56261. optimizeMesh?: boolean | undefined);
  56262. }
  56263. /**
  56264. * Interface used to define a simplification task
  56265. */
  56266. export interface ISimplificationTask {
  56267. /**
  56268. * Array of settings
  56269. */
  56270. settings: Array<ISimplificationSettings>;
  56271. /**
  56272. * Simplification type
  56273. */
  56274. simplificationType: SimplificationType;
  56275. /**
  56276. * Mesh to simplify
  56277. */
  56278. mesh: Mesh;
  56279. /**
  56280. * Callback called on success
  56281. */
  56282. successCallback?: () => void;
  56283. /**
  56284. * Defines if parallel processing can be used
  56285. */
  56286. parallelProcessing: boolean;
  56287. }
  56288. /**
  56289. * Queue used to order the simplification tasks
  56290. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56291. */
  56292. export class SimplificationQueue {
  56293. private _simplificationArray;
  56294. /**
  56295. * Gets a boolean indicating that the process is still running
  56296. */
  56297. running: boolean;
  56298. /**
  56299. * Creates a new queue
  56300. */
  56301. constructor();
  56302. /**
  56303. * Adds a new simplification task
  56304. * @param task defines a task to add
  56305. */
  56306. addTask(task: ISimplificationTask): void;
  56307. /**
  56308. * Execute next task
  56309. */
  56310. executeNext(): void;
  56311. /**
  56312. * Execute a simplification task
  56313. * @param task defines the task to run
  56314. */
  56315. runSimplification(task: ISimplificationTask): void;
  56316. private getSimplifier;
  56317. }
  56318. /**
  56319. * The implemented types of simplification
  56320. * At the moment only Quadratic Error Decimation is implemented
  56321. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56322. */
  56323. export enum SimplificationType {
  56324. /** Quadratic error decimation */
  56325. QUADRATIC = 0
  56326. }
  56327. }
  56328. declare module BABYLON {
  56329. interface Scene {
  56330. /** @hidden (Backing field) */ private _simplificationQueue: SimplificationQueue;
  56331. /**
  56332. * Gets or sets the simplification queue attached to the scene
  56333. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56334. */
  56335. simplificationQueue: SimplificationQueue;
  56336. }
  56337. interface Mesh {
  56338. /**
  56339. * Simplify the mesh according to the given array of settings.
  56340. * Function will return immediately and will simplify async
  56341. * @param settings a collection of simplification settings
  56342. * @param parallelProcessing should all levels calculate parallel or one after the other
  56343. * @param simplificationType the type of simplification to run
  56344. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56345. * @returns the current mesh
  56346. */
  56347. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56348. }
  56349. /**
  56350. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56351. * created in a scene
  56352. */
  56353. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56354. /**
  56355. * The component name helpfull to identify the component in the list of scene components.
  56356. */
  56357. readonly name: string;
  56358. /**
  56359. * The scene the component belongs to.
  56360. */
  56361. scene: Scene;
  56362. /**
  56363. * Creates a new instance of the component for the given scene
  56364. * @param scene Defines the scene to register the component in
  56365. */
  56366. constructor(scene: Scene);
  56367. /**
  56368. * Registers the component in a given scene
  56369. */
  56370. register(): void;
  56371. /**
  56372. * Rebuilds the elements related to this component in case of
  56373. * context lost for instance.
  56374. */
  56375. rebuild(): void;
  56376. /**
  56377. * Disposes the component and the associated ressources
  56378. */
  56379. dispose(): void;
  56380. private _beforeCameraUpdate;
  56381. }
  56382. }
  56383. declare module BABYLON {
  56384. /**
  56385. * Navigation plugin interface to add navigation constrained by a navigation mesh
  56386. */
  56387. export interface INavigationEnginePlugin {
  56388. /**
  56389. * plugin name
  56390. */
  56391. name: string;
  56392. /**
  56393. * Creates a navigation mesh
  56394. * @param meshes array of all the geometry used to compute the navigatio mesh
  56395. * @param parameters bunch of parameters used to filter geometry
  56396. */
  56397. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56398. /**
  56399. * Create a navigation mesh debug mesh
  56400. * @param scene is where the mesh will be added
  56401. * @returns debug display mesh
  56402. */
  56403. createDebugNavMesh(scene: Scene): Mesh;
  56404. /**
  56405. * Get a navigation mesh constrained position, closest to the parameter position
  56406. * @param position world position
  56407. * @returns the closest point to position constrained by the navigation mesh
  56408. */
  56409. getClosestPoint(position: Vector3): Vector3;
  56410. /**
  56411. * Get a navigation mesh constrained position, within a particular radius
  56412. * @param position world position
  56413. * @param maxRadius the maximum distance to the constrained world position
  56414. * @returns the closest point to position constrained by the navigation mesh
  56415. */
  56416. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56417. /**
  56418. * Compute the final position from a segment made of destination-position
  56419. * @param position world position
  56420. * @param destination world position
  56421. * @returns the resulting point along the navmesh
  56422. */
  56423. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56424. /**
  56425. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56426. * @param start world position
  56427. * @param end world position
  56428. * @returns array containing world position composing the path
  56429. */
  56430. computePath(start: Vector3, end: Vector3): Vector3[];
  56431. /**
  56432. * If this plugin is supported
  56433. * @returns true if plugin is supported
  56434. */
  56435. isSupported(): boolean;
  56436. /**
  56437. * Create a new Crowd so you can add agents
  56438. * @param maxAgents the maximum agent count in the crowd
  56439. * @param maxAgentRadius the maximum radius an agent can have
  56440. * @param scene to attach the crowd to
  56441. * @returns the crowd you can add agents to
  56442. */
  56443. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56444. /**
  56445. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56446. * The queries will try to find a solution within those bounds
  56447. * default is (1,1,1)
  56448. * @param extent x,y,z value that define the extent around the queries point of reference
  56449. */
  56450. setDefaultQueryExtent(extent: Vector3): void;
  56451. /**
  56452. * Get the Bounding box extent specified by setDefaultQueryExtent
  56453. * @returns the box extent values
  56454. */
  56455. getDefaultQueryExtent(): Vector3;
  56456. /**
  56457. * Release all resources
  56458. */
  56459. dispose(): void;
  56460. }
  56461. /**
  56462. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  56463. */
  56464. export interface ICrowd {
  56465. /**
  56466. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56467. * You can attach anything to that node. The node position is updated in the scene update tick.
  56468. * @param pos world position that will be constrained by the navigation mesh
  56469. * @param parameters agent parameters
  56470. * @param transform hooked to the agent that will be update by the scene
  56471. * @returns agent index
  56472. */
  56473. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56474. /**
  56475. * Returns the agent position in world space
  56476. * @param index agent index returned by addAgent
  56477. * @returns world space position
  56478. */
  56479. getAgentPosition(index: number): Vector3;
  56480. /**
  56481. * Gets the agent velocity in world space
  56482. * @param index agent index returned by addAgent
  56483. * @returns world space velocity
  56484. */
  56485. getAgentVelocity(index: number): Vector3;
  56486. /**
  56487. * remove a particular agent previously created
  56488. * @param index agent index returned by addAgent
  56489. */
  56490. removeAgent(index: number): void;
  56491. /**
  56492. * get the list of all agents attached to this crowd
  56493. * @returns list of agent indices
  56494. */
  56495. getAgents(): number[];
  56496. /**
  56497. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56498. * @param deltaTime in seconds
  56499. */
  56500. update(deltaTime: number): void;
  56501. /**
  56502. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56503. * @param index agent index returned by addAgent
  56504. * @param destination targeted world position
  56505. */
  56506. agentGoto(index: number, destination: Vector3): void;
  56507. /**
  56508. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56509. * The queries will try to find a solution within those bounds
  56510. * default is (1,1,1)
  56511. * @param extent x,y,z value that define the extent around the queries point of reference
  56512. */
  56513. setDefaultQueryExtent(extent: Vector3): void;
  56514. /**
  56515. * Get the Bounding box extent specified by setDefaultQueryExtent
  56516. * @returns the box extent values
  56517. */
  56518. getDefaultQueryExtent(): Vector3;
  56519. /**
  56520. * Release all resources
  56521. */
  56522. dispose(): void;
  56523. }
  56524. /**
  56525. * Configures an agent
  56526. */
  56527. export interface IAgentParameters {
  56528. /**
  56529. * Agent radius. [Limit: >= 0]
  56530. */
  56531. radius: number;
  56532. /**
  56533. * Agent height. [Limit: > 0]
  56534. */
  56535. height: number;
  56536. /**
  56537. * Maximum allowed acceleration. [Limit: >= 0]
  56538. */
  56539. maxAcceleration: number;
  56540. /**
  56541. * Maximum allowed speed. [Limit: >= 0]
  56542. */
  56543. maxSpeed: number;
  56544. /**
  56545. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  56546. */
  56547. collisionQueryRange: number;
  56548. /**
  56549. * The path visibility optimization range. [Limit: > 0]
  56550. */
  56551. pathOptimizationRange: number;
  56552. /**
  56553. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  56554. */
  56555. separationWeight: number;
  56556. }
  56557. /**
  56558. * Configures the navigation mesh creation
  56559. */
  56560. export interface INavMeshParameters {
  56561. /**
  56562. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  56563. */
  56564. cs: number;
  56565. /**
  56566. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  56567. */
  56568. ch: number;
  56569. /**
  56570. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  56571. */
  56572. walkableSlopeAngle: number;
  56573. /**
  56574. * Minimum floor to 'ceiling' height that will still allow the floor area to
  56575. * be considered walkable. [Limit: >= 3] [Units: vx]
  56576. */
  56577. walkableHeight: number;
  56578. /**
  56579. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  56580. */
  56581. walkableClimb: number;
  56582. /**
  56583. * The distance to erode/shrink the walkable area of the heightfield away from
  56584. * obstructions. [Limit: >=0] [Units: vx]
  56585. */
  56586. walkableRadius: number;
  56587. /**
  56588. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  56589. */
  56590. maxEdgeLen: number;
  56591. /**
  56592. * The maximum distance a simplfied contour's border edges should deviate
  56593. * the original raw contour. [Limit: >=0] [Units: vx]
  56594. */
  56595. maxSimplificationError: number;
  56596. /**
  56597. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  56598. */
  56599. minRegionArea: number;
  56600. /**
  56601. * Any regions with a span count smaller than this value will, if possible,
  56602. * be merged with larger regions. [Limit: >=0] [Units: vx]
  56603. */
  56604. mergeRegionArea: number;
  56605. /**
  56606. * The maximum number of vertices allowed for polygons generated during the
  56607. * contour to polygon conversion process. [Limit: >= 3]
  56608. */
  56609. maxVertsPerPoly: number;
  56610. /**
  56611. * Sets the sampling distance to use when generating the detail mesh.
  56612. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  56613. */
  56614. detailSampleDist: number;
  56615. /**
  56616. * The maximum distance the detail mesh surface should deviate from heightfield
  56617. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  56618. */
  56619. detailSampleMaxError: number;
  56620. }
  56621. }
  56622. declare module BABYLON {
  56623. /**
  56624. * RecastJS navigation plugin
  56625. */
  56626. export class RecastJSPlugin implements INavigationEnginePlugin {
  56627. /**
  56628. * Reference to the Recast library
  56629. */
  56630. bjsRECAST: any;
  56631. /**
  56632. * plugin name
  56633. */
  56634. name: string;
  56635. /**
  56636. * the first navmesh created. We might extend this to support multiple navmeshes
  56637. */
  56638. navMesh: any;
  56639. /**
  56640. * Initializes the recastJS plugin
  56641. * @param recastInjection can be used to inject your own recast reference
  56642. */
  56643. constructor(recastInjection?: any);
  56644. /**
  56645. * Creates a navigation mesh
  56646. * @param meshes array of all the geometry used to compute the navigatio mesh
  56647. * @param parameters bunch of parameters used to filter geometry
  56648. */
  56649. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56650. /**
  56651. * Create a navigation mesh debug mesh
  56652. * @param scene is where the mesh will be added
  56653. * @returns debug display mesh
  56654. */
  56655. createDebugNavMesh(scene: Scene): Mesh;
  56656. /**
  56657. * Get a navigation mesh constrained position, closest to the parameter position
  56658. * @param position world position
  56659. * @returns the closest point to position constrained by the navigation mesh
  56660. */
  56661. getClosestPoint(position: Vector3): Vector3;
  56662. /**
  56663. * Get a navigation mesh constrained position, within a particular radius
  56664. * @param position world position
  56665. * @param maxRadius the maximum distance to the constrained world position
  56666. * @returns the closest point to position constrained by the navigation mesh
  56667. */
  56668. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56669. /**
  56670. * Compute the final position from a segment made of destination-position
  56671. * @param position world position
  56672. * @param destination world position
  56673. * @returns the resulting point along the navmesh
  56674. */
  56675. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56676. /**
  56677. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56678. * @param start world position
  56679. * @param end world position
  56680. * @returns array containing world position composing the path
  56681. */
  56682. computePath(start: Vector3, end: Vector3): Vector3[];
  56683. /**
  56684. * Create a new Crowd so you can add agents
  56685. * @param maxAgents the maximum agent count in the crowd
  56686. * @param maxAgentRadius the maximum radius an agent can have
  56687. * @param scene to attach the crowd to
  56688. * @returns the crowd you can add agents to
  56689. */
  56690. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56691. /**
  56692. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56693. * The queries will try to find a solution within those bounds
  56694. * default is (1,1,1)
  56695. * @param extent x,y,z value that define the extent around the queries point of reference
  56696. */
  56697. setDefaultQueryExtent(extent: Vector3): void;
  56698. /**
  56699. * Get the Bounding box extent specified by setDefaultQueryExtent
  56700. * @returns the box extent values
  56701. */
  56702. getDefaultQueryExtent(): Vector3;
  56703. /**
  56704. * Disposes
  56705. */
  56706. dispose(): void;
  56707. /**
  56708. * If this plugin is supported
  56709. * @returns true if plugin is supported
  56710. */
  56711. isSupported(): boolean;
  56712. }
  56713. /**
  56714. * Recast detour crowd implementation
  56715. */
  56716. export class RecastJSCrowd implements ICrowd {
  56717. /**
  56718. * Recast/detour plugin
  56719. */
  56720. bjsRECASTPlugin: RecastJSPlugin;
  56721. /**
  56722. * Link to the detour crowd
  56723. */
  56724. recastCrowd: any;
  56725. /**
  56726. * One transform per agent
  56727. */
  56728. transforms: TransformNode[];
  56729. /**
  56730. * All agents created
  56731. */
  56732. agents: number[];
  56733. /**
  56734. * Link to the scene is kept to unregister the crowd from the scene
  56735. */
  56736. private _scene;
  56737. /**
  56738. * Observer for crowd updates
  56739. */
  56740. private _onBeforeAnimationsObserver;
  56741. /**
  56742. * Constructor
  56743. * @param plugin recastJS plugin
  56744. * @param maxAgents the maximum agent count in the crowd
  56745. * @param maxAgentRadius the maximum radius an agent can have
  56746. * @param scene to attach the crowd to
  56747. * @returns the crowd you can add agents to
  56748. */
  56749. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  56750. /**
  56751. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56752. * You can attach anything to that node. The node position is updated in the scene update tick.
  56753. * @param pos world position that will be constrained by the navigation mesh
  56754. * @param parameters agent parameters
  56755. * @param transform hooked to the agent that will be update by the scene
  56756. * @returns agent index
  56757. */
  56758. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56759. /**
  56760. * Returns the agent position in world space
  56761. * @param index agent index returned by addAgent
  56762. * @returns world space position
  56763. */
  56764. getAgentPosition(index: number): Vector3;
  56765. /**
  56766. * Returns the agent velocity in world space
  56767. * @param index agent index returned by addAgent
  56768. * @returns world space velocity
  56769. */
  56770. getAgentVelocity(index: number): Vector3;
  56771. /**
  56772. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56773. * @param index agent index returned by addAgent
  56774. * @param destination targeted world position
  56775. */
  56776. agentGoto(index: number, destination: Vector3): void;
  56777. /**
  56778. * remove a particular agent previously created
  56779. * @param index agent index returned by addAgent
  56780. */
  56781. removeAgent(index: number): void;
  56782. /**
  56783. * get the list of all agents attached to this crowd
  56784. * @returns list of agent indices
  56785. */
  56786. getAgents(): number[];
  56787. /**
  56788. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56789. * @param deltaTime in seconds
  56790. */
  56791. update(deltaTime: number): void;
  56792. /**
  56793. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56794. * The queries will try to find a solution within those bounds
  56795. * default is (1,1,1)
  56796. * @param extent x,y,z value that define the extent around the queries point of reference
  56797. */
  56798. setDefaultQueryExtent(extent: Vector3): void;
  56799. /**
  56800. * Get the Bounding box extent specified by setDefaultQueryExtent
  56801. * @returns the box extent values
  56802. */
  56803. getDefaultQueryExtent(): Vector3;
  56804. /**
  56805. * Release all resources
  56806. */
  56807. dispose(): void;
  56808. }
  56809. }
  56810. declare module BABYLON {
  56811. /**
  56812. * Class used to enable access to IndexedDB
  56813. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56814. */
  56815. export class Database implements IOfflineProvider {
  56816. private _callbackManifestChecked;
  56817. private _currentSceneUrl;
  56818. private _db;
  56819. private _enableSceneOffline;
  56820. private _enableTexturesOffline;
  56821. private _manifestVersionFound;
  56822. private _mustUpdateRessources;
  56823. private _hasReachedQuota;
  56824. private _isSupported;
  56825. private _idbFactory;
  56826. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56827. private static IsUASupportingBlobStorage;
  56828. /**
  56829. * Gets a boolean indicating if Database storate is enabled (off by default)
  56830. */
  56831. static IDBStorageEnabled: boolean;
  56832. /**
  56833. * Gets a boolean indicating if scene must be saved in the database
  56834. */
  56835. readonly enableSceneOffline: boolean;
  56836. /**
  56837. * Gets a boolean indicating if textures must be saved in the database
  56838. */
  56839. readonly enableTexturesOffline: boolean;
  56840. /**
  56841. * Creates a new Database
  56842. * @param urlToScene defines the url to load the scene
  56843. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56844. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56845. */
  56846. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56847. private static _ParseURL;
  56848. private static _ReturnFullUrlLocation;
  56849. private _checkManifestFile;
  56850. /**
  56851. * Open the database and make it available
  56852. * @param successCallback defines the callback to call on success
  56853. * @param errorCallback defines the callback to call on error
  56854. */
  56855. open(successCallback: () => void, errorCallback: () => void): void;
  56856. /**
  56857. * Loads an image from the database
  56858. * @param url defines the url to load from
  56859. * @param image defines the target DOM image
  56860. */
  56861. loadImage(url: string, image: HTMLImageElement): void;
  56862. private _loadImageFromDBAsync;
  56863. private _saveImageIntoDBAsync;
  56864. private _checkVersionFromDB;
  56865. private _loadVersionFromDBAsync;
  56866. private _saveVersionIntoDBAsync;
  56867. /**
  56868. * Loads a file from database
  56869. * @param url defines the URL to load from
  56870. * @param sceneLoaded defines a callback to call on success
  56871. * @param progressCallBack defines a callback to call when progress changed
  56872. * @param errorCallback defines a callback to call on error
  56873. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56874. */
  56875. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56876. private _loadFileAsync;
  56877. private _saveFileAsync;
  56878. /**
  56879. * Validates if xhr data is correct
  56880. * @param xhr defines the request to validate
  56881. * @param dataType defines the expected data type
  56882. * @returns true if data is correct
  56883. */
  56884. private static _ValidateXHRData;
  56885. }
  56886. }
  56887. declare module BABYLON {
  56888. /** @hidden */
  56889. export var gpuUpdateParticlesPixelShader: {
  56890. name: string;
  56891. shader: string;
  56892. };
  56893. }
  56894. declare module BABYLON {
  56895. /** @hidden */
  56896. export var gpuUpdateParticlesVertexShader: {
  56897. name: string;
  56898. shader: string;
  56899. };
  56900. }
  56901. declare module BABYLON {
  56902. /** @hidden */
  56903. export var clipPlaneFragmentDeclaration2: {
  56904. name: string;
  56905. shader: string;
  56906. };
  56907. }
  56908. declare module BABYLON {
  56909. /** @hidden */
  56910. export var gpuRenderParticlesPixelShader: {
  56911. name: string;
  56912. shader: string;
  56913. };
  56914. }
  56915. declare module BABYLON {
  56916. /** @hidden */
  56917. export var clipPlaneVertexDeclaration2: {
  56918. name: string;
  56919. shader: string;
  56920. };
  56921. }
  56922. declare module BABYLON {
  56923. /** @hidden */
  56924. export var gpuRenderParticlesVertexShader: {
  56925. name: string;
  56926. shader: string;
  56927. };
  56928. }
  56929. declare module BABYLON {
  56930. /**
  56931. * This represents a GPU particle system in Babylon
  56932. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56933. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56934. */
  56935. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56936. /**
  56937. * The layer mask we are rendering the particles through.
  56938. */
  56939. layerMask: number;
  56940. private _capacity;
  56941. private _activeCount;
  56942. private _currentActiveCount;
  56943. private _accumulatedCount;
  56944. private _renderEffect;
  56945. private _updateEffect;
  56946. private _buffer0;
  56947. private _buffer1;
  56948. private _spriteBuffer;
  56949. private _updateVAO;
  56950. private _renderVAO;
  56951. private _targetIndex;
  56952. private _sourceBuffer;
  56953. private _targetBuffer;
  56954. private _engine;
  56955. private _currentRenderId;
  56956. private _started;
  56957. private _stopped;
  56958. private _timeDelta;
  56959. private _randomTexture;
  56960. private _randomTexture2;
  56961. private _attributesStrideSize;
  56962. private _updateEffectOptions;
  56963. private _randomTextureSize;
  56964. private _actualFrame;
  56965. private readonly _rawTextureWidth;
  56966. /**
  56967. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56968. */
  56969. static readonly IsSupported: boolean;
  56970. /**
  56971. * An event triggered when the system is disposed.
  56972. */
  56973. onDisposeObservable: Observable<GPUParticleSystem>;
  56974. /**
  56975. * Gets the maximum number of particles active at the same time.
  56976. * @returns The max number of active particles.
  56977. */
  56978. getCapacity(): number;
  56979. /**
  56980. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56981. * to override the particles.
  56982. */
  56983. forceDepthWrite: boolean;
  56984. /**
  56985. * Gets or set the number of active particles
  56986. */
  56987. activeParticleCount: number;
  56988. private _preWarmDone;
  56989. /**
  56990. * Is this system ready to be used/rendered
  56991. * @return true if the system is ready
  56992. */
  56993. isReady(): boolean;
  56994. /**
  56995. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56996. * @returns True if it has been started, otherwise false.
  56997. */
  56998. isStarted(): boolean;
  56999. /**
  57000. * Starts the particle system and begins to emit
  57001. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  57002. */
  57003. start(delay?: number): void;
  57004. /**
  57005. * Stops the particle system.
  57006. */
  57007. stop(): void;
  57008. /**
  57009. * Remove all active particles
  57010. */
  57011. reset(): void;
  57012. /**
  57013. * Returns the string "GPUParticleSystem"
  57014. * @returns a string containing the class name
  57015. */
  57016. getClassName(): string;
  57017. private _colorGradientsTexture;
  57018. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  57019. /**
  57020. * Adds a new color gradient
  57021. * @param gradient defines the gradient to use (between 0 and 1)
  57022. * @param color1 defines the color to affect to the specified gradient
  57023. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  57024. * @returns the current particle system
  57025. */
  57026. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  57027. /**
  57028. * Remove a specific color gradient
  57029. * @param gradient defines the gradient to remove
  57030. * @returns the current particle system
  57031. */
  57032. removeColorGradient(gradient: number): GPUParticleSystem;
  57033. private _angularSpeedGradientsTexture;
  57034. private _sizeGradientsTexture;
  57035. private _velocityGradientsTexture;
  57036. private _limitVelocityGradientsTexture;
  57037. private _dragGradientsTexture;
  57038. private _addFactorGradient;
  57039. /**
  57040. * Adds a new size gradient
  57041. * @param gradient defines the gradient to use (between 0 and 1)
  57042. * @param factor defines the size factor to affect to the specified gradient
  57043. * @returns the current particle system
  57044. */
  57045. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  57046. /**
  57047. * Remove a specific size gradient
  57048. * @param gradient defines the gradient to remove
  57049. * @returns the current particle system
  57050. */
  57051. removeSizeGradient(gradient: number): GPUParticleSystem;
  57052. /**
  57053. * Adds a new angular speed gradient
  57054. * @param gradient defines the gradient to use (between 0 and 1)
  57055. * @param factor defines the angular speed to affect to the specified gradient
  57056. * @returns the current particle system
  57057. */
  57058. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  57059. /**
  57060. * Remove a specific angular speed gradient
  57061. * @param gradient defines the gradient to remove
  57062. * @returns the current particle system
  57063. */
  57064. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  57065. /**
  57066. * Adds a new velocity gradient
  57067. * @param gradient defines the gradient to use (between 0 and 1)
  57068. * @param factor defines the velocity to affect to the specified gradient
  57069. * @returns the current particle system
  57070. */
  57071. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57072. /**
  57073. * Remove a specific velocity gradient
  57074. * @param gradient defines the gradient to remove
  57075. * @returns the current particle system
  57076. */
  57077. removeVelocityGradient(gradient: number): GPUParticleSystem;
  57078. /**
  57079. * Adds a new limit velocity gradient
  57080. * @param gradient defines the gradient to use (between 0 and 1)
  57081. * @param factor defines the limit velocity value to affect to the specified gradient
  57082. * @returns the current particle system
  57083. */
  57084. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57085. /**
  57086. * Remove a specific limit velocity gradient
  57087. * @param gradient defines the gradient to remove
  57088. * @returns the current particle system
  57089. */
  57090. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  57091. /**
  57092. * Adds a new drag gradient
  57093. * @param gradient defines the gradient to use (between 0 and 1)
  57094. * @param factor defines the drag value to affect to the specified gradient
  57095. * @returns the current particle system
  57096. */
  57097. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  57098. /**
  57099. * Remove a specific drag gradient
  57100. * @param gradient defines the gradient to remove
  57101. * @returns the current particle system
  57102. */
  57103. removeDragGradient(gradient: number): GPUParticleSystem;
  57104. /**
  57105. * Not supported by GPUParticleSystem
  57106. * @param gradient defines the gradient to use (between 0 and 1)
  57107. * @param factor defines the emit rate value to affect to the specified gradient
  57108. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57109. * @returns the current particle system
  57110. */
  57111. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57112. /**
  57113. * Not supported by GPUParticleSystem
  57114. * @param gradient defines the gradient to remove
  57115. * @returns the current particle system
  57116. */
  57117. removeEmitRateGradient(gradient: number): IParticleSystem;
  57118. /**
  57119. * Not supported by GPUParticleSystem
  57120. * @param gradient defines the gradient to use (between 0 and 1)
  57121. * @param factor defines the start size value to affect to the specified gradient
  57122. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57123. * @returns the current particle system
  57124. */
  57125. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57126. /**
  57127. * Not supported by GPUParticleSystem
  57128. * @param gradient defines the gradient to remove
  57129. * @returns the current particle system
  57130. */
  57131. removeStartSizeGradient(gradient: number): IParticleSystem;
  57132. /**
  57133. * Not supported by GPUParticleSystem
  57134. * @param gradient defines the gradient to use (between 0 and 1)
  57135. * @param min defines the color remap minimal range
  57136. * @param max defines the color remap maximal range
  57137. * @returns the current particle system
  57138. */
  57139. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57140. /**
  57141. * Not supported by GPUParticleSystem
  57142. * @param gradient defines the gradient to remove
  57143. * @returns the current particle system
  57144. */
  57145. removeColorRemapGradient(): IParticleSystem;
  57146. /**
  57147. * Not supported by GPUParticleSystem
  57148. * @param gradient defines the gradient to use (between 0 and 1)
  57149. * @param min defines the alpha remap minimal range
  57150. * @param max defines the alpha remap maximal range
  57151. * @returns the current particle system
  57152. */
  57153. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57154. /**
  57155. * Not supported by GPUParticleSystem
  57156. * @param gradient defines the gradient to remove
  57157. * @returns the current particle system
  57158. */
  57159. removeAlphaRemapGradient(): IParticleSystem;
  57160. /**
  57161. * Not supported by GPUParticleSystem
  57162. * @param gradient defines the gradient to use (between 0 and 1)
  57163. * @param color defines the color to affect to the specified gradient
  57164. * @returns the current particle system
  57165. */
  57166. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  57167. /**
  57168. * Not supported by GPUParticleSystem
  57169. * @param gradient defines the gradient to remove
  57170. * @returns the current particle system
  57171. */
  57172. removeRampGradient(): IParticleSystem;
  57173. /**
  57174. * Not supported by GPUParticleSystem
  57175. * @returns the list of ramp gradients
  57176. */
  57177. getRampGradients(): Nullable<Array<Color3Gradient>>;
  57178. /**
  57179. * Not supported by GPUParticleSystem
  57180. * Gets or sets a boolean indicating that ramp gradients must be used
  57181. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  57182. */
  57183. useRampGradients: boolean;
  57184. /**
  57185. * Not supported by GPUParticleSystem
  57186. * @param gradient defines the gradient to use (between 0 and 1)
  57187. * @param factor defines the life time factor to affect to the specified gradient
  57188. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57189. * @returns the current particle system
  57190. */
  57191. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57192. /**
  57193. * Not supported by GPUParticleSystem
  57194. * @param gradient defines the gradient to remove
  57195. * @returns the current particle system
  57196. */
  57197. removeLifeTimeGradient(gradient: number): IParticleSystem;
  57198. /**
  57199. * Instantiates a GPU particle system.
  57200. * 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.
  57201. * @param name The name of the particle system
  57202. * @param options The options used to create the system
  57203. * @param scene The scene the particle system belongs to
  57204. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  57205. */
  57206. constructor(name: string, options: Partial<{
  57207. capacity: number;
  57208. randomTextureSize: number;
  57209. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  57210. protected _reset(): void;
  57211. private _createUpdateVAO;
  57212. private _createRenderVAO;
  57213. private _initialize;
  57214. /** @hidden */ private _recreateUpdateEffect(): void;
  57215. /** @hidden */ private _recreateRenderEffect(): void;
  57216. /**
  57217. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  57218. * @param preWarm defines if we are in the pre-warmimg phase
  57219. */
  57220. animate(preWarm?: boolean): void;
  57221. private _createFactorGradientTexture;
  57222. private _createSizeGradientTexture;
  57223. private _createAngularSpeedGradientTexture;
  57224. private _createVelocityGradientTexture;
  57225. private _createLimitVelocityGradientTexture;
  57226. private _createDragGradientTexture;
  57227. private _createColorGradientTexture;
  57228. /**
  57229. * Renders the particle system in its current state
  57230. * @param preWarm defines if the system should only update the particles but not render them
  57231. * @returns the current number of particles
  57232. */
  57233. render(preWarm?: boolean): number;
  57234. /**
  57235. * Rebuilds the particle system
  57236. */
  57237. rebuild(): void;
  57238. private _releaseBuffers;
  57239. private _releaseVAOs;
  57240. /**
  57241. * Disposes the particle system and free the associated resources
  57242. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  57243. */
  57244. dispose(disposeTexture?: boolean): void;
  57245. /**
  57246. * Clones the particle system.
  57247. * @param name The name of the cloned object
  57248. * @param newEmitter The new emitter to use
  57249. * @returns the cloned particle system
  57250. */
  57251. clone(name: string, newEmitter: any): GPUParticleSystem;
  57252. /**
  57253. * Serializes the particle system to a JSON object.
  57254. * @returns the JSON object
  57255. */
  57256. serialize(): any;
  57257. /**
  57258. * Parses a JSON object to create a GPU particle system.
  57259. * @param parsedParticleSystem The JSON object to parse
  57260. * @param scene The scene to create the particle system in
  57261. * @param rootUrl The root url to use to load external dependencies like texture
  57262. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  57263. * @returns the parsed GPU particle system
  57264. */
  57265. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  57266. }
  57267. }
  57268. declare module BABYLON {
  57269. /**
  57270. * Represents a set of particle systems working together to create a specific effect
  57271. */
  57272. export class ParticleSystemSet implements IDisposable {
  57273. private _emitterCreationOptions;
  57274. private _emitterNode;
  57275. /**
  57276. * Gets the particle system list
  57277. */
  57278. systems: IParticleSystem[];
  57279. /**
  57280. * Gets the emitter node used with this set
  57281. */
  57282. readonly emitterNode: Nullable<TransformNode>;
  57283. /**
  57284. * Creates a new emitter mesh as a sphere
  57285. * @param options defines the options used to create the sphere
  57286. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  57287. * @param scene defines the hosting scene
  57288. */
  57289. setEmitterAsSphere(options: {
  57290. diameter: number;
  57291. segments: number;
  57292. color: Color3;
  57293. }, renderingGroupId: number, scene: Scene): void;
  57294. /**
  57295. * Starts all particle systems of the set
  57296. * @param emitter defines an optional mesh to use as emitter for the particle systems
  57297. */
  57298. start(emitter?: AbstractMesh): void;
  57299. /**
  57300. * Release all associated resources
  57301. */
  57302. dispose(): void;
  57303. /**
  57304. * Serialize the set into a JSON compatible object
  57305. * @returns a JSON compatible representation of the set
  57306. */
  57307. serialize(): any;
  57308. /**
  57309. * Parse a new ParticleSystemSet from a serialized source
  57310. * @param data defines a JSON compatible representation of the set
  57311. * @param scene defines the hosting scene
  57312. * @param gpu defines if we want GPU particles or CPU particles
  57313. * @returns a new ParticleSystemSet
  57314. */
  57315. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  57316. }
  57317. }
  57318. declare module BABYLON {
  57319. /**
  57320. * This class is made for on one-liner static method to help creating particle system set.
  57321. */
  57322. export class ParticleHelper {
  57323. /**
  57324. * Gets or sets base Assets URL
  57325. */
  57326. static BaseAssetsUrl: string;
  57327. /**
  57328. * Create a default particle system that you can tweak
  57329. * @param emitter defines the emitter to use
  57330. * @param capacity defines the system capacity (default is 500 particles)
  57331. * @param scene defines the hosting scene
  57332. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57333. * @returns the new Particle system
  57334. */
  57335. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57336. /**
  57337. * This is the main static method (one-liner) of this helper to create different particle systems
  57338. * @param type This string represents the type to the particle system to create
  57339. * @param scene The scene where the particle system should live
  57340. * @param gpu If the system will use gpu
  57341. * @returns the ParticleSystemSet created
  57342. */
  57343. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57344. /**
  57345. * Static function used to export a particle system to a ParticleSystemSet variable.
  57346. * Please note that the emitter shape is not exported
  57347. * @param systems defines the particle systems to export
  57348. * @returns the created particle system set
  57349. */
  57350. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57351. }
  57352. }
  57353. declare module BABYLON {
  57354. interface Engine {
  57355. /**
  57356. * Create an effect to use with particle systems.
  57357. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57358. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57359. * @param uniformsNames defines a list of attribute names
  57360. * @param samplers defines an array of string used to represent textures
  57361. * @param defines defines the string containing the defines to use to compile the shaders
  57362. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57363. * @param onCompiled defines a function to call when the effect creation is successful
  57364. * @param onError defines a function to call when the effect creation has failed
  57365. * @returns the new Effect
  57366. */
  57367. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57368. }
  57369. interface Mesh {
  57370. /**
  57371. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57372. * @returns an array of IParticleSystem
  57373. */
  57374. getEmittedParticleSystems(): IParticleSystem[];
  57375. /**
  57376. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57377. * @returns an array of IParticleSystem
  57378. */
  57379. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57380. }
  57381. /**
  57382. * @hidden
  57383. */
  57384. export var _IDoNeedToBeInTheBuild: number;
  57385. }
  57386. declare module BABYLON {
  57387. interface Scene {
  57388. /** @hidden (Backing field) */ private _physicsEngine: Nullable<IPhysicsEngine>;
  57389. /**
  57390. * Gets the current physics engine
  57391. * @returns a IPhysicsEngine or null if none attached
  57392. */
  57393. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57394. /**
  57395. * Enables physics to the current scene
  57396. * @param gravity defines the scene's gravity for the physics engine
  57397. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57398. * @return a boolean indicating if the physics engine was initialized
  57399. */
  57400. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57401. /**
  57402. * Disables and disposes the physics engine associated with the scene
  57403. */
  57404. disablePhysicsEngine(): void;
  57405. /**
  57406. * Gets a boolean indicating if there is an active physics engine
  57407. * @returns a boolean indicating if there is an active physics engine
  57408. */
  57409. isPhysicsEnabled(): boolean;
  57410. /**
  57411. * Deletes a physics compound impostor
  57412. * @param compound defines the compound to delete
  57413. */
  57414. deleteCompoundImpostor(compound: any): void;
  57415. /**
  57416. * An event triggered when physic simulation is about to be run
  57417. */
  57418. onBeforePhysicsObservable: Observable<Scene>;
  57419. /**
  57420. * An event triggered when physic simulation has been done
  57421. */
  57422. onAfterPhysicsObservable: Observable<Scene>;
  57423. }
  57424. interface AbstractMesh {
  57425. /** @hidden */ private _physicsImpostor: Nullable<PhysicsImpostor>;
  57426. /**
  57427. * Gets or sets impostor used for physic simulation
  57428. * @see http://doc.babylonjs.com/features/physics_engine
  57429. */
  57430. physicsImpostor: Nullable<PhysicsImpostor>;
  57431. /**
  57432. * Gets the current physics impostor
  57433. * @see http://doc.babylonjs.com/features/physics_engine
  57434. * @returns a physics impostor or null
  57435. */
  57436. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57437. /** Apply a physic impulse to the mesh
  57438. * @param force defines the force to apply
  57439. * @param contactPoint defines where to apply the force
  57440. * @returns the current mesh
  57441. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57442. */
  57443. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57444. /**
  57445. * Creates a physic joint between two meshes
  57446. * @param otherMesh defines the other mesh to use
  57447. * @param pivot1 defines the pivot to use on this mesh
  57448. * @param pivot2 defines the pivot to use on the other mesh
  57449. * @param options defines additional options (can be plugin dependent)
  57450. * @returns the current mesh
  57451. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57452. */
  57453. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57454. /** @hidden */ private _disposePhysicsObserver: Nullable<Observer<Node>>;
  57455. }
  57456. /**
  57457. * Defines the physics engine scene component responsible to manage a physics engine
  57458. */
  57459. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57460. /**
  57461. * The component name helpful to identify the component in the list of scene components.
  57462. */
  57463. readonly name: string;
  57464. /**
  57465. * The scene the component belongs to.
  57466. */
  57467. scene: Scene;
  57468. /**
  57469. * Creates a new instance of the component for the given scene
  57470. * @param scene Defines the scene to register the component in
  57471. */
  57472. constructor(scene: Scene);
  57473. /**
  57474. * Registers the component in a given scene
  57475. */
  57476. register(): void;
  57477. /**
  57478. * Rebuilds the elements related to this component in case of
  57479. * context lost for instance.
  57480. */
  57481. rebuild(): void;
  57482. /**
  57483. * Disposes the component and the associated ressources
  57484. */
  57485. dispose(): void;
  57486. }
  57487. }
  57488. declare module BABYLON {
  57489. /**
  57490. * A helper for physics simulations
  57491. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57492. */
  57493. export class PhysicsHelper {
  57494. private _scene;
  57495. private _physicsEngine;
  57496. /**
  57497. * Initializes the Physics helper
  57498. * @param scene Babylon.js scene
  57499. */
  57500. constructor(scene: Scene);
  57501. /**
  57502. * Applies a radial explosion impulse
  57503. * @param origin the origin of the explosion
  57504. * @param radiusOrEventOptions the radius or the options of radial explosion
  57505. * @param strength the explosion strength
  57506. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57507. * @returns A physics radial explosion event, or null
  57508. */
  57509. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57510. /**
  57511. * Applies a radial explosion force
  57512. * @param origin the origin of the explosion
  57513. * @param radiusOrEventOptions the radius or the options of radial explosion
  57514. * @param strength the explosion strength
  57515. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57516. * @returns A physics radial explosion event, or null
  57517. */
  57518. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57519. /**
  57520. * Creates a gravitational field
  57521. * @param origin the origin of the explosion
  57522. * @param radiusOrEventOptions the radius or the options of radial explosion
  57523. * @param strength the explosion strength
  57524. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57525. * @returns A physics gravitational field event, or null
  57526. */
  57527. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57528. /**
  57529. * Creates a physics updraft event
  57530. * @param origin the origin of the updraft
  57531. * @param radiusOrEventOptions the radius or the options of the updraft
  57532. * @param strength the strength of the updraft
  57533. * @param height the height of the updraft
  57534. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57535. * @returns A physics updraft event, or null
  57536. */
  57537. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57538. /**
  57539. * Creates a physics vortex event
  57540. * @param origin the of the vortex
  57541. * @param radiusOrEventOptions the radius or the options of the vortex
  57542. * @param strength the strength of the vortex
  57543. * @param height the height of the vortex
  57544. * @returns a Physics vortex event, or null
  57545. * A physics vortex event or null
  57546. */
  57547. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  57548. }
  57549. /**
  57550. * Represents a physics radial explosion event
  57551. */
  57552. class PhysicsRadialExplosionEvent {
  57553. private _scene;
  57554. private _options;
  57555. private _sphere;
  57556. private _dataFetched;
  57557. /**
  57558. * Initializes a radial explosioin event
  57559. * @param _scene BabylonJS scene
  57560. * @param _options The options for the vortex event
  57561. */
  57562. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  57563. /**
  57564. * Returns the data related to the radial explosion event (sphere).
  57565. * @returns The radial explosion event data
  57566. */
  57567. getData(): PhysicsRadialExplosionEventData;
  57568. /**
  57569. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  57570. * @param impostor A physics imposter
  57571. * @param origin the origin of the explosion
  57572. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  57573. */
  57574. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  57575. /**
  57576. * Triggers affecterd impostors callbacks
  57577. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  57578. */
  57579. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  57580. /**
  57581. * Disposes the sphere.
  57582. * @param force Specifies if the sphere should be disposed by force
  57583. */
  57584. dispose(force?: boolean): void;
  57585. /*** Helpers ***/
  57586. private _prepareSphere;
  57587. private _intersectsWithSphere;
  57588. }
  57589. /**
  57590. * Represents a gravitational field event
  57591. */
  57592. class PhysicsGravitationalFieldEvent {
  57593. private _physicsHelper;
  57594. private _scene;
  57595. private _origin;
  57596. private _options;
  57597. private _tickCallback;
  57598. private _sphere;
  57599. private _dataFetched;
  57600. /**
  57601. * Initializes the physics gravitational field event
  57602. * @param _physicsHelper A physics helper
  57603. * @param _scene BabylonJS scene
  57604. * @param _origin The origin position of the gravitational field event
  57605. * @param _options The options for the vortex event
  57606. */
  57607. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  57608. /**
  57609. * Returns the data related to the gravitational field event (sphere).
  57610. * @returns A gravitational field event
  57611. */
  57612. getData(): PhysicsGravitationalFieldEventData;
  57613. /**
  57614. * Enables the gravitational field.
  57615. */
  57616. enable(): void;
  57617. /**
  57618. * Disables the gravitational field.
  57619. */
  57620. disable(): void;
  57621. /**
  57622. * Disposes the sphere.
  57623. * @param force The force to dispose from the gravitational field event
  57624. */
  57625. dispose(force?: boolean): void;
  57626. private _tick;
  57627. }
  57628. /**
  57629. * Represents a physics updraft event
  57630. */
  57631. class PhysicsUpdraftEvent {
  57632. private _scene;
  57633. private _origin;
  57634. private _options;
  57635. private _physicsEngine;
  57636. private _originTop;
  57637. private _originDirection;
  57638. private _tickCallback;
  57639. private _cylinder;
  57640. private _cylinderPosition;
  57641. private _dataFetched;
  57642. /**
  57643. * Initializes the physics updraft event
  57644. * @param _scene BabylonJS scene
  57645. * @param _origin The origin position of the updraft
  57646. * @param _options The options for the updraft event
  57647. */
  57648. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  57649. /**
  57650. * Returns the data related to the updraft event (cylinder).
  57651. * @returns A physics updraft event
  57652. */
  57653. getData(): PhysicsUpdraftEventData;
  57654. /**
  57655. * Enables the updraft.
  57656. */
  57657. enable(): void;
  57658. /**
  57659. * Disables the updraft.
  57660. */
  57661. disable(): void;
  57662. /**
  57663. * Disposes the cylinder.
  57664. * @param force Specifies if the updraft should be disposed by force
  57665. */
  57666. dispose(force?: boolean): void;
  57667. private getImpostorHitData;
  57668. private _tick;
  57669. /*** Helpers ***/
  57670. private _prepareCylinder;
  57671. private _intersectsWithCylinder;
  57672. }
  57673. /**
  57674. * Represents a physics vortex event
  57675. */
  57676. class PhysicsVortexEvent {
  57677. private _scene;
  57678. private _origin;
  57679. private _options;
  57680. private _physicsEngine;
  57681. private _originTop;
  57682. private _tickCallback;
  57683. private _cylinder;
  57684. private _cylinderPosition;
  57685. private _dataFetched;
  57686. /**
  57687. * Initializes the physics vortex event
  57688. * @param _scene The BabylonJS scene
  57689. * @param _origin The origin position of the vortex
  57690. * @param _options The options for the vortex event
  57691. */
  57692. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57693. /**
  57694. * Returns the data related to the vortex event (cylinder).
  57695. * @returns The physics vortex event data
  57696. */
  57697. getData(): PhysicsVortexEventData;
  57698. /**
  57699. * Enables the vortex.
  57700. */
  57701. enable(): void;
  57702. /**
  57703. * Disables the cortex.
  57704. */
  57705. disable(): void;
  57706. /**
  57707. * Disposes the sphere.
  57708. * @param force
  57709. */
  57710. dispose(force?: boolean): void;
  57711. private getImpostorHitData;
  57712. private _tick;
  57713. /*** Helpers ***/
  57714. private _prepareCylinder;
  57715. private _intersectsWithCylinder;
  57716. }
  57717. /**
  57718. * Options fot the radial explosion event
  57719. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57720. */
  57721. export class PhysicsRadialExplosionEventOptions {
  57722. /**
  57723. * The radius of the sphere for the radial explosion.
  57724. */
  57725. radius: number;
  57726. /**
  57727. * The strenth of the explosion.
  57728. */
  57729. strength: number;
  57730. /**
  57731. * The strenght of the force in correspondence to the distance of the affected object
  57732. */
  57733. falloff: PhysicsRadialImpulseFalloff;
  57734. /**
  57735. * Sphere options for the radial explosion.
  57736. */
  57737. sphere: {
  57738. segments: number;
  57739. diameter: number;
  57740. };
  57741. /**
  57742. * Sphere options for the radial explosion.
  57743. */
  57744. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57745. }
  57746. /**
  57747. * Options fot the updraft event
  57748. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57749. */
  57750. export class PhysicsUpdraftEventOptions {
  57751. /**
  57752. * The radius of the cylinder for the vortex
  57753. */
  57754. radius: number;
  57755. /**
  57756. * The strenth of the updraft.
  57757. */
  57758. strength: number;
  57759. /**
  57760. * The height of the cylinder for the updraft.
  57761. */
  57762. height: number;
  57763. /**
  57764. * The mode for the the updraft.
  57765. */
  57766. updraftMode: PhysicsUpdraftMode;
  57767. }
  57768. /**
  57769. * Options fot the vortex event
  57770. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57771. */
  57772. export class PhysicsVortexEventOptions {
  57773. /**
  57774. * The radius of the cylinder for the vortex
  57775. */
  57776. radius: number;
  57777. /**
  57778. * The strenth of the vortex.
  57779. */
  57780. strength: number;
  57781. /**
  57782. * The height of the cylinder for the vortex.
  57783. */
  57784. height: number;
  57785. /**
  57786. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57787. */
  57788. centripetalForceThreshold: number;
  57789. /**
  57790. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57791. */
  57792. centripetalForceMultiplier: number;
  57793. /**
  57794. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57795. */
  57796. centrifugalForceMultiplier: number;
  57797. /**
  57798. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57799. */
  57800. updraftForceMultiplier: number;
  57801. }
  57802. /**
  57803. * The strenght of the force in correspondence to the distance of the affected object
  57804. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57805. */
  57806. export enum PhysicsRadialImpulseFalloff {
  57807. /** Defines that impulse is constant in strength across it's whole radius */
  57808. Constant = 0,
  57809. /** Defines that impulse gets weaker if it's further from the origin */
  57810. Linear = 1
  57811. }
  57812. /**
  57813. * The strength of the force in correspondence to the distance of the affected object
  57814. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57815. */
  57816. export enum PhysicsUpdraftMode {
  57817. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57818. Center = 0,
  57819. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57820. Perpendicular = 1
  57821. }
  57822. /**
  57823. * Interface for a physics hit data
  57824. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57825. */
  57826. export interface PhysicsHitData {
  57827. /**
  57828. * The force applied at the contact point
  57829. */
  57830. force: Vector3;
  57831. /**
  57832. * The contact point
  57833. */
  57834. contactPoint: Vector3;
  57835. /**
  57836. * The distance from the origin to the contact point
  57837. */
  57838. distanceFromOrigin: number;
  57839. }
  57840. /**
  57841. * Interface for radial explosion event data
  57842. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57843. */
  57844. export interface PhysicsRadialExplosionEventData {
  57845. /**
  57846. * A sphere used for the radial explosion event
  57847. */
  57848. sphere: Mesh;
  57849. }
  57850. /**
  57851. * Interface for gravitational field event data
  57852. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57853. */
  57854. export interface PhysicsGravitationalFieldEventData {
  57855. /**
  57856. * A sphere mesh used for the gravitational field event
  57857. */
  57858. sphere: Mesh;
  57859. }
  57860. /**
  57861. * Interface for updraft event data
  57862. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57863. */
  57864. export interface PhysicsUpdraftEventData {
  57865. /**
  57866. * A cylinder used for the updraft event
  57867. */
  57868. cylinder: Mesh;
  57869. }
  57870. /**
  57871. * Interface for vortex event data
  57872. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57873. */
  57874. export interface PhysicsVortexEventData {
  57875. /**
  57876. * A cylinder used for the vortex event
  57877. */
  57878. cylinder: Mesh;
  57879. }
  57880. /**
  57881. * Interface for an affected physics impostor
  57882. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57883. */
  57884. export interface PhysicsAffectedImpostorWithData {
  57885. /**
  57886. * The impostor affected by the effect
  57887. */
  57888. impostor: PhysicsImpostor;
  57889. /**
  57890. * The data about the hit/horce from the explosion
  57891. */
  57892. hitData: PhysicsHitData;
  57893. }
  57894. }
  57895. declare module BABYLON {
  57896. /** @hidden */
  57897. export var blackAndWhitePixelShader: {
  57898. name: string;
  57899. shader: string;
  57900. };
  57901. }
  57902. declare module BABYLON {
  57903. /**
  57904. * Post process used to render in black and white
  57905. */
  57906. export class BlackAndWhitePostProcess extends PostProcess {
  57907. /**
  57908. * Linear about to convert he result to black and white (default: 1)
  57909. */
  57910. degree: number;
  57911. /**
  57912. * Creates a black and white post process
  57913. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57914. * @param name The name of the effect.
  57915. * @param options The required width/height ratio to downsize to before computing the render pass.
  57916. * @param camera The camera to apply the render pass to.
  57917. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57918. * @param engine The engine which the post process will be applied. (default: current engine)
  57919. * @param reusable If the post process can be reused on the same frame. (default: false)
  57920. */
  57921. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57922. }
  57923. }
  57924. declare module BABYLON {
  57925. /**
  57926. * This represents a set of one or more post processes in Babylon.
  57927. * A post process can be used to apply a shader to a texture after it is rendered.
  57928. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57929. */
  57930. export class PostProcessRenderEffect {
  57931. private _postProcesses;
  57932. private _getPostProcesses;
  57933. private _singleInstance;
  57934. private _cameras;
  57935. private _indicesForCamera;
  57936. /**
  57937. * Name of the effect
  57938. * @hidden
  57939. */ private _name: string;
  57940. /**
  57941. * Instantiates a post process render effect.
  57942. * A post process can be used to apply a shader to a texture after it is rendered.
  57943. * @param engine The engine the effect is tied to
  57944. * @param name The name of the effect
  57945. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57946. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57947. */
  57948. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57949. /**
  57950. * Checks if all the post processes in the effect are supported.
  57951. */
  57952. readonly isSupported: boolean;
  57953. /**
  57954. * Updates the current state of the effect
  57955. * @hidden
  57956. */ private _update(): void;
  57957. /**
  57958. * Attaches the effect on cameras
  57959. * @param cameras The camera to attach to.
  57960. * @hidden
  57961. */ private _attachCameras(cameras: Camera): void;
  57962. /**
  57963. * Attaches the effect on cameras
  57964. * @param cameras The camera to attach to.
  57965. * @hidden
  57966. */ private _attachCameras(cameras: Camera[]): void;
  57967. /**
  57968. * Detaches the effect on cameras
  57969. * @param cameras The camera to detatch from.
  57970. * @hidden
  57971. */ private _detachCameras(cameras: Camera): void;
  57972. /**
  57973. * Detatches the effect on cameras
  57974. * @param cameras The camera to detatch from.
  57975. * @hidden
  57976. */ private _detachCameras(cameras: Camera[]): void;
  57977. /**
  57978. * Enables the effect on given cameras
  57979. * @param cameras The camera to enable.
  57980. * @hidden
  57981. */ private _enable(cameras: Camera): void;
  57982. /**
  57983. * Enables the effect on given cameras
  57984. * @param cameras The camera to enable.
  57985. * @hidden
  57986. */ private _enable(cameras: Nullable<Camera[]>): void;
  57987. /**
  57988. * Disables the effect on the given cameras
  57989. * @param cameras The camera to disable.
  57990. * @hidden
  57991. */ private _disable(cameras: Camera): void;
  57992. /**
  57993. * Disables the effect on the given cameras
  57994. * @param cameras The camera to disable.
  57995. * @hidden
  57996. */ private _disable(cameras: Nullable<Camera[]>): void;
  57997. /**
  57998. * Gets a list of the post processes contained in the effect.
  57999. * @param camera The camera to get the post processes on.
  58000. * @returns The list of the post processes in the effect.
  58001. */
  58002. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  58003. }
  58004. }
  58005. declare module BABYLON {
  58006. /** @hidden */
  58007. export var extractHighlightsPixelShader: {
  58008. name: string;
  58009. shader: string;
  58010. };
  58011. }
  58012. declare module BABYLON {
  58013. /**
  58014. * 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.
  58015. */
  58016. export class ExtractHighlightsPostProcess extends PostProcess {
  58017. /**
  58018. * The luminance threshold, pixels below this value will be set to black.
  58019. */
  58020. threshold: number;
  58021. /** @hidden */ private _exposure: number;
  58022. /**
  58023. * Post process which has the input texture to be used when performing highlight extraction
  58024. * @hidden
  58025. */ private _inputPostProcess: Nullable<PostProcess>;
  58026. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58027. }
  58028. }
  58029. declare module BABYLON {
  58030. /** @hidden */
  58031. export var bloomMergePixelShader: {
  58032. name: string;
  58033. shader: string;
  58034. };
  58035. }
  58036. declare module BABYLON {
  58037. /**
  58038. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58039. */
  58040. export class BloomMergePostProcess extends PostProcess {
  58041. /** Weight of the bloom to be added to the original input. */
  58042. weight: number;
  58043. /**
  58044. * Creates a new instance of @see BloomMergePostProcess
  58045. * @param name The name of the effect.
  58046. * @param originalFromInput Post process which's input will be used for the merge.
  58047. * @param blurred Blurred highlights post process which's output will be used.
  58048. * @param weight Weight of the bloom to be added to the original input.
  58049. * @param options The required width/height ratio to downsize to before computing the render pass.
  58050. * @param camera The camera to apply the render pass to.
  58051. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58052. * @param engine The engine which the post process will be applied. (default: current engine)
  58053. * @param reusable If the post process can be reused on the same frame. (default: false)
  58054. * @param textureType Type of textures used when performing the post process. (default: 0)
  58055. * @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)
  58056. */
  58057. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  58058. /** Weight of the bloom to be added to the original input. */
  58059. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58060. }
  58061. }
  58062. declare module BABYLON {
  58063. /**
  58064. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  58065. */
  58066. export class BloomEffect extends PostProcessRenderEffect {
  58067. private bloomScale;
  58068. /**
  58069. * @hidden Internal
  58070. */ private _effects: Array<PostProcess>;
  58071. /**
  58072. * @hidden Internal
  58073. */ private _downscale: ExtractHighlightsPostProcess;
  58074. private _blurX;
  58075. private _blurY;
  58076. private _merge;
  58077. /**
  58078. * The luminance threshold to find bright areas of the image to bloom.
  58079. */
  58080. threshold: number;
  58081. /**
  58082. * The strength of the bloom.
  58083. */
  58084. weight: number;
  58085. /**
  58086. * Specifies the size of the bloom blur kernel, relative to the final output size
  58087. */
  58088. kernel: number;
  58089. /**
  58090. * Creates a new instance of @see BloomEffect
  58091. * @param scene The scene the effect belongs to.
  58092. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  58093. * @param bloomKernel The size of the kernel to be used when applying the blur.
  58094. * @param bloomWeight The the strength of bloom.
  58095. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58096. * @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)
  58097. */
  58098. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  58099. /**
  58100. * Disposes each of the internal effects for a given camera.
  58101. * @param camera The camera to dispose the effect on.
  58102. */
  58103. disposeEffects(camera: Camera): void;
  58104. /**
  58105. * @hidden Internal
  58106. */ private _updateEffects(): void;
  58107. /**
  58108. * Internal
  58109. * @returns if all the contained post processes are ready.
  58110. * @hidden
  58111. */ private _isReady(): boolean;
  58112. }
  58113. }
  58114. declare module BABYLON {
  58115. /** @hidden */
  58116. export var chromaticAberrationPixelShader: {
  58117. name: string;
  58118. shader: string;
  58119. };
  58120. }
  58121. declare module BABYLON {
  58122. /**
  58123. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  58124. */
  58125. export class ChromaticAberrationPostProcess extends PostProcess {
  58126. /**
  58127. * The amount of seperation of rgb channels (default: 30)
  58128. */
  58129. aberrationAmount: number;
  58130. /**
  58131. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  58132. */
  58133. radialIntensity: number;
  58134. /**
  58135. * 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))
  58136. */
  58137. direction: Vector2;
  58138. /**
  58139. * 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))
  58140. */
  58141. centerPosition: Vector2;
  58142. /**
  58143. * Creates a new instance ChromaticAberrationPostProcess
  58144. * @param name The name of the effect.
  58145. * @param screenWidth The width of the screen to apply the effect on.
  58146. * @param screenHeight The height of the screen to apply the effect on.
  58147. * @param options The required width/height ratio to downsize to before computing the render pass.
  58148. * @param camera The camera to apply the render pass to.
  58149. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58150. * @param engine The engine which the post process will be applied. (default: current engine)
  58151. * @param reusable If the post process can be reused on the same frame. (default: false)
  58152. * @param textureType Type of textures used when performing the post process. (default: 0)
  58153. * @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)
  58154. */
  58155. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58156. }
  58157. }
  58158. declare module BABYLON {
  58159. /** @hidden */
  58160. export var circleOfConfusionPixelShader: {
  58161. name: string;
  58162. shader: string;
  58163. };
  58164. }
  58165. declare module BABYLON {
  58166. /**
  58167. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  58168. */
  58169. export class CircleOfConfusionPostProcess extends PostProcess {
  58170. /**
  58171. * 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.
  58172. */
  58173. lensSize: number;
  58174. /**
  58175. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58176. */
  58177. fStop: number;
  58178. /**
  58179. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58180. */
  58181. focusDistance: number;
  58182. /**
  58183. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  58184. */
  58185. focalLength: number;
  58186. private _depthTexture;
  58187. /**
  58188. * Creates a new instance CircleOfConfusionPostProcess
  58189. * @param name The name of the effect.
  58190. * @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.
  58191. * @param options The required width/height ratio to downsize to before computing the render pass.
  58192. * @param camera The camera to apply the render pass to.
  58193. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58194. * @param engine The engine which the post process will be applied. (default: current engine)
  58195. * @param reusable If the post process can be reused on the same frame. (default: false)
  58196. * @param textureType Type of textures used when performing the post process. (default: 0)
  58197. * @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)
  58198. */
  58199. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58200. /**
  58201. * 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.
  58202. */
  58203. depthTexture: RenderTargetTexture;
  58204. }
  58205. }
  58206. declare module BABYLON {
  58207. /** @hidden */
  58208. export var colorCorrectionPixelShader: {
  58209. name: string;
  58210. shader: string;
  58211. };
  58212. }
  58213. declare module BABYLON {
  58214. /**
  58215. *
  58216. * This post-process allows the modification of rendered colors by using
  58217. * a 'look-up table' (LUT). This effect is also called Color Grading.
  58218. *
  58219. * The object needs to be provided an url to a texture containing the color
  58220. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  58221. * Use an image editing software to tweak the LUT to match your needs.
  58222. *
  58223. * For an example of a color LUT, see here:
  58224. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  58225. * For explanations on color grading, see here:
  58226. * @see http://udn.epicgames.com/Three/ColorGrading.html
  58227. *
  58228. */
  58229. export class ColorCorrectionPostProcess extends PostProcess {
  58230. private _colorTableTexture;
  58231. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58232. }
  58233. }
  58234. declare module BABYLON {
  58235. /** @hidden */
  58236. export var convolutionPixelShader: {
  58237. name: string;
  58238. shader: string;
  58239. };
  58240. }
  58241. declare module BABYLON {
  58242. /**
  58243. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  58244. * input texture to perform effects such as edge detection or sharpening
  58245. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58246. */
  58247. export class ConvolutionPostProcess extends PostProcess {
  58248. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58249. kernel: number[];
  58250. /**
  58251. * Creates a new instance ConvolutionPostProcess
  58252. * @param name The name of the effect.
  58253. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  58254. * @param options The required width/height ratio to downsize to before computing the render pass.
  58255. * @param camera The camera to apply the render pass to.
  58256. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58257. * @param engine The engine which the post process will be applied. (default: current engine)
  58258. * @param reusable If the post process can be reused on the same frame. (default: false)
  58259. * @param textureType Type of textures used when performing the post process. (default: 0)
  58260. */
  58261. constructor(name: string,
  58262. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58263. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58264. /**
  58265. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58266. */
  58267. static EdgeDetect0Kernel: number[];
  58268. /**
  58269. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58270. */
  58271. static EdgeDetect1Kernel: number[];
  58272. /**
  58273. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58274. */
  58275. static EdgeDetect2Kernel: number[];
  58276. /**
  58277. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58278. */
  58279. static SharpenKernel: number[];
  58280. /**
  58281. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58282. */
  58283. static EmbossKernel: number[];
  58284. /**
  58285. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58286. */
  58287. static GaussianKernel: number[];
  58288. }
  58289. }
  58290. declare module BABYLON {
  58291. /**
  58292. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58293. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58294. * based on samples that have a large difference in distance than the center pixel.
  58295. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58296. */
  58297. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58298. direction: Vector2;
  58299. /**
  58300. * Creates a new instance CircleOfConfusionPostProcess
  58301. * @param name The name of the effect.
  58302. * @param scene The scene the effect belongs to.
  58303. * @param direction The direction the blur should be applied.
  58304. * @param kernel The size of the kernel used to blur.
  58305. * @param options The required width/height ratio to downsize to before computing the render pass.
  58306. * @param camera The camera to apply the render pass to.
  58307. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58308. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58309. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58310. * @param engine The engine which the post process will be applied. (default: current engine)
  58311. * @param reusable If the post process can be reused on the same frame. (default: false)
  58312. * @param textureType Type of textures used when performing the post process. (default: 0)
  58313. * @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)
  58314. */
  58315. 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);
  58316. }
  58317. }
  58318. declare module BABYLON {
  58319. /** @hidden */
  58320. export var depthOfFieldMergePixelShader: {
  58321. name: string;
  58322. shader: string;
  58323. };
  58324. }
  58325. declare module BABYLON {
  58326. /**
  58327. * Options to be set when merging outputs from the default pipeline.
  58328. */
  58329. export class DepthOfFieldMergePostProcessOptions {
  58330. /**
  58331. * The original image to merge on top of
  58332. */
  58333. originalFromInput: PostProcess;
  58334. /**
  58335. * Parameters to perform the merge of the depth of field effect
  58336. */
  58337. depthOfField?: {
  58338. circleOfConfusion: PostProcess;
  58339. blurSteps: Array<PostProcess>;
  58340. };
  58341. /**
  58342. * Parameters to perform the merge of bloom effect
  58343. */
  58344. bloom?: {
  58345. blurred: PostProcess;
  58346. weight: number;
  58347. };
  58348. }
  58349. /**
  58350. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58351. */
  58352. export class DepthOfFieldMergePostProcess extends PostProcess {
  58353. private blurSteps;
  58354. /**
  58355. * Creates a new instance of DepthOfFieldMergePostProcess
  58356. * @param name The name of the effect.
  58357. * @param originalFromInput Post process which's input will be used for the merge.
  58358. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58359. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58360. * @param options The required width/height ratio to downsize to before computing the render pass.
  58361. * @param camera The camera to apply the render pass to.
  58362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58363. * @param engine The engine which the post process will be applied. (default: current engine)
  58364. * @param reusable If the post process can be reused on the same frame. (default: false)
  58365. * @param textureType Type of textures used when performing the post process. (default: 0)
  58366. * @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)
  58367. */
  58368. 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);
  58369. /**
  58370. * Updates the effect with the current post process compile time values and recompiles the shader.
  58371. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58372. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58373. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58374. * @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
  58375. * @param onCompiled Called when the shader has been compiled.
  58376. * @param onError Called if there is an error when compiling a shader.
  58377. */
  58378. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58379. }
  58380. }
  58381. declare module BABYLON {
  58382. /**
  58383. * Specifies the level of max blur that should be applied when using the depth of field effect
  58384. */
  58385. export enum DepthOfFieldEffectBlurLevel {
  58386. /**
  58387. * Subtle blur
  58388. */
  58389. Low = 0,
  58390. /**
  58391. * Medium blur
  58392. */
  58393. Medium = 1,
  58394. /**
  58395. * Large blur
  58396. */
  58397. High = 2
  58398. }
  58399. /**
  58400. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58401. */
  58402. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58403. private _circleOfConfusion;
  58404. /**
  58405. * @hidden Internal, blurs from high to low
  58406. */ private _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58407. private _depthOfFieldBlurY;
  58408. private _dofMerge;
  58409. /**
  58410. * @hidden Internal post processes in depth of field effect
  58411. */ private _effects: Array<PostProcess>;
  58412. /**
  58413. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58414. */
  58415. focalLength: number;
  58416. /**
  58417. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58418. */
  58419. fStop: number;
  58420. /**
  58421. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58422. */
  58423. focusDistance: number;
  58424. /**
  58425. * 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.
  58426. */
  58427. lensSize: number;
  58428. /**
  58429. * Creates a new instance DepthOfFieldEffect
  58430. * @param scene The scene the effect belongs to.
  58431. * @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.
  58432. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58433. * @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)
  58434. */
  58435. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58436. /**
  58437. * Get the current class name of the current effet
  58438. * @returns "DepthOfFieldEffect"
  58439. */
  58440. getClassName(): string;
  58441. /**
  58442. * 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.
  58443. */
  58444. depthTexture: RenderTargetTexture;
  58445. /**
  58446. * Disposes each of the internal effects for a given camera.
  58447. * @param camera The camera to dispose the effect on.
  58448. */
  58449. disposeEffects(camera: Camera): void;
  58450. /**
  58451. * @hidden Internal
  58452. */ private _updateEffects(): void;
  58453. /**
  58454. * Internal
  58455. * @returns if all the contained post processes are ready.
  58456. * @hidden
  58457. */ private _isReady(): boolean;
  58458. }
  58459. }
  58460. declare module BABYLON {
  58461. /** @hidden */
  58462. export var displayPassPixelShader: {
  58463. name: string;
  58464. shader: string;
  58465. };
  58466. }
  58467. declare module BABYLON {
  58468. /**
  58469. * DisplayPassPostProcess which produces an output the same as it's input
  58470. */
  58471. export class DisplayPassPostProcess extends PostProcess {
  58472. /**
  58473. * Creates the DisplayPassPostProcess
  58474. * @param name The name of the effect.
  58475. * @param options The required width/height ratio to downsize to before computing the render pass.
  58476. * @param camera The camera to apply the render pass to.
  58477. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58478. * @param engine The engine which the post process will be applied. (default: current engine)
  58479. * @param reusable If the post process can be reused on the same frame. (default: false)
  58480. */
  58481. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58482. }
  58483. }
  58484. declare module BABYLON {
  58485. /** @hidden */
  58486. export var filterPixelShader: {
  58487. name: string;
  58488. shader: string;
  58489. };
  58490. }
  58491. declare module BABYLON {
  58492. /**
  58493. * Applies a kernel filter to the image
  58494. */
  58495. export class FilterPostProcess extends PostProcess {
  58496. /** The matrix to be applied to the image */
  58497. kernelMatrix: Matrix;
  58498. /**
  58499. *
  58500. * @param name The name of the effect.
  58501. * @param kernelMatrix The matrix to be applied to the image
  58502. * @param options The required width/height ratio to downsize to before computing the render pass.
  58503. * @param camera The camera to apply the render pass to.
  58504. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58505. * @param engine The engine which the post process will be applied. (default: current engine)
  58506. * @param reusable If the post process can be reused on the same frame. (default: false)
  58507. */
  58508. constructor(name: string,
  58509. /** The matrix to be applied to the image */
  58510. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58511. }
  58512. }
  58513. declare module BABYLON {
  58514. /** @hidden */
  58515. export var fxaaPixelShader: {
  58516. name: string;
  58517. shader: string;
  58518. };
  58519. }
  58520. declare module BABYLON {
  58521. /** @hidden */
  58522. export var fxaaVertexShader: {
  58523. name: string;
  58524. shader: string;
  58525. };
  58526. }
  58527. declare module BABYLON {
  58528. /**
  58529. * Fxaa post process
  58530. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58531. */
  58532. export class FxaaPostProcess extends PostProcess {
  58533. /** @hidden */
  58534. texelWidth: number;
  58535. /** @hidden */
  58536. texelHeight: number;
  58537. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58538. private _getDefines;
  58539. }
  58540. }
  58541. declare module BABYLON {
  58542. /** @hidden */
  58543. export var grainPixelShader: {
  58544. name: string;
  58545. shader: string;
  58546. };
  58547. }
  58548. declare module BABYLON {
  58549. /**
  58550. * The GrainPostProcess adds noise to the image at mid luminance levels
  58551. */
  58552. export class GrainPostProcess extends PostProcess {
  58553. /**
  58554. * The intensity of the grain added (default: 30)
  58555. */
  58556. intensity: number;
  58557. /**
  58558. * If the grain should be randomized on every frame
  58559. */
  58560. animated: boolean;
  58561. /**
  58562. * Creates a new instance of @see GrainPostProcess
  58563. * @param name The name of the effect.
  58564. * @param options The required width/height ratio to downsize to before computing the render pass.
  58565. * @param camera The camera to apply the render pass to.
  58566. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58567. * @param engine The engine which the post process will be applied. (default: current engine)
  58568. * @param reusable If the post process can be reused on the same frame. (default: false)
  58569. * @param textureType Type of textures used when performing the post process. (default: 0)
  58570. * @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)
  58571. */
  58572. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58573. }
  58574. }
  58575. declare module BABYLON {
  58576. /** @hidden */
  58577. export var highlightsPixelShader: {
  58578. name: string;
  58579. shader: string;
  58580. };
  58581. }
  58582. declare module BABYLON {
  58583. /**
  58584. * Extracts highlights from the image
  58585. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58586. */
  58587. export class HighlightsPostProcess extends PostProcess {
  58588. /**
  58589. * Extracts highlights from the image
  58590. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58591. * @param name The name of the effect.
  58592. * @param options The required width/height ratio to downsize to before computing the render pass.
  58593. * @param camera The camera to apply the render pass to.
  58594. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58595. * @param engine The engine which the post process will be applied. (default: current engine)
  58596. * @param reusable If the post process can be reused on the same frame. (default: false)
  58597. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58598. */
  58599. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58600. }
  58601. }
  58602. declare module BABYLON {
  58603. /** @hidden */
  58604. export var mrtFragmentDeclaration: {
  58605. name: string;
  58606. shader: string;
  58607. };
  58608. }
  58609. declare module BABYLON {
  58610. /** @hidden */
  58611. export var geometryPixelShader: {
  58612. name: string;
  58613. shader: string;
  58614. };
  58615. }
  58616. declare module BABYLON {
  58617. /** @hidden */
  58618. export var geometryVertexShader: {
  58619. name: string;
  58620. shader: string;
  58621. };
  58622. }
  58623. declare module BABYLON {
  58624. /** @hidden */
  58625. interface ISavedTransformationMatrix {
  58626. world: Matrix;
  58627. viewProjection: Matrix;
  58628. }
  58629. /**
  58630. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58631. */
  58632. export class GeometryBufferRenderer {
  58633. /**
  58634. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58635. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58636. */
  58637. static readonly POSITION_TEXTURE_TYPE: number;
  58638. /**
  58639. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58640. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58641. */
  58642. static readonly VELOCITY_TEXTURE_TYPE: number;
  58643. /**
  58644. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58645. * in order to compute objects velocities when enableVelocity is set to "true"
  58646. * @hidden
  58647. */ private _previousTransformationMatrices: {
  58648. [index: number]: ISavedTransformationMatrix;
  58649. };
  58650. /**
  58651. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58652. * in order to compute objects velocities when enableVelocity is set to "true"
  58653. * @hidden
  58654. */ private _previousBonesTransformationMatrices: {
  58655. [index: number]: Float32Array;
  58656. };
  58657. /**
  58658. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58659. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58660. */
  58661. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58662. private _scene;
  58663. private _multiRenderTarget;
  58664. private _ratio;
  58665. private _enablePosition;
  58666. private _enableVelocity;
  58667. private _positionIndex;
  58668. private _velocityIndex;
  58669. protected _effect: Effect;
  58670. protected _cachedDefines: string;
  58671. /**
  58672. * Set the render list (meshes to be rendered) used in the G buffer.
  58673. */
  58674. renderList: Mesh[];
  58675. /**
  58676. * Gets wether or not G buffer are supported by the running hardware.
  58677. * This requires draw buffer supports
  58678. */
  58679. readonly isSupported: boolean;
  58680. /**
  58681. * Returns the index of the given texture type in the G-Buffer textures array
  58682. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58683. * @returns the index of the given texture type in the G-Buffer textures array
  58684. */
  58685. getTextureIndex(textureType: number): number;
  58686. /**
  58687. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58688. */
  58689. /**
  58690. * Sets whether or not objects positions are enabled for the G buffer.
  58691. */
  58692. enablePosition: boolean;
  58693. /**
  58694. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58695. */
  58696. /**
  58697. * Sets wether or not objects velocities are enabled for the G buffer.
  58698. */
  58699. enableVelocity: boolean;
  58700. /**
  58701. * Gets the scene associated with the buffer.
  58702. */
  58703. readonly scene: Scene;
  58704. /**
  58705. * Gets the ratio used by the buffer during its creation.
  58706. * How big is the buffer related to the main canvas.
  58707. */
  58708. readonly ratio: number;
  58709. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  58710. /**
  58711. * Creates a new G Buffer for the scene
  58712. * @param scene The scene the buffer belongs to
  58713. * @param ratio How big is the buffer related to the main canvas.
  58714. */
  58715. constructor(scene: Scene, ratio?: number);
  58716. /**
  58717. * Checks wether everything is ready to render a submesh to the G buffer.
  58718. * @param subMesh the submesh to check readiness for
  58719. * @param useInstances is the mesh drawn using instance or not
  58720. * @returns true if ready otherwise false
  58721. */
  58722. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58723. /**
  58724. * Gets the current underlying G Buffer.
  58725. * @returns the buffer
  58726. */
  58727. getGBuffer(): MultiRenderTarget;
  58728. /**
  58729. * Gets the number of samples used to render the buffer (anti aliasing).
  58730. */
  58731. /**
  58732. * Sets the number of samples used to render the buffer (anti aliasing).
  58733. */
  58734. samples: number;
  58735. /**
  58736. * Disposes the renderer and frees up associated resources.
  58737. */
  58738. dispose(): void;
  58739. protected _createRenderTargets(): void;
  58740. private _copyBonesTransformationMatrices;
  58741. }
  58742. }
  58743. declare module BABYLON {
  58744. interface Scene {
  58745. /** @hidden (Backing field) */ private _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58746. /**
  58747. * Gets or Sets the current geometry buffer associated to the scene.
  58748. */
  58749. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58750. /**
  58751. * Enables a GeometryBufferRender and associates it with the scene
  58752. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58753. * @returns the GeometryBufferRenderer
  58754. */
  58755. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58756. /**
  58757. * Disables the GeometryBufferRender associated with the scene
  58758. */
  58759. disableGeometryBufferRenderer(): void;
  58760. }
  58761. /**
  58762. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58763. * in several rendering techniques.
  58764. */
  58765. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58766. /**
  58767. * The component name helpful to identify the component in the list of scene components.
  58768. */
  58769. readonly name: string;
  58770. /**
  58771. * The scene the component belongs to.
  58772. */
  58773. scene: Scene;
  58774. /**
  58775. * Creates a new instance of the component for the given scene
  58776. * @param scene Defines the scene to register the component in
  58777. */
  58778. constructor(scene: Scene);
  58779. /**
  58780. * Registers the component in a given scene
  58781. */
  58782. register(): void;
  58783. /**
  58784. * Rebuilds the elements related to this component in case of
  58785. * context lost for instance.
  58786. */
  58787. rebuild(): void;
  58788. /**
  58789. * Disposes the component and the associated ressources
  58790. */
  58791. dispose(): void;
  58792. private _gatherRenderTargets;
  58793. }
  58794. }
  58795. declare module BABYLON {
  58796. /** @hidden */
  58797. export var motionBlurPixelShader: {
  58798. name: string;
  58799. shader: string;
  58800. };
  58801. }
  58802. declare module BABYLON {
  58803. /**
  58804. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58805. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58806. * As an example, all you have to do is to create the post-process:
  58807. * var mb = new BABYLON.MotionBlurPostProcess(
  58808. * 'mb', // The name of the effect.
  58809. * scene, // The scene containing the objects to blur according to their velocity.
  58810. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58811. * camera // The camera to apply the render pass to.
  58812. * );
  58813. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58814. */
  58815. export class MotionBlurPostProcess extends PostProcess {
  58816. /**
  58817. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58818. */
  58819. motionStrength: number;
  58820. /**
  58821. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58822. */
  58823. /**
  58824. * Sets the number of iterations to be used for motion blur quality
  58825. */
  58826. motionBlurSamples: number;
  58827. private _motionBlurSamples;
  58828. private _geometryBufferRenderer;
  58829. /**
  58830. * Creates a new instance MotionBlurPostProcess
  58831. * @param name The name of the effect.
  58832. * @param scene The scene containing the objects to blur according to their velocity.
  58833. * @param options The required width/height ratio to downsize to before computing the render pass.
  58834. * @param camera The camera to apply the render pass to.
  58835. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58836. * @param engine The engine which the post process will be applied. (default: current engine)
  58837. * @param reusable If the post process can be reused on the same frame. (default: false)
  58838. * @param textureType Type of textures used when performing the post process. (default: 0)
  58839. * @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)
  58840. */
  58841. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58842. /**
  58843. * Excludes the given skinned mesh from computing bones velocities.
  58844. * 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.
  58845. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58846. */
  58847. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58848. /**
  58849. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58850. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58851. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58852. */
  58853. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58854. /**
  58855. * Disposes the post process.
  58856. * @param camera The camera to dispose the post process on.
  58857. */
  58858. dispose(camera?: Camera): void;
  58859. }
  58860. }
  58861. declare module BABYLON {
  58862. /** @hidden */
  58863. export var refractionPixelShader: {
  58864. name: string;
  58865. shader: string;
  58866. };
  58867. }
  58868. declare module BABYLON {
  58869. /**
  58870. * Post process which applies a refractin texture
  58871. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58872. */
  58873. export class RefractionPostProcess extends PostProcess {
  58874. /** the base color of the refraction (used to taint the rendering) */
  58875. color: Color3;
  58876. /** simulated refraction depth */
  58877. depth: number;
  58878. /** the coefficient of the base color (0 to remove base color tainting) */
  58879. colorLevel: number;
  58880. private _refTexture;
  58881. private _ownRefractionTexture;
  58882. /**
  58883. * Gets or sets the refraction texture
  58884. * Please note that you are responsible for disposing the texture if you set it manually
  58885. */
  58886. refractionTexture: Texture;
  58887. /**
  58888. * Initializes the RefractionPostProcess
  58889. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58890. * @param name The name of the effect.
  58891. * @param refractionTextureUrl Url of the refraction texture to use
  58892. * @param color the base color of the refraction (used to taint the rendering)
  58893. * @param depth simulated refraction depth
  58894. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58895. * @param camera The camera to apply the render pass to.
  58896. * @param options The required width/height ratio to downsize to before computing the render pass.
  58897. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58898. * @param engine The engine which the post process will be applied. (default: current engine)
  58899. * @param reusable If the post process can be reused on the same frame. (default: false)
  58900. */
  58901. constructor(name: string, refractionTextureUrl: string,
  58902. /** the base color of the refraction (used to taint the rendering) */
  58903. color: Color3,
  58904. /** simulated refraction depth */
  58905. depth: number,
  58906. /** the coefficient of the base color (0 to remove base color tainting) */
  58907. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58908. /**
  58909. * Disposes of the post process
  58910. * @param camera Camera to dispose post process on
  58911. */
  58912. dispose(camera: Camera): void;
  58913. }
  58914. }
  58915. declare module BABYLON {
  58916. /** @hidden */
  58917. export var sharpenPixelShader: {
  58918. name: string;
  58919. shader: string;
  58920. };
  58921. }
  58922. declare module BABYLON {
  58923. /**
  58924. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58925. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58926. */
  58927. export class SharpenPostProcess extends PostProcess {
  58928. /**
  58929. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58930. */
  58931. colorAmount: number;
  58932. /**
  58933. * How much sharpness should be applied (default: 0.3)
  58934. */
  58935. edgeAmount: number;
  58936. /**
  58937. * Creates a new instance ConvolutionPostProcess
  58938. * @param name The name of the effect.
  58939. * @param options The required width/height ratio to downsize to before computing the render pass.
  58940. * @param camera The camera to apply the render pass to.
  58941. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58942. * @param engine The engine which the post process will be applied. (default: current engine)
  58943. * @param reusable If the post process can be reused on the same frame. (default: false)
  58944. * @param textureType Type of textures used when performing the post process. (default: 0)
  58945. * @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)
  58946. */
  58947. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58948. }
  58949. }
  58950. declare module BABYLON {
  58951. /**
  58952. * PostProcessRenderPipeline
  58953. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58954. */
  58955. export class PostProcessRenderPipeline {
  58956. private engine;
  58957. private _renderEffects;
  58958. private _renderEffectsForIsolatedPass;
  58959. /**
  58960. * List of inspectable custom properties (used by the Inspector)
  58961. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58962. */
  58963. inspectableCustomProperties: IInspectable[];
  58964. /**
  58965. * @hidden
  58966. */
  58967. protected _cameras: Camera[];
  58968. /** @hidden */ private _name: string;
  58969. /**
  58970. * Gets pipeline name
  58971. */
  58972. readonly name: string;
  58973. /**
  58974. * Initializes a PostProcessRenderPipeline
  58975. * @param engine engine to add the pipeline to
  58976. * @param name name of the pipeline
  58977. */
  58978. constructor(engine: Engine, name: string);
  58979. /**
  58980. * Gets the class name
  58981. * @returns "PostProcessRenderPipeline"
  58982. */
  58983. getClassName(): string;
  58984. /**
  58985. * If all the render effects in the pipeline are supported
  58986. */
  58987. readonly isSupported: boolean;
  58988. /**
  58989. * Adds an effect to the pipeline
  58990. * @param renderEffect the effect to add
  58991. */
  58992. addEffect(renderEffect: PostProcessRenderEffect): void;
  58993. /** @hidden */ private _rebuild(): void;
  58994. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera): void;
  58995. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58996. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58997. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58998. /** @hidden */ private _attachCameras(cameras: Camera, unique: boolean): void;
  58999. /** @hidden */ private _attachCameras(cameras: Camera[], unique: boolean): void;
  59000. /** @hidden */ private _detachCameras(cameras: Camera): void;
  59001. /** @hidden */ private _detachCameras(cameras: Nullable<Camera[]>): void;
  59002. /** @hidden */ private _update(): void;
  59003. /** @hidden */ private _reset(): void;
  59004. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  59005. /**
  59006. * Disposes of the pipeline
  59007. */
  59008. dispose(): void;
  59009. }
  59010. }
  59011. declare module BABYLON {
  59012. /**
  59013. * PostProcessRenderPipelineManager class
  59014. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59015. */
  59016. export class PostProcessRenderPipelineManager {
  59017. private _renderPipelines;
  59018. /**
  59019. * Initializes a PostProcessRenderPipelineManager
  59020. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59021. */
  59022. constructor();
  59023. /**
  59024. * Gets the list of supported render pipelines
  59025. */
  59026. readonly supportedPipelines: PostProcessRenderPipeline[];
  59027. /**
  59028. * Adds a pipeline to the manager
  59029. * @param renderPipeline The pipeline to add
  59030. */
  59031. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  59032. /**
  59033. * Attaches a camera to the pipeline
  59034. * @param renderPipelineName The name of the pipeline to attach to
  59035. * @param cameras the camera to attach
  59036. * @param unique if the camera can be attached multiple times to the pipeline
  59037. */
  59038. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  59039. /**
  59040. * Detaches a camera from the pipeline
  59041. * @param renderPipelineName The name of the pipeline to detach from
  59042. * @param cameras the camera to detach
  59043. */
  59044. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  59045. /**
  59046. * Enables an effect by name on a pipeline
  59047. * @param renderPipelineName the name of the pipeline to enable the effect in
  59048. * @param renderEffectName the name of the effect to enable
  59049. * @param cameras the cameras that the effect should be enabled on
  59050. */
  59051. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59052. /**
  59053. * Disables an effect by name on a pipeline
  59054. * @param renderPipelineName the name of the pipeline to disable the effect in
  59055. * @param renderEffectName the name of the effect to disable
  59056. * @param cameras the cameras that the effect should be disabled on
  59057. */
  59058. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59059. /**
  59060. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  59061. */
  59062. update(): void;
  59063. /** @hidden */ private _rebuild(): void;
  59064. /**
  59065. * Disposes of the manager and pipelines
  59066. */
  59067. dispose(): void;
  59068. }
  59069. }
  59070. declare module BABYLON {
  59071. interface Scene {
  59072. /** @hidden (Backing field) */ private _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59073. /**
  59074. * Gets the postprocess render pipeline manager
  59075. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59076. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59077. */
  59078. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59079. }
  59080. /**
  59081. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59082. */
  59083. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59084. /**
  59085. * The component name helpfull to identify the component in the list of scene components.
  59086. */
  59087. readonly name: string;
  59088. /**
  59089. * The scene the component belongs to.
  59090. */
  59091. scene: Scene;
  59092. /**
  59093. * Creates a new instance of the component for the given scene
  59094. * @param scene Defines the scene to register the component in
  59095. */
  59096. constructor(scene: Scene);
  59097. /**
  59098. * Registers the component in a given scene
  59099. */
  59100. register(): void;
  59101. /**
  59102. * Rebuilds the elements related to this component in case of
  59103. * context lost for instance.
  59104. */
  59105. rebuild(): void;
  59106. /**
  59107. * Disposes the component and the associated ressources
  59108. */
  59109. dispose(): void;
  59110. private _gatherRenderTargets;
  59111. }
  59112. }
  59113. declare module BABYLON {
  59114. /**
  59115. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59116. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59117. */
  59118. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59119. private _scene;
  59120. private _camerasToBeAttached;
  59121. /**
  59122. * ID of the sharpen post process,
  59123. */
  59124. private readonly SharpenPostProcessId;
  59125. /**
  59126. * @ignore
  59127. * ID of the image processing post process;
  59128. */
  59129. readonly ImageProcessingPostProcessId: string;
  59130. /**
  59131. * @ignore
  59132. * ID of the Fast Approximate Anti-Aliasing post process;
  59133. */
  59134. readonly FxaaPostProcessId: string;
  59135. /**
  59136. * ID of the chromatic aberration post process,
  59137. */
  59138. private readonly ChromaticAberrationPostProcessId;
  59139. /**
  59140. * ID of the grain post process
  59141. */
  59142. private readonly GrainPostProcessId;
  59143. /**
  59144. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59145. */
  59146. sharpen: SharpenPostProcess;
  59147. private _sharpenEffect;
  59148. private bloom;
  59149. /**
  59150. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59151. */
  59152. depthOfField: DepthOfFieldEffect;
  59153. /**
  59154. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59155. */
  59156. fxaa: FxaaPostProcess;
  59157. /**
  59158. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59159. */
  59160. imageProcessing: ImageProcessingPostProcess;
  59161. /**
  59162. * Chromatic aberration post process which will shift rgb colors in the image
  59163. */
  59164. chromaticAberration: ChromaticAberrationPostProcess;
  59165. private _chromaticAberrationEffect;
  59166. /**
  59167. * Grain post process which add noise to the image
  59168. */
  59169. grain: GrainPostProcess;
  59170. private _grainEffect;
  59171. /**
  59172. * Glow post process which adds a glow to emissive areas of the image
  59173. */
  59174. private _glowLayer;
  59175. /**
  59176. * Animations which can be used to tweak settings over a period of time
  59177. */
  59178. animations: Animation[];
  59179. private _imageProcessingConfigurationObserver;
  59180. private _sharpenEnabled;
  59181. private _bloomEnabled;
  59182. private _depthOfFieldEnabled;
  59183. private _depthOfFieldBlurLevel;
  59184. private _fxaaEnabled;
  59185. private _imageProcessingEnabled;
  59186. private _defaultPipelineTextureType;
  59187. private _bloomScale;
  59188. private _chromaticAberrationEnabled;
  59189. private _grainEnabled;
  59190. private _buildAllowed;
  59191. /**
  59192. * Gets active scene
  59193. */
  59194. readonly scene: Scene;
  59195. /**
  59196. * Enable or disable the sharpen process from the pipeline
  59197. */
  59198. sharpenEnabled: boolean;
  59199. private _resizeObserver;
  59200. private _hardwareScaleLevel;
  59201. private _bloomKernel;
  59202. /**
  59203. * Specifies the size of the bloom blur kernel, relative to the final output size
  59204. */
  59205. bloomKernel: number;
  59206. /**
  59207. * Specifies the weight of the bloom in the final rendering
  59208. */
  59209. private _bloomWeight;
  59210. /**
  59211. * Specifies the luma threshold for the area that will be blurred by the bloom
  59212. */
  59213. private _bloomThreshold;
  59214. private _hdr;
  59215. /**
  59216. * The strength of the bloom.
  59217. */
  59218. bloomWeight: number;
  59219. /**
  59220. * The strength of the bloom.
  59221. */
  59222. bloomThreshold: number;
  59223. /**
  59224. * The scale of the bloom, lower value will provide better performance.
  59225. */
  59226. bloomScale: number;
  59227. /**
  59228. * Enable or disable the bloom from the pipeline
  59229. */
  59230. bloomEnabled: boolean;
  59231. private _rebuildBloom;
  59232. /**
  59233. * If the depth of field is enabled.
  59234. */
  59235. depthOfFieldEnabled: boolean;
  59236. /**
  59237. * Blur level of the depth of field effect. (Higher blur will effect performance)
  59238. */
  59239. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  59240. /**
  59241. * If the anti aliasing is enabled.
  59242. */
  59243. fxaaEnabled: boolean;
  59244. private _samples;
  59245. /**
  59246. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59247. */
  59248. samples: number;
  59249. /**
  59250. * If image processing is enabled.
  59251. */
  59252. imageProcessingEnabled: boolean;
  59253. /**
  59254. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59255. */
  59256. glowLayerEnabled: boolean;
  59257. /**
  59258. * Gets the glow layer (or null if not defined)
  59259. */
  59260. readonly glowLayer: Nullable<GlowLayer>;
  59261. /**
  59262. * Enable or disable the chromaticAberration process from the pipeline
  59263. */
  59264. chromaticAberrationEnabled: boolean;
  59265. /**
  59266. * Enable or disable the grain process from the pipeline
  59267. */
  59268. grainEnabled: boolean;
  59269. /**
  59270. * @constructor
  59271. * @param name - The rendering pipeline name (default: "")
  59272. * @param hdr - If high dynamic range textures should be used (default: true)
  59273. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59274. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59275. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59276. */
  59277. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59278. /**
  59279. * Get the class name
  59280. * @returns "DefaultRenderingPipeline"
  59281. */
  59282. getClassName(): string;
  59283. /**
  59284. * Force the compilation of the entire pipeline.
  59285. */
  59286. prepare(): void;
  59287. private _hasCleared;
  59288. private _prevPostProcess;
  59289. private _prevPrevPostProcess;
  59290. private _setAutoClearAndTextureSharing;
  59291. private _depthOfFieldSceneObserver;
  59292. private _buildPipeline;
  59293. private _disposePostProcesses;
  59294. /**
  59295. * Adds a camera to the pipeline
  59296. * @param camera the camera to be added
  59297. */
  59298. addCamera(camera: Camera): void;
  59299. /**
  59300. * Removes a camera from the pipeline
  59301. * @param camera the camera to remove
  59302. */
  59303. removeCamera(camera: Camera): void;
  59304. /**
  59305. * Dispose of the pipeline and stop all post processes
  59306. */
  59307. dispose(): void;
  59308. /**
  59309. * Serialize the rendering pipeline (Used when exporting)
  59310. * @returns the serialized object
  59311. */
  59312. serialize(): any;
  59313. /**
  59314. * Parse the serialized pipeline
  59315. * @param source Source pipeline.
  59316. * @param scene The scene to load the pipeline to.
  59317. * @param rootUrl The URL of the serialized pipeline.
  59318. * @returns An instantiated pipeline from the serialized object.
  59319. */
  59320. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59321. }
  59322. }
  59323. declare module BABYLON {
  59324. /** @hidden */
  59325. export var lensHighlightsPixelShader: {
  59326. name: string;
  59327. shader: string;
  59328. };
  59329. }
  59330. declare module BABYLON {
  59331. /** @hidden */
  59332. export var depthOfFieldPixelShader: {
  59333. name: string;
  59334. shader: string;
  59335. };
  59336. }
  59337. declare module BABYLON {
  59338. /**
  59339. * BABYLON.JS Chromatic Aberration GLSL Shader
  59340. * Author: Olivier Guyot
  59341. * Separates very slightly R, G and B colors on the edges of the screen
  59342. * Inspired by Francois Tarlier & Martins Upitis
  59343. */
  59344. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59345. /**
  59346. * @ignore
  59347. * The chromatic aberration PostProcess id in the pipeline
  59348. */
  59349. LensChromaticAberrationEffect: string;
  59350. /**
  59351. * @ignore
  59352. * The highlights enhancing PostProcess id in the pipeline
  59353. */
  59354. HighlightsEnhancingEffect: string;
  59355. /**
  59356. * @ignore
  59357. * The depth-of-field PostProcess id in the pipeline
  59358. */
  59359. LensDepthOfFieldEffect: string;
  59360. private _scene;
  59361. private _depthTexture;
  59362. private _grainTexture;
  59363. private _chromaticAberrationPostProcess;
  59364. private _highlightsPostProcess;
  59365. private _depthOfFieldPostProcess;
  59366. private _edgeBlur;
  59367. private _grainAmount;
  59368. private _chromaticAberration;
  59369. private _distortion;
  59370. private _highlightsGain;
  59371. private _highlightsThreshold;
  59372. private _dofDistance;
  59373. private _dofAperture;
  59374. private _dofDarken;
  59375. private _dofPentagon;
  59376. private _blurNoise;
  59377. /**
  59378. * @constructor
  59379. *
  59380. * Effect parameters are as follow:
  59381. * {
  59382. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59383. * edge_blur: number; // from 0 to x (1 for realism)
  59384. * distortion: number; // from 0 to x (1 for realism)
  59385. * grain_amount: number; // from 0 to 1
  59386. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59387. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59388. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59389. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59390. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59391. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59392. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59393. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59394. * }
  59395. * Note: if an effect parameter is unset, effect is disabled
  59396. *
  59397. * @param name The rendering pipeline name
  59398. * @param parameters - An object containing all parameters (see above)
  59399. * @param scene The scene linked to this pipeline
  59400. * @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)
  59401. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59402. */
  59403. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59404. /**
  59405. * Get the class name
  59406. * @returns "LensRenderingPipeline"
  59407. */
  59408. getClassName(): string;
  59409. /**
  59410. * Gets associated scene
  59411. */
  59412. readonly scene: Scene;
  59413. /**
  59414. * Gets or sets the edge blur
  59415. */
  59416. edgeBlur: number;
  59417. /**
  59418. * Gets or sets the grain amount
  59419. */
  59420. grainAmount: number;
  59421. /**
  59422. * Gets or sets the chromatic aberration amount
  59423. */
  59424. chromaticAberration: number;
  59425. /**
  59426. * Gets or sets the depth of field aperture
  59427. */
  59428. dofAperture: number;
  59429. /**
  59430. * Gets or sets the edge distortion
  59431. */
  59432. edgeDistortion: number;
  59433. /**
  59434. * Gets or sets the depth of field distortion
  59435. */
  59436. dofDistortion: number;
  59437. /**
  59438. * Gets or sets the darken out of focus amount
  59439. */
  59440. darkenOutOfFocus: number;
  59441. /**
  59442. * Gets or sets a boolean indicating if blur noise is enabled
  59443. */
  59444. blurNoise: boolean;
  59445. /**
  59446. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59447. */
  59448. pentagonBokeh: boolean;
  59449. /**
  59450. * Gets or sets the highlight grain amount
  59451. */
  59452. highlightsGain: number;
  59453. /**
  59454. * Gets or sets the highlight threshold
  59455. */
  59456. highlightsThreshold: number;
  59457. /**
  59458. * Sets the amount of blur at the edges
  59459. * @param amount blur amount
  59460. */
  59461. setEdgeBlur(amount: number): void;
  59462. /**
  59463. * Sets edge blur to 0
  59464. */
  59465. disableEdgeBlur(): void;
  59466. /**
  59467. * Sets the amout of grain
  59468. * @param amount Amount of grain
  59469. */
  59470. setGrainAmount(amount: number): void;
  59471. /**
  59472. * Set grain amount to 0
  59473. */
  59474. disableGrain(): void;
  59475. /**
  59476. * Sets the chromatic aberration amount
  59477. * @param amount amount of chromatic aberration
  59478. */
  59479. setChromaticAberration(amount: number): void;
  59480. /**
  59481. * Sets chromatic aberration amount to 0
  59482. */
  59483. disableChromaticAberration(): void;
  59484. /**
  59485. * Sets the EdgeDistortion amount
  59486. * @param amount amount of EdgeDistortion
  59487. */
  59488. setEdgeDistortion(amount: number): void;
  59489. /**
  59490. * Sets edge distortion to 0
  59491. */
  59492. disableEdgeDistortion(): void;
  59493. /**
  59494. * Sets the FocusDistance amount
  59495. * @param amount amount of FocusDistance
  59496. */
  59497. setFocusDistance(amount: number): void;
  59498. /**
  59499. * Disables depth of field
  59500. */
  59501. disableDepthOfField(): void;
  59502. /**
  59503. * Sets the Aperture amount
  59504. * @param amount amount of Aperture
  59505. */
  59506. setAperture(amount: number): void;
  59507. /**
  59508. * Sets the DarkenOutOfFocus amount
  59509. * @param amount amount of DarkenOutOfFocus
  59510. */
  59511. setDarkenOutOfFocus(amount: number): void;
  59512. private _pentagonBokehIsEnabled;
  59513. /**
  59514. * Creates a pentagon bokeh effect
  59515. */
  59516. enablePentagonBokeh(): void;
  59517. /**
  59518. * Disables the pentagon bokeh effect
  59519. */
  59520. disablePentagonBokeh(): void;
  59521. /**
  59522. * Enables noise blur
  59523. */
  59524. enableNoiseBlur(): void;
  59525. /**
  59526. * Disables noise blur
  59527. */
  59528. disableNoiseBlur(): void;
  59529. /**
  59530. * Sets the HighlightsGain amount
  59531. * @param amount amount of HighlightsGain
  59532. */
  59533. setHighlightsGain(amount: number): void;
  59534. /**
  59535. * Sets the HighlightsThreshold amount
  59536. * @param amount amount of HighlightsThreshold
  59537. */
  59538. setHighlightsThreshold(amount: number): void;
  59539. /**
  59540. * Disables highlights
  59541. */
  59542. disableHighlights(): void;
  59543. /**
  59544. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59545. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59546. */
  59547. dispose(disableDepthRender?: boolean): void;
  59548. private _createChromaticAberrationPostProcess;
  59549. private _createHighlightsPostProcess;
  59550. private _createDepthOfFieldPostProcess;
  59551. private _createGrainTexture;
  59552. }
  59553. }
  59554. declare module BABYLON {
  59555. /** @hidden */
  59556. export var ssao2PixelShader: {
  59557. name: string;
  59558. shader: string;
  59559. };
  59560. }
  59561. declare module BABYLON {
  59562. /** @hidden */
  59563. export var ssaoCombinePixelShader: {
  59564. name: string;
  59565. shader: string;
  59566. };
  59567. }
  59568. declare module BABYLON {
  59569. /**
  59570. * Render pipeline to produce ssao effect
  59571. */
  59572. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59573. /**
  59574. * @ignore
  59575. * The PassPostProcess id in the pipeline that contains the original scene color
  59576. */
  59577. SSAOOriginalSceneColorEffect: string;
  59578. /**
  59579. * @ignore
  59580. * The SSAO PostProcess id in the pipeline
  59581. */
  59582. SSAORenderEffect: string;
  59583. /**
  59584. * @ignore
  59585. * The horizontal blur PostProcess id in the pipeline
  59586. */
  59587. SSAOBlurHRenderEffect: string;
  59588. /**
  59589. * @ignore
  59590. * The vertical blur PostProcess id in the pipeline
  59591. */
  59592. SSAOBlurVRenderEffect: string;
  59593. /**
  59594. * @ignore
  59595. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59596. */
  59597. SSAOCombineRenderEffect: string;
  59598. /**
  59599. * The output strength of the SSAO post-process. Default value is 1.0.
  59600. */
  59601. totalStrength: number;
  59602. /**
  59603. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59604. */
  59605. maxZ: number;
  59606. /**
  59607. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59608. */
  59609. minZAspect: number;
  59610. private _samples;
  59611. /**
  59612. * Number of samples used for the SSAO calculations. Default value is 8
  59613. */
  59614. samples: number;
  59615. private _textureSamples;
  59616. /**
  59617. * Number of samples to use for antialiasing
  59618. */
  59619. textureSamples: number;
  59620. /**
  59621. * Ratio object used for SSAO ratio and blur ratio
  59622. */
  59623. private _ratio;
  59624. /**
  59625. * Dynamically generated sphere sampler.
  59626. */
  59627. private _sampleSphere;
  59628. /**
  59629. * Blur filter offsets
  59630. */
  59631. private _samplerOffsets;
  59632. private _expensiveBlur;
  59633. /**
  59634. * If bilateral blur should be used
  59635. */
  59636. expensiveBlur: boolean;
  59637. /**
  59638. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59639. */
  59640. radius: number;
  59641. /**
  59642. * The base color of the SSAO post-process
  59643. * The final result is "base + ssao" between [0, 1]
  59644. */
  59645. base: number;
  59646. /**
  59647. * Support test.
  59648. */
  59649. static readonly IsSupported: boolean;
  59650. private _scene;
  59651. private _depthTexture;
  59652. private _normalTexture;
  59653. private _randomTexture;
  59654. private _originalColorPostProcess;
  59655. private _ssaoPostProcess;
  59656. private _blurHPostProcess;
  59657. private _blurVPostProcess;
  59658. private _ssaoCombinePostProcess;
  59659. private _firstUpdate;
  59660. /**
  59661. * Gets active scene
  59662. */
  59663. readonly scene: Scene;
  59664. /**
  59665. * @constructor
  59666. * @param name The rendering pipeline name
  59667. * @param scene The scene linked to this pipeline
  59668. * @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 }
  59669. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59670. */
  59671. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59672. /**
  59673. * Get the class name
  59674. * @returns "SSAO2RenderingPipeline"
  59675. */
  59676. getClassName(): string;
  59677. /**
  59678. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59679. */
  59680. dispose(disableGeometryBufferRenderer?: boolean): void;
  59681. private _createBlurPostProcess;
  59682. /** @hidden */ private _rebuild(): void;
  59683. private _bits;
  59684. private _radicalInverse_VdC;
  59685. private _hammersley;
  59686. private _hemisphereSample_uniform;
  59687. private _generateHemisphere;
  59688. private _createSSAOPostProcess;
  59689. private _createSSAOCombinePostProcess;
  59690. private _createRandomTexture;
  59691. /**
  59692. * Serialize the rendering pipeline (Used when exporting)
  59693. * @returns the serialized object
  59694. */
  59695. serialize(): any;
  59696. /**
  59697. * Parse the serialized pipeline
  59698. * @param source Source pipeline.
  59699. * @param scene The scene to load the pipeline to.
  59700. * @param rootUrl The URL of the serialized pipeline.
  59701. * @returns An instantiated pipeline from the serialized object.
  59702. */
  59703. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59704. }
  59705. }
  59706. declare module BABYLON {
  59707. /** @hidden */
  59708. export var ssaoPixelShader: {
  59709. name: string;
  59710. shader: string;
  59711. };
  59712. }
  59713. declare module BABYLON {
  59714. /**
  59715. * Render pipeline to produce ssao effect
  59716. */
  59717. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59718. /**
  59719. * @ignore
  59720. * The PassPostProcess id in the pipeline that contains the original scene color
  59721. */
  59722. SSAOOriginalSceneColorEffect: string;
  59723. /**
  59724. * @ignore
  59725. * The SSAO PostProcess id in the pipeline
  59726. */
  59727. SSAORenderEffect: string;
  59728. /**
  59729. * @ignore
  59730. * The horizontal blur PostProcess id in the pipeline
  59731. */
  59732. SSAOBlurHRenderEffect: string;
  59733. /**
  59734. * @ignore
  59735. * The vertical blur PostProcess id in the pipeline
  59736. */
  59737. SSAOBlurVRenderEffect: string;
  59738. /**
  59739. * @ignore
  59740. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59741. */
  59742. SSAOCombineRenderEffect: string;
  59743. /**
  59744. * The output strength of the SSAO post-process. Default value is 1.0.
  59745. */
  59746. totalStrength: number;
  59747. /**
  59748. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59749. */
  59750. radius: number;
  59751. /**
  59752. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59753. * Must not be equal to fallOff and superior to fallOff.
  59754. * Default value is 0.0075
  59755. */
  59756. area: number;
  59757. /**
  59758. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59759. * Must not be equal to area and inferior to area.
  59760. * Default value is 0.000001
  59761. */
  59762. fallOff: number;
  59763. /**
  59764. * The base color of the SSAO post-process
  59765. * The final result is "base + ssao" between [0, 1]
  59766. */
  59767. base: number;
  59768. private _scene;
  59769. private _depthTexture;
  59770. private _randomTexture;
  59771. private _originalColorPostProcess;
  59772. private _ssaoPostProcess;
  59773. private _blurHPostProcess;
  59774. private _blurVPostProcess;
  59775. private _ssaoCombinePostProcess;
  59776. private _firstUpdate;
  59777. /**
  59778. * Gets active scene
  59779. */
  59780. readonly scene: Scene;
  59781. /**
  59782. * @constructor
  59783. * @param name - The rendering pipeline name
  59784. * @param scene - The scene linked to this pipeline
  59785. * @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 }
  59786. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59787. */
  59788. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59789. /**
  59790. * Get the class name
  59791. * @returns "SSAORenderingPipeline"
  59792. */
  59793. getClassName(): string;
  59794. /**
  59795. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59796. */
  59797. dispose(disableDepthRender?: boolean): void;
  59798. private _createBlurPostProcess;
  59799. /** @hidden */ private _rebuild(): void;
  59800. private _createSSAOPostProcess;
  59801. private _createSSAOCombinePostProcess;
  59802. private _createRandomTexture;
  59803. }
  59804. }
  59805. declare module BABYLON {
  59806. /** @hidden */
  59807. export var standardPixelShader: {
  59808. name: string;
  59809. shader: string;
  59810. };
  59811. }
  59812. declare module BABYLON {
  59813. /**
  59814. * Standard rendering pipeline
  59815. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59816. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59817. */
  59818. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59819. /**
  59820. * Public members
  59821. */
  59822. /**
  59823. * Post-process which contains the original scene color before the pipeline applies all the effects
  59824. */
  59825. originalPostProcess: Nullable<PostProcess>;
  59826. /**
  59827. * Post-process used to down scale an image x4
  59828. */
  59829. downSampleX4PostProcess: Nullable<PostProcess>;
  59830. /**
  59831. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59832. */
  59833. brightPassPostProcess: Nullable<PostProcess>;
  59834. /**
  59835. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59836. */
  59837. blurHPostProcesses: PostProcess[];
  59838. /**
  59839. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59840. */
  59841. blurVPostProcesses: PostProcess[];
  59842. /**
  59843. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59844. */
  59845. textureAdderPostProcess: Nullable<PostProcess>;
  59846. /**
  59847. * Post-process used to create volumetric lighting effect
  59848. */
  59849. volumetricLightPostProcess: Nullable<PostProcess>;
  59850. /**
  59851. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59852. */
  59853. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59854. /**
  59855. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59856. */
  59857. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59858. /**
  59859. * Post-process used to merge the volumetric light effect and the real scene color
  59860. */
  59861. volumetricLightMergePostProces: Nullable<PostProcess>;
  59862. /**
  59863. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59864. */
  59865. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59866. /**
  59867. * Base post-process used to calculate the average luminance of the final image for HDR
  59868. */
  59869. luminancePostProcess: Nullable<PostProcess>;
  59870. /**
  59871. * Post-processes used to create down sample post-processes in order to get
  59872. * the average luminance of the final image for HDR
  59873. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59874. */
  59875. luminanceDownSamplePostProcesses: PostProcess[];
  59876. /**
  59877. * Post-process used to create a HDR effect (light adaptation)
  59878. */
  59879. hdrPostProcess: Nullable<PostProcess>;
  59880. /**
  59881. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59882. */
  59883. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59884. /**
  59885. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59886. */
  59887. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59888. /**
  59889. * Post-process used to merge the final HDR post-process and the real scene color
  59890. */
  59891. hdrFinalPostProcess: Nullable<PostProcess>;
  59892. /**
  59893. * Post-process used to create a lens flare effect
  59894. */
  59895. lensFlarePostProcess: Nullable<PostProcess>;
  59896. /**
  59897. * Post-process that merges the result of the lens flare post-process and the real scene color
  59898. */
  59899. lensFlareComposePostProcess: Nullable<PostProcess>;
  59900. /**
  59901. * Post-process used to create a motion blur effect
  59902. */
  59903. motionBlurPostProcess: Nullable<PostProcess>;
  59904. /**
  59905. * Post-process used to create a depth of field effect
  59906. */
  59907. depthOfFieldPostProcess: Nullable<PostProcess>;
  59908. /**
  59909. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59910. */
  59911. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59912. /**
  59913. * Represents the brightness threshold in order to configure the illuminated surfaces
  59914. */
  59915. brightThreshold: number;
  59916. /**
  59917. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59918. */
  59919. blurWidth: number;
  59920. /**
  59921. * Sets if the blur for highlighted surfaces must be only horizontal
  59922. */
  59923. horizontalBlur: boolean;
  59924. /**
  59925. * Gets the overall exposure used by the pipeline
  59926. */
  59927. /**
  59928. * Sets the overall exposure used by the pipeline
  59929. */
  59930. exposure: number;
  59931. /**
  59932. * Texture used typically to simulate "dirty" on camera lens
  59933. */
  59934. lensTexture: Nullable<Texture>;
  59935. /**
  59936. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59937. */
  59938. volumetricLightCoefficient: number;
  59939. /**
  59940. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59941. */
  59942. volumetricLightPower: number;
  59943. /**
  59944. * Used the set the blur intensity to smooth the volumetric lights
  59945. */
  59946. volumetricLightBlurScale: number;
  59947. /**
  59948. * Light (spot or directional) used to generate the volumetric lights rays
  59949. * The source light must have a shadow generate so the pipeline can get its
  59950. * depth map
  59951. */
  59952. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59953. /**
  59954. * For eye adaptation, represents the minimum luminance the eye can see
  59955. */
  59956. hdrMinimumLuminance: number;
  59957. /**
  59958. * For eye adaptation, represents the decrease luminance speed
  59959. */
  59960. hdrDecreaseRate: number;
  59961. /**
  59962. * For eye adaptation, represents the increase luminance speed
  59963. */
  59964. hdrIncreaseRate: number;
  59965. /**
  59966. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59967. */
  59968. /**
  59969. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59970. */
  59971. hdrAutoExposure: boolean;
  59972. /**
  59973. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59974. */
  59975. lensColorTexture: Nullable<Texture>;
  59976. /**
  59977. * The overall strengh for the lens flare effect
  59978. */
  59979. lensFlareStrength: number;
  59980. /**
  59981. * Dispersion coefficient for lens flare ghosts
  59982. */
  59983. lensFlareGhostDispersal: number;
  59984. /**
  59985. * Main lens flare halo width
  59986. */
  59987. lensFlareHaloWidth: number;
  59988. /**
  59989. * Based on the lens distortion effect, defines how much the lens flare result
  59990. * is distorted
  59991. */
  59992. lensFlareDistortionStrength: number;
  59993. /**
  59994. * Configures the blur intensity used for for lens flare (halo)
  59995. */
  59996. lensFlareBlurWidth: number;
  59997. /**
  59998. * Lens star texture must be used to simulate rays on the flares and is available
  59999. * in the documentation
  60000. */
  60001. lensStarTexture: Nullable<Texture>;
  60002. /**
  60003. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  60004. * flare effect by taking account of the dirt texture
  60005. */
  60006. lensFlareDirtTexture: Nullable<Texture>;
  60007. /**
  60008. * Represents the focal length for the depth of field effect
  60009. */
  60010. depthOfFieldDistance: number;
  60011. /**
  60012. * Represents the blur intensity for the blurred part of the depth of field effect
  60013. */
  60014. depthOfFieldBlurWidth: number;
  60015. /**
  60016. * Gets how much the image is blurred by the movement while using the motion blur post-process
  60017. */
  60018. /**
  60019. * Sets how much the image is blurred by the movement while using the motion blur post-process
  60020. */
  60021. motionStrength: number;
  60022. /**
  60023. * Gets wether or not the motion blur post-process is object based or screen based.
  60024. */
  60025. /**
  60026. * Sets wether or not the motion blur post-process should be object based or screen based
  60027. */
  60028. objectBasedMotionBlur: boolean;
  60029. /**
  60030. * List of animations for the pipeline (IAnimatable implementation)
  60031. */
  60032. animations: Animation[];
  60033. /**
  60034. * Private members
  60035. */
  60036. private _scene;
  60037. private _currentDepthOfFieldSource;
  60038. private _basePostProcess;
  60039. private _fixedExposure;
  60040. private _currentExposure;
  60041. private _hdrAutoExposure;
  60042. private _hdrCurrentLuminance;
  60043. private _motionStrength;
  60044. private _isObjectBasedMotionBlur;
  60045. private _floatTextureType;
  60046. private _camerasToBeAttached;
  60047. private _ratio;
  60048. private _bloomEnabled;
  60049. private _depthOfFieldEnabled;
  60050. private _vlsEnabled;
  60051. private _lensFlareEnabled;
  60052. private _hdrEnabled;
  60053. private _motionBlurEnabled;
  60054. private _fxaaEnabled;
  60055. private _motionBlurSamples;
  60056. private _volumetricLightStepsCount;
  60057. private _samples;
  60058. /**
  60059. * @ignore
  60060. * Specifies if the bloom pipeline is enabled
  60061. */
  60062. BloomEnabled: boolean;
  60063. /**
  60064. * @ignore
  60065. * Specifies if the depth of field pipeline is enabed
  60066. */
  60067. DepthOfFieldEnabled: boolean;
  60068. /**
  60069. * @ignore
  60070. * Specifies if the lens flare pipeline is enabed
  60071. */
  60072. LensFlareEnabled: boolean;
  60073. /**
  60074. * @ignore
  60075. * Specifies if the HDR pipeline is enabled
  60076. */
  60077. HDREnabled: boolean;
  60078. /**
  60079. * @ignore
  60080. * Specifies if the volumetric lights scattering effect is enabled
  60081. */
  60082. VLSEnabled: boolean;
  60083. /**
  60084. * @ignore
  60085. * Specifies if the motion blur effect is enabled
  60086. */
  60087. MotionBlurEnabled: boolean;
  60088. /**
  60089. * Specifies if anti-aliasing is enabled
  60090. */
  60091. fxaaEnabled: boolean;
  60092. /**
  60093. * Specifies the number of steps used to calculate the volumetric lights
  60094. * Typically in interval [50, 200]
  60095. */
  60096. volumetricLightStepsCount: number;
  60097. /**
  60098. * Specifies the number of samples used for the motion blur effect
  60099. * Typically in interval [16, 64]
  60100. */
  60101. motionBlurSamples: number;
  60102. /**
  60103. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60104. */
  60105. samples: number;
  60106. /**
  60107. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60108. * @constructor
  60109. * @param name The rendering pipeline name
  60110. * @param scene The scene linked to this pipeline
  60111. * @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)
  60112. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60113. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60114. */
  60115. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60116. private _buildPipeline;
  60117. private _createDownSampleX4PostProcess;
  60118. private _createBrightPassPostProcess;
  60119. private _createBlurPostProcesses;
  60120. private _createTextureAdderPostProcess;
  60121. private _createVolumetricLightPostProcess;
  60122. private _createLuminancePostProcesses;
  60123. private _createHdrPostProcess;
  60124. private _createLensFlarePostProcess;
  60125. private _createDepthOfFieldPostProcess;
  60126. private _createMotionBlurPostProcess;
  60127. private _getDepthTexture;
  60128. private _disposePostProcesses;
  60129. /**
  60130. * Dispose of the pipeline and stop all post processes
  60131. */
  60132. dispose(): void;
  60133. /**
  60134. * Serialize the rendering pipeline (Used when exporting)
  60135. * @returns the serialized object
  60136. */
  60137. serialize(): any;
  60138. /**
  60139. * Parse the serialized pipeline
  60140. * @param source Source pipeline.
  60141. * @param scene The scene to load the pipeline to.
  60142. * @param rootUrl The URL of the serialized pipeline.
  60143. * @returns An instantiated pipeline from the serialized object.
  60144. */
  60145. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60146. /**
  60147. * Luminance steps
  60148. */
  60149. static LuminanceSteps: number;
  60150. }
  60151. }
  60152. declare module BABYLON {
  60153. /** @hidden */
  60154. export var tonemapPixelShader: {
  60155. name: string;
  60156. shader: string;
  60157. };
  60158. }
  60159. declare module BABYLON {
  60160. /** Defines operator used for tonemapping */
  60161. export enum TonemappingOperator {
  60162. /** Hable */
  60163. Hable = 0,
  60164. /** Reinhard */
  60165. Reinhard = 1,
  60166. /** HejiDawson */
  60167. HejiDawson = 2,
  60168. /** Photographic */
  60169. Photographic = 3
  60170. }
  60171. /**
  60172. * Defines a post process to apply tone mapping
  60173. */
  60174. export class TonemapPostProcess extends PostProcess {
  60175. private _operator;
  60176. /** Defines the required exposure adjustement */
  60177. exposureAdjustment: number;
  60178. /**
  60179. * Creates a new TonemapPostProcess
  60180. * @param name defines the name of the postprocess
  60181. * @param _operator defines the operator to use
  60182. * @param exposureAdjustment defines the required exposure adjustement
  60183. * @param camera defines the camera to use (can be null)
  60184. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  60185. * @param engine defines the hosting engine (can be ignore if camera is set)
  60186. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60187. */
  60188. constructor(name: string, _operator: TonemappingOperator,
  60189. /** Defines the required exposure adjustement */
  60190. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  60191. }
  60192. }
  60193. declare module BABYLON {
  60194. /** @hidden */
  60195. export var depthVertexShader: {
  60196. name: string;
  60197. shader: string;
  60198. };
  60199. }
  60200. declare module BABYLON {
  60201. /** @hidden */
  60202. export var volumetricLightScatteringPixelShader: {
  60203. name: string;
  60204. shader: string;
  60205. };
  60206. }
  60207. declare module BABYLON {
  60208. /** @hidden */
  60209. export var volumetricLightScatteringPassVertexShader: {
  60210. name: string;
  60211. shader: string;
  60212. };
  60213. }
  60214. declare module BABYLON {
  60215. /** @hidden */
  60216. export var volumetricLightScatteringPassPixelShader: {
  60217. name: string;
  60218. shader: string;
  60219. };
  60220. }
  60221. declare module BABYLON {
  60222. /**
  60223. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  60224. */
  60225. export class VolumetricLightScatteringPostProcess extends PostProcess {
  60226. private _volumetricLightScatteringPass;
  60227. private _volumetricLightScatteringRTT;
  60228. private _viewPort;
  60229. private _screenCoordinates;
  60230. private _cachedDefines;
  60231. /**
  60232. * If not undefined, the mesh position is computed from the attached node position
  60233. */
  60234. attachedNode: {
  60235. position: Vector3;
  60236. };
  60237. /**
  60238. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  60239. */
  60240. customMeshPosition: Vector3;
  60241. /**
  60242. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  60243. */
  60244. useCustomMeshPosition: boolean;
  60245. /**
  60246. * If the post-process should inverse the light scattering direction
  60247. */
  60248. invert: boolean;
  60249. /**
  60250. * The internal mesh used by the post-process
  60251. */
  60252. mesh: Mesh;
  60253. /**
  60254. * @hidden
  60255. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60256. */
  60257. useDiffuseColor: boolean;
  60258. /**
  60259. * Array containing the excluded meshes not rendered in the internal pass
  60260. */
  60261. excludedMeshes: AbstractMesh[];
  60262. /**
  60263. * Controls the overall intensity of the post-process
  60264. */
  60265. exposure: number;
  60266. /**
  60267. * Dissipates each sample's contribution in range [0, 1]
  60268. */
  60269. decay: number;
  60270. /**
  60271. * Controls the overall intensity of each sample
  60272. */
  60273. weight: number;
  60274. /**
  60275. * Controls the density of each sample
  60276. */
  60277. density: number;
  60278. /**
  60279. * @constructor
  60280. * @param name The post-process name
  60281. * @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)
  60282. * @param camera The camera that the post-process will be attached to
  60283. * @param mesh The mesh used to create the light scattering
  60284. * @param samples The post-process quality, default 100
  60285. * @param samplingModeThe post-process filtering mode
  60286. * @param engine The babylon engine
  60287. * @param reusable If the post-process is reusable
  60288. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60289. */
  60290. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60291. /**
  60292. * Returns the string "VolumetricLightScatteringPostProcess"
  60293. * @returns "VolumetricLightScatteringPostProcess"
  60294. */
  60295. getClassName(): string;
  60296. private _isReady;
  60297. /**
  60298. * Sets the new light position for light scattering effect
  60299. * @param position The new custom light position
  60300. */
  60301. setCustomMeshPosition(position: Vector3): void;
  60302. /**
  60303. * Returns the light position for light scattering effect
  60304. * @return Vector3 The custom light position
  60305. */
  60306. getCustomMeshPosition(): Vector3;
  60307. /**
  60308. * Disposes the internal assets and detaches the post-process from the camera
  60309. */
  60310. dispose(camera: Camera): void;
  60311. /**
  60312. * Returns the render target texture used by the post-process
  60313. * @return the render target texture used by the post-process
  60314. */
  60315. getPass(): RenderTargetTexture;
  60316. private _meshExcluded;
  60317. private _createPass;
  60318. private _updateMeshScreenCoordinates;
  60319. /**
  60320. * Creates a default mesh for the Volumeric Light Scattering post-process
  60321. * @param name The mesh name
  60322. * @param scene The scene where to create the mesh
  60323. * @return the default mesh
  60324. */
  60325. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60326. }
  60327. }
  60328. declare module BABYLON {
  60329. interface Scene {
  60330. /** @hidden (Backing field) */ private _boundingBoxRenderer: BoundingBoxRenderer;
  60331. /** @hidden (Backing field) */ private _forceShowBoundingBoxes: boolean;
  60332. /**
  60333. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60334. */
  60335. forceShowBoundingBoxes: boolean;
  60336. /**
  60337. * Gets the bounding box renderer associated with the scene
  60338. * @returns a BoundingBoxRenderer
  60339. */
  60340. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60341. }
  60342. interface AbstractMesh {
  60343. /** @hidden (Backing field) */ private _showBoundingBox: boolean;
  60344. /**
  60345. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60346. */
  60347. showBoundingBox: boolean;
  60348. }
  60349. /**
  60350. * Component responsible of rendering the bounding box of the meshes in a scene.
  60351. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60352. */
  60353. export class BoundingBoxRenderer implements ISceneComponent {
  60354. /**
  60355. * The component name helpfull to identify the component in the list of scene components.
  60356. */
  60357. readonly name: string;
  60358. /**
  60359. * The scene the component belongs to.
  60360. */
  60361. scene: Scene;
  60362. /**
  60363. * Color of the bounding box lines placed in front of an object
  60364. */
  60365. frontColor: Color3;
  60366. /**
  60367. * Color of the bounding box lines placed behind an object
  60368. */
  60369. backColor: Color3;
  60370. /**
  60371. * Defines if the renderer should show the back lines or not
  60372. */
  60373. showBackLines: boolean;
  60374. /**
  60375. * @hidden
  60376. */
  60377. renderList: SmartArray<BoundingBox>;
  60378. private _colorShader;
  60379. private _vertexBuffers;
  60380. private _indexBuffer;
  60381. private _fillIndexBuffer;
  60382. private _fillIndexData;
  60383. /**
  60384. * Instantiates a new bounding box renderer in a scene.
  60385. * @param scene the scene the renderer renders in
  60386. */
  60387. constructor(scene: Scene);
  60388. /**
  60389. * Registers the component in a given scene
  60390. */
  60391. register(): void;
  60392. private _evaluateSubMesh;
  60393. private _activeMesh;
  60394. private _prepareRessources;
  60395. private _createIndexBuffer;
  60396. /**
  60397. * Rebuilds the elements related to this component in case of
  60398. * context lost for instance.
  60399. */
  60400. rebuild(): void;
  60401. /**
  60402. * @hidden
  60403. */
  60404. reset(): void;
  60405. /**
  60406. * Render the bounding boxes of a specific rendering group
  60407. * @param renderingGroupId defines the rendering group to render
  60408. */
  60409. render(renderingGroupId: number): void;
  60410. /**
  60411. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60412. * @param mesh Define the mesh to render the occlusion bounding box for
  60413. */
  60414. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60415. /**
  60416. * Dispose and release the resources attached to this renderer.
  60417. */
  60418. dispose(): void;
  60419. }
  60420. }
  60421. declare module BABYLON {
  60422. /** @hidden */
  60423. export var depthPixelShader: {
  60424. name: string;
  60425. shader: string;
  60426. };
  60427. }
  60428. declare module BABYLON {
  60429. /**
  60430. * This represents a depth renderer in Babylon.
  60431. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60432. */
  60433. export class DepthRenderer {
  60434. private _scene;
  60435. private _depthMap;
  60436. private _effect;
  60437. private readonly _storeNonLinearDepth;
  60438. private readonly _clearColor;
  60439. /** Get if the depth renderer is using packed depth or not */
  60440. readonly isPacked: boolean;
  60441. private _cachedDefines;
  60442. private _camera;
  60443. /**
  60444. * Specifiess that the depth renderer will only be used within
  60445. * the camera it is created for.
  60446. * This can help forcing its rendering during the camera processing.
  60447. */
  60448. useOnlyInActiveCamera: boolean;
  60449. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  60450. /**
  60451. * Instantiates a depth renderer
  60452. * @param scene The scene the renderer belongs to
  60453. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60454. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60455. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60456. */
  60457. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60458. /**
  60459. * Creates the depth rendering effect and checks if the effect is ready.
  60460. * @param subMesh The submesh to be used to render the depth map of
  60461. * @param useInstances If multiple world instances should be used
  60462. * @returns if the depth renderer is ready to render the depth map
  60463. */
  60464. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60465. /**
  60466. * Gets the texture which the depth map will be written to.
  60467. * @returns The depth map texture
  60468. */
  60469. getDepthMap(): RenderTargetTexture;
  60470. /**
  60471. * Disposes of the depth renderer.
  60472. */
  60473. dispose(): void;
  60474. }
  60475. }
  60476. declare module BABYLON {
  60477. interface Scene {
  60478. /** @hidden (Backing field) */ private _depthRenderer: {
  60479. [id: string]: DepthRenderer;
  60480. };
  60481. /**
  60482. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60483. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60484. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60485. * @returns the created depth renderer
  60486. */
  60487. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  60488. /**
  60489. * Disables a depth renderer for a given camera
  60490. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60491. */
  60492. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60493. }
  60494. /**
  60495. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60496. * in several rendering techniques.
  60497. */
  60498. export class DepthRendererSceneComponent implements ISceneComponent {
  60499. /**
  60500. * The component name helpfull to identify the component in the list of scene components.
  60501. */
  60502. readonly name: string;
  60503. /**
  60504. * The scene the component belongs to.
  60505. */
  60506. scene: Scene;
  60507. /**
  60508. * Creates a new instance of the component for the given scene
  60509. * @param scene Defines the scene to register the component in
  60510. */
  60511. constructor(scene: Scene);
  60512. /**
  60513. * Registers the component in a given scene
  60514. */
  60515. register(): void;
  60516. /**
  60517. * Rebuilds the elements related to this component in case of
  60518. * context lost for instance.
  60519. */
  60520. rebuild(): void;
  60521. /**
  60522. * Disposes the component and the associated ressources
  60523. */
  60524. dispose(): void;
  60525. private _gatherRenderTargets;
  60526. private _gatherActiveCameraRenderTargets;
  60527. }
  60528. }
  60529. declare module BABYLON {
  60530. /** @hidden */
  60531. export var outlinePixelShader: {
  60532. name: string;
  60533. shader: string;
  60534. };
  60535. }
  60536. declare module BABYLON {
  60537. /** @hidden */
  60538. export var outlineVertexShader: {
  60539. name: string;
  60540. shader: string;
  60541. };
  60542. }
  60543. declare module BABYLON {
  60544. interface Scene {
  60545. /** @hidden */ private _outlineRenderer: OutlineRenderer;
  60546. /**
  60547. * Gets the outline renderer associated with the scene
  60548. * @returns a OutlineRenderer
  60549. */
  60550. getOutlineRenderer(): OutlineRenderer;
  60551. }
  60552. interface AbstractMesh {
  60553. /** @hidden (Backing field) */ private _renderOutline: boolean;
  60554. /**
  60555. * Gets or sets a boolean indicating if the outline must be rendered as well
  60556. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60557. */
  60558. renderOutline: boolean;
  60559. /** @hidden (Backing field) */ private _renderOverlay: boolean;
  60560. /**
  60561. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60562. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60563. */
  60564. renderOverlay: boolean;
  60565. }
  60566. /**
  60567. * This class is responsible to draw bothe outline/overlay of meshes.
  60568. * It should not be used directly but through the available method on mesh.
  60569. */
  60570. export class OutlineRenderer implements ISceneComponent {
  60571. /**
  60572. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60573. */
  60574. private static _StencilReference;
  60575. /**
  60576. * The name of the component. Each component must have a unique name.
  60577. */
  60578. name: string;
  60579. /**
  60580. * The scene the component belongs to.
  60581. */
  60582. scene: Scene;
  60583. /**
  60584. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60585. */
  60586. zOffset: number;
  60587. private _engine;
  60588. private _effect;
  60589. private _cachedDefines;
  60590. private _savedDepthWrite;
  60591. /**
  60592. * Instantiates a new outline renderer. (There could be only one per scene).
  60593. * @param scene Defines the scene it belongs to
  60594. */
  60595. constructor(scene: Scene);
  60596. /**
  60597. * Register the component to one instance of a scene.
  60598. */
  60599. register(): void;
  60600. /**
  60601. * Rebuilds the elements related to this component in case of
  60602. * context lost for instance.
  60603. */
  60604. rebuild(): void;
  60605. /**
  60606. * Disposes the component and the associated ressources.
  60607. */
  60608. dispose(): void;
  60609. /**
  60610. * Renders the outline in the canvas.
  60611. * @param subMesh Defines the sumesh to render
  60612. * @param batch Defines the batch of meshes in case of instances
  60613. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60614. */
  60615. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60616. /**
  60617. * Returns whether or not the outline renderer is ready for a given submesh.
  60618. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60619. * @param subMesh Defines the submesh to check readyness for
  60620. * @param useInstances Defines wheter wee are trying to render instances or not
  60621. * @returns true if ready otherwise false
  60622. */
  60623. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60624. private _beforeRenderingMesh;
  60625. private _afterRenderingMesh;
  60626. }
  60627. }
  60628. declare module BABYLON {
  60629. /**
  60630. * Class used to manage multiple sprites of different sizes on the same spritesheet
  60631. * @see http://doc.babylonjs.com/babylon101/sprites
  60632. */
  60633. export class SpritePackedManager extends SpriteManager {
  60634. /** defines the packed manager's name */
  60635. name: string;
  60636. /**
  60637. * Creates a new sprite manager from a packed sprite sheet
  60638. * @param name defines the manager's name
  60639. * @param imgUrl defines the sprite sheet url
  60640. * @param capacity defines the maximum allowed number of sprites
  60641. * @param scene defines the hosting scene
  60642. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  60643. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  60644. * @param samplingMode defines the smapling mode to use with spritesheet
  60645. * @param fromPacked set to true; do not alter
  60646. */
  60647. constructor(
  60648. /** defines the packed manager's name */
  60649. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  60650. }
  60651. }
  60652. declare module BABYLON {
  60653. /**
  60654. * Defines the list of states available for a task inside a AssetsManager
  60655. */
  60656. export enum AssetTaskState {
  60657. /**
  60658. * Initialization
  60659. */
  60660. INIT = 0,
  60661. /**
  60662. * Running
  60663. */
  60664. RUNNING = 1,
  60665. /**
  60666. * Done
  60667. */
  60668. DONE = 2,
  60669. /**
  60670. * Error
  60671. */
  60672. ERROR = 3
  60673. }
  60674. /**
  60675. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60676. */
  60677. export abstract class AbstractAssetTask {
  60678. /**
  60679. * Task name
  60680. */ name: string;
  60681. /**
  60682. * Callback called when the task is successful
  60683. */
  60684. onSuccess: (task: any) => void;
  60685. /**
  60686. * Callback called when the task is not successful
  60687. */
  60688. onError: (task: any, message?: string, exception?: any) => void;
  60689. /**
  60690. * Creates a new AssetsManager
  60691. * @param name defines the name of the task
  60692. */
  60693. constructor(
  60694. /**
  60695. * Task name
  60696. */ name: string);
  60697. private _isCompleted;
  60698. private _taskState;
  60699. private _errorObject;
  60700. /**
  60701. * Get if the task is completed
  60702. */
  60703. readonly isCompleted: boolean;
  60704. /**
  60705. * Gets the current state of the task
  60706. */
  60707. readonly taskState: AssetTaskState;
  60708. /**
  60709. * Gets the current error object (if task is in error)
  60710. */
  60711. readonly errorObject: {
  60712. message?: string;
  60713. exception?: any;
  60714. };
  60715. /**
  60716. * Internal only
  60717. * @hidden
  60718. */ private _setErrorObject(message?: string, exception?: any): void;
  60719. /**
  60720. * Execute the current task
  60721. * @param scene defines the scene where you want your assets to be loaded
  60722. * @param onSuccess is a callback called when the task is successfully executed
  60723. * @param onError is a callback called if an error occurs
  60724. */
  60725. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60726. /**
  60727. * Execute the current task
  60728. * @param scene defines the scene where you want your assets to be loaded
  60729. * @param onSuccess is a callback called when the task is successfully executed
  60730. * @param onError is a callback called if an error occurs
  60731. */
  60732. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60733. /**
  60734. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60735. * This can be used with failed tasks that have the reason for failure fixed.
  60736. */
  60737. reset(): void;
  60738. private onErrorCallback;
  60739. private onDoneCallback;
  60740. }
  60741. /**
  60742. * Define the interface used by progress events raised during assets loading
  60743. */
  60744. export interface IAssetsProgressEvent {
  60745. /**
  60746. * Defines the number of remaining tasks to process
  60747. */
  60748. remainingCount: number;
  60749. /**
  60750. * Defines the total number of tasks
  60751. */
  60752. totalCount: number;
  60753. /**
  60754. * Defines the task that was just processed
  60755. */
  60756. task: AbstractAssetTask;
  60757. }
  60758. /**
  60759. * Class used to share progress information about assets loading
  60760. */
  60761. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60762. /**
  60763. * Defines the number of remaining tasks to process
  60764. */
  60765. remainingCount: number;
  60766. /**
  60767. * Defines the total number of tasks
  60768. */
  60769. totalCount: number;
  60770. /**
  60771. * Defines the task that was just processed
  60772. */
  60773. task: AbstractAssetTask;
  60774. /**
  60775. * Creates a AssetsProgressEvent
  60776. * @param remainingCount defines the number of remaining tasks to process
  60777. * @param totalCount defines the total number of tasks
  60778. * @param task defines the task that was just processed
  60779. */
  60780. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60781. }
  60782. /**
  60783. * Define a task used by AssetsManager to load meshes
  60784. */
  60785. export class MeshAssetTask extends AbstractAssetTask {
  60786. /**
  60787. * Defines the name of the task
  60788. */
  60789. name: string;
  60790. /**
  60791. * Defines the list of mesh's names you want to load
  60792. */
  60793. meshesNames: any;
  60794. /**
  60795. * Defines the root url to use as a base to load your meshes and associated resources
  60796. */
  60797. rootUrl: string;
  60798. /**
  60799. * Defines the filename of the scene to load from
  60800. */
  60801. sceneFilename: string;
  60802. /**
  60803. * Gets the list of loaded meshes
  60804. */
  60805. loadedMeshes: Array<AbstractMesh>;
  60806. /**
  60807. * Gets the list of loaded particle systems
  60808. */
  60809. loadedParticleSystems: Array<IParticleSystem>;
  60810. /**
  60811. * Gets the list of loaded skeletons
  60812. */
  60813. loadedSkeletons: Array<Skeleton>;
  60814. /**
  60815. * Gets the list of loaded animation groups
  60816. */
  60817. loadedAnimationGroups: Array<AnimationGroup>;
  60818. /**
  60819. * Callback called when the task is successful
  60820. */
  60821. onSuccess: (task: MeshAssetTask) => void;
  60822. /**
  60823. * Callback called when the task is successful
  60824. */
  60825. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60826. /**
  60827. * Creates a new MeshAssetTask
  60828. * @param name defines the name of the task
  60829. * @param meshesNames defines the list of mesh's names you want to load
  60830. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60831. * @param sceneFilename defines the filename of the scene to load from
  60832. */
  60833. constructor(
  60834. /**
  60835. * Defines the name of the task
  60836. */
  60837. name: string,
  60838. /**
  60839. * Defines the list of mesh's names you want to load
  60840. */
  60841. meshesNames: any,
  60842. /**
  60843. * Defines the root url to use as a base to load your meshes and associated resources
  60844. */
  60845. rootUrl: string,
  60846. /**
  60847. * Defines the filename of the scene to load from
  60848. */
  60849. sceneFilename: string);
  60850. /**
  60851. * Execute the current task
  60852. * @param scene defines the scene where you want your assets to be loaded
  60853. * @param onSuccess is a callback called when the task is successfully executed
  60854. * @param onError is a callback called if an error occurs
  60855. */
  60856. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60857. }
  60858. /**
  60859. * Define a task used by AssetsManager to load text content
  60860. */
  60861. export class TextFileAssetTask extends AbstractAssetTask {
  60862. /**
  60863. * Defines the name of the task
  60864. */
  60865. name: string;
  60866. /**
  60867. * Defines the location of the file to load
  60868. */
  60869. url: string;
  60870. /**
  60871. * Gets the loaded text string
  60872. */
  60873. text: string;
  60874. /**
  60875. * Callback called when the task is successful
  60876. */
  60877. onSuccess: (task: TextFileAssetTask) => void;
  60878. /**
  60879. * Callback called when the task is successful
  60880. */
  60881. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60882. /**
  60883. * Creates a new TextFileAssetTask object
  60884. * @param name defines the name of the task
  60885. * @param url defines the location of the file to load
  60886. */
  60887. constructor(
  60888. /**
  60889. * Defines the name of the task
  60890. */
  60891. name: string,
  60892. /**
  60893. * Defines the location of the file to load
  60894. */
  60895. url: string);
  60896. /**
  60897. * Execute the current task
  60898. * @param scene defines the scene where you want your assets to be loaded
  60899. * @param onSuccess is a callback called when the task is successfully executed
  60900. * @param onError is a callback called if an error occurs
  60901. */
  60902. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60903. }
  60904. /**
  60905. * Define a task used by AssetsManager to load binary data
  60906. */
  60907. export class BinaryFileAssetTask extends AbstractAssetTask {
  60908. /**
  60909. * Defines the name of the task
  60910. */
  60911. name: string;
  60912. /**
  60913. * Defines the location of the file to load
  60914. */
  60915. url: string;
  60916. /**
  60917. * Gets the lodaded data (as an array buffer)
  60918. */
  60919. data: ArrayBuffer;
  60920. /**
  60921. * Callback called when the task is successful
  60922. */
  60923. onSuccess: (task: BinaryFileAssetTask) => void;
  60924. /**
  60925. * Callback called when the task is successful
  60926. */
  60927. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  60928. /**
  60929. * Creates a new BinaryFileAssetTask object
  60930. * @param name defines the name of the new task
  60931. * @param url defines the location of the file to load
  60932. */
  60933. constructor(
  60934. /**
  60935. * Defines the name of the task
  60936. */
  60937. name: string,
  60938. /**
  60939. * Defines the location of the file to load
  60940. */
  60941. url: string);
  60942. /**
  60943. * Execute the current task
  60944. * @param scene defines the scene where you want your assets to be loaded
  60945. * @param onSuccess is a callback called when the task is successfully executed
  60946. * @param onError is a callback called if an error occurs
  60947. */
  60948. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60949. }
  60950. /**
  60951. * Define a task used by AssetsManager to load images
  60952. */
  60953. export class ImageAssetTask extends AbstractAssetTask {
  60954. /**
  60955. * Defines the name of the task
  60956. */
  60957. name: string;
  60958. /**
  60959. * Defines the location of the image to load
  60960. */
  60961. url: string;
  60962. /**
  60963. * Gets the loaded images
  60964. */
  60965. image: HTMLImageElement;
  60966. /**
  60967. * Callback called when the task is successful
  60968. */
  60969. onSuccess: (task: ImageAssetTask) => void;
  60970. /**
  60971. * Callback called when the task is successful
  60972. */
  60973. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  60974. /**
  60975. * Creates a new ImageAssetTask
  60976. * @param name defines the name of the task
  60977. * @param url defines the location of the image to load
  60978. */
  60979. constructor(
  60980. /**
  60981. * Defines the name of the task
  60982. */
  60983. name: string,
  60984. /**
  60985. * Defines the location of the image to load
  60986. */
  60987. url: string);
  60988. /**
  60989. * Execute the current task
  60990. * @param scene defines the scene where you want your assets to be loaded
  60991. * @param onSuccess is a callback called when the task is successfully executed
  60992. * @param onError is a callback called if an error occurs
  60993. */
  60994. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60995. }
  60996. /**
  60997. * Defines the interface used by texture loading tasks
  60998. */
  60999. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61000. /**
  61001. * Gets the loaded texture
  61002. */
  61003. texture: TEX;
  61004. }
  61005. /**
  61006. * Define a task used by AssetsManager to load 2D textures
  61007. */
  61008. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61009. /**
  61010. * Defines the name of the task
  61011. */
  61012. name: string;
  61013. /**
  61014. * Defines the location of the file to load
  61015. */
  61016. url: string;
  61017. /**
  61018. * Defines if mipmap should not be generated (default is false)
  61019. */
  61020. noMipmap?: boolean | undefined;
  61021. /**
  61022. * Defines if texture must be inverted on Y axis (default is false)
  61023. */
  61024. invertY?: boolean | undefined;
  61025. /**
  61026. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61027. */
  61028. samplingMode: number;
  61029. /**
  61030. * Gets the loaded texture
  61031. */
  61032. texture: Texture;
  61033. /**
  61034. * Callback called when the task is successful
  61035. */
  61036. onSuccess: (task: TextureAssetTask) => void;
  61037. /**
  61038. * Callback called when the task is successful
  61039. */
  61040. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61041. /**
  61042. * Creates a new TextureAssetTask object
  61043. * @param name defines the name of the task
  61044. * @param url defines the location of the file to load
  61045. * @param noMipmap defines if mipmap should not be generated (default is false)
  61046. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61047. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61048. */
  61049. constructor(
  61050. /**
  61051. * Defines the name of the task
  61052. */
  61053. name: string,
  61054. /**
  61055. * Defines the location of the file to load
  61056. */
  61057. url: string,
  61058. /**
  61059. * Defines if mipmap should not be generated (default is false)
  61060. */
  61061. noMipmap?: boolean | undefined,
  61062. /**
  61063. * Defines if texture must be inverted on Y axis (default is false)
  61064. */
  61065. invertY?: boolean | undefined,
  61066. /**
  61067. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61068. */
  61069. samplingMode?: number);
  61070. /**
  61071. * Execute the current task
  61072. * @param scene defines the scene where you want your assets to be loaded
  61073. * @param onSuccess is a callback called when the task is successfully executed
  61074. * @param onError is a callback called if an error occurs
  61075. */
  61076. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61077. }
  61078. /**
  61079. * Define a task used by AssetsManager to load cube textures
  61080. */
  61081. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61082. /**
  61083. * Defines the name of the task
  61084. */
  61085. name: string;
  61086. /**
  61087. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61088. */
  61089. url: string;
  61090. /**
  61091. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61092. */
  61093. extensions?: string[] | undefined;
  61094. /**
  61095. * Defines if mipmaps should not be generated (default is false)
  61096. */
  61097. noMipmap?: boolean | undefined;
  61098. /**
  61099. * Defines the explicit list of files (undefined by default)
  61100. */
  61101. files?: string[] | undefined;
  61102. /**
  61103. * Gets the loaded texture
  61104. */
  61105. texture: CubeTexture;
  61106. /**
  61107. * Callback called when the task is successful
  61108. */
  61109. onSuccess: (task: CubeTextureAssetTask) => void;
  61110. /**
  61111. * Callback called when the task is successful
  61112. */
  61113. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61114. /**
  61115. * Creates a new CubeTextureAssetTask
  61116. * @param name defines the name of the task
  61117. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61118. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61119. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61120. * @param files defines the explicit list of files (undefined by default)
  61121. */
  61122. constructor(
  61123. /**
  61124. * Defines the name of the task
  61125. */
  61126. name: string,
  61127. /**
  61128. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61129. */
  61130. url: string,
  61131. /**
  61132. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61133. */
  61134. extensions?: string[] | undefined,
  61135. /**
  61136. * Defines if mipmaps should not be generated (default is false)
  61137. */
  61138. noMipmap?: boolean | undefined,
  61139. /**
  61140. * Defines the explicit list of files (undefined by default)
  61141. */
  61142. files?: string[] | undefined);
  61143. /**
  61144. * Execute the current task
  61145. * @param scene defines the scene where you want your assets to be loaded
  61146. * @param onSuccess is a callback called when the task is successfully executed
  61147. * @param onError is a callback called if an error occurs
  61148. */
  61149. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61150. }
  61151. /**
  61152. * Define a task used by AssetsManager to load HDR cube textures
  61153. */
  61154. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61155. /**
  61156. * Defines the name of the task
  61157. */
  61158. name: string;
  61159. /**
  61160. * Defines the location of the file to load
  61161. */
  61162. url: string;
  61163. /**
  61164. * Defines the desired size (the more it increases the longer the generation will be)
  61165. */
  61166. size: number;
  61167. /**
  61168. * Defines if mipmaps should not be generated (default is false)
  61169. */
  61170. noMipmap: boolean;
  61171. /**
  61172. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61173. */
  61174. generateHarmonics: boolean;
  61175. /**
  61176. * 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)
  61177. */
  61178. gammaSpace: boolean;
  61179. /**
  61180. * Internal Use Only
  61181. */
  61182. reserved: boolean;
  61183. /**
  61184. * Gets the loaded texture
  61185. */
  61186. texture: HDRCubeTexture;
  61187. /**
  61188. * Callback called when the task is successful
  61189. */
  61190. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  61191. /**
  61192. * Callback called when the task is successful
  61193. */
  61194. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  61195. /**
  61196. * Creates a new HDRCubeTextureAssetTask object
  61197. * @param name defines the name of the task
  61198. * @param url defines the location of the file to load
  61199. * @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.
  61200. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61201. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61202. * @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)
  61203. * @param reserved Internal use only
  61204. */
  61205. constructor(
  61206. /**
  61207. * Defines the name of the task
  61208. */
  61209. name: string,
  61210. /**
  61211. * Defines the location of the file to load
  61212. */
  61213. url: string,
  61214. /**
  61215. * Defines the desired size (the more it increases the longer the generation will be)
  61216. */
  61217. size: number,
  61218. /**
  61219. * Defines if mipmaps should not be generated (default is false)
  61220. */
  61221. noMipmap?: boolean,
  61222. /**
  61223. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61224. */
  61225. generateHarmonics?: boolean,
  61226. /**
  61227. * 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)
  61228. */
  61229. gammaSpace?: boolean,
  61230. /**
  61231. * Internal Use Only
  61232. */
  61233. reserved?: boolean);
  61234. /**
  61235. * Execute the current task
  61236. * @param scene defines the scene where you want your assets to be loaded
  61237. * @param onSuccess is a callback called when the task is successfully executed
  61238. * @param onError is a callback called if an error occurs
  61239. */
  61240. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61241. }
  61242. /**
  61243. * Define a task used by AssetsManager to load Equirectangular cube textures
  61244. */
  61245. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61246. /**
  61247. * Defines the name of the task
  61248. */
  61249. name: string;
  61250. /**
  61251. * Defines the location of the file to load
  61252. */
  61253. url: string;
  61254. /**
  61255. * Defines the desired size (the more it increases the longer the generation will be)
  61256. */
  61257. size: number;
  61258. /**
  61259. * Defines if mipmaps should not be generated (default is false)
  61260. */
  61261. noMipmap: boolean;
  61262. /**
  61263. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61264. * but the standard material would require them in Gamma space) (default is true)
  61265. */
  61266. gammaSpace: boolean;
  61267. /**
  61268. * Gets the loaded texture
  61269. */
  61270. texture: EquiRectangularCubeTexture;
  61271. /**
  61272. * Callback called when the task is successful
  61273. */
  61274. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61275. /**
  61276. * Callback called when the task is successful
  61277. */
  61278. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61279. /**
  61280. * Creates a new EquiRectangularCubeTextureAssetTask object
  61281. * @param name defines the name of the task
  61282. * @param url defines the location of the file to load
  61283. * @param size defines the desired size (the more it increases the longer the generation will be)
  61284. * If the size is omitted this implies you are using a preprocessed cubemap.
  61285. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61286. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61287. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61288. * (default is true)
  61289. */
  61290. constructor(
  61291. /**
  61292. * Defines the name of the task
  61293. */
  61294. name: string,
  61295. /**
  61296. * Defines the location of the file to load
  61297. */
  61298. url: string,
  61299. /**
  61300. * Defines the desired size (the more it increases the longer the generation will be)
  61301. */
  61302. size: number,
  61303. /**
  61304. * Defines if mipmaps should not be generated (default is false)
  61305. */
  61306. noMipmap?: boolean,
  61307. /**
  61308. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61309. * but the standard material would require them in Gamma space) (default is true)
  61310. */
  61311. gammaSpace?: boolean);
  61312. /**
  61313. * Execute the current task
  61314. * @param scene defines the scene where you want your assets to be loaded
  61315. * @param onSuccess is a callback called when the task is successfully executed
  61316. * @param onError is a callback called if an error occurs
  61317. */
  61318. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61319. }
  61320. /**
  61321. * This class can be used to easily import assets into a scene
  61322. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61323. */
  61324. export class AssetsManager {
  61325. private _scene;
  61326. private _isLoading;
  61327. protected _tasks: AbstractAssetTask[];
  61328. protected _waitingTasksCount: number;
  61329. protected _totalTasksCount: number;
  61330. /**
  61331. * Callback called when all tasks are processed
  61332. */
  61333. onFinish: (tasks: AbstractAssetTask[]) => void;
  61334. /**
  61335. * Callback called when a task is successful
  61336. */
  61337. onTaskSuccess: (task: AbstractAssetTask) => void;
  61338. /**
  61339. * Callback called when a task had an error
  61340. */
  61341. onTaskError: (task: AbstractAssetTask) => void;
  61342. /**
  61343. * Callback called when a task is done (whatever the result is)
  61344. */
  61345. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61346. /**
  61347. * Observable called when all tasks are processed
  61348. */
  61349. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61350. /**
  61351. * Observable called when a task had an error
  61352. */
  61353. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61354. /**
  61355. * Observable called when all tasks were executed
  61356. */
  61357. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61358. /**
  61359. * Observable called when a task is done (whatever the result is)
  61360. */
  61361. onProgressObservable: Observable<IAssetsProgressEvent>;
  61362. /**
  61363. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61364. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61365. */
  61366. useDefaultLoadingScreen: boolean;
  61367. /**
  61368. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  61369. * when all assets have been downloaded.
  61370. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  61371. */
  61372. autoHideLoadingUI: boolean;
  61373. /**
  61374. * Creates a new AssetsManager
  61375. * @param scene defines the scene to work on
  61376. */
  61377. constructor(scene: Scene);
  61378. /**
  61379. * Add a MeshAssetTask to the list of active tasks
  61380. * @param taskName defines the name of the new task
  61381. * @param meshesNames defines the name of meshes to load
  61382. * @param rootUrl defines the root url to use to locate files
  61383. * @param sceneFilename defines the filename of the scene file
  61384. * @returns a new MeshAssetTask object
  61385. */
  61386. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61387. /**
  61388. * Add a TextFileAssetTask to the list of active tasks
  61389. * @param taskName defines the name of the new task
  61390. * @param url defines the url of the file to load
  61391. * @returns a new TextFileAssetTask object
  61392. */
  61393. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61394. /**
  61395. * Add a BinaryFileAssetTask to the list of active tasks
  61396. * @param taskName defines the name of the new task
  61397. * @param url defines the url of the file to load
  61398. * @returns a new BinaryFileAssetTask object
  61399. */
  61400. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61401. /**
  61402. * Add a ImageAssetTask to the list of active tasks
  61403. * @param taskName defines the name of the new task
  61404. * @param url defines the url of the file to load
  61405. * @returns a new ImageAssetTask object
  61406. */
  61407. addImageTask(taskName: string, url: string): ImageAssetTask;
  61408. /**
  61409. * Add a TextureAssetTask to the list of active tasks
  61410. * @param taskName defines the name of the new task
  61411. * @param url defines the url of the file to load
  61412. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61413. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61414. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61415. * @returns a new TextureAssetTask object
  61416. */
  61417. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61418. /**
  61419. * Add a CubeTextureAssetTask to the list of active tasks
  61420. * @param taskName defines the name of the new task
  61421. * @param url defines the url of the file to load
  61422. * @param extensions defines the extension to use to load the cube map (can be null)
  61423. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61424. * @param files defines the list of files to load (can be null)
  61425. * @returns a new CubeTextureAssetTask object
  61426. */
  61427. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61428. /**
  61429. *
  61430. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61431. * @param taskName defines the name of the new task
  61432. * @param url defines the url of the file to load
  61433. * @param size defines the size you want for the cubemap (can be null)
  61434. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61435. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61436. * @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)
  61437. * @param reserved Internal use only
  61438. * @returns a new HDRCubeTextureAssetTask object
  61439. */
  61440. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61441. /**
  61442. *
  61443. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61444. * @param taskName defines the name of the new task
  61445. * @param url defines the url of the file to load
  61446. * @param size defines the size you want for the cubemap (can be null)
  61447. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61448. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61449. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61450. * @returns a new EquiRectangularCubeTextureAssetTask object
  61451. */
  61452. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61453. /**
  61454. * Remove a task from the assets manager.
  61455. * @param task the task to remove
  61456. */
  61457. removeTask(task: AbstractAssetTask): void;
  61458. private _decreaseWaitingTasksCount;
  61459. private _runTask;
  61460. /**
  61461. * Reset the AssetsManager and remove all tasks
  61462. * @return the current instance of the AssetsManager
  61463. */
  61464. reset(): AssetsManager;
  61465. /**
  61466. * Start the loading process
  61467. * @return the current instance of the AssetsManager
  61468. */
  61469. load(): AssetsManager;
  61470. /**
  61471. * Start the loading process as an async operation
  61472. * @return a promise returning the list of failed tasks
  61473. */
  61474. loadAsync(): Promise<void>;
  61475. }
  61476. }
  61477. declare module BABYLON {
  61478. /**
  61479. * Wrapper class for promise with external resolve and reject.
  61480. */
  61481. export class Deferred<T> {
  61482. /**
  61483. * The promise associated with this deferred object.
  61484. */
  61485. readonly promise: Promise<T>;
  61486. private _resolve;
  61487. private _reject;
  61488. /**
  61489. * The resolve method of the promise associated with this deferred object.
  61490. */
  61491. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61492. /**
  61493. * The reject method of the promise associated with this deferred object.
  61494. */
  61495. readonly reject: (reason?: any) => void;
  61496. /**
  61497. * Constructor for this deferred object.
  61498. */
  61499. constructor();
  61500. }
  61501. }
  61502. declare module BABYLON {
  61503. /**
  61504. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61505. */
  61506. export class MeshExploder {
  61507. private _centerMesh;
  61508. private _meshes;
  61509. private _meshesOrigins;
  61510. private _toCenterVectors;
  61511. private _scaledDirection;
  61512. private _newPosition;
  61513. private _centerPosition;
  61514. /**
  61515. * Explodes meshes from a center mesh.
  61516. * @param meshes The meshes to explode.
  61517. * @param centerMesh The mesh to be center of explosion.
  61518. */
  61519. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61520. private _setCenterMesh;
  61521. /**
  61522. * Get class name
  61523. * @returns "MeshExploder"
  61524. */
  61525. getClassName(): string;
  61526. /**
  61527. * "Exploded meshes"
  61528. * @returns Array of meshes with the centerMesh at index 0.
  61529. */
  61530. getMeshes(): Array<Mesh>;
  61531. /**
  61532. * Explodes meshes giving a specific direction
  61533. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61534. */
  61535. explode(direction?: number): void;
  61536. }
  61537. }
  61538. declare module BABYLON {
  61539. /**
  61540. * Class used to help managing file picking and drag'n'drop
  61541. */
  61542. export class FilesInput {
  61543. /**
  61544. * List of files ready to be loaded
  61545. */
  61546. static readonly FilesToLoad: {
  61547. [key: string]: File;
  61548. };
  61549. /**
  61550. * Callback called when a file is processed
  61551. */
  61552. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61553. private _engine;
  61554. private _currentScene;
  61555. private _sceneLoadedCallback;
  61556. private _progressCallback;
  61557. private _additionalRenderLoopLogicCallback;
  61558. private _textureLoadingCallback;
  61559. private _startingProcessingFilesCallback;
  61560. private _onReloadCallback;
  61561. private _errorCallback;
  61562. private _elementToMonitor;
  61563. private _sceneFileToLoad;
  61564. private _filesToLoad;
  61565. /**
  61566. * Creates a new FilesInput
  61567. * @param engine defines the rendering engine
  61568. * @param scene defines the hosting scene
  61569. * @param sceneLoadedCallback callback called when scene is loaded
  61570. * @param progressCallback callback called to track progress
  61571. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61572. * @param textureLoadingCallback callback called when a texture is loading
  61573. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61574. * @param onReloadCallback callback called when a reload is requested
  61575. * @param errorCallback callback call if an error occurs
  61576. */
  61577. 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);
  61578. private _dragEnterHandler;
  61579. private _dragOverHandler;
  61580. private _dropHandler;
  61581. /**
  61582. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61583. * @param elementToMonitor defines the DOM element to track
  61584. */
  61585. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61586. /**
  61587. * Release all associated resources
  61588. */
  61589. dispose(): void;
  61590. private renderFunction;
  61591. private drag;
  61592. private drop;
  61593. private _traverseFolder;
  61594. private _processFiles;
  61595. /**
  61596. * Load files from a drop event
  61597. * @param event defines the drop event to use as source
  61598. */
  61599. loadFiles(event: any): void;
  61600. private _processReload;
  61601. /**
  61602. * Reload the current scene from the loaded files
  61603. */
  61604. reload(): void;
  61605. }
  61606. }
  61607. declare module BABYLON {
  61608. /**
  61609. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61610. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61611. */
  61612. export class SceneOptimization {
  61613. /**
  61614. * Defines the priority of this optimization (0 by default which means first in the list)
  61615. */
  61616. priority: number;
  61617. /**
  61618. * Gets a string describing the action executed by the current optimization
  61619. * @returns description string
  61620. */
  61621. getDescription(): string;
  61622. /**
  61623. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61624. * @param scene defines the current scene where to apply this optimization
  61625. * @param optimizer defines the current optimizer
  61626. * @returns true if everything that can be done was applied
  61627. */
  61628. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61629. /**
  61630. * Creates the SceneOptimization object
  61631. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61632. * @param desc defines the description associated with the optimization
  61633. */
  61634. constructor(
  61635. /**
  61636. * Defines the priority of this optimization (0 by default which means first in the list)
  61637. */
  61638. priority?: number);
  61639. }
  61640. /**
  61641. * Defines an optimization used to reduce the size of render target textures
  61642. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61643. */
  61644. export class TextureOptimization extends SceneOptimization {
  61645. /**
  61646. * Defines the priority of this optimization (0 by default which means first in the list)
  61647. */
  61648. priority: number;
  61649. /**
  61650. * 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
  61651. */
  61652. maximumSize: number;
  61653. /**
  61654. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61655. */
  61656. step: number;
  61657. /**
  61658. * Gets a string describing the action executed by the current optimization
  61659. * @returns description string
  61660. */
  61661. getDescription(): string;
  61662. /**
  61663. * Creates the TextureOptimization object
  61664. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61665. * @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
  61666. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61667. */
  61668. constructor(
  61669. /**
  61670. * Defines the priority of this optimization (0 by default which means first in the list)
  61671. */
  61672. priority?: number,
  61673. /**
  61674. * 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
  61675. */
  61676. maximumSize?: number,
  61677. /**
  61678. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61679. */
  61680. step?: number);
  61681. /**
  61682. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61683. * @param scene defines the current scene where to apply this optimization
  61684. * @param optimizer defines the current optimizer
  61685. * @returns true if everything that can be done was applied
  61686. */
  61687. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61688. }
  61689. /**
  61690. * Defines an optimization used to increase or decrease the rendering resolution
  61691. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61692. */
  61693. export class HardwareScalingOptimization extends SceneOptimization {
  61694. /**
  61695. * Defines the priority of this optimization (0 by default which means first in the list)
  61696. */
  61697. priority: number;
  61698. /**
  61699. * Defines the maximum scale to use (2 by default)
  61700. */
  61701. maximumScale: number;
  61702. /**
  61703. * Defines the step to use between two passes (0.5 by default)
  61704. */
  61705. step: number;
  61706. private _currentScale;
  61707. private _directionOffset;
  61708. /**
  61709. * Gets a string describing the action executed by the current optimization
  61710. * @return description string
  61711. */
  61712. getDescription(): string;
  61713. /**
  61714. * Creates the HardwareScalingOptimization object
  61715. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61716. * @param maximumScale defines the maximum scale to use (2 by default)
  61717. * @param step defines the step to use between two passes (0.5 by default)
  61718. */
  61719. constructor(
  61720. /**
  61721. * Defines the priority of this optimization (0 by default which means first in the list)
  61722. */
  61723. priority?: number,
  61724. /**
  61725. * Defines the maximum scale to use (2 by default)
  61726. */
  61727. maximumScale?: number,
  61728. /**
  61729. * Defines the step to use between two passes (0.5 by default)
  61730. */
  61731. step?: number);
  61732. /**
  61733. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61734. * @param scene defines the current scene where to apply this optimization
  61735. * @param optimizer defines the current optimizer
  61736. * @returns true if everything that can be done was applied
  61737. */
  61738. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61739. }
  61740. /**
  61741. * Defines an optimization used to remove shadows
  61742. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61743. */
  61744. export class ShadowsOptimization extends SceneOptimization {
  61745. /**
  61746. * Gets a string describing the action executed by the current optimization
  61747. * @return description string
  61748. */
  61749. getDescription(): string;
  61750. /**
  61751. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61752. * @param scene defines the current scene where to apply this optimization
  61753. * @param optimizer defines the current optimizer
  61754. * @returns true if everything that can be done was applied
  61755. */
  61756. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61757. }
  61758. /**
  61759. * Defines an optimization used to turn post-processes off
  61760. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61761. */
  61762. export class PostProcessesOptimization extends SceneOptimization {
  61763. /**
  61764. * Gets a string describing the action executed by the current optimization
  61765. * @return description string
  61766. */
  61767. getDescription(): string;
  61768. /**
  61769. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61770. * @param scene defines the current scene where to apply this optimization
  61771. * @param optimizer defines the current optimizer
  61772. * @returns true if everything that can be done was applied
  61773. */
  61774. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61775. }
  61776. /**
  61777. * Defines an optimization used to turn lens flares off
  61778. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61779. */
  61780. export class LensFlaresOptimization extends SceneOptimization {
  61781. /**
  61782. * Gets a string describing the action executed by the current optimization
  61783. * @return description string
  61784. */
  61785. getDescription(): string;
  61786. /**
  61787. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61788. * @param scene defines the current scene where to apply this optimization
  61789. * @param optimizer defines the current optimizer
  61790. * @returns true if everything that can be done was applied
  61791. */
  61792. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61793. }
  61794. /**
  61795. * Defines an optimization based on user defined callback.
  61796. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61797. */
  61798. export class CustomOptimization extends SceneOptimization {
  61799. /**
  61800. * Callback called to apply the custom optimization.
  61801. */
  61802. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61803. /**
  61804. * Callback called to get custom description
  61805. */
  61806. onGetDescription: () => string;
  61807. /**
  61808. * Gets a string describing the action executed by the current optimization
  61809. * @returns description string
  61810. */
  61811. getDescription(): string;
  61812. /**
  61813. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61814. * @param scene defines the current scene where to apply this optimization
  61815. * @param optimizer defines the current optimizer
  61816. * @returns true if everything that can be done was applied
  61817. */
  61818. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61819. }
  61820. /**
  61821. * Defines an optimization used to turn particles off
  61822. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61823. */
  61824. export class ParticlesOptimization extends SceneOptimization {
  61825. /**
  61826. * Gets a string describing the action executed by the current optimization
  61827. * @return description string
  61828. */
  61829. getDescription(): string;
  61830. /**
  61831. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61832. * @param scene defines the current scene where to apply this optimization
  61833. * @param optimizer defines the current optimizer
  61834. * @returns true if everything that can be done was applied
  61835. */
  61836. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61837. }
  61838. /**
  61839. * Defines an optimization used to turn render targets off
  61840. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61841. */
  61842. export class RenderTargetsOptimization extends SceneOptimization {
  61843. /**
  61844. * Gets a string describing the action executed by the current optimization
  61845. * @return description string
  61846. */
  61847. getDescription(): string;
  61848. /**
  61849. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61850. * @param scene defines the current scene where to apply this optimization
  61851. * @param optimizer defines the current optimizer
  61852. * @returns true if everything that can be done was applied
  61853. */
  61854. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61855. }
  61856. /**
  61857. * Defines an optimization used to merge meshes with compatible materials
  61858. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61859. */
  61860. export class MergeMeshesOptimization extends SceneOptimization {
  61861. private static _UpdateSelectionTree;
  61862. /**
  61863. * Gets or sets a boolean which defines if optimization octree has to be updated
  61864. */
  61865. /**
  61866. * Gets or sets a boolean which defines if optimization octree has to be updated
  61867. */
  61868. static UpdateSelectionTree: boolean;
  61869. /**
  61870. * Gets a string describing the action executed by the current optimization
  61871. * @return description string
  61872. */
  61873. getDescription(): string;
  61874. private _canBeMerged;
  61875. /**
  61876. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61877. * @param scene defines the current scene where to apply this optimization
  61878. * @param optimizer defines the current optimizer
  61879. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61880. * @returns true if everything that can be done was applied
  61881. */
  61882. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61883. }
  61884. /**
  61885. * Defines a list of options used by SceneOptimizer
  61886. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61887. */
  61888. export class SceneOptimizerOptions {
  61889. /**
  61890. * Defines the target frame rate to reach (60 by default)
  61891. */
  61892. targetFrameRate: number;
  61893. /**
  61894. * Defines the interval between two checkes (2000ms by default)
  61895. */
  61896. trackerDuration: number;
  61897. /**
  61898. * Gets the list of optimizations to apply
  61899. */
  61900. optimizations: SceneOptimization[];
  61901. /**
  61902. * Creates a new list of options used by SceneOptimizer
  61903. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61904. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61905. */
  61906. constructor(
  61907. /**
  61908. * Defines the target frame rate to reach (60 by default)
  61909. */
  61910. targetFrameRate?: number,
  61911. /**
  61912. * Defines the interval between two checkes (2000ms by default)
  61913. */
  61914. trackerDuration?: number);
  61915. /**
  61916. * Add a new optimization
  61917. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61918. * @returns the current SceneOptimizerOptions
  61919. */
  61920. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61921. /**
  61922. * Add a new custom optimization
  61923. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  61924. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  61925. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61926. * @returns the current SceneOptimizerOptions
  61927. */
  61928. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  61929. /**
  61930. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  61931. * @param targetFrameRate defines the target frame rate (60 by default)
  61932. * @returns a SceneOptimizerOptions object
  61933. */
  61934. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61935. /**
  61936. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  61937. * @param targetFrameRate defines the target frame rate (60 by default)
  61938. * @returns a SceneOptimizerOptions object
  61939. */
  61940. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61941. /**
  61942. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  61943. * @param targetFrameRate defines the target frame rate (60 by default)
  61944. * @returns a SceneOptimizerOptions object
  61945. */
  61946. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61947. }
  61948. /**
  61949. * Class used to run optimizations in order to reach a target frame rate
  61950. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61951. */
  61952. export class SceneOptimizer implements IDisposable {
  61953. private _isRunning;
  61954. private _options;
  61955. private _scene;
  61956. private _currentPriorityLevel;
  61957. private _targetFrameRate;
  61958. private _trackerDuration;
  61959. private _currentFrameRate;
  61960. private _sceneDisposeObserver;
  61961. private _improvementMode;
  61962. /**
  61963. * Defines an observable called when the optimizer reaches the target frame rate
  61964. */
  61965. onSuccessObservable: Observable<SceneOptimizer>;
  61966. /**
  61967. * Defines an observable called when the optimizer enables an optimization
  61968. */
  61969. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  61970. /**
  61971. * Defines an observable called when the optimizer is not able to reach the target frame rate
  61972. */
  61973. onFailureObservable: Observable<SceneOptimizer>;
  61974. /**
  61975. * Gets a boolean indicating if the optimizer is in improvement mode
  61976. */
  61977. readonly isInImprovementMode: boolean;
  61978. /**
  61979. * Gets the current priority level (0 at start)
  61980. */
  61981. readonly currentPriorityLevel: number;
  61982. /**
  61983. * Gets the current frame rate checked by the SceneOptimizer
  61984. */
  61985. readonly currentFrameRate: number;
  61986. /**
  61987. * Gets or sets the current target frame rate (60 by default)
  61988. */
  61989. /**
  61990. * Gets or sets the current target frame rate (60 by default)
  61991. */
  61992. targetFrameRate: number;
  61993. /**
  61994. * Gets or sets the current interval between two checks (every 2000ms by default)
  61995. */
  61996. /**
  61997. * Gets or sets the current interval between two checks (every 2000ms by default)
  61998. */
  61999. trackerDuration: number;
  62000. /**
  62001. * Gets the list of active optimizations
  62002. */
  62003. readonly optimizations: SceneOptimization[];
  62004. /**
  62005. * Creates a new SceneOptimizer
  62006. * @param scene defines the scene to work on
  62007. * @param options defines the options to use with the SceneOptimizer
  62008. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62009. * @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)
  62010. */
  62011. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62012. /**
  62013. * Stops the current optimizer
  62014. */
  62015. stop(): void;
  62016. /**
  62017. * Reset the optimizer to initial step (current priority level = 0)
  62018. */
  62019. reset(): void;
  62020. /**
  62021. * Start the optimizer. By default it will try to reach a specific framerate
  62022. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62023. */
  62024. start(): void;
  62025. private _checkCurrentState;
  62026. /**
  62027. * Release all resources
  62028. */
  62029. dispose(): void;
  62030. /**
  62031. * Helper function to create a SceneOptimizer with one single line of code
  62032. * @param scene defines the scene to work on
  62033. * @param options defines the options to use with the SceneOptimizer
  62034. * @param onSuccess defines a callback to call on success
  62035. * @param onFailure defines a callback to call on failure
  62036. * @returns the new SceneOptimizer object
  62037. */
  62038. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62039. }
  62040. }
  62041. declare module BABYLON {
  62042. /**
  62043. * Class used to serialize a scene into a string
  62044. */
  62045. export class SceneSerializer {
  62046. /**
  62047. * Clear cache used by a previous serialization
  62048. */
  62049. static ClearCache(): void;
  62050. /**
  62051. * Serialize a scene into a JSON compatible object
  62052. * @param scene defines the scene to serialize
  62053. * @returns a JSON compatible object
  62054. */
  62055. static Serialize(scene: Scene): any;
  62056. /**
  62057. * Serialize a mesh into a JSON compatible object
  62058. * @param toSerialize defines the mesh to serialize
  62059. * @param withParents defines if parents must be serialized as well
  62060. * @param withChildren defines if children must be serialized as well
  62061. * @returns a JSON compatible object
  62062. */
  62063. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62064. }
  62065. }
  62066. declare module BABYLON {
  62067. /**
  62068. * Class used to host texture specific utilities
  62069. */
  62070. export class TextureTools {
  62071. /**
  62072. * Uses the GPU to create a copy texture rescaled at a given size
  62073. * @param texture Texture to copy from
  62074. * @param width defines the desired width
  62075. * @param height defines the desired height
  62076. * @param useBilinearMode defines if bilinear mode has to be used
  62077. * @return the generated texture
  62078. */
  62079. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62080. }
  62081. }
  62082. declare module BABYLON {
  62083. /**
  62084. * This represents the different options available for the video capture.
  62085. */
  62086. export interface VideoRecorderOptions {
  62087. /** Defines the mime type of the video. */
  62088. mimeType: string;
  62089. /** Defines the FPS the video should be recorded at. */
  62090. fps: number;
  62091. /** Defines the chunk size for the recording data. */
  62092. recordChunckSize: number;
  62093. /** The audio tracks to attach to the recording. */
  62094. audioTracks?: MediaStreamTrack[];
  62095. }
  62096. /**
  62097. * This can help with recording videos from BabylonJS.
  62098. * This is based on the available WebRTC functionalities of the browser.
  62099. *
  62100. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62101. */
  62102. export class VideoRecorder {
  62103. private static readonly _defaultOptions;
  62104. /**
  62105. * Returns whether or not the VideoRecorder is available in your browser.
  62106. * @param engine Defines the Babylon Engine.
  62107. * @returns true if supported otherwise false.
  62108. */
  62109. static IsSupported(engine: Engine): boolean;
  62110. private readonly _options;
  62111. private _canvas;
  62112. private _mediaRecorder;
  62113. private _recordedChunks;
  62114. private _fileName;
  62115. private _resolve;
  62116. private _reject;
  62117. /**
  62118. * True when a recording is already in progress.
  62119. */
  62120. readonly isRecording: boolean;
  62121. /**
  62122. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62123. * @param engine Defines the BabylonJS Engine you wish to record.
  62124. * @param options Defines options that can be used to customize the capture.
  62125. */
  62126. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62127. /**
  62128. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62129. */
  62130. stopRecording(): void;
  62131. /**
  62132. * Starts recording the canvas for a max duration specified in parameters.
  62133. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62134. * If null no automatic download will start and you can rely on the promise to get the data back.
  62135. * @param maxDuration Defines the maximum recording time in seconds.
  62136. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62137. * @return A promise callback at the end of the recording with the video data in Blob.
  62138. */
  62139. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62140. /**
  62141. * Releases internal resources used during the recording.
  62142. */
  62143. dispose(): void;
  62144. private _handleDataAvailable;
  62145. private _handleError;
  62146. private _handleStop;
  62147. }
  62148. }
  62149. declare module BABYLON {
  62150. /**
  62151. * Class containing a set of static utilities functions for screenshots
  62152. */
  62153. export class ScreenshotTools {
  62154. /**
  62155. * Captures a screenshot of the current rendering
  62156. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62157. * @param engine defines the rendering engine
  62158. * @param camera defines the source camera
  62159. * @param size This parameter can be set to a single number or to an object with the
  62160. * following (optional) properties: precision, width, height. If a single number is passed,
  62161. * it will be used for both width and height. If an object is passed, the screenshot size
  62162. * will be derived from the parameters. The precision property is a multiplier allowing
  62163. * rendering at a higher or lower resolution
  62164. * @param successCallback defines the callback receives a single parameter which contains the
  62165. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62166. * src parameter of an <img> to display it
  62167. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62168. * Check your browser for supported MIME types
  62169. */
  62170. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  62171. /**
  62172. * Captures a screenshot of the current rendering
  62173. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62174. * @param engine defines the rendering engine
  62175. * @param camera defines the source camera
  62176. * @param size This parameter can be set to a single number or to an object with the
  62177. * following (optional) properties: precision, width, height. If a single number is passed,
  62178. * it will be used for both width and height. If an object is passed, the screenshot size
  62179. * will be derived from the parameters. The precision property is a multiplier allowing
  62180. * rendering at a higher or lower resolution
  62181. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62182. * Check your browser for supported MIME types
  62183. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62184. * to the src parameter of an <img> to display it
  62185. */
  62186. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  62187. /**
  62188. * Generates an image screenshot from the specified camera.
  62189. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62190. * @param engine The engine to use for rendering
  62191. * @param camera The camera to use for rendering
  62192. * @param size This parameter can be set to a single number or to an object with the
  62193. * following (optional) properties: precision, width, height. If a single number is passed,
  62194. * it will be used for both width and height. If an object is passed, the screenshot size
  62195. * will be derived from the parameters. The precision property is a multiplier allowing
  62196. * rendering at a higher or lower resolution
  62197. * @param successCallback The callback receives a single parameter which contains the
  62198. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62199. * src parameter of an <img> to display it
  62200. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62201. * Check your browser for supported MIME types
  62202. * @param samples Texture samples (default: 1)
  62203. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62204. * @param fileName A name for for the downloaded file.
  62205. */
  62206. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  62207. /**
  62208. * Generates an image screenshot from the specified camera.
  62209. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62210. * @param engine The engine to use for rendering
  62211. * @param camera The camera to use for rendering
  62212. * @param size This parameter can be set to a single number or to an object with the
  62213. * following (optional) properties: precision, width, height. If a single number is passed,
  62214. * it will be used for both width and height. If an object is passed, the screenshot size
  62215. * will be derived from the parameters. The precision property is a multiplier allowing
  62216. * rendering at a higher or lower resolution
  62217. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62218. * Check your browser for supported MIME types
  62219. * @param samples Texture samples (default: 1)
  62220. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62221. * @param fileName A name for for the downloaded file.
  62222. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62223. * to the src parameter of an <img> to display it
  62224. */
  62225. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  62226. /**
  62227. * Gets height and width for screenshot size
  62228. * @private
  62229. */
  62230. private static _getScreenshotSize;
  62231. }
  62232. }
  62233. declare module BABYLON {
  62234. /**
  62235. * A cursor which tracks a point on a path
  62236. */
  62237. export class PathCursor {
  62238. private path;
  62239. /**
  62240. * Stores path cursor callbacks for when an onchange event is triggered
  62241. */
  62242. private _onchange;
  62243. /**
  62244. * The value of the path cursor
  62245. */
  62246. value: number;
  62247. /**
  62248. * The animation array of the path cursor
  62249. */
  62250. animations: Animation[];
  62251. /**
  62252. * Initializes the path cursor
  62253. * @param path The path to track
  62254. */
  62255. constructor(path: Path2);
  62256. /**
  62257. * Gets the cursor point on the path
  62258. * @returns A point on the path cursor at the cursor location
  62259. */
  62260. getPoint(): Vector3;
  62261. /**
  62262. * Moves the cursor ahead by the step amount
  62263. * @param step The amount to move the cursor forward
  62264. * @returns This path cursor
  62265. */
  62266. moveAhead(step?: number): PathCursor;
  62267. /**
  62268. * Moves the cursor behind by the step amount
  62269. * @param step The amount to move the cursor back
  62270. * @returns This path cursor
  62271. */
  62272. moveBack(step?: number): PathCursor;
  62273. /**
  62274. * Moves the cursor by the step amount
  62275. * If the step amount is greater than one, an exception is thrown
  62276. * @param step The amount to move the cursor
  62277. * @returns This path cursor
  62278. */
  62279. move(step: number): PathCursor;
  62280. /**
  62281. * Ensures that the value is limited between zero and one
  62282. * @returns This path cursor
  62283. */
  62284. private ensureLimits;
  62285. /**
  62286. * Runs onchange callbacks on change (used by the animation engine)
  62287. * @returns This path cursor
  62288. */
  62289. private raiseOnChange;
  62290. /**
  62291. * Executes a function on change
  62292. * @param f A path cursor onchange callback
  62293. * @returns This path cursor
  62294. */
  62295. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62296. }
  62297. }
  62298. declare module BABYLON {
  62299. /** @hidden */
  62300. export var blurPixelShader: {
  62301. name: string;
  62302. shader: string;
  62303. };
  62304. }
  62305. declare module BABYLON {
  62306. /** @hidden */
  62307. export var pointCloudVertexDeclaration: {
  62308. name: string;
  62309. shader: string;
  62310. };
  62311. }
  62312. // Mixins
  62313. interface Window {
  62314. mozIndexedDB: IDBFactory;
  62315. webkitIndexedDB: IDBFactory;
  62316. msIndexedDB: IDBFactory;
  62317. webkitURL: typeof URL;
  62318. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  62319. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  62320. WebGLRenderingContext: WebGLRenderingContext;
  62321. MSGesture: MSGesture;
  62322. CANNON: any;
  62323. AudioContext: AudioContext;
  62324. webkitAudioContext: AudioContext;
  62325. PointerEvent: any;
  62326. Math: Math;
  62327. Uint8Array: Uint8ArrayConstructor;
  62328. Float32Array: Float32ArrayConstructor;
  62329. mozURL: typeof URL;
  62330. msURL: typeof URL;
  62331. VRFrameData: any; // WebVR, from specs 1.1
  62332. DracoDecoderModule: any;
  62333. setImmediate(handler: (...args: any[]) => void): number;
  62334. }
  62335. interface HTMLCanvasElement {
  62336. requestPointerLock(): void;
  62337. msRequestPointerLock?(): void;
  62338. mozRequestPointerLock?(): void;
  62339. webkitRequestPointerLock?(): void;
  62340. /** Track wether a record is in progress */
  62341. isRecording: boolean;
  62342. /** Capture Stream method defined by some browsers */
  62343. captureStream(fps?: number): MediaStream;
  62344. }
  62345. interface CanvasRenderingContext2D {
  62346. msImageSmoothingEnabled: boolean;
  62347. }
  62348. interface MouseEvent {
  62349. mozMovementX: number;
  62350. mozMovementY: number;
  62351. webkitMovementX: number;
  62352. webkitMovementY: number;
  62353. msMovementX: number;
  62354. msMovementY: number;
  62355. }
  62356. interface Navigator {
  62357. mozGetVRDevices: (any: any) => any;
  62358. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62359. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62360. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62361. webkitGetGamepads(): Gamepad[];
  62362. msGetGamepads(): Gamepad[];
  62363. webkitGamepads(): Gamepad[];
  62364. }
  62365. interface HTMLVideoElement {
  62366. mozSrcObject: any;
  62367. }
  62368. interface Math {
  62369. fround(x: number): number;
  62370. imul(a: number, b: number): number;
  62371. }
  62372. interface WebGLRenderingContext {
  62373. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62374. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62375. vertexAttribDivisor(index: number, divisor: number): void;
  62376. createVertexArray(): any;
  62377. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62378. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62379. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62380. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62381. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62382. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62383. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62384. // Queries
  62385. createQuery(): WebGLQuery;
  62386. deleteQuery(query: WebGLQuery): void;
  62387. beginQuery(target: number, query: WebGLQuery): void;
  62388. endQuery(target: number): void;
  62389. getQueryParameter(query: WebGLQuery, pname: number): any;
  62390. getQuery(target: number, pname: number): any;
  62391. MAX_SAMPLES: number;
  62392. RGBA8: number;
  62393. READ_FRAMEBUFFER: number;
  62394. DRAW_FRAMEBUFFER: number;
  62395. UNIFORM_BUFFER: number;
  62396. HALF_FLOAT_OES: number;
  62397. RGBA16F: number;
  62398. RGBA32F: number;
  62399. R32F: number;
  62400. RG32F: number;
  62401. RGB32F: number;
  62402. R16F: number;
  62403. RG16F: number;
  62404. RGB16F: number;
  62405. RED: number;
  62406. RG: number;
  62407. R8: number;
  62408. RG8: number;
  62409. UNSIGNED_INT_24_8: number;
  62410. DEPTH24_STENCIL8: number;
  62411. MIN: number;
  62412. MAX: number;
  62413. /* Multiple Render Targets */
  62414. drawBuffers(buffers: number[]): void;
  62415. readBuffer(src: number): void;
  62416. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62417. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62418. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62419. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62420. // Occlusion Query
  62421. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62422. ANY_SAMPLES_PASSED: number;
  62423. QUERY_RESULT_AVAILABLE: number;
  62424. QUERY_RESULT: number;
  62425. }
  62426. interface WebGLProgram { private __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62427. }
  62428. interface EXT_disjoint_timer_query {
  62429. QUERY_COUNTER_BITS_EXT: number;
  62430. TIME_ELAPSED_EXT: number;
  62431. TIMESTAMP_EXT: number;
  62432. GPU_DISJOINT_EXT: number;
  62433. QUERY_RESULT_EXT: number;
  62434. QUERY_RESULT_AVAILABLE_EXT: number;
  62435. queryCounterEXT(query: WebGLQuery, target: number): void;
  62436. createQueryEXT(): WebGLQuery;
  62437. beginQueryEXT(target: number, query: WebGLQuery): void;
  62438. endQueryEXT(target: number): void;
  62439. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62440. deleteQueryEXT(query: WebGLQuery): void;
  62441. }
  62442. interface WebGLUniformLocation { private _currentState: any;
  62443. }
  62444. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62445. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62446. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62447. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62448. interface WebGLRenderingContext {
  62449. readonly RASTERIZER_DISCARD: number;
  62450. readonly DEPTH_COMPONENT24: number;
  62451. readonly TEXTURE_3D: number;
  62452. readonly TEXTURE_2D_ARRAY: number;
  62453. readonly TEXTURE_COMPARE_FUNC: number;
  62454. readonly TEXTURE_COMPARE_MODE: number;
  62455. readonly COMPARE_REF_TO_TEXTURE: number;
  62456. readonly TEXTURE_WRAP_R: number;
  62457. readonly HALF_FLOAT: number;
  62458. readonly RGB8: number;
  62459. readonly RED_INTEGER: number;
  62460. readonly RG_INTEGER: number;
  62461. readonly RGB_INTEGER: number;
  62462. readonly RGBA_INTEGER: number;
  62463. readonly R8_SNORM: number;
  62464. readonly RG8_SNORM: number;
  62465. readonly RGB8_SNORM: number;
  62466. readonly RGBA8_SNORM: number;
  62467. readonly R8I: number;
  62468. readonly RG8I: number;
  62469. readonly RGB8I: number;
  62470. readonly RGBA8I: number;
  62471. readonly R8UI: number;
  62472. readonly RG8UI: number;
  62473. readonly RGB8UI: number;
  62474. readonly RGBA8UI: number;
  62475. readonly R16I: number;
  62476. readonly RG16I: number;
  62477. readonly RGB16I: number;
  62478. readonly RGBA16I: number;
  62479. readonly R16UI: number;
  62480. readonly RG16UI: number;
  62481. readonly RGB16UI: number;
  62482. readonly RGBA16UI: number;
  62483. readonly R32I: number;
  62484. readonly RG32I: number;
  62485. readonly RGB32I: number;
  62486. readonly RGBA32I: number;
  62487. readonly R32UI: number;
  62488. readonly RG32UI: number;
  62489. readonly RGB32UI: number;
  62490. readonly RGBA32UI: number;
  62491. readonly RGB10_A2UI: number;
  62492. readonly R11F_G11F_B10F: number;
  62493. readonly RGB9_E5: number;
  62494. readonly RGB10_A2: number;
  62495. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62496. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62497. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62498. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62499. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62500. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  62501. 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;
  62502. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  62503. readonly TRANSFORM_FEEDBACK: number;
  62504. readonly INTERLEAVED_ATTRIBS: number;
  62505. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  62506. createTransformFeedback(): WebGLTransformFeedback;
  62507. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  62508. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  62509. beginTransformFeedback(primitiveMode: number): void;
  62510. endTransformFeedback(): void;
  62511. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  62512. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62513. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62514. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62515. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  62516. }
  62517. interface ImageBitmap {
  62518. readonly width: number;
  62519. readonly height: number;
  62520. close(): void;
  62521. }
  62522. interface WebGLQuery extends WebGLObject {
  62523. }
  62524. declare var WebGLQuery: {
  62525. prototype: WebGLQuery;
  62526. new(): WebGLQuery;
  62527. };
  62528. interface WebGLSampler extends WebGLObject {
  62529. }
  62530. declare var WebGLSampler: {
  62531. prototype: WebGLSampler;
  62532. new(): WebGLSampler;
  62533. };
  62534. interface WebGLSync extends WebGLObject {
  62535. }
  62536. declare var WebGLSync: {
  62537. prototype: WebGLSync;
  62538. new(): WebGLSync;
  62539. };
  62540. interface WebGLTransformFeedback extends WebGLObject {
  62541. }
  62542. declare var WebGLTransformFeedback: {
  62543. prototype: WebGLTransformFeedback;
  62544. new(): WebGLTransformFeedback;
  62545. };
  62546. interface WebGLVertexArrayObject extends WebGLObject {
  62547. }
  62548. declare var WebGLVertexArrayObject: {
  62549. prototype: WebGLVertexArrayObject;
  62550. new(): WebGLVertexArrayObject;
  62551. };
  62552. // Type definitions for WebVR API
  62553. // Project: https://w3c.github.io/webvr/
  62554. // Definitions by: six a <https://github.com/lostfictions>
  62555. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62556. interface VRDisplay extends EventTarget {
  62557. /**
  62558. * Dictionary of capabilities describing the VRDisplay.
  62559. */
  62560. readonly capabilities: VRDisplayCapabilities;
  62561. /**
  62562. * z-depth defining the far plane of the eye view frustum
  62563. * enables mapping of values in the render target depth
  62564. * attachment to scene coordinates. Initially set to 10000.0.
  62565. */
  62566. depthFar: number;
  62567. /**
  62568. * z-depth defining the near plane of the eye view frustum
  62569. * enables mapping of values in the render target depth
  62570. * attachment to scene coordinates. Initially set to 0.01.
  62571. */
  62572. depthNear: number;
  62573. /**
  62574. * An identifier for this distinct VRDisplay. Used as an
  62575. * association point in the Gamepad API.
  62576. */
  62577. readonly displayId: number;
  62578. /**
  62579. * A display name, a user-readable name identifying it.
  62580. */
  62581. readonly displayName: string;
  62582. readonly isConnected: boolean;
  62583. readonly isPresenting: boolean;
  62584. /**
  62585. * If this VRDisplay supports room-scale experiences, the optional
  62586. * stage attribute contains details on the room-scale parameters.
  62587. */
  62588. readonly stageParameters: VRStageParameters | null;
  62589. /**
  62590. * Passing the value returned by `requestAnimationFrame` to
  62591. * `cancelAnimationFrame` will unregister the callback.
  62592. * @param handle Define the hanle of the request to cancel
  62593. */
  62594. cancelAnimationFrame(handle: number): void;
  62595. /**
  62596. * Stops presenting to the VRDisplay.
  62597. * @returns a promise to know when it stopped
  62598. */
  62599. exitPresent(): Promise<void>;
  62600. /**
  62601. * Return the current VREyeParameters for the given eye.
  62602. * @param whichEye Define the eye we want the parameter for
  62603. * @returns the eye parameters
  62604. */
  62605. getEyeParameters(whichEye: string): VREyeParameters;
  62606. /**
  62607. * Populates the passed VRFrameData with the information required to render
  62608. * the current frame.
  62609. * @param frameData Define the data structure to populate
  62610. * @returns true if ok otherwise false
  62611. */
  62612. getFrameData(frameData: VRFrameData): boolean;
  62613. /**
  62614. * Get the layers currently being presented.
  62615. * @returns the list of VR layers
  62616. */
  62617. getLayers(): VRLayer[];
  62618. /**
  62619. * Return a VRPose containing the future predicted pose of the VRDisplay
  62620. * when the current frame will be presented. The value returned will not
  62621. * change until JavaScript has returned control to the browser.
  62622. *
  62623. * The VRPose will contain the position, orientation, velocity,
  62624. * and acceleration of each of these properties.
  62625. * @returns the pose object
  62626. */
  62627. getPose(): VRPose;
  62628. /**
  62629. * Return the current instantaneous pose of the VRDisplay, with no
  62630. * prediction applied.
  62631. * @returns the current instantaneous pose
  62632. */
  62633. getImmediatePose(): VRPose;
  62634. /**
  62635. * The callback passed to `requestAnimationFrame` will be called
  62636. * any time a new frame should be rendered. When the VRDisplay is
  62637. * presenting the callback will be called at the native refresh
  62638. * rate of the HMD. When not presenting this function acts
  62639. * identically to how window.requestAnimationFrame acts. Content should
  62640. * make no assumptions of frame rate or vsync behavior as the HMD runs
  62641. * asynchronously from other displays and at differing refresh rates.
  62642. * @param callback Define the eaction to run next frame
  62643. * @returns the request handle it
  62644. */
  62645. requestAnimationFrame(callback: FrameRequestCallback): number;
  62646. /**
  62647. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  62648. * Repeat calls while already presenting will update the VRLayers being displayed.
  62649. * @param layers Define the list of layer to present
  62650. * @returns a promise to know when the request has been fulfilled
  62651. */
  62652. requestPresent(layers: VRLayer[]): Promise<void>;
  62653. /**
  62654. * Reset the pose for this display, treating its current position and
  62655. * orientation as the "origin/zero" values. VRPose.position,
  62656. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62657. * updated when calling resetPose(). This should be called in only
  62658. * sitting-space experiences.
  62659. */
  62660. resetPose(): void;
  62661. /**
  62662. * The VRLayer provided to the VRDisplay will be captured and presented
  62663. * in the HMD. Calling this function has the same effect on the source
  62664. * canvas as any other operation that uses its source image, and canvases
  62665. * created without preserveDrawingBuffer set to true will be cleared.
  62666. * @param pose Define the pose to submit
  62667. */
  62668. submitFrame(pose?: VRPose): void;
  62669. }
  62670. declare var VRDisplay: {
  62671. prototype: VRDisplay;
  62672. new(): VRDisplay;
  62673. };
  62674. interface VRLayer {
  62675. leftBounds?: number[] | Float32Array | null;
  62676. rightBounds?: number[] | Float32Array | null;
  62677. source?: HTMLCanvasElement | null;
  62678. }
  62679. interface VRDisplayCapabilities {
  62680. readonly canPresent: boolean;
  62681. readonly hasExternalDisplay: boolean;
  62682. readonly hasOrientation: boolean;
  62683. readonly hasPosition: boolean;
  62684. readonly maxLayers: number;
  62685. }
  62686. interface VREyeParameters {
  62687. /** @deprecated */
  62688. readonly fieldOfView: VRFieldOfView;
  62689. readonly offset: Float32Array;
  62690. readonly renderHeight: number;
  62691. readonly renderWidth: number;
  62692. }
  62693. interface VRFieldOfView {
  62694. readonly downDegrees: number;
  62695. readonly leftDegrees: number;
  62696. readonly rightDegrees: number;
  62697. readonly upDegrees: number;
  62698. }
  62699. interface VRFrameData {
  62700. readonly leftProjectionMatrix: Float32Array;
  62701. readonly leftViewMatrix: Float32Array;
  62702. readonly pose: VRPose;
  62703. readonly rightProjectionMatrix: Float32Array;
  62704. readonly rightViewMatrix: Float32Array;
  62705. readonly timestamp: number;
  62706. }
  62707. interface VRPose {
  62708. readonly angularAcceleration: Float32Array | null;
  62709. readonly angularVelocity: Float32Array | null;
  62710. readonly linearAcceleration: Float32Array | null;
  62711. readonly linearVelocity: Float32Array | null;
  62712. readonly orientation: Float32Array | null;
  62713. readonly position: Float32Array | null;
  62714. readonly timestamp: number;
  62715. }
  62716. interface VRStageParameters {
  62717. sittingToStandingTransform?: Float32Array;
  62718. sizeX?: number;
  62719. sizeY?: number;
  62720. }
  62721. interface Navigator {
  62722. getVRDisplays(): Promise<VRDisplay[]>;
  62723. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62724. }
  62725. interface Window {
  62726. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62727. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62728. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62729. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62730. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62731. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62732. }
  62733. interface Gamepad {
  62734. readonly displayId: number;
  62735. }
  62736. type XRSessionMode =
  62737. | "inline"
  62738. | "immersive-vr"
  62739. | "immersive-ar";
  62740. type XRReferenceSpaceType =
  62741. | "viewer"
  62742. | "local"
  62743. | "local-floor"
  62744. | "bounded-floor"
  62745. | "unbounded";
  62746. type XREnvironmentBlendMode =
  62747. | "opaque"
  62748. | "additive"
  62749. | "alpha-blend";
  62750. type XRVisibilityState =
  62751. | "visible"
  62752. | "visible-blurred"
  62753. | "hidden";
  62754. type XRHandedness =
  62755. | "none"
  62756. | "left"
  62757. | "right";
  62758. type XRTargetRayMode =
  62759. | "gaze"
  62760. | "tracked-pointer"
  62761. | "screen";
  62762. type XREye =
  62763. | "none"
  62764. | "left"
  62765. | "right";
  62766. interface XRSpace extends EventTarget {
  62767. }
  62768. interface XRRenderState {
  62769. depthNear?: number;
  62770. depthFar?: number;
  62771. inlineVerticalFieldOfView?: number;
  62772. baseLayer?: XRWebGLLayer;
  62773. }
  62774. interface XRInputSource {
  62775. handedness: XRHandedness;
  62776. targetRayMode: XRTargetRayMode;
  62777. targetRaySpace: XRSpace;
  62778. gripSpace: XRSpace | undefined;
  62779. gamepad: Gamepad | undefined;
  62780. profiles: Array<string>;
  62781. }
  62782. interface XRSession {
  62783. addEventListener: Function;
  62784. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  62785. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  62786. requestAnimationFrame: Function;
  62787. end(): Promise<void>;
  62788. renderState: XRRenderState;
  62789. inputSources: Array<XRInputSource>;
  62790. }
  62791. interface XRReferenceSpace extends XRSpace {
  62792. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  62793. onreset: any;
  62794. }
  62795. interface XRFrame {
  62796. session: XRSession;
  62797. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  62798. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  62799. }
  62800. interface XRViewerPose extends XRPose {
  62801. views: Array<XRView>;
  62802. }
  62803. interface XRPose {
  62804. transform: XRRigidTransform;
  62805. emulatedPosition: boolean;
  62806. }
  62807. declare var XRWebGLLayer: {
  62808. prototype: XRWebGLLayer;
  62809. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  62810. };
  62811. interface XRWebGLLayer {
  62812. framebuffer: WebGLFramebuffer;
  62813. framebufferWidth: number;
  62814. framebufferHeight: number;
  62815. getViewport: Function;
  62816. }
  62817. interface XRRigidTransform {
  62818. position: DOMPointReadOnly;
  62819. orientation: DOMPointReadOnly;
  62820. matrix: Float32Array;
  62821. inverse: XRRigidTransform;
  62822. }
  62823. interface XRView {
  62824. eye: XREye;
  62825. projectionMatrix: Float32Array;
  62826. transform: XRRigidTransform;
  62827. }
  62828. interface XRInputSourceChangeEvent {
  62829. session: XRSession;
  62830. removed: Array<XRInputSource>;
  62831. added: Array<XRInputSource>;
  62832. }
  62833. /**
  62834. * @ignore
  62835. */
  62836. declare module BABYLON.GLTF2.Exporter {
  62837. }
  62838. /**
  62839. * @ignore
  62840. */
  62841. declare module BABYLON.GLTF1 {
  62842. }
  62843. declare module BABYLON.GUI {
  62844. /**
  62845. * Class used to specific a value and its associated unit
  62846. */
  62847. export class ValueAndUnit {
  62848. /** defines the unit to store */
  62849. unit: number;
  62850. /** defines a boolean indicating if the value can be negative */
  62851. negativeValueAllowed: boolean;
  62852. private _value;
  62853. private _originalUnit;
  62854. /**
  62855. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  62856. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62857. */
  62858. ignoreAdaptiveScaling: boolean;
  62859. /**
  62860. * Creates a new ValueAndUnit
  62861. * @param value defines the value to store
  62862. * @param unit defines the unit to store
  62863. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  62864. */
  62865. constructor(value: number,
  62866. /** defines the unit to store */
  62867. unit?: number,
  62868. /** defines a boolean indicating if the value can be negative */
  62869. negativeValueAllowed?: boolean);
  62870. /** Gets a boolean indicating if the value is a percentage */
  62871. readonly isPercentage: boolean;
  62872. /** Gets a boolean indicating if the value is store as pixel */
  62873. readonly isPixel: boolean;
  62874. /** Gets direct internal value */
  62875. readonly internalValue: number;
  62876. /**
  62877. * Gets value as pixel
  62878. * @param host defines the root host
  62879. * @param refValue defines the reference value for percentages
  62880. * @returns the value as pixel
  62881. */
  62882. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  62883. /**
  62884. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  62885. * @param value defines the value to store
  62886. * @param unit defines the unit to store
  62887. * @returns the current ValueAndUnit
  62888. */
  62889. updateInPlace(value: number, unit?: number): ValueAndUnit;
  62890. /**
  62891. * Gets the value accordingly to its unit
  62892. * @param host defines the root host
  62893. * @returns the value
  62894. */
  62895. getValue(host: AdvancedDynamicTexture): number;
  62896. /**
  62897. * Gets a string representation of the value
  62898. * @param host defines the root host
  62899. * @param decimals defines an optional number of decimals to display
  62900. * @returns a string
  62901. */
  62902. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  62903. /**
  62904. * Store a value parsed from a string
  62905. * @param source defines the source string
  62906. * @returns true if the value was successfully parsed
  62907. */
  62908. fromString(source: string | number): boolean;
  62909. private static _Regex;
  62910. private static _UNITMODE_PERCENTAGE;
  62911. private static _UNITMODE_PIXEL;
  62912. /** UNITMODE_PERCENTAGE */
  62913. static readonly UNITMODE_PERCENTAGE: number;
  62914. /** UNITMODE_PIXEL */
  62915. static readonly UNITMODE_PIXEL: number;
  62916. }
  62917. }
  62918. declare module BABYLON.GUI {
  62919. /**
  62920. * Define a style used by control to automatically setup properties based on a template.
  62921. * Only support font related properties so far
  62922. */
  62923. export class Style implements BABYLON.IDisposable {
  62924. private _fontFamily;
  62925. private _fontStyle;
  62926. private _fontWeight;
  62927. /** @hidden */ private _host: AdvancedDynamicTexture;
  62928. /** @hidden */ private _fontSize: ValueAndUnit;
  62929. /**
  62930. * BABYLON.Observable raised when the style values are changed
  62931. */
  62932. onChangedObservable: BABYLON.Observable<Style>;
  62933. /**
  62934. * Creates a new style object
  62935. * @param host defines the AdvancedDynamicTexture which hosts this style
  62936. */
  62937. constructor(host: AdvancedDynamicTexture);
  62938. /**
  62939. * Gets or sets the font size
  62940. */
  62941. fontSize: string | number;
  62942. /**
  62943. * Gets or sets the font family
  62944. */
  62945. fontFamily: string;
  62946. /**
  62947. * Gets or sets the font style
  62948. */
  62949. fontStyle: string;
  62950. /** Gets or sets font weight */
  62951. fontWeight: string;
  62952. /** Dispose all associated resources */
  62953. dispose(): void;
  62954. }
  62955. }
  62956. declare module BABYLON.GUI {
  62957. /**
  62958. * Class used to transport BABYLON.Vector2 information for pointer events
  62959. */
  62960. export class Vector2WithInfo extends BABYLON.Vector2 {
  62961. /** defines the current mouse button index */
  62962. buttonIndex: number;
  62963. /**
  62964. * Creates a new Vector2WithInfo
  62965. * @param source defines the vector2 data to transport
  62966. * @param buttonIndex defines the current mouse button index
  62967. */
  62968. constructor(source: BABYLON.Vector2,
  62969. /** defines the current mouse button index */
  62970. buttonIndex?: number);
  62971. }
  62972. /** Class used to provide 2D matrix features */
  62973. export class Matrix2D {
  62974. /** Gets the internal array of 6 floats used to store matrix data */
  62975. m: Float32Array;
  62976. /**
  62977. * Creates a new matrix
  62978. * @param m00 defines value for (0, 0)
  62979. * @param m01 defines value for (0, 1)
  62980. * @param m10 defines value for (1, 0)
  62981. * @param m11 defines value for (1, 1)
  62982. * @param m20 defines value for (2, 0)
  62983. * @param m21 defines value for (2, 1)
  62984. */
  62985. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  62986. /**
  62987. * Fills the matrix from direct values
  62988. * @param m00 defines value for (0, 0)
  62989. * @param m01 defines value for (0, 1)
  62990. * @param m10 defines value for (1, 0)
  62991. * @param m11 defines value for (1, 1)
  62992. * @param m20 defines value for (2, 0)
  62993. * @param m21 defines value for (2, 1)
  62994. * @returns the current modified matrix
  62995. */
  62996. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  62997. /**
  62998. * Gets matrix determinant
  62999. * @returns the determinant
  63000. */
  63001. determinant(): number;
  63002. /**
  63003. * Inverses the matrix and stores it in a target matrix
  63004. * @param result defines the target matrix
  63005. * @returns the current matrix
  63006. */
  63007. invertToRef(result: Matrix2D): Matrix2D;
  63008. /**
  63009. * Multiplies the current matrix with another one
  63010. * @param other defines the second operand
  63011. * @param result defines the target matrix
  63012. * @returns the current matrix
  63013. */
  63014. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  63015. /**
  63016. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  63017. * @param x defines the x coordinate to transform
  63018. * @param y defines the x coordinate to transform
  63019. * @param result defines the target vector2
  63020. * @returns the current matrix
  63021. */
  63022. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  63023. /**
  63024. * Creates an identity matrix
  63025. * @returns a new matrix
  63026. */
  63027. static Identity(): Matrix2D;
  63028. /**
  63029. * Creates a translation matrix and stores it in a target matrix
  63030. * @param x defines the x coordinate of the translation
  63031. * @param y defines the y coordinate of the translation
  63032. * @param result defines the target matrix
  63033. */
  63034. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  63035. /**
  63036. * Creates a scaling matrix and stores it in a target matrix
  63037. * @param x defines the x coordinate of the scaling
  63038. * @param y defines the y coordinate of the scaling
  63039. * @param result defines the target matrix
  63040. */
  63041. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  63042. /**
  63043. * Creates a rotation matrix and stores it in a target matrix
  63044. * @param angle defines the rotation angle
  63045. * @param result defines the target matrix
  63046. */
  63047. static RotationToRef(angle: number, result: Matrix2D): void;
  63048. private static _TempPreTranslationMatrix;
  63049. private static _TempPostTranslationMatrix;
  63050. private static _TempRotationMatrix;
  63051. private static _TempScalingMatrix;
  63052. private static _TempCompose0;
  63053. private static _TempCompose1;
  63054. private static _TempCompose2;
  63055. /**
  63056. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  63057. * @param tx defines the x coordinate of the translation
  63058. * @param ty defines the y coordinate of the translation
  63059. * @param angle defines the rotation angle
  63060. * @param scaleX defines the x coordinate of the scaling
  63061. * @param scaleY defines the y coordinate of the scaling
  63062. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  63063. * @param result defines the target matrix
  63064. */
  63065. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  63066. }
  63067. }
  63068. declare module BABYLON.GUI {
  63069. /**
  63070. * Class used to store 2D control sizes
  63071. */
  63072. export class Measure {
  63073. /** defines left coordinate */
  63074. left: number;
  63075. /** defines top coordinate */
  63076. top: number;
  63077. /** defines width dimension */
  63078. width: number;
  63079. /** defines height dimension */
  63080. height: number;
  63081. /**
  63082. * Creates a new measure
  63083. * @param left defines left coordinate
  63084. * @param top defines top coordinate
  63085. * @param width defines width dimension
  63086. * @param height defines height dimension
  63087. */
  63088. constructor(
  63089. /** defines left coordinate */
  63090. left: number,
  63091. /** defines top coordinate */
  63092. top: number,
  63093. /** defines width dimension */
  63094. width: number,
  63095. /** defines height dimension */
  63096. height: number);
  63097. /**
  63098. * Copy from another measure
  63099. * @param other defines the other measure to copy from
  63100. */
  63101. copyFrom(other: Measure): void;
  63102. /**
  63103. * Copy from a group of 4 floats
  63104. * @param left defines left coordinate
  63105. * @param top defines top coordinate
  63106. * @param width defines width dimension
  63107. * @param height defines height dimension
  63108. */
  63109. copyFromFloats(left: number, top: number, width: number, height: number): void;
  63110. /**
  63111. * Computes the axis aligned bounding box measure for two given measures
  63112. * @param a Input measure
  63113. * @param b Input measure
  63114. * @param result the resulting bounding measure
  63115. */
  63116. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  63117. /**
  63118. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  63119. * @param transform the matrix to transform the measure before computing the AABB
  63120. * @param result the resulting AABB
  63121. */
  63122. transformToRef(transform: Matrix2D, result: Measure): void;
  63123. /**
  63124. * Check equality between this measure and another one
  63125. * @param other defines the other measures
  63126. * @returns true if both measures are equals
  63127. */
  63128. isEqualsTo(other: Measure): boolean;
  63129. /**
  63130. * Creates an empty measure
  63131. * @returns a new measure
  63132. */
  63133. static Empty(): Measure;
  63134. }
  63135. }
  63136. declare module BABYLON.GUI {
  63137. /**
  63138. * Interface used to define a control that can receive focus
  63139. */
  63140. export interface IFocusableControl {
  63141. /**
  63142. * Function called when the control receives the focus
  63143. */
  63144. onFocus(): void;
  63145. /**
  63146. * Function called when the control loses the focus
  63147. */
  63148. onBlur(): void;
  63149. /**
  63150. * Function called to let the control handle keyboard events
  63151. * @param evt defines the current keyboard event
  63152. */
  63153. processKeyboard(evt: KeyboardEvent): void;
  63154. /**
  63155. * Function called to get the list of controls that should not steal the focus from this control
  63156. * @returns an array of controls
  63157. */
  63158. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  63159. }
  63160. /**
  63161. * Class used to create texture to support 2D GUI elements
  63162. * @see http://doc.babylonjs.com/how_to/gui
  63163. */
  63164. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  63165. private _isDirty;
  63166. private _renderObserver;
  63167. private _resizeObserver;
  63168. private _preKeyboardObserver;
  63169. private _pointerMoveObserver;
  63170. private _pointerObserver;
  63171. private _canvasPointerOutObserver;
  63172. private _background;
  63173. /** @hidden */ private _rootContainer: Container;
  63174. /** @hidden */ private _lastPickedControl: Control;
  63175. /** @hidden */ private _lastControlOver: {
  63176. [pointerId: number]: Control;
  63177. };
  63178. /** @hidden */ private _lastControlDown: {
  63179. [pointerId: number]: Control;
  63180. };
  63181. /** @hidden */ private _capturingControl: {
  63182. [pointerId: number]: Control;
  63183. };
  63184. /** @hidden */ private _shouldBlockPointer: boolean;
  63185. /** @hidden */ private _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  63186. /** @hidden */ private _linkedControls: Control[];
  63187. private _isFullscreen;
  63188. private _fullscreenViewport;
  63189. private _idealWidth;
  63190. private _idealHeight;
  63191. private _useSmallestIdeal;
  63192. private _renderAtIdealSize;
  63193. private _focusedControl;
  63194. private _blockNextFocusCheck;
  63195. private _renderScale;
  63196. private _rootCanvas;
  63197. private _cursorChanged;
  63198. /**
  63199. * Define type to string to ensure compatibility across browsers
  63200. * Safari doesn't support DataTransfer constructor
  63201. */
  63202. private _clipboardData;
  63203. /**
  63204. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  63205. */
  63206. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  63207. /**
  63208. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  63209. */
  63210. onControlPickedObservable: BABYLON.Observable<Control>;
  63211. /**
  63212. * BABYLON.Observable event triggered before layout is evaluated
  63213. */
  63214. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63215. /**
  63216. * BABYLON.Observable event triggered after the layout was evaluated
  63217. */
  63218. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63219. /**
  63220. * BABYLON.Observable event triggered before the texture is rendered
  63221. */
  63222. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63223. /**
  63224. * BABYLON.Observable event triggered after the texture was rendered
  63225. */
  63226. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63227. /**
  63228. * Gets or sets a boolean defining if alpha is stored as premultiplied
  63229. */
  63230. premulAlpha: boolean;
  63231. /**
  63232. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  63233. * Useful when you want more antialiasing
  63234. */
  63235. renderScale: number;
  63236. /** Gets or sets the background color */
  63237. background: string;
  63238. /**
  63239. * Gets or sets the ideal width used to design controls.
  63240. * The GUI will then rescale everything accordingly
  63241. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63242. */
  63243. idealWidth: number;
  63244. /**
  63245. * Gets or sets the ideal height used to design controls.
  63246. * The GUI will then rescale everything accordingly
  63247. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63248. */
  63249. idealHeight: number;
  63250. /**
  63251. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  63252. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63253. */
  63254. useSmallestIdeal: boolean;
  63255. /**
  63256. * Gets or sets a boolean indicating if adaptive scaling must be used
  63257. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63258. */
  63259. renderAtIdealSize: boolean;
  63260. /**
  63261. * Gets the underlying layer used to render the texture when in fullscreen mode
  63262. */
  63263. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  63264. /**
  63265. * Gets the root container control
  63266. */
  63267. readonly rootContainer: Container;
  63268. /**
  63269. * Returns an array containing the root container.
  63270. * This is mostly used to let the Inspector introspects the ADT
  63271. * @returns an array containing the rootContainer
  63272. */
  63273. getChildren(): Array<Container>;
  63274. /**
  63275. * Will return all controls that are inside this texture
  63276. * @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
  63277. * @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
  63278. * @return all child controls
  63279. */
  63280. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63281. /**
  63282. * Gets or sets the current focused control
  63283. */
  63284. focusedControl: BABYLON.Nullable<IFocusableControl>;
  63285. /**
  63286. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  63287. */
  63288. isForeground: boolean;
  63289. /**
  63290. * Gets or set information about clipboardData
  63291. */
  63292. clipboardData: string;
  63293. /**
  63294. * Creates a new AdvancedDynamicTexture
  63295. * @param name defines the name of the texture
  63296. * @param width defines the width of the texture
  63297. * @param height defines the height of the texture
  63298. * @param scene defines the hosting scene
  63299. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  63300. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  63301. */
  63302. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  63303. /**
  63304. * Get the current class name of the texture useful for serialization or dynamic coding.
  63305. * @returns "AdvancedDynamicTexture"
  63306. */
  63307. getClassName(): string;
  63308. /**
  63309. * Function used to execute a function on all controls
  63310. * @param func defines the function to execute
  63311. * @param container defines the container where controls belong. If null the root container will be used
  63312. */
  63313. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  63314. private _useInvalidateRectOptimization;
  63315. /**
  63316. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  63317. */
  63318. useInvalidateRectOptimization: boolean;
  63319. private _invalidatedRectangle;
  63320. /**
  63321. * Invalidates a rectangle area on the gui texture
  63322. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  63323. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  63324. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  63325. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  63326. */
  63327. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  63328. /**
  63329. * Marks the texture as dirty forcing a complete update
  63330. */
  63331. markAsDirty(): void;
  63332. /**
  63333. * Helper function used to create a new style
  63334. * @returns a new style
  63335. * @see http://doc.babylonjs.com/how_to/gui#styles
  63336. */
  63337. createStyle(): Style;
  63338. /**
  63339. * Adds a new control to the root container
  63340. * @param control defines the control to add
  63341. * @returns the current texture
  63342. */
  63343. addControl(control: Control): AdvancedDynamicTexture;
  63344. /**
  63345. * Removes a control from the root container
  63346. * @param control defines the control to remove
  63347. * @returns the current texture
  63348. */
  63349. removeControl(control: Control): AdvancedDynamicTexture;
  63350. /**
  63351. * Release all resources
  63352. */
  63353. dispose(): void;
  63354. private _onResize;
  63355. /** @hidden */ private _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  63356. /**
  63357. * Get screen coordinates for a vector3
  63358. * @param position defines the position to project
  63359. * @param worldMatrix defines the world matrix to use
  63360. * @returns the projected position
  63361. */
  63362. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  63363. private _checkUpdate;
  63364. private _clearMeasure;
  63365. private _render;
  63366. /** @hidden */ private _changeCursor(cursor: string): void;
  63367. /** @hidden */ private _registerLastControlDown(control: Control, pointerId: number): void;
  63368. private _doPicking;
  63369. /** @hidden */ private _cleanControlAfterRemovalFromList(list: {
  63370. [pointerId: number]: Control;
  63371. }, control: Control): void;
  63372. /** @hidden */ private _cleanControlAfterRemoval(control: Control): void;
  63373. /** Attach to all scene events required to support pointer events */
  63374. attach(): void;
  63375. /** @hidden */
  63376. private onClipboardCopy;
  63377. /** @hidden */
  63378. private onClipboardCut;
  63379. /** @hidden */
  63380. private onClipboardPaste;
  63381. /**
  63382. * Register the clipboard Events onto the canvas
  63383. */
  63384. registerClipboardEvents(): void;
  63385. /**
  63386. * Unregister the clipboard Events from the canvas
  63387. */
  63388. unRegisterClipboardEvents(): void;
  63389. /**
  63390. * Connect the texture to a hosting mesh to enable interactions
  63391. * @param mesh defines the mesh to attach to
  63392. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  63393. */
  63394. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  63395. /**
  63396. * Move the focus to a specific control
  63397. * @param control defines the control which will receive the focus
  63398. */
  63399. moveFocusToControl(control: IFocusableControl): void;
  63400. private _manageFocus;
  63401. private _attachToOnPointerOut;
  63402. /**
  63403. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  63404. * @param mesh defines the mesh which will receive the texture
  63405. * @param width defines the texture width (1024 by default)
  63406. * @param height defines the texture height (1024 by default)
  63407. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  63408. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  63409. * @returns a new AdvancedDynamicTexture
  63410. */
  63411. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  63412. /**
  63413. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  63414. * In this mode the texture will rely on a layer for its rendering.
  63415. * This allows it to be treated like any other layer.
  63416. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  63417. * LayerMask is set through advancedTexture.layer.layerMask
  63418. * @param name defines name for the texture
  63419. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  63420. * @param scene defines the hsoting scene
  63421. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  63422. * @returns a new AdvancedDynamicTexture
  63423. */
  63424. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  63425. }
  63426. }
  63427. declare module BABYLON.GUI {
  63428. /**
  63429. * Root class used for all 2D controls
  63430. * @see http://doc.babylonjs.com/how_to/gui#controls
  63431. */
  63432. export class Control {
  63433. /** defines the name of the control */
  63434. name?: string | undefined;
  63435. /**
  63436. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  63437. */
  63438. static AllowAlphaInheritance: boolean;
  63439. private _alpha;
  63440. private _alphaSet;
  63441. private _zIndex;
  63442. /** @hidden */ private _host: AdvancedDynamicTexture;
  63443. /** Gets or sets the control parent */
  63444. parent: BABYLON.Nullable<Container>;
  63445. /** @hidden */ private _currentMeasure: Measure;
  63446. private _fontFamily;
  63447. private _fontStyle;
  63448. private _fontWeight;
  63449. private _fontSize;
  63450. private _font;
  63451. /** @hidden */ private _width: ValueAndUnit;
  63452. /** @hidden */ private _height: ValueAndUnit;
  63453. /** @hidden */
  63454. protected _fontOffset: {
  63455. ascent: number;
  63456. height: number;
  63457. descent: number;
  63458. };
  63459. private _color;
  63460. private _style;
  63461. private _styleObserver;
  63462. /** @hidden */
  63463. protected _horizontalAlignment: number;
  63464. /** @hidden */
  63465. protected _verticalAlignment: number;
  63466. /** @hidden */
  63467. protected _isDirty: boolean;
  63468. /** @hidden */
  63469. protected _wasDirty: boolean;
  63470. /** @hidden */ private _tempParentMeasure: Measure;
  63471. /** @hidden */ private _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  63472. /** @hidden */
  63473. protected _cachedParentMeasure: Measure;
  63474. private _paddingLeft;
  63475. private _paddingRight;
  63476. private _paddingTop;
  63477. private _paddingBottom;
  63478. /** @hidden */ private _left: ValueAndUnit;
  63479. /** @hidden */ private _top: ValueAndUnit;
  63480. private _scaleX;
  63481. private _scaleY;
  63482. private _rotation;
  63483. private _transformCenterX;
  63484. private _transformCenterY;
  63485. /** @hidden */ private _transformMatrix: Matrix2D;
  63486. /** @hidden */
  63487. protected _invertTransformMatrix: Matrix2D;
  63488. /** @hidden */
  63489. protected _transformedPosition: BABYLON.Vector2;
  63490. private _isMatrixDirty;
  63491. private _cachedOffsetX;
  63492. private _cachedOffsetY;
  63493. private _isVisible;
  63494. private _isHighlighted;
  63495. /** @hidden */ private _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63496. private _fontSet;
  63497. private _dummyVector2;
  63498. private _downCount;
  63499. private _enterCount;
  63500. private _doNotRender;
  63501. private _downPointerIds;
  63502. protected _isEnabled: boolean;
  63503. protected _disabledColor: string;
  63504. /** @hidden */
  63505. protected _rebuildLayout: boolean;
  63506. /** @hidden */ private _isClipped: boolean;
  63507. /** @hidden */ private _tag: any;
  63508. /**
  63509. * 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
  63510. */
  63511. uniqueId: number;
  63512. /**
  63513. * Gets or sets an object used to store user defined information for the node
  63514. */
  63515. metadata: any;
  63516. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  63517. isHitTestVisible: boolean;
  63518. /** Gets or sets a boolean indicating if the control can block pointer events */
  63519. isPointerBlocker: boolean;
  63520. /** Gets or sets a boolean indicating if the control can be focusable */
  63521. isFocusInvisible: boolean;
  63522. /**
  63523. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  63524. * 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
  63525. */
  63526. clipChildren: boolean;
  63527. /**
  63528. * Gets or sets a boolean indicating that control content must be clipped
  63529. * 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
  63530. */
  63531. clipContent: boolean;
  63532. /**
  63533. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  63534. */
  63535. useBitmapCache: boolean;
  63536. private _cacheData;
  63537. private _shadowOffsetX;
  63538. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  63539. shadowOffsetX: number;
  63540. private _shadowOffsetY;
  63541. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  63542. shadowOffsetY: number;
  63543. private _shadowBlur;
  63544. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  63545. shadowBlur: number;
  63546. private _shadowColor;
  63547. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  63548. shadowColor: string;
  63549. /** Gets or sets the cursor to use when the control is hovered */
  63550. hoverCursor: string;
  63551. /** @hidden */
  63552. protected _linkOffsetX: ValueAndUnit;
  63553. /** @hidden */
  63554. protected _linkOffsetY: ValueAndUnit;
  63555. /** Gets the control type name */
  63556. readonly typeName: string;
  63557. /**
  63558. * Get the current class name of the control.
  63559. * @returns current class name
  63560. */
  63561. getClassName(): string;
  63562. /**
  63563. * An event triggered when the pointer move over the control.
  63564. */
  63565. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  63566. /**
  63567. * An event triggered when the pointer move out of the control.
  63568. */
  63569. onPointerOutObservable: BABYLON.Observable<Control>;
  63570. /**
  63571. * An event triggered when the pointer taps the control
  63572. */
  63573. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  63574. /**
  63575. * An event triggered when pointer up
  63576. */
  63577. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  63578. /**
  63579. * An event triggered when a control is clicked on
  63580. */
  63581. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  63582. /**
  63583. * An event triggered when pointer enters the control
  63584. */
  63585. onPointerEnterObservable: BABYLON.Observable<Control>;
  63586. /**
  63587. * An event triggered when the control is marked as dirty
  63588. */
  63589. onDirtyObservable: BABYLON.Observable<Control>;
  63590. /**
  63591. * An event triggered before drawing the control
  63592. */
  63593. onBeforeDrawObservable: BABYLON.Observable<Control>;
  63594. /**
  63595. * An event triggered after the control was drawn
  63596. */
  63597. onAfterDrawObservable: BABYLON.Observable<Control>;
  63598. /**
  63599. * Get the hosting AdvancedDynamicTexture
  63600. */
  63601. readonly host: AdvancedDynamicTexture;
  63602. /** Gets or set information about font offsets (used to render and align text) */
  63603. fontOffset: {
  63604. ascent: number;
  63605. height: number;
  63606. descent: number;
  63607. };
  63608. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  63609. alpha: number;
  63610. /**
  63611. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  63612. */
  63613. isHighlighted: boolean;
  63614. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  63615. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63616. */
  63617. scaleX: number;
  63618. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  63619. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63620. */
  63621. scaleY: number;
  63622. /** Gets or sets the rotation angle (0 by default)
  63623. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63624. */
  63625. rotation: number;
  63626. /** Gets or sets the transformation center on Y axis (0 by default)
  63627. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63628. */
  63629. transformCenterY: number;
  63630. /** Gets or sets the transformation center on X axis (0 by default)
  63631. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63632. */
  63633. transformCenterX: number;
  63634. /**
  63635. * Gets or sets the horizontal alignment
  63636. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63637. */
  63638. horizontalAlignment: number;
  63639. /**
  63640. * Gets or sets the vertical alignment
  63641. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63642. */
  63643. verticalAlignment: number;
  63644. /**
  63645. * Gets or sets control width
  63646. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63647. */
  63648. width: string | number;
  63649. /**
  63650. * Gets or sets the control width in pixel
  63651. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63652. */
  63653. widthInPixels: number;
  63654. /**
  63655. * Gets or sets control height
  63656. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63657. */
  63658. height: string | number;
  63659. /**
  63660. * Gets or sets control height in pixel
  63661. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63662. */
  63663. heightInPixels: number;
  63664. /** Gets or set font family */
  63665. fontFamily: string;
  63666. /** Gets or sets font style */
  63667. fontStyle: string;
  63668. /** Gets or sets font weight */
  63669. fontWeight: string;
  63670. /**
  63671. * Gets or sets style
  63672. * @see http://doc.babylonjs.com/how_to/gui#styles
  63673. */
  63674. style: BABYLON.Nullable<Style>;
  63675. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  63676. /** Gets or sets font size in pixels */
  63677. fontSizeInPixels: number;
  63678. /** Gets or sets font size */
  63679. fontSize: string | number;
  63680. /** Gets or sets foreground color */
  63681. color: string;
  63682. /** Gets or sets z index which is used to reorder controls on the z axis */
  63683. zIndex: number;
  63684. /** Gets or sets a boolean indicating if the control can be rendered */
  63685. notRenderable: boolean;
  63686. /** Gets or sets a boolean indicating if the control is visible */
  63687. isVisible: boolean;
  63688. /** Gets a boolean indicating that the control needs to update its rendering */
  63689. readonly isDirty: boolean;
  63690. /**
  63691. * Gets the current linked mesh (or null if none)
  63692. */
  63693. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63694. /**
  63695. * Gets or sets a value indicating the padding to use on the left of the control
  63696. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63697. */
  63698. paddingLeft: string | number;
  63699. /**
  63700. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  63701. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63702. */
  63703. paddingLeftInPixels: number;
  63704. /**
  63705. * Gets or sets a value indicating the padding to use on the right of the control
  63706. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63707. */
  63708. paddingRight: string | number;
  63709. /**
  63710. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  63711. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63712. */
  63713. paddingRightInPixels: number;
  63714. /**
  63715. * Gets or sets a value indicating the padding to use on the top of the control
  63716. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63717. */
  63718. paddingTop: string | number;
  63719. /**
  63720. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  63721. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63722. */
  63723. paddingTopInPixels: number;
  63724. /**
  63725. * Gets or sets a value indicating the padding to use on the bottom of the control
  63726. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63727. */
  63728. paddingBottom: string | number;
  63729. /**
  63730. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  63731. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63732. */
  63733. paddingBottomInPixels: number;
  63734. /**
  63735. * Gets or sets a value indicating the left coordinate of the control
  63736. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63737. */
  63738. left: string | number;
  63739. /**
  63740. * Gets or sets a value indicating the left coordinate in pixels of the control
  63741. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63742. */
  63743. leftInPixels: number;
  63744. /**
  63745. * Gets or sets a value indicating the top coordinate of the control
  63746. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63747. */
  63748. top: string | number;
  63749. /**
  63750. * Gets or sets a value indicating the top coordinate in pixels of the control
  63751. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63752. */
  63753. topInPixels: number;
  63754. /**
  63755. * Gets or sets a value indicating the offset on X axis to the linked mesh
  63756. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63757. */
  63758. linkOffsetX: string | number;
  63759. /**
  63760. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  63761. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63762. */
  63763. linkOffsetXInPixels: number;
  63764. /**
  63765. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  63766. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63767. */
  63768. linkOffsetY: string | number;
  63769. /**
  63770. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  63771. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63772. */
  63773. linkOffsetYInPixels: number;
  63774. /** Gets the center coordinate on X axis */
  63775. readonly centerX: number;
  63776. /** Gets the center coordinate on Y axis */
  63777. readonly centerY: number;
  63778. /** Gets or sets if control is Enabled*/
  63779. isEnabled: boolean;
  63780. /** Gets or sets background color of control if it's disabled*/
  63781. disabledColor: string;
  63782. /**
  63783. * Creates a new control
  63784. * @param name defines the name of the control
  63785. */
  63786. constructor(
  63787. /** defines the name of the control */
  63788. name?: string | undefined);
  63789. /** @hidden */
  63790. protected _getTypeName(): string;
  63791. /**
  63792. * Gets the first ascendant in the hierarchy of the given type
  63793. * @param className defines the required type
  63794. * @returns the ascendant or null if not found
  63795. */
  63796. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  63797. /** @hidden */ private _resetFontCache(): void;
  63798. /**
  63799. * Determines if a container is an ascendant of the current control
  63800. * @param container defines the container to look for
  63801. * @returns true if the container is one of the ascendant of the control
  63802. */
  63803. isAscendant(container: Control): boolean;
  63804. /**
  63805. * Gets coordinates in local control space
  63806. * @param globalCoordinates defines the coordinates to transform
  63807. * @returns the new coordinates in local space
  63808. */
  63809. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63810. /**
  63811. * Gets coordinates in local control space
  63812. * @param globalCoordinates defines the coordinates to transform
  63813. * @param result defines the target vector2 where to store the result
  63814. * @returns the current control
  63815. */
  63816. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  63817. /**
  63818. * Gets coordinates in parent local control space
  63819. * @param globalCoordinates defines the coordinates to transform
  63820. * @returns the new coordinates in parent local space
  63821. */
  63822. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63823. /**
  63824. * Move the current control to a vector3 position projected onto the screen.
  63825. * @param position defines the target position
  63826. * @param scene defines the hosting scene
  63827. */
  63828. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  63829. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  63830. /**
  63831. * Will return all controls that have this control as ascendant
  63832. * @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
  63833. * @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
  63834. * @return all child controls
  63835. */
  63836. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63837. /**
  63838. * Link current control with a target mesh
  63839. * @param mesh defines the mesh to link with
  63840. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63841. */
  63842. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  63843. /** @hidden */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  63844. /** @hidden */ private _offsetLeft(offset: number): void;
  63845. /** @hidden */ private _offsetTop(offset: number): void;
  63846. /** @hidden */ private _markMatrixAsDirty(): void;
  63847. /** @hidden */ private _flagDescendantsAsMatrixDirty(): void;
  63848. /** @hidden */ private _intersectsRect(rect: Measure): boolean;
  63849. /** @hidden */
  63850. protected invalidateRect(): void;
  63851. /** @hidden */ private _markAsDirty(force?: boolean): void;
  63852. /** @hidden */ private _markAllAsDirty(): void;
  63853. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  63854. /** @hidden */
  63855. protected _transform(context?: CanvasRenderingContext2D): void;
  63856. /** @hidden */ private _renderHighlight(context: CanvasRenderingContext2D): void;
  63857. /** @hidden */ private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63858. /** @hidden */
  63859. protected _applyStates(context: CanvasRenderingContext2D): void;
  63860. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  63861. /** @hidden */
  63862. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63863. protected _evaluateClippingState(parentMeasure: Measure): void;
  63864. /** @hidden */ private _measure(): void;
  63865. /** @hidden */
  63866. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63867. /** @hidden */
  63868. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63869. /** @hidden */
  63870. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63871. /** @hidden */
  63872. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63873. private static _ClipMeasure;
  63874. private _tmpMeasureA;
  63875. private _clip;
  63876. /** @hidden */ private _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  63877. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  63878. /**
  63879. * Tests if a given coordinates belong to the current control
  63880. * @param x defines x coordinate to test
  63881. * @param y defines y coordinate to test
  63882. * @returns true if the coordinates are inside the control
  63883. */
  63884. contains(x: number, y: number): boolean;
  63885. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63886. /** @hidden */ private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63887. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  63888. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  63889. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63890. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63891. /** @hidden */ private _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  63892. /** @hidden */ private _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  63893. private _prepareFont;
  63894. /** Releases associated resources */
  63895. dispose(): void;
  63896. private static _HORIZONTAL_ALIGNMENT_LEFT;
  63897. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  63898. private static _HORIZONTAL_ALIGNMENT_CENTER;
  63899. private static _VERTICAL_ALIGNMENT_TOP;
  63900. private static _VERTICAL_ALIGNMENT_BOTTOM;
  63901. private static _VERTICAL_ALIGNMENT_CENTER;
  63902. /** HORIZONTAL_ALIGNMENT_LEFT */
  63903. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  63904. /** HORIZONTAL_ALIGNMENT_RIGHT */
  63905. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  63906. /** HORIZONTAL_ALIGNMENT_CENTER */
  63907. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  63908. /** VERTICAL_ALIGNMENT_TOP */
  63909. static readonly VERTICAL_ALIGNMENT_TOP: number;
  63910. /** VERTICAL_ALIGNMENT_BOTTOM */
  63911. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  63912. /** VERTICAL_ALIGNMENT_CENTER */
  63913. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  63914. private static _FontHeightSizes;
  63915. /** @hidden */ private static _GetFontOffset(font: string): {
  63916. ascent: number;
  63917. height: number;
  63918. descent: number;
  63919. };
  63920. /**
  63921. * Creates a stack panel that can be used to render headers
  63922. * @param control defines the control to associate with the header
  63923. * @param text defines the text of the header
  63924. * @param size defines the size of the header
  63925. * @param options defines options used to configure the header
  63926. * @returns a new StackPanel
  63927. * @ignore
  63928. * @hidden
  63929. */
  63930. static AddHeader: (control: Control, text: string, size: string | number, options: {
  63931. isHorizontal: boolean;
  63932. controlFirst: boolean;
  63933. }) => any;
  63934. /** @hidden */
  63935. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  63936. }
  63937. }
  63938. declare module BABYLON.GUI {
  63939. /**
  63940. * Root class for 2D containers
  63941. * @see http://doc.babylonjs.com/how_to/gui#containers
  63942. */
  63943. export class Container extends Control {
  63944. name?: string | undefined;
  63945. /** @hidden */
  63946. protected _children: Control[];
  63947. /** @hidden */
  63948. protected _measureForChildren: Measure;
  63949. /** @hidden */
  63950. protected _background: string;
  63951. /** @hidden */
  63952. protected _adaptWidthToChildren: boolean;
  63953. /** @hidden */
  63954. protected _adaptHeightToChildren: boolean;
  63955. /**
  63956. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  63957. */
  63958. logLayoutCycleErrors: boolean;
  63959. /**
  63960. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  63961. */
  63962. maxLayoutCycle: number;
  63963. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  63964. adaptHeightToChildren: boolean;
  63965. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  63966. adaptWidthToChildren: boolean;
  63967. /** Gets or sets background color */
  63968. background: string;
  63969. /** Gets the list of children */
  63970. readonly children: Control[];
  63971. /**
  63972. * Creates a new Container
  63973. * @param name defines the name of the container
  63974. */
  63975. constructor(name?: string | undefined);
  63976. protected _getTypeName(): string; private _flagDescendantsAsMatrixDirty(): void;
  63977. /**
  63978. * Gets a child using its name
  63979. * @param name defines the child name to look for
  63980. * @returns the child control if found
  63981. */
  63982. getChildByName(name: string): BABYLON.Nullable<Control>;
  63983. /**
  63984. * Gets a child using its type and its name
  63985. * @param name defines the child name to look for
  63986. * @param type defines the child type to look for
  63987. * @returns the child control if found
  63988. */
  63989. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  63990. /**
  63991. * Search for a specific control in children
  63992. * @param control defines the control to look for
  63993. * @returns true if the control is in child list
  63994. */
  63995. containsControl(control: Control): boolean;
  63996. /**
  63997. * Adds a new control to the current container
  63998. * @param control defines the control to add
  63999. * @returns the current container
  64000. */
  64001. addControl(control: BABYLON.Nullable<Control>): Container;
  64002. /**
  64003. * Removes all controls from the current container
  64004. * @returns the current container
  64005. */
  64006. clearControls(): Container;
  64007. /**
  64008. * Removes a control from the current container
  64009. * @param control defines the control to remove
  64010. * @returns the current container
  64011. */
  64012. removeControl(control: Control): Container;
  64013. /** @hidden */ private _reOrderControl(control: Control): void;
  64014. /** @hidden */ private _offsetLeft(offset: number): void;
  64015. /** @hidden */ private _offsetTop(offset: number): void;
  64016. /** @hidden */ private _markAllAsDirty(): void;
  64017. /** @hidden */
  64018. protected _localDraw(context: CanvasRenderingContext2D): void;
  64019. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  64020. /** @hidden */
  64021. protected _beforeLayout(): void;
  64022. /** @hidden */
  64023. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64024. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64025. protected _postMeasure(): void;
  64026. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  64027. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64028. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64029. /** @hidden */
  64030. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64031. /** Releases associated resources */
  64032. dispose(): void;
  64033. }
  64034. }
  64035. declare module BABYLON.GUI {
  64036. /** Class used to create rectangle container */
  64037. export class Rectangle extends Container {
  64038. name?: string | undefined;
  64039. private _thickness;
  64040. private _cornerRadius;
  64041. /** Gets or sets border thickness */
  64042. thickness: number;
  64043. /** Gets or sets the corner radius angle */
  64044. cornerRadius: number;
  64045. /**
  64046. * Creates a new Rectangle
  64047. * @param name defines the control name
  64048. */
  64049. constructor(name?: string | undefined);
  64050. protected _getTypeName(): string;
  64051. protected _localDraw(context: CanvasRenderingContext2D): void;
  64052. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64053. private _drawRoundedRect;
  64054. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64055. }
  64056. }
  64057. declare module BABYLON.GUI {
  64058. /**
  64059. * Enum that determines the text-wrapping mode to use.
  64060. */
  64061. export enum TextWrapping {
  64062. /**
  64063. * Clip the text when it's larger than Control.width; this is the default mode.
  64064. */
  64065. Clip = 0,
  64066. /**
  64067. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  64068. */
  64069. WordWrap = 1,
  64070. /**
  64071. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  64072. */
  64073. Ellipsis = 2
  64074. }
  64075. /**
  64076. * Class used to create text block control
  64077. */
  64078. export class TextBlock extends Control {
  64079. /**
  64080. * Defines the name of the control
  64081. */
  64082. name?: string | undefined;
  64083. private _text;
  64084. private _textWrapping;
  64085. private _textHorizontalAlignment;
  64086. private _textVerticalAlignment;
  64087. private _lines;
  64088. private _resizeToFit;
  64089. private _lineSpacing;
  64090. private _outlineWidth;
  64091. private _outlineColor;
  64092. /**
  64093. * An event triggered after the text is changed
  64094. */
  64095. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  64096. /**
  64097. * An event triggered after the text was broken up into lines
  64098. */
  64099. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  64100. /**
  64101. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  64102. */
  64103. readonly lines: any[];
  64104. /**
  64105. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64106. */
  64107. /**
  64108. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64109. */
  64110. resizeToFit: boolean;
  64111. /**
  64112. * Gets or sets a boolean indicating if text must be wrapped
  64113. */
  64114. /**
  64115. * Gets or sets a boolean indicating if text must be wrapped
  64116. */
  64117. textWrapping: TextWrapping | boolean;
  64118. /**
  64119. * Gets or sets text to display
  64120. */
  64121. /**
  64122. * Gets or sets text to display
  64123. */
  64124. text: string;
  64125. /**
  64126. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64127. */
  64128. /**
  64129. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64130. */
  64131. textHorizontalAlignment: number;
  64132. /**
  64133. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64134. */
  64135. /**
  64136. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64137. */
  64138. textVerticalAlignment: number;
  64139. /**
  64140. * Gets or sets line spacing value
  64141. */
  64142. /**
  64143. * Gets or sets line spacing value
  64144. */
  64145. lineSpacing: string | number;
  64146. /**
  64147. * Gets or sets outlineWidth of the text to display
  64148. */
  64149. /**
  64150. * Gets or sets outlineWidth of the text to display
  64151. */
  64152. outlineWidth: number;
  64153. /**
  64154. * Gets or sets outlineColor of the text to display
  64155. */
  64156. /**
  64157. * Gets or sets outlineColor of the text to display
  64158. */
  64159. outlineColor: string;
  64160. /**
  64161. * Creates a new TextBlock object
  64162. * @param name defines the name of the control
  64163. * @param text defines the text to display (emptry string by default)
  64164. */
  64165. constructor(
  64166. /**
  64167. * Defines the name of the control
  64168. */
  64169. name?: string | undefined, text?: string);
  64170. protected _getTypeName(): string;
  64171. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64172. private _drawText;
  64173. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  64174. protected _applyStates(context: CanvasRenderingContext2D): void;
  64175. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  64176. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  64177. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  64178. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  64179. protected _renderLines(context: CanvasRenderingContext2D): void;
  64180. /**
  64181. * Given a width constraint applied on the text block, find the expected height
  64182. * @returns expected height
  64183. */
  64184. computeExpectedHeight(): number;
  64185. dispose(): void;
  64186. }
  64187. }
  64188. declare module BABYLON.GUI {
  64189. /**
  64190. * Class used to create 2D images
  64191. */
  64192. export class Image extends Control {
  64193. name?: string | undefined;
  64194. private static _WorkingCanvas;
  64195. private _domImage;
  64196. private _imageWidth;
  64197. private _imageHeight;
  64198. private _loaded;
  64199. private _stretch;
  64200. private _source;
  64201. private _autoScale;
  64202. private _sourceLeft;
  64203. private _sourceTop;
  64204. private _sourceWidth;
  64205. private _sourceHeight;
  64206. private _cellWidth;
  64207. private _cellHeight;
  64208. private _cellId;
  64209. private _populateNinePatchSlicesFromImage;
  64210. private _sliceLeft;
  64211. private _sliceRight;
  64212. private _sliceTop;
  64213. private _sliceBottom;
  64214. private _detectPointerOnOpaqueOnly;
  64215. /**
  64216. * BABYLON.Observable notified when the content is loaded
  64217. */
  64218. onImageLoadedObservable: BABYLON.Observable<Image>;
  64219. /**
  64220. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  64221. */
  64222. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  64223. /**
  64224. * Gets a boolean indicating that the content is loaded
  64225. */
  64226. readonly isLoaded: boolean;
  64227. /**
  64228. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  64229. */
  64230. populateNinePatchSlicesFromImage: boolean;
  64231. /**
  64232. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  64233. * Beware using this as this will comsume more memory as the image has to be stored twice
  64234. */
  64235. detectPointerOnOpaqueOnly: boolean;
  64236. /**
  64237. * Gets or sets the left value for slicing (9-patch)
  64238. */
  64239. sliceLeft: number;
  64240. /**
  64241. * Gets or sets the right value for slicing (9-patch)
  64242. */
  64243. sliceRight: number;
  64244. /**
  64245. * Gets or sets the top value for slicing (9-patch)
  64246. */
  64247. sliceTop: number;
  64248. /**
  64249. * Gets or sets the bottom value for slicing (9-patch)
  64250. */
  64251. sliceBottom: number;
  64252. /**
  64253. * Gets or sets the left coordinate in the source image
  64254. */
  64255. sourceLeft: number;
  64256. /**
  64257. * Gets or sets the top coordinate in the source image
  64258. */
  64259. sourceTop: number;
  64260. /**
  64261. * Gets or sets the width to capture in the source image
  64262. */
  64263. sourceWidth: number;
  64264. /**
  64265. * Gets or sets the height to capture in the source image
  64266. */
  64267. sourceHeight: number;
  64268. /**
  64269. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  64270. * @see http://doc.babylonjs.com/how_to/gui#image
  64271. */
  64272. autoScale: boolean;
  64273. /** Gets or sets the streching mode used by the image */
  64274. stretch: number;
  64275. /**
  64276. * Gets or sets the internal DOM image used to render the control
  64277. */
  64278. domImage: HTMLImageElement;
  64279. private _onImageLoaded;
  64280. private _extractNinePatchSliceDataFromImage;
  64281. /**
  64282. * Gets or sets image source url
  64283. */
  64284. source: BABYLON.Nullable<string>;
  64285. /**
  64286. * Checks for svg document with icon id present
  64287. */
  64288. private _svgCheck;
  64289. /**
  64290. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  64291. * given external svg file and icon id
  64292. */
  64293. private _getSVGAttribs;
  64294. /**
  64295. * Gets or sets the cell width to use when animation sheet is enabled
  64296. * @see http://doc.babylonjs.com/how_to/gui#image
  64297. */
  64298. cellWidth: number;
  64299. /**
  64300. * Gets or sets the cell height to use when animation sheet is enabled
  64301. * @see http://doc.babylonjs.com/how_to/gui#image
  64302. */
  64303. cellHeight: number;
  64304. /**
  64305. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  64306. * @see http://doc.babylonjs.com/how_to/gui#image
  64307. */
  64308. cellId: number;
  64309. /**
  64310. * Creates a new Image
  64311. * @param name defines the control name
  64312. * @param url defines the image url
  64313. */
  64314. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  64315. /**
  64316. * Tests if a given coordinates belong to the current control
  64317. * @param x defines x coordinate to test
  64318. * @param y defines y coordinate to test
  64319. * @returns true if the coordinates are inside the control
  64320. */
  64321. contains(x: number, y: number): boolean;
  64322. protected _getTypeName(): string;
  64323. /** Force the control to synchronize with its content */
  64324. synchronizeSizeWithContent(): void;
  64325. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64326. private _prepareWorkingCanvasForOpaqueDetection;
  64327. private _drawImage; private _draw(context: CanvasRenderingContext2D): void;
  64328. private _renderCornerPatch;
  64329. private _renderNinePatch;
  64330. dispose(): void;
  64331. /** STRETCH_NONE */
  64332. static readonly STRETCH_NONE: number;
  64333. /** STRETCH_FILL */
  64334. static readonly STRETCH_FILL: number;
  64335. /** STRETCH_UNIFORM */
  64336. static readonly STRETCH_UNIFORM: number;
  64337. /** STRETCH_EXTEND */
  64338. static readonly STRETCH_EXTEND: number;
  64339. /** NINE_PATCH */
  64340. static readonly STRETCH_NINE_PATCH: number;
  64341. }
  64342. }
  64343. declare module BABYLON.GUI {
  64344. /**
  64345. * Class used to create 2D buttons
  64346. */
  64347. export class Button extends Rectangle {
  64348. name?: string | undefined;
  64349. /**
  64350. * Function called to generate a pointer enter animation
  64351. */
  64352. pointerEnterAnimation: () => void;
  64353. /**
  64354. * Function called to generate a pointer out animation
  64355. */
  64356. pointerOutAnimation: () => void;
  64357. /**
  64358. * Function called to generate a pointer down animation
  64359. */
  64360. pointerDownAnimation: () => void;
  64361. /**
  64362. * Function called to generate a pointer up animation
  64363. */
  64364. pointerUpAnimation: () => void;
  64365. /**
  64366. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  64367. */
  64368. delegatePickingToChildren: boolean;
  64369. private _image;
  64370. /**
  64371. * Returns the image part of the button (if any)
  64372. */
  64373. readonly image: BABYLON.Nullable<Image>;
  64374. private _textBlock;
  64375. /**
  64376. * Returns the image part of the button (if any)
  64377. */
  64378. readonly textBlock: BABYLON.Nullable<TextBlock>;
  64379. /**
  64380. * Creates a new Button
  64381. * @param name defines the name of the button
  64382. */
  64383. constructor(name?: string | undefined);
  64384. protected _getTypeName(): string;
  64385. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64386. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  64387. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  64388. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64389. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64390. /**
  64391. * Creates a new button made with an image and a text
  64392. * @param name defines the name of the button
  64393. * @param text defines the text of the button
  64394. * @param imageUrl defines the url of the image
  64395. * @returns a new Button
  64396. */
  64397. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  64398. /**
  64399. * Creates a new button made with an image
  64400. * @param name defines the name of the button
  64401. * @param imageUrl defines the url of the image
  64402. * @returns a new Button
  64403. */
  64404. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  64405. /**
  64406. * Creates a new button made with a text
  64407. * @param name defines the name of the button
  64408. * @param text defines the text of the button
  64409. * @returns a new Button
  64410. */
  64411. static CreateSimpleButton(name: string, text: string): Button;
  64412. /**
  64413. * Creates a new button made with an image and a centered text
  64414. * @param name defines the name of the button
  64415. * @param text defines the text of the button
  64416. * @param imageUrl defines the url of the image
  64417. * @returns a new Button
  64418. */
  64419. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  64420. }
  64421. }
  64422. declare module BABYLON.GUI {
  64423. /**
  64424. * Class used to create a 2D stack panel container
  64425. */
  64426. export class StackPanel extends Container {
  64427. name?: string | undefined;
  64428. private _isVertical;
  64429. private _manualWidth;
  64430. private _manualHeight;
  64431. private _doNotTrackManualChanges;
  64432. /**
  64433. * Gets or sets a boolean indicating that layou warnings should be ignored
  64434. */
  64435. ignoreLayoutWarnings: boolean;
  64436. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  64437. isVertical: boolean;
  64438. /**
  64439. * Gets or sets panel width.
  64440. * This value should not be set when in horizontal mode as it will be computed automatically
  64441. */
  64442. width: string | number;
  64443. /**
  64444. * Gets or sets panel height.
  64445. * This value should not be set when in vertical mode as it will be computed automatically
  64446. */
  64447. height: string | number;
  64448. /**
  64449. * Creates a new StackPanel
  64450. * @param name defines control name
  64451. */
  64452. constructor(name?: string | undefined);
  64453. protected _getTypeName(): string;
  64454. /** @hidden */
  64455. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64456. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64457. protected _postMeasure(): void;
  64458. }
  64459. }
  64460. declare module BABYLON.GUI {
  64461. /**
  64462. * Class used to represent a 2D checkbox
  64463. */
  64464. export class Checkbox extends Control {
  64465. name?: string | undefined;
  64466. private _isChecked;
  64467. private _background;
  64468. private _checkSizeRatio;
  64469. private _thickness;
  64470. /** Gets or sets border thickness */
  64471. thickness: number;
  64472. /**
  64473. * BABYLON.Observable raised when isChecked property changes
  64474. */
  64475. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  64476. /** Gets or sets a value indicating the ratio between overall size and check size */
  64477. checkSizeRatio: number;
  64478. /** Gets or sets background color */
  64479. background: string;
  64480. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  64481. isChecked: boolean;
  64482. /**
  64483. * Creates a new CheckBox
  64484. * @param name defines the control name
  64485. */
  64486. constructor(name?: string | undefined);
  64487. protected _getTypeName(): string;
  64488. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  64489. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64490. /**
  64491. * Utility function to easily create a checkbox with a header
  64492. * @param title defines the label to use for the header
  64493. * @param onValueChanged defines the callback to call when value changes
  64494. * @returns a StackPanel containing the checkbox and a textBlock
  64495. */
  64496. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  64497. }
  64498. }
  64499. declare module BABYLON.GUI {
  64500. /**
  64501. * Class used to store key control properties
  64502. */
  64503. export class KeyPropertySet {
  64504. /** Width */
  64505. width?: string;
  64506. /** Height */
  64507. height?: string;
  64508. /** Left padding */
  64509. paddingLeft?: string;
  64510. /** Right padding */
  64511. paddingRight?: string;
  64512. /** Top padding */
  64513. paddingTop?: string;
  64514. /** Bottom padding */
  64515. paddingBottom?: string;
  64516. /** Foreground color */
  64517. color?: string;
  64518. /** Background color */
  64519. background?: string;
  64520. }
  64521. /**
  64522. * Class used to create virtual keyboard
  64523. */
  64524. export class VirtualKeyboard extends StackPanel {
  64525. /** BABYLON.Observable raised when a key is pressed */
  64526. onKeyPressObservable: BABYLON.Observable<string>;
  64527. /** Gets or sets default key button width */
  64528. defaultButtonWidth: string;
  64529. /** Gets or sets default key button height */
  64530. defaultButtonHeight: string;
  64531. /** Gets or sets default key button left padding */
  64532. defaultButtonPaddingLeft: string;
  64533. /** Gets or sets default key button right padding */
  64534. defaultButtonPaddingRight: string;
  64535. /** Gets or sets default key button top padding */
  64536. defaultButtonPaddingTop: string;
  64537. /** Gets or sets default key button bottom padding */
  64538. defaultButtonPaddingBottom: string;
  64539. /** Gets or sets default key button foreground color */
  64540. defaultButtonColor: string;
  64541. /** Gets or sets default key button background color */
  64542. defaultButtonBackground: string;
  64543. /** Gets or sets shift button foreground color */
  64544. shiftButtonColor: string;
  64545. /** Gets or sets shift button thickness*/
  64546. selectedShiftThickness: number;
  64547. /** Gets shift key state */
  64548. shiftState: number;
  64549. protected _getTypeName(): string;
  64550. private _createKey;
  64551. /**
  64552. * Adds a new row of keys
  64553. * @param keys defines the list of keys to add
  64554. * @param propertySets defines the associated property sets
  64555. */
  64556. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  64557. /**
  64558. * Set the shift key to a specific state
  64559. * @param shiftState defines the new shift state
  64560. */
  64561. applyShiftState(shiftState: number): void;
  64562. private _currentlyConnectedInputText;
  64563. private _connectedInputTexts;
  64564. private _onKeyPressObserver;
  64565. /** Gets the input text control currently attached to the keyboard */
  64566. readonly connectedInputText: BABYLON.Nullable<InputText>;
  64567. /**
  64568. * Connects the keyboard with an input text control
  64569. *
  64570. * @param input defines the target control
  64571. */
  64572. connect(input: InputText): void;
  64573. /**
  64574. * Disconnects the keyboard from connected InputText controls
  64575. *
  64576. * @param input optionally defines a target control, otherwise all are disconnected
  64577. */
  64578. disconnect(input?: InputText): void;
  64579. private _removeConnectedInputObservables;
  64580. /**
  64581. * Release all resources
  64582. */
  64583. dispose(): void;
  64584. /**
  64585. * Creates a new keyboard using a default layout
  64586. *
  64587. * @param name defines control name
  64588. * @returns a new VirtualKeyboard
  64589. */
  64590. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  64591. }
  64592. }
  64593. declare module BABYLON.GUI {
  64594. /**
  64595. * Class used to create input text control
  64596. */
  64597. export class InputText extends Control implements IFocusableControl {
  64598. name?: string | undefined;
  64599. private _text;
  64600. private _placeholderText;
  64601. private _background;
  64602. private _focusedBackground;
  64603. private _focusedColor;
  64604. private _placeholderColor;
  64605. private _thickness;
  64606. private _margin;
  64607. private _autoStretchWidth;
  64608. private _maxWidth;
  64609. private _isFocused;
  64610. private _blinkTimeout;
  64611. private _blinkIsEven;
  64612. private _cursorOffset;
  64613. private _scrollLeft;
  64614. private _textWidth;
  64615. private _clickedCoordinate;
  64616. private _deadKey;
  64617. private _addKey;
  64618. private _currentKey;
  64619. private _isTextHighlightOn;
  64620. private _textHighlightColor;
  64621. private _highligherOpacity;
  64622. private _highlightedText;
  64623. private _startHighlightIndex;
  64624. private _endHighlightIndex;
  64625. private _cursorIndex;
  64626. private _onFocusSelectAll;
  64627. private _isPointerDown;
  64628. private _onClipboardObserver;
  64629. private _onPointerDblTapObserver;
  64630. /** @hidden */ private _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  64631. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  64632. promptMessage: string;
  64633. /** Force disable prompt on mobile device */
  64634. disableMobilePrompt: boolean;
  64635. /** BABYLON.Observable raised when the text changes */
  64636. onTextChangedObservable: BABYLON.Observable<InputText>;
  64637. /** BABYLON.Observable raised just before an entered character is to be added */
  64638. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  64639. /** BABYLON.Observable raised when the control gets the focus */
  64640. onFocusObservable: BABYLON.Observable<InputText>;
  64641. /** BABYLON.Observable raised when the control loses the focus */
  64642. onBlurObservable: BABYLON.Observable<InputText>;
  64643. /**Observable raised when the text is highlighted */
  64644. onTextHighlightObservable: BABYLON.Observable<InputText>;
  64645. /**Observable raised when copy event is triggered */
  64646. onTextCopyObservable: BABYLON.Observable<InputText>;
  64647. /** BABYLON.Observable raised when cut event is triggered */
  64648. onTextCutObservable: BABYLON.Observable<InputText>;
  64649. /** BABYLON.Observable raised when paste event is triggered */
  64650. onTextPasteObservable: BABYLON.Observable<InputText>;
  64651. /** BABYLON.Observable raised when a key event was processed */
  64652. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  64653. /** Gets or sets the maximum width allowed by the control */
  64654. maxWidth: string | number;
  64655. /** Gets the maximum width allowed by the control in pixels */
  64656. readonly maxWidthInPixels: number;
  64657. /** Gets or sets the text highlighter transparency; default: 0.4 */
  64658. highligherOpacity: number;
  64659. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  64660. onFocusSelectAll: boolean;
  64661. /** Gets or sets the text hightlight color */
  64662. textHighlightColor: string;
  64663. /** Gets or sets control margin */
  64664. margin: string;
  64665. /** Gets control margin in pixels */
  64666. readonly marginInPixels: number;
  64667. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  64668. autoStretchWidth: boolean;
  64669. /** Gets or sets border thickness */
  64670. thickness: number;
  64671. /** Gets or sets the background color when focused */
  64672. focusedBackground: string;
  64673. /** Gets or sets the background color when focused */
  64674. focusedColor: string;
  64675. /** Gets or sets the background color */
  64676. background: string;
  64677. /** Gets or sets the placeholder color */
  64678. placeholderColor: string;
  64679. /** Gets or sets the text displayed when the control is empty */
  64680. placeholderText: string;
  64681. /** Gets or sets the dead key flag */
  64682. deadKey: boolean;
  64683. /** Gets or sets the highlight text */
  64684. highlightedText: string;
  64685. /** Gets or sets if the current key should be added */
  64686. addKey: boolean;
  64687. /** Gets or sets the value of the current key being entered */
  64688. currentKey: string;
  64689. /** Gets or sets the text displayed in the control */
  64690. text: string;
  64691. /** Gets or sets control width */
  64692. width: string | number;
  64693. /**
  64694. * Creates a new InputText
  64695. * @param name defines the control name
  64696. * @param text defines the text of the control
  64697. */
  64698. constructor(name?: string | undefined, text?: string);
  64699. /** @hidden */
  64700. onBlur(): void;
  64701. /** @hidden */
  64702. onFocus(): void;
  64703. protected _getTypeName(): string;
  64704. /**
  64705. * Function called to get the list of controls that should not steal the focus from this control
  64706. * @returns an array of controls
  64707. */
  64708. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  64709. /** @hidden */
  64710. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  64711. /** @hidden */
  64712. private _updateValueFromCursorIndex;
  64713. /** @hidden */
  64714. private _processDblClick;
  64715. /** @hidden */
  64716. private _selectAllText;
  64717. /**
  64718. * Handles the keyboard event
  64719. * @param evt Defines the KeyboardEvent
  64720. */
  64721. processKeyboard(evt: KeyboardEvent): void;
  64722. /** @hidden */
  64723. private _onCopyText;
  64724. /** @hidden */
  64725. private _onCutText;
  64726. /** @hidden */
  64727. 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;
  64728. protected _beforeRenderText(text: string): string;
  64729. dispose(): void;
  64730. }
  64731. }
  64732. declare module BABYLON.GUI {
  64733. /**
  64734. * Class used to create a 2D grid container
  64735. */
  64736. export class Grid extends Container {
  64737. name?: string | undefined;
  64738. private _rowDefinitions;
  64739. private _columnDefinitions;
  64740. private _cells;
  64741. private _childControls;
  64742. /**
  64743. * Gets the number of columns
  64744. */
  64745. readonly columnCount: number;
  64746. /**
  64747. * Gets the number of rows
  64748. */
  64749. readonly rowCount: number;
  64750. /** Gets the list of children */
  64751. readonly children: Control[];
  64752. /** Gets the list of cells (e.g. the containers) */
  64753. readonly cells: {
  64754. [key: string]: Container;
  64755. };
  64756. /**
  64757. * Gets the definition of a specific row
  64758. * @param index defines the index of the row
  64759. * @returns the row definition
  64760. */
  64761. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64762. /**
  64763. * Gets the definition of a specific column
  64764. * @param index defines the index of the column
  64765. * @returns the column definition
  64766. */
  64767. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64768. /**
  64769. * Adds a new row to the grid
  64770. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64771. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  64772. * @returns the current grid
  64773. */
  64774. addRowDefinition(height: number, isPixel?: boolean): Grid;
  64775. /**
  64776. * Adds a new column to the grid
  64777. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64778. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64779. * @returns the current grid
  64780. */
  64781. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  64782. /**
  64783. * Update a row definition
  64784. * @param index defines the index of the row to update
  64785. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64786. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  64787. * @returns the current grid
  64788. */
  64789. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  64790. /**
  64791. * Update a column definition
  64792. * @param index defines the index of the column to update
  64793. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64794. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64795. * @returns the current grid
  64796. */
  64797. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  64798. /**
  64799. * Gets the list of children stored in a specific cell
  64800. * @param row defines the row to check
  64801. * @param column defines the column to check
  64802. * @returns the list of controls
  64803. */
  64804. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  64805. /**
  64806. * Gets a string representing the child cell info (row x column)
  64807. * @param child defines the control to get info from
  64808. * @returns a string containing the child cell info (row x column)
  64809. */
  64810. getChildCellInfo(child: Control): string;
  64811. private _removeCell;
  64812. private _offsetCell;
  64813. /**
  64814. * Remove a column definition at specified index
  64815. * @param index defines the index of the column to remove
  64816. * @returns the current grid
  64817. */
  64818. removeColumnDefinition(index: number): Grid;
  64819. /**
  64820. * Remove a row definition at specified index
  64821. * @param index defines the index of the row to remove
  64822. * @returns the current grid
  64823. */
  64824. removeRowDefinition(index: number): Grid;
  64825. /**
  64826. * Adds a new control to the current grid
  64827. * @param control defines the control to add
  64828. * @param row defines the row where to add the control (0 by default)
  64829. * @param column defines the column where to add the control (0 by default)
  64830. * @returns the current grid
  64831. */
  64832. addControl(control: Control, row?: number, column?: number): Grid;
  64833. /**
  64834. * Removes a control from the current container
  64835. * @param control defines the control to remove
  64836. * @returns the current container
  64837. */
  64838. removeControl(control: Control): Container;
  64839. /**
  64840. * Creates a new Grid
  64841. * @param name defines control name
  64842. */
  64843. constructor(name?: string | undefined);
  64844. protected _getTypeName(): string;
  64845. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  64846. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _flagDescendantsAsMatrixDirty(): void; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64847. /** Releases associated resources */
  64848. dispose(): void;
  64849. }
  64850. }
  64851. declare module BABYLON.GUI {
  64852. /** Class used to create color pickers */
  64853. export class ColorPicker extends Control {
  64854. name?: string | undefined;
  64855. private static _Epsilon;
  64856. private _colorWheelCanvas;
  64857. private _value;
  64858. private _tmpColor;
  64859. private _pointerStartedOnSquare;
  64860. private _pointerStartedOnWheel;
  64861. private _squareLeft;
  64862. private _squareTop;
  64863. private _squareSize;
  64864. private _h;
  64865. private _s;
  64866. private _v;
  64867. private _lastPointerDownID;
  64868. /**
  64869. * BABYLON.Observable raised when the value changes
  64870. */
  64871. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  64872. /** Gets or sets the color of the color picker */
  64873. value: BABYLON.Color3;
  64874. /**
  64875. * Gets or sets control width
  64876. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64877. */
  64878. width: string | number;
  64879. /**
  64880. * Gets or sets control height
  64881. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64882. */
  64883. /** Gets or sets control height */
  64884. height: string | number;
  64885. /** Gets or sets control size */
  64886. size: string | number;
  64887. /**
  64888. * Creates a new ColorPicker
  64889. * @param name defines the control name
  64890. */
  64891. constructor(name?: string | undefined);
  64892. protected _getTypeName(): string;
  64893. /** @hidden */
  64894. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64895. private _updateSquareProps;
  64896. private _drawGradientSquare;
  64897. private _drawCircle;
  64898. private _createColorWheelCanvas;
  64899. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  64900. private _pointerIsDown;
  64901. private _updateValueFromPointer;
  64902. private _isPointOnSquare;
  64903. 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;
  64904. /**
  64905. * This function expands the color picker by creating a color picker dialog with manual
  64906. * color value input and the ability to save colors into an array to be used later in
  64907. * subsequent launches of the dialogue.
  64908. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  64909. * @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.
  64910. * @returns picked color as a hex string and the saved colors array as hex strings.
  64911. */
  64912. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  64913. pickerWidth?: string;
  64914. pickerHeight?: string;
  64915. headerHeight?: string;
  64916. lastColor?: string;
  64917. swatchLimit?: number;
  64918. numSwatchesPerLine?: number;
  64919. savedColors?: Array<string>;
  64920. }): Promise<{
  64921. savedColors?: string[];
  64922. pickedColor: string;
  64923. }>;
  64924. }
  64925. }
  64926. declare module BABYLON.GUI {
  64927. /** Class used to create 2D ellipse containers */
  64928. export class Ellipse extends Container {
  64929. name?: string | undefined;
  64930. private _thickness;
  64931. /** Gets or sets border thickness */
  64932. thickness: number;
  64933. /**
  64934. * Creates a new Ellipse
  64935. * @param name defines the control name
  64936. */
  64937. constructor(name?: string | undefined);
  64938. protected _getTypeName(): string;
  64939. protected _localDraw(context: CanvasRenderingContext2D): void;
  64940. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64941. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64942. }
  64943. }
  64944. declare module BABYLON.GUI {
  64945. /**
  64946. * Class used to create a password control
  64947. */
  64948. export class InputPassword extends InputText {
  64949. protected _beforeRenderText(text: string): string;
  64950. }
  64951. }
  64952. declare module BABYLON.GUI {
  64953. /** Class used to render 2D lines */
  64954. export class Line extends Control {
  64955. name?: string | undefined;
  64956. private _lineWidth;
  64957. private _x1;
  64958. private _y1;
  64959. private _x2;
  64960. private _y2;
  64961. private _dash;
  64962. private _connectedControl;
  64963. private _connectedControlDirtyObserver;
  64964. /** Gets or sets the dash pattern */
  64965. dash: Array<number>;
  64966. /** Gets or sets the control connected with the line end */
  64967. connectedControl: Control;
  64968. /** Gets or sets start coordinates on X axis */
  64969. x1: string | number;
  64970. /** Gets or sets start coordinates on Y axis */
  64971. y1: string | number;
  64972. /** Gets or sets end coordinates on X axis */
  64973. x2: string | number;
  64974. /** Gets or sets end coordinates on Y axis */
  64975. y2: string | number;
  64976. /** Gets or sets line width */
  64977. lineWidth: number;
  64978. /** Gets or sets horizontal alignment */
  64979. horizontalAlignment: number;
  64980. /** Gets or sets vertical alignment */
  64981. verticalAlignment: number;
  64982. private readonly _effectiveX2;
  64983. private readonly _effectiveY2;
  64984. /**
  64985. * Creates a new Line
  64986. * @param name defines the control name
  64987. */
  64988. constructor(name?: string | undefined);
  64989. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _measure(): void;
  64990. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64991. /**
  64992. * Move one end of the line given 3D cartesian coordinates.
  64993. * @param position Targeted world position
  64994. * @param scene BABYLON.Scene
  64995. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  64996. */
  64997. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  64998. /**
  64999. * Move one end of the line to a position in screen absolute space.
  65000. * @param projectedPosition Position in screen absolute space (X, Y)
  65001. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65002. */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  65003. }
  65004. }
  65005. declare module BABYLON.GUI {
  65006. /**
  65007. * Class used to store a point for a MultiLine object.
  65008. * The point can be pure 2D coordinates, a mesh or a control
  65009. */
  65010. export class MultiLinePoint {
  65011. private _multiLine;
  65012. private _x;
  65013. private _y;
  65014. private _control;
  65015. private _mesh;
  65016. private _controlObserver;
  65017. private _meshObserver;
  65018. /** @hidden */ private _point: BABYLON.Vector2;
  65019. /**
  65020. * Creates a new MultiLinePoint
  65021. * @param multiLine defines the source MultiLine object
  65022. */
  65023. constructor(multiLine: MultiLine);
  65024. /** Gets or sets x coordinate */
  65025. x: string | number;
  65026. /** Gets or sets y coordinate */
  65027. y: string | number;
  65028. /** Gets or sets the control associated with this point */
  65029. control: BABYLON.Nullable<Control>;
  65030. /** Gets or sets the mesh associated with this point */
  65031. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65032. /** Resets links */
  65033. resetLinks(): void;
  65034. /**
  65035. * Gets a translation vector
  65036. * @returns the translation vector
  65037. */
  65038. translate(): BABYLON.Vector2;
  65039. private _translatePoint;
  65040. /** Release associated resources */
  65041. dispose(): void;
  65042. }
  65043. }
  65044. declare module BABYLON.GUI {
  65045. /**
  65046. * Class used to create multi line control
  65047. */
  65048. export class MultiLine extends Control {
  65049. name?: string | undefined;
  65050. private _lineWidth;
  65051. private _dash;
  65052. private _points;
  65053. private _minX;
  65054. private _minY;
  65055. private _maxX;
  65056. private _maxY;
  65057. /**
  65058. * Creates a new MultiLine
  65059. * @param name defines the control name
  65060. */
  65061. constructor(name?: string | undefined);
  65062. /** Gets or sets dash pattern */
  65063. dash: Array<number>;
  65064. /**
  65065. * Gets point stored at specified index
  65066. * @param index defines the index to look for
  65067. * @returns the requested point if found
  65068. */
  65069. getAt(index: number): MultiLinePoint;
  65070. /** Function called when a point is updated */
  65071. onPointUpdate: () => void;
  65072. /**
  65073. * Adds new points to the point collection
  65074. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  65075. * @returns the list of created MultiLinePoint
  65076. */
  65077. add(...items: (AbstractMesh | Control | {
  65078. x: string | number;
  65079. y: string | number;
  65080. })[]): MultiLinePoint[];
  65081. /**
  65082. * Adds a new point to the point collection
  65083. * @param item defines the item (mesh, control or 2d coordiantes) to add
  65084. * @returns the created MultiLinePoint
  65085. */
  65086. push(item?: (AbstractMesh | Control | {
  65087. x: string | number;
  65088. y: string | number;
  65089. })): MultiLinePoint;
  65090. /**
  65091. * Remove a specific value or point from the active point collection
  65092. * @param value defines the value or point to remove
  65093. */
  65094. remove(value: number | MultiLinePoint): void;
  65095. /**
  65096. * Resets this object to initial state (no point)
  65097. */
  65098. reset(): void;
  65099. /**
  65100. * Resets all links
  65101. */
  65102. resetLinks(): void;
  65103. /** Gets or sets line width */
  65104. lineWidth: number;
  65105. horizontalAlignment: number;
  65106. verticalAlignment: number;
  65107. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  65108. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _measure(): void;
  65109. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65110. dispose(): void;
  65111. }
  65112. }
  65113. declare module BABYLON.GUI {
  65114. /**
  65115. * Class used to create radio button controls
  65116. */
  65117. export class RadioButton extends Control {
  65118. name?: string | undefined;
  65119. private _isChecked;
  65120. private _background;
  65121. private _checkSizeRatio;
  65122. private _thickness;
  65123. /** Gets or sets border thickness */
  65124. thickness: number;
  65125. /** Gets or sets group name */
  65126. group: string;
  65127. /** BABYLON.Observable raised when isChecked is changed */
  65128. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65129. /** Gets or sets a value indicating the ratio between overall size and check size */
  65130. checkSizeRatio: number;
  65131. /** Gets or sets background color */
  65132. background: string;
  65133. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65134. isChecked: boolean;
  65135. /**
  65136. * Creates a new RadioButton
  65137. * @param name defines the control name
  65138. */
  65139. constructor(name?: string | undefined);
  65140. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65141. /**
  65142. * Utility function to easily create a radio button with a header
  65143. * @param title defines the label to use for the header
  65144. * @param group defines the group to use for the radio button
  65145. * @param isChecked defines the initial state of the radio button
  65146. * @param onValueChanged defines the callback to call when value changes
  65147. * @returns a StackPanel containing the radio button and a textBlock
  65148. */
  65149. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  65150. }
  65151. }
  65152. declare module BABYLON.GUI {
  65153. /**
  65154. * Class used to create slider controls
  65155. */
  65156. export class BaseSlider extends Control {
  65157. name?: string | undefined;
  65158. protected _thumbWidth: ValueAndUnit;
  65159. private _minimum;
  65160. private _maximum;
  65161. private _value;
  65162. private _isVertical;
  65163. protected _barOffset: ValueAndUnit;
  65164. private _isThumbClamped;
  65165. protected _displayThumb: boolean;
  65166. private _step;
  65167. private _lastPointerDownID;
  65168. protected _effectiveBarOffset: number;
  65169. protected _renderLeft: number;
  65170. protected _renderTop: number;
  65171. protected _renderWidth: number;
  65172. protected _renderHeight: number;
  65173. protected _backgroundBoxLength: number;
  65174. protected _backgroundBoxThickness: number;
  65175. protected _effectiveThumbThickness: number;
  65176. /** BABYLON.Observable raised when the sldier value changes */
  65177. onValueChangedObservable: BABYLON.Observable<number>;
  65178. /** Gets or sets a boolean indicating if the thumb must be rendered */
  65179. displayThumb: boolean;
  65180. /** Gets or sets a step to apply to values (0 by default) */
  65181. step: number;
  65182. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  65183. barOffset: string | number;
  65184. /** Gets main bar offset in pixels*/
  65185. readonly barOffsetInPixels: number;
  65186. /** Gets or sets thumb width */
  65187. thumbWidth: string | number;
  65188. /** Gets thumb width in pixels */
  65189. readonly thumbWidthInPixels: number;
  65190. /** Gets or sets minimum value */
  65191. minimum: number;
  65192. /** Gets or sets maximum value */
  65193. maximum: number;
  65194. /** Gets or sets current value */
  65195. value: number;
  65196. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  65197. isVertical: boolean;
  65198. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  65199. isThumbClamped: boolean;
  65200. /**
  65201. * Creates a new BaseSlider
  65202. * @param name defines the control name
  65203. */
  65204. constructor(name?: string | undefined);
  65205. protected _getTypeName(): string;
  65206. protected _getThumbPosition(): number;
  65207. protected _getThumbThickness(type: string): number;
  65208. protected _prepareRenderingData(type: string): void;
  65209. private _pointerIsDown;
  65210. /** @hidden */
  65211. 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;
  65212. }
  65213. }
  65214. declare module BABYLON.GUI {
  65215. /**
  65216. * Class used to create slider controls
  65217. */
  65218. export class Slider extends BaseSlider {
  65219. name?: string | undefined;
  65220. private _background;
  65221. private _borderColor;
  65222. private _isThumbCircle;
  65223. protected _displayValueBar: boolean;
  65224. /** Gets or sets a boolean indicating if the value bar must be rendered */
  65225. displayValueBar: boolean;
  65226. /** Gets or sets border color */
  65227. borderColor: string;
  65228. /** Gets or sets background color */
  65229. background: string;
  65230. /** Gets or sets a boolean indicating if the thumb should be round or square */
  65231. isThumbCircle: boolean;
  65232. /**
  65233. * Creates a new Slider
  65234. * @param name defines the control name
  65235. */
  65236. constructor(name?: string | undefined);
  65237. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  65238. }
  65239. }
  65240. declare module BABYLON.GUI {
  65241. /** Class used to create a RadioGroup
  65242. * which contains groups of radio buttons
  65243. */
  65244. export class SelectorGroup {
  65245. /** name of SelectorGroup */
  65246. name: string;
  65247. private _groupPanel;
  65248. private _selectors;
  65249. private _groupHeader;
  65250. /**
  65251. * Creates a new SelectorGroup
  65252. * @param name of group, used as a group heading
  65253. */
  65254. constructor(
  65255. /** name of SelectorGroup */
  65256. name: string);
  65257. /** Gets the groupPanel of the SelectorGroup */
  65258. readonly groupPanel: StackPanel;
  65259. /** Gets the selectors array */
  65260. readonly selectors: StackPanel[];
  65261. /** Gets and sets the group header */
  65262. header: string;
  65263. /** @hidden */
  65264. private _addGroupHeader;
  65265. /** @hidden*/ private _getSelector(selectorNb: number): StackPanel | undefined;
  65266. /** Removes the selector at the given position
  65267. * @param selectorNb the position of the selector within the group
  65268. */
  65269. removeSelector(selectorNb: number): void;
  65270. }
  65271. /** Class used to create a CheckboxGroup
  65272. * which contains groups of checkbox buttons
  65273. */
  65274. export class CheckboxGroup extends SelectorGroup {
  65275. /** Adds a checkbox as a control
  65276. * @param text is the label for the selector
  65277. * @param func is the function called when the Selector is checked
  65278. * @param checked is true when Selector is checked
  65279. */
  65280. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  65281. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  65282. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  65283. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  65284. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65285. }
  65286. /** Class used to create a RadioGroup
  65287. * which contains groups of radio buttons
  65288. */
  65289. export class RadioGroup extends SelectorGroup {
  65290. private _selectNb;
  65291. /** Adds a radio button as a control
  65292. * @param label is the label for the selector
  65293. * @param func is the function called when the Selector is checked
  65294. * @param checked is true when Selector is checked
  65295. */
  65296. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  65297. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  65298. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  65299. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  65300. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65301. }
  65302. /** Class used to create a SliderGroup
  65303. * which contains groups of slider buttons
  65304. */
  65305. export class SliderGroup extends SelectorGroup {
  65306. /**
  65307. * Adds a slider to the SelectorGroup
  65308. * @param label is the label for the SliderBar
  65309. * @param func is the function called when the Slider moves
  65310. * @param unit is a string describing the units used, eg degrees or metres
  65311. * @param min is the minimum value for the Slider
  65312. * @param max is the maximum value for the Slider
  65313. * @param value is the start value for the Slider between min and max
  65314. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  65315. */
  65316. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  65317. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  65318. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  65319. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  65320. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65321. }
  65322. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  65323. * @see http://doc.babylonjs.com/how_to/selector
  65324. */
  65325. export class SelectionPanel extends Rectangle {
  65326. /** name of SelectionPanel */
  65327. name: string;
  65328. /** an array of SelectionGroups */
  65329. groups: SelectorGroup[];
  65330. private _panel;
  65331. private _buttonColor;
  65332. private _buttonBackground;
  65333. private _headerColor;
  65334. private _barColor;
  65335. private _barHeight;
  65336. private _spacerHeight;
  65337. private _labelColor;
  65338. private _groups;
  65339. private _bars;
  65340. /**
  65341. * Creates a new SelectionPanel
  65342. * @param name of SelectionPanel
  65343. * @param groups is an array of SelectionGroups
  65344. */
  65345. constructor(
  65346. /** name of SelectionPanel */
  65347. name: string,
  65348. /** an array of SelectionGroups */
  65349. groups?: SelectorGroup[]);
  65350. protected _getTypeName(): string;
  65351. /** Gets or sets the headerColor */
  65352. headerColor: string;
  65353. private _setHeaderColor;
  65354. /** Gets or sets the button color */
  65355. buttonColor: string;
  65356. private _setbuttonColor;
  65357. /** Gets or sets the label color */
  65358. labelColor: string;
  65359. private _setLabelColor;
  65360. /** Gets or sets the button background */
  65361. buttonBackground: string;
  65362. private _setButtonBackground;
  65363. /** Gets or sets the color of separator bar */
  65364. barColor: string;
  65365. private _setBarColor;
  65366. /** Gets or sets the height of separator bar */
  65367. barHeight: string;
  65368. private _setBarHeight;
  65369. /** Gets or sets the height of spacers*/
  65370. spacerHeight: string;
  65371. private _setSpacerHeight;
  65372. /** Adds a bar between groups */
  65373. private _addSpacer;
  65374. /** Add a group to the selection panel
  65375. * @param group is the selector group to add
  65376. */
  65377. addGroup(group: SelectorGroup): void;
  65378. /** Remove the group from the given position
  65379. * @param groupNb is the position of the group in the list
  65380. */
  65381. removeGroup(groupNb: number): void;
  65382. /** Change a group header label
  65383. * @param label is the new group header label
  65384. * @param groupNb is the number of the group to relabel
  65385. * */
  65386. setHeaderName(label: string, groupNb: number): void;
  65387. /** Change selector label to the one given
  65388. * @param label is the new selector label
  65389. * @param groupNb is the number of the groupcontaining the selector
  65390. * @param selectorNb is the number of the selector within a group to relabel
  65391. * */
  65392. relabel(label: string, groupNb: number, selectorNb: number): void;
  65393. /** For a given group position remove the selector at the given position
  65394. * @param groupNb is the number of the group to remove the selector from
  65395. * @param selectorNb is the number of the selector within the group
  65396. */
  65397. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  65398. /** For a given group position of correct type add a checkbox button
  65399. * @param groupNb is the number of the group to remove the selector from
  65400. * @param label is the label for the selector
  65401. * @param func is the function called when the Selector is checked
  65402. * @param checked is true when Selector is checked
  65403. */
  65404. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  65405. /** For a given group position of correct type add a radio button
  65406. * @param groupNb is the number of the group to remove the selector from
  65407. * @param label is the label for the selector
  65408. * @param func is the function called when the Selector is checked
  65409. * @param checked is true when Selector is checked
  65410. */
  65411. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  65412. /**
  65413. * For a given slider group add a slider
  65414. * @param groupNb is the number of the group to add the slider to
  65415. * @param label is the label for the Slider
  65416. * @param func is the function called when the Slider moves
  65417. * @param unit is a string describing the units used, eg degrees or metres
  65418. * @param min is the minimum value for the Slider
  65419. * @param max is the maximum value for the Slider
  65420. * @param value is the start value for the Slider between min and max
  65421. * @param onVal is the function used to format the value displayed, eg radians to degrees
  65422. */
  65423. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  65424. }
  65425. }
  65426. declare module BABYLON.GUI {
  65427. /**
  65428. * Class used to hold a the container for ScrollViewer
  65429. * @hidden
  65430. */
  65431. export class _ScrollViewerWindow extends Container {
  65432. parentClientWidth: number;
  65433. parentClientHeight: number;
  65434. /**
  65435. * Creates a new ScrollViewerWindow
  65436. * @param name of ScrollViewerWindow
  65437. */
  65438. constructor(name?: string);
  65439. protected _getTypeName(): string;
  65440. /** @hidden */
  65441. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65442. protected _postMeasure(): void;
  65443. }
  65444. }
  65445. declare module BABYLON.GUI {
  65446. /**
  65447. * Class used to create slider controls
  65448. */
  65449. export class ScrollBar extends BaseSlider {
  65450. name?: string | undefined;
  65451. private _background;
  65452. private _borderColor;
  65453. private _thumbMeasure;
  65454. /** Gets or sets border color */
  65455. borderColor: string;
  65456. /** Gets or sets background color */
  65457. background: string;
  65458. /**
  65459. * Creates a new Slider
  65460. * @param name defines the control name
  65461. */
  65462. constructor(name?: string | undefined);
  65463. protected _getTypeName(): string;
  65464. protected _getThumbThickness(): number; private _draw(context: CanvasRenderingContext2D): void;
  65465. private _first;
  65466. private _originX;
  65467. private _originY;
  65468. /** @hidden */
  65469. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65470. }
  65471. }
  65472. declare module BABYLON.GUI {
  65473. /**
  65474. * Class used to hold a viewer window and sliders in a grid
  65475. */
  65476. export class ScrollViewer extends Rectangle {
  65477. private _grid;
  65478. private _horizontalBarSpace;
  65479. private _verticalBarSpace;
  65480. private _dragSpace;
  65481. private _horizontalBar;
  65482. private _verticalBar;
  65483. private _barColor;
  65484. private _barBackground;
  65485. private _barSize;
  65486. private _endLeft;
  65487. private _endTop;
  65488. private _window;
  65489. private _pointerIsOver;
  65490. private _wheelPrecision;
  65491. private _onPointerObserver;
  65492. private _clientWidth;
  65493. private _clientHeight;
  65494. /**
  65495. * Gets the horizontal scrollbar
  65496. */
  65497. readonly horizontalBar: ScrollBar;
  65498. /**
  65499. * Gets the vertical scrollbar
  65500. */
  65501. readonly verticalBar: ScrollBar;
  65502. /**
  65503. * Adds a new control to the current container
  65504. * @param control defines the control to add
  65505. * @returns the current container
  65506. */
  65507. addControl(control: BABYLON.Nullable<Control>): Container;
  65508. /**
  65509. * Removes a control from the current container
  65510. * @param control defines the control to remove
  65511. * @returns the current container
  65512. */
  65513. removeControl(control: Control): Container;
  65514. /** Gets the list of children */
  65515. readonly children: Control[]; private _flagDescendantsAsMatrixDirty(): void;
  65516. /**
  65517. * Creates a new ScrollViewer
  65518. * @param name of ScrollViewer
  65519. */
  65520. constructor(name?: string);
  65521. /** Reset the scroll viewer window to initial size */
  65522. resetWindow(): void;
  65523. protected _getTypeName(): string;
  65524. private _buildClientSizes;
  65525. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65526. protected _postMeasure(): void;
  65527. /**
  65528. * Gets or sets the mouse wheel precision
  65529. * from 0 to 1 with a default value of 0.05
  65530. * */
  65531. wheelPrecision: number;
  65532. /** Gets or sets the bar color */
  65533. barColor: string;
  65534. /** Gets or sets the size of the bar */
  65535. barSize: number;
  65536. /** Gets or sets the bar background */
  65537. barBackground: string;
  65538. /** @hidden */
  65539. private _updateScroller; private _link(host: AdvancedDynamicTexture): void;
  65540. /** @hidden */
  65541. private _attachWheel; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65542. /** Releases associated resources */
  65543. dispose(): void;
  65544. }
  65545. }
  65546. declare module BABYLON.GUI {
  65547. /** Class used to render a grid */
  65548. export class DisplayGrid extends Control {
  65549. name?: string | undefined;
  65550. private _cellWidth;
  65551. private _cellHeight;
  65552. private _minorLineTickness;
  65553. private _minorLineColor;
  65554. private _majorLineTickness;
  65555. private _majorLineColor;
  65556. private _majorLineFrequency;
  65557. private _background;
  65558. private _displayMajorLines;
  65559. private _displayMinorLines;
  65560. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  65561. displayMinorLines: boolean;
  65562. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  65563. displayMajorLines: boolean;
  65564. /** Gets or sets background color (Black by default) */
  65565. background: string;
  65566. /** Gets or sets the width of each cell (20 by default) */
  65567. cellWidth: number;
  65568. /** Gets or sets the height of each cell (20 by default) */
  65569. cellHeight: number;
  65570. /** Gets or sets the tickness of minor lines (1 by default) */
  65571. minorLineTickness: number;
  65572. /** Gets or sets the color of minor lines (DarkGray by default) */
  65573. minorLineColor: string;
  65574. /** Gets or sets the tickness of major lines (2 by default) */
  65575. majorLineTickness: number;
  65576. /** Gets or sets the color of major lines (White by default) */
  65577. majorLineColor: string;
  65578. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  65579. majorLineFrequency: number;
  65580. /**
  65581. * Creates a new GridDisplayRectangle
  65582. * @param name defines the control name
  65583. */
  65584. constructor(name?: string | undefined); private _draw(context: CanvasRenderingContext2D): void;
  65585. protected _getTypeName(): string;
  65586. }
  65587. }
  65588. declare module BABYLON.GUI {
  65589. /**
  65590. * Class used to create slider controls based on images
  65591. */
  65592. export class ImageBasedSlider extends BaseSlider {
  65593. name?: string | undefined;
  65594. private _backgroundImage;
  65595. private _thumbImage;
  65596. private _valueBarImage;
  65597. private _tempMeasure;
  65598. displayThumb: boolean;
  65599. /**
  65600. * Gets or sets the image used to render the background
  65601. */
  65602. backgroundImage: Image;
  65603. /**
  65604. * Gets or sets the image used to render the value bar
  65605. */
  65606. valueBarImage: Image;
  65607. /**
  65608. * Gets or sets the image used to render the thumb
  65609. */
  65610. thumbImage: Image;
  65611. /**
  65612. * Creates a new ImageBasedSlider
  65613. * @param name defines the control name
  65614. */
  65615. constructor(name?: string | undefined);
  65616. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  65617. }
  65618. }
  65619. declare module BABYLON.GUI {
  65620. /**
  65621. * Forcing an export so that this code will execute
  65622. * @hidden
  65623. */
  65624. const name = "Statics";
  65625. }
  65626. declare module BABYLON.GUI {
  65627. /**
  65628. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  65629. */
  65630. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  65631. /**
  65632. * Define the instrumented AdvancedDynamicTexture.
  65633. */
  65634. texture: AdvancedDynamicTexture;
  65635. private _captureRenderTime;
  65636. private _renderTime;
  65637. private _captureLayoutTime;
  65638. private _layoutTime;
  65639. private _onBeginRenderObserver;
  65640. private _onEndRenderObserver;
  65641. private _onBeginLayoutObserver;
  65642. private _onEndLayoutObserver;
  65643. /**
  65644. * Gets the perf counter used to capture render time
  65645. */
  65646. readonly renderTimeCounter: BABYLON.PerfCounter;
  65647. /**
  65648. * Gets the perf counter used to capture layout time
  65649. */
  65650. readonly layoutTimeCounter: BABYLON.PerfCounter;
  65651. /**
  65652. * Enable or disable the render time capture
  65653. */
  65654. captureRenderTime: boolean;
  65655. /**
  65656. * Enable or disable the layout time capture
  65657. */
  65658. captureLayoutTime: boolean;
  65659. /**
  65660. * Instantiates a new advanced dynamic texture instrumentation.
  65661. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  65662. * @param texture Defines the AdvancedDynamicTexture to instrument
  65663. */
  65664. constructor(
  65665. /**
  65666. * Define the instrumented AdvancedDynamicTexture.
  65667. */
  65668. texture: AdvancedDynamicTexture);
  65669. /**
  65670. * Dispose and release associated resources.
  65671. */
  65672. dispose(): void;
  65673. }
  65674. }
  65675. declare module BABYLON.GUI {
  65676. /**
  65677. * Class used to load GUI via XML.
  65678. */
  65679. export class XmlLoader {
  65680. private _nodes;
  65681. private _nodeTypes;
  65682. private _isLoaded;
  65683. private _objectAttributes;
  65684. private _parentClass;
  65685. /**
  65686. * Create a new xml loader
  65687. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  65688. */
  65689. constructor(parentClass?: null);
  65690. private _getChainElement;
  65691. private _getClassAttribute;
  65692. private _createGuiElement;
  65693. private _parseGrid;
  65694. private _parseElement;
  65695. private _prepareSourceElement;
  65696. private _parseElementsFromSource;
  65697. private _parseXml;
  65698. /**
  65699. * Gets if the loading has finished.
  65700. * @returns whether the loading has finished or not
  65701. */
  65702. isLoaded(): boolean;
  65703. /**
  65704. * Gets a loaded node / control by id.
  65705. * @param id the Controls id set in the xml
  65706. * @returns element of type Control
  65707. */
  65708. getNodeById(id: string): any;
  65709. /**
  65710. * Gets all loaded nodes / controls
  65711. * @returns Array of controls
  65712. */
  65713. getNodes(): any;
  65714. /**
  65715. * Initiates the xml layout loading
  65716. * @param xmlFile defines the xml layout to load
  65717. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  65718. * @param callback defines the callback called on layout load.
  65719. */
  65720. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  65721. }
  65722. }
  65723. declare module BABYLON.GUI {
  65724. /**
  65725. * Class used to create containers for controls
  65726. */
  65727. export class Container3D extends Control3D {
  65728. private _blockLayout;
  65729. /**
  65730. * Gets the list of child controls
  65731. */
  65732. protected _children: Control3D[];
  65733. /**
  65734. * Gets the list of child controls
  65735. */
  65736. readonly children: Array<Control3D>;
  65737. /**
  65738. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  65739. * This is helpful to optimize layout operation when adding multiple children in a row
  65740. */
  65741. blockLayout: boolean;
  65742. /**
  65743. * Creates a new container
  65744. * @param name defines the container name
  65745. */
  65746. constructor(name?: string);
  65747. /**
  65748. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  65749. * @returns the current container
  65750. */
  65751. updateLayout(): Container3D;
  65752. /**
  65753. * Gets a boolean indicating if the given control is in the children of this control
  65754. * @param control defines the control to check
  65755. * @returns true if the control is in the child list
  65756. */
  65757. containsControl(control: Control3D): boolean;
  65758. /**
  65759. * Adds a control to the children of this control
  65760. * @param control defines the control to add
  65761. * @returns the current container
  65762. */
  65763. addControl(control: Control3D): Container3D;
  65764. /**
  65765. * This function will be called everytime a new control is added
  65766. */
  65767. protected _arrangeChildren(): void;
  65768. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65769. /**
  65770. * Removes a control from the children of this control
  65771. * @param control defines the control to remove
  65772. * @returns the current container
  65773. */
  65774. removeControl(control: Control3D): Container3D;
  65775. protected _getTypeName(): string;
  65776. /**
  65777. * Releases all associated resources
  65778. */
  65779. dispose(): void;
  65780. /** Control rotation will remain unchanged */
  65781. static readonly UNSET_ORIENTATION: number;
  65782. /** Control will rotate to make it look at sphere central axis */
  65783. static readonly FACEORIGIN_ORIENTATION: number;
  65784. /** Control will rotate to make it look back at sphere central axis */
  65785. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  65786. /** Control will rotate to look at z axis (0, 0, 1) */
  65787. static readonly FACEFORWARD_ORIENTATION: number;
  65788. /** Control will rotate to look at negative z axis (0, 0, -1) */
  65789. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  65790. }
  65791. }
  65792. declare module BABYLON.GUI {
  65793. /**
  65794. * Class used to manage 3D user interface
  65795. * @see http://doc.babylonjs.com/how_to/gui3d
  65796. */
  65797. export class GUI3DManager implements BABYLON.IDisposable {
  65798. private _scene;
  65799. private _sceneDisposeObserver;
  65800. private _utilityLayer;
  65801. private _rootContainer;
  65802. private _pointerObserver;
  65803. private _pointerOutObserver;
  65804. /** @hidden */ private _lastPickedControl: Control3D;
  65805. /** @hidden */ private _lastControlOver: {
  65806. [pointerId: number]: Control3D;
  65807. };
  65808. /** @hidden */ private _lastControlDown: {
  65809. [pointerId: number]: Control3D;
  65810. };
  65811. /**
  65812. * BABYLON.Observable raised when the point picked by the pointer events changed
  65813. */
  65814. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  65815. /** @hidden */ private _sharedMaterials: {
  65816. [key: string]: BABYLON.Material;
  65817. };
  65818. /** Gets the hosting scene */
  65819. readonly scene: BABYLON.Scene;
  65820. /** Gets associated utility layer */
  65821. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  65822. /**
  65823. * Creates a new GUI3DManager
  65824. * @param scene
  65825. */
  65826. constructor(scene?: BABYLON.Scene);
  65827. private _handlePointerOut;
  65828. private _doPicking;
  65829. /**
  65830. * Gets the root container
  65831. */
  65832. readonly rootContainer: Container3D;
  65833. /**
  65834. * Gets a boolean indicating if the given control is in the root child list
  65835. * @param control defines the control to check
  65836. * @returns true if the control is in the root child list
  65837. */
  65838. containsControl(control: Control3D): boolean;
  65839. /**
  65840. * Adds a control to the root child list
  65841. * @param control defines the control to add
  65842. * @returns the current manager
  65843. */
  65844. addControl(control: Control3D): GUI3DManager;
  65845. /**
  65846. * Removes a control from the root child list
  65847. * @param control defines the control to remove
  65848. * @returns the current container
  65849. */
  65850. removeControl(control: Control3D): GUI3DManager;
  65851. /**
  65852. * Releases all associated resources
  65853. */
  65854. dispose(): void;
  65855. }
  65856. }
  65857. declare module BABYLON.GUI {
  65858. /**
  65859. * Class used to transport BABYLON.Vector3 information for pointer events
  65860. */
  65861. export class Vector3WithInfo extends BABYLON.Vector3 {
  65862. /** defines the current mouse button index */
  65863. buttonIndex: number;
  65864. /**
  65865. * Creates a new Vector3WithInfo
  65866. * @param source defines the vector3 data to transport
  65867. * @param buttonIndex defines the current mouse button index
  65868. */
  65869. constructor(source: BABYLON.Vector3,
  65870. /** defines the current mouse button index */
  65871. buttonIndex?: number);
  65872. }
  65873. }
  65874. declare module BABYLON.GUI {
  65875. /**
  65876. * Class used as base class for controls
  65877. */
  65878. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  65879. /** Defines the control name */
  65880. name?: string | undefined;
  65881. /** @hidden */ private _host: GUI3DManager;
  65882. private _node;
  65883. private _downCount;
  65884. private _enterCount;
  65885. private _downPointerIds;
  65886. private _isVisible;
  65887. /** Gets or sets the control position in world space */
  65888. position: BABYLON.Vector3;
  65889. /** Gets or sets the control scaling in world space */
  65890. scaling: BABYLON.Vector3;
  65891. /** Callback used to start pointer enter animation */
  65892. pointerEnterAnimation: () => void;
  65893. /** Callback used to start pointer out animation */
  65894. pointerOutAnimation: () => void;
  65895. /** Callback used to start pointer down animation */
  65896. pointerDownAnimation: () => void;
  65897. /** Callback used to start pointer up animation */
  65898. pointerUpAnimation: () => void;
  65899. /**
  65900. * An event triggered when the pointer move over the control
  65901. */
  65902. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  65903. /**
  65904. * An event triggered when the pointer move out of the control
  65905. */
  65906. onPointerOutObservable: BABYLON.Observable<Control3D>;
  65907. /**
  65908. * An event triggered when the pointer taps the control
  65909. */
  65910. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  65911. /**
  65912. * An event triggered when pointer is up
  65913. */
  65914. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  65915. /**
  65916. * An event triggered when a control is clicked on (with a mouse)
  65917. */
  65918. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  65919. /**
  65920. * An event triggered when pointer enters the control
  65921. */
  65922. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  65923. /**
  65924. * Gets or sets the parent container
  65925. */
  65926. parent: BABYLON.Nullable<Container3D>;
  65927. private _behaviors;
  65928. /**
  65929. * Gets the list of attached behaviors
  65930. * @see http://doc.babylonjs.com/features/behaviour
  65931. */
  65932. readonly behaviors: BABYLON.Behavior<Control3D>[];
  65933. /**
  65934. * Attach a behavior to the control
  65935. * @see http://doc.babylonjs.com/features/behaviour
  65936. * @param behavior defines the behavior to attach
  65937. * @returns the current control
  65938. */
  65939. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65940. /**
  65941. * Remove an attached behavior
  65942. * @see http://doc.babylonjs.com/features/behaviour
  65943. * @param behavior defines the behavior to attach
  65944. * @returns the current control
  65945. */
  65946. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65947. /**
  65948. * Gets an attached behavior by name
  65949. * @param name defines the name of the behavior to look for
  65950. * @see http://doc.babylonjs.com/features/behaviour
  65951. * @returns null if behavior was not found else the requested behavior
  65952. */
  65953. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  65954. /** Gets or sets a boolean indicating if the control is visible */
  65955. isVisible: boolean;
  65956. /**
  65957. * Creates a new control
  65958. * @param name defines the control name
  65959. */
  65960. constructor(
  65961. /** Defines the control name */
  65962. name?: string | undefined);
  65963. /**
  65964. * Gets a string representing the class name
  65965. */
  65966. readonly typeName: string;
  65967. /**
  65968. * Get the current class name of the control.
  65969. * @returns current class name
  65970. */
  65971. getClassName(): string;
  65972. protected _getTypeName(): string;
  65973. /**
  65974. * Gets the transform node used by this control
  65975. */
  65976. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  65977. /**
  65978. * Gets the mesh used to render this control
  65979. */
  65980. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65981. /**
  65982. * Link the control as child of the given node
  65983. * @param node defines the node to link to. Use null to unlink the control
  65984. * @returns the current control
  65985. */
  65986. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  65987. /** @hidden **/ private _prepareNode(scene: BABYLON.Scene): void;
  65988. /**
  65989. * Node creation.
  65990. * Can be overriden by children
  65991. * @param scene defines the scene where the node must be attached
  65992. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  65993. */
  65994. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65995. /**
  65996. * Affect a material to the given mesh
  65997. * @param mesh defines the mesh which will represent the control
  65998. */
  65999. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66000. /** @hidden */ private _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  66001. /** @hidden */ private _onPointerEnter(target: Control3D): boolean;
  66002. /** @hidden */ private _onPointerOut(target: Control3D): void;
  66003. /** @hidden */ private _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66004. /** @hidden */ private _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66005. /** @hidden */
  66006. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  66007. /** @hidden */ private _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66008. /** @hidden */ private _disposeNode(): void;
  66009. /**
  66010. * Releases all associated resources
  66011. */
  66012. dispose(): void;
  66013. }
  66014. }
  66015. declare module BABYLON.GUI {
  66016. /**
  66017. * Class used as a root to all buttons
  66018. */
  66019. export class AbstractButton3D extends Control3D {
  66020. /**
  66021. * Creates a new button
  66022. * @param name defines the control name
  66023. */
  66024. constructor(name?: string);
  66025. protected _getTypeName(): string;
  66026. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66027. }
  66028. }
  66029. declare module BABYLON.GUI {
  66030. /**
  66031. * Class used to create a button in 3D
  66032. */
  66033. export class Button3D extends AbstractButton3D {
  66034. /** @hidden */
  66035. protected _currentMaterial: BABYLON.Material;
  66036. private _facadeTexture;
  66037. private _content;
  66038. private _contentResolution;
  66039. private _contentScaleRatio;
  66040. /**
  66041. * Gets or sets the texture resolution used to render content (512 by default)
  66042. */
  66043. contentResolution: BABYLON.int;
  66044. /**
  66045. * Gets or sets the texture scale ratio used to render content (2 by default)
  66046. */
  66047. contentScaleRatio: number;
  66048. protected _disposeFacadeTexture(): void;
  66049. protected _resetContent(): void;
  66050. /**
  66051. * Creates a new button
  66052. * @param name defines the control name
  66053. */
  66054. constructor(name?: string);
  66055. /**
  66056. * Gets or sets the GUI 2D content used to display the button's facade
  66057. */
  66058. content: Control;
  66059. /**
  66060. * Apply the facade texture (created from the content property).
  66061. * This function can be overloaded by child classes
  66062. * @param facadeTexture defines the AdvancedDynamicTexture to use
  66063. */
  66064. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66065. protected _getTypeName(): string;
  66066. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66067. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66068. /**
  66069. * Releases all associated resources
  66070. */
  66071. dispose(): void;
  66072. }
  66073. }
  66074. declare module BABYLON.GUI {
  66075. /**
  66076. * Abstract class used to create a container panel deployed on the surface of a volume
  66077. */
  66078. export abstract class VolumeBasedPanel extends Container3D {
  66079. private _columns;
  66080. private _rows;
  66081. private _rowThenColum;
  66082. private _orientation;
  66083. protected _cellWidth: number;
  66084. protected _cellHeight: number;
  66085. /**
  66086. * Gets or sets the distance between elements
  66087. */
  66088. margin: number;
  66089. /**
  66090. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  66091. * | Value | Type | Description |
  66092. * | ----- | ----------------------------------- | ----------- |
  66093. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  66094. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  66095. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  66096. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  66097. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  66098. */
  66099. orientation: number;
  66100. /**
  66101. * Gets or sets the number of columns requested (10 by default).
  66102. * The panel will automatically compute the number of rows based on number of child controls.
  66103. */
  66104. columns: BABYLON.int;
  66105. /**
  66106. * Gets or sets a the number of rows requested.
  66107. * The panel will automatically compute the number of columns based on number of child controls.
  66108. */
  66109. rows: BABYLON.int;
  66110. /**
  66111. * Creates new VolumeBasedPanel
  66112. */
  66113. constructor();
  66114. protected _arrangeChildren(): void;
  66115. /** Child classes must implement this function to provide correct control positioning */
  66116. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66117. /** Child classes can implement this function to provide additional processing */
  66118. protected _finalProcessing(): void;
  66119. }
  66120. }
  66121. declare module BABYLON.GUI {
  66122. /**
  66123. * Class used to create a container panel deployed on the surface of a cylinder
  66124. */
  66125. export class CylinderPanel extends VolumeBasedPanel {
  66126. private _radius;
  66127. /**
  66128. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  66129. */
  66130. radius: BABYLON.float;
  66131. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66132. private _cylindricalMapping;
  66133. }
  66134. }
  66135. declare module BABYLON.GUI {
  66136. /** @hidden */
  66137. export var fluentVertexShader: {
  66138. name: string;
  66139. shader: string;
  66140. };
  66141. }
  66142. declare module BABYLON.GUI {
  66143. /** @hidden */
  66144. export var fluentPixelShader: {
  66145. name: string;
  66146. shader: string;
  66147. };
  66148. }
  66149. declare module BABYLON.GUI {
  66150. /** @hidden */
  66151. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  66152. INNERGLOW: boolean;
  66153. BORDER: boolean;
  66154. HOVERLIGHT: boolean;
  66155. TEXTURE: boolean;
  66156. constructor();
  66157. }
  66158. /**
  66159. * Class used to render controls with fluent desgin
  66160. */
  66161. export class FluentMaterial extends BABYLON.PushMaterial {
  66162. /**
  66163. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  66164. */
  66165. innerGlowColorIntensity: number;
  66166. /**
  66167. * Gets or sets the inner glow color (white by default)
  66168. */
  66169. innerGlowColor: BABYLON.Color3;
  66170. /**
  66171. * Gets or sets alpha value (default is 1.0)
  66172. */
  66173. alpha: number;
  66174. /**
  66175. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  66176. */
  66177. albedoColor: BABYLON.Color3;
  66178. /**
  66179. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  66180. */
  66181. renderBorders: boolean;
  66182. /**
  66183. * Gets or sets border width (default is 0.5)
  66184. */
  66185. borderWidth: number;
  66186. /**
  66187. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  66188. */
  66189. edgeSmoothingValue: number;
  66190. /**
  66191. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  66192. */
  66193. borderMinValue: number;
  66194. /**
  66195. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  66196. */
  66197. renderHoverLight: boolean;
  66198. /**
  66199. * Gets or sets the radius used to render the hover light (default is 1.0)
  66200. */
  66201. hoverRadius: number;
  66202. /**
  66203. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  66204. */
  66205. hoverColor: BABYLON.Color4;
  66206. /**
  66207. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  66208. */
  66209. hoverPosition: BABYLON.Vector3;
  66210. private _albedoTexture;
  66211. /** Gets or sets the texture to use for albedo color */
  66212. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66213. /**
  66214. * Creates a new Fluent material
  66215. * @param name defines the name of the material
  66216. * @param scene defines the hosting scene
  66217. */
  66218. constructor(name: string, scene: BABYLON.Scene);
  66219. needAlphaBlending(): boolean;
  66220. needAlphaTesting(): boolean;
  66221. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66222. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66223. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66224. getActiveTextures(): BABYLON.BaseTexture[];
  66225. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66226. dispose(forceDisposeEffect?: boolean): void;
  66227. clone(name: string): FluentMaterial;
  66228. serialize(): any;
  66229. getClassName(): string;
  66230. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  66231. }
  66232. }
  66233. declare module BABYLON.GUI {
  66234. /**
  66235. * Class used to create a holographic button in 3D
  66236. */
  66237. export class HolographicButton extends Button3D {
  66238. private _backPlate;
  66239. private _textPlate;
  66240. private _frontPlate;
  66241. private _text;
  66242. private _imageUrl;
  66243. private _shareMaterials;
  66244. private _frontMaterial;
  66245. private _backMaterial;
  66246. private _plateMaterial;
  66247. private _pickedPointObserver;
  66248. private _tooltipFade;
  66249. private _tooltipTextBlock;
  66250. private _tooltipTexture;
  66251. private _tooltipMesh;
  66252. private _tooltipHoverObserver;
  66253. private _tooltipOutObserver;
  66254. private _disposeTooltip;
  66255. /**
  66256. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  66257. */
  66258. tooltipText: BABYLON.Nullable<string>;
  66259. /**
  66260. * Gets or sets text for the button
  66261. */
  66262. text: string;
  66263. /**
  66264. * Gets or sets the image url for the button
  66265. */
  66266. imageUrl: string;
  66267. /**
  66268. * Gets the back material used by this button
  66269. */
  66270. readonly backMaterial: FluentMaterial;
  66271. /**
  66272. * Gets the front material used by this button
  66273. */
  66274. readonly frontMaterial: FluentMaterial;
  66275. /**
  66276. * Gets the plate material used by this button
  66277. */
  66278. readonly plateMaterial: BABYLON.StandardMaterial;
  66279. /**
  66280. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  66281. */
  66282. readonly shareMaterials: boolean;
  66283. /**
  66284. * Creates a new button
  66285. * @param name defines the control name
  66286. */
  66287. constructor(name?: string, shareMaterials?: boolean);
  66288. protected _getTypeName(): string;
  66289. private _rebuildContent;
  66290. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66291. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66292. private _createBackMaterial;
  66293. private _createFrontMaterial;
  66294. private _createPlateMaterial;
  66295. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  66296. /**
  66297. * Releases all associated resources
  66298. */
  66299. dispose(): void;
  66300. }
  66301. }
  66302. declare module BABYLON.GUI {
  66303. /**
  66304. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  66305. */
  66306. export class MeshButton3D extends Button3D {
  66307. /** @hidden */
  66308. protected _currentMesh: BABYLON.Mesh;
  66309. /**
  66310. * Creates a new 3D button based on a mesh
  66311. * @param mesh mesh to become a 3D button
  66312. * @param name defines the control name
  66313. */
  66314. constructor(mesh: BABYLON.Mesh, name?: string);
  66315. protected _getTypeName(): string;
  66316. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66317. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66318. }
  66319. }
  66320. declare module BABYLON.GUI {
  66321. /**
  66322. * Class used to create a container panel deployed on the surface of a plane
  66323. */
  66324. export class PlanePanel extends VolumeBasedPanel {
  66325. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66326. }
  66327. }
  66328. declare module BABYLON.GUI {
  66329. /**
  66330. * Class used to create a container panel where items get randomized planar mapping
  66331. */
  66332. export class ScatterPanel extends VolumeBasedPanel {
  66333. private _iteration;
  66334. /**
  66335. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  66336. */
  66337. iteration: BABYLON.float;
  66338. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66339. private _scatterMapping;
  66340. protected _finalProcessing(): void;
  66341. }
  66342. }
  66343. declare module BABYLON.GUI {
  66344. /**
  66345. * Class used to create a container panel deployed on the surface of a sphere
  66346. */
  66347. export class SpherePanel extends VolumeBasedPanel {
  66348. private _radius;
  66349. /**
  66350. * Gets or sets the radius of the sphere where to project controls (5 by default)
  66351. */
  66352. radius: BABYLON.float;
  66353. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66354. private _sphericalMapping;
  66355. }
  66356. }
  66357. declare module BABYLON.GUI {
  66358. /**
  66359. * Class used to create a stack panel in 3D on XY plane
  66360. */
  66361. export class StackPanel3D extends Container3D {
  66362. private _isVertical;
  66363. /**
  66364. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  66365. */
  66366. isVertical: boolean;
  66367. /**
  66368. * Gets or sets the distance between elements
  66369. */
  66370. margin: number;
  66371. /**
  66372. * Creates new StackPanel
  66373. * @param isVertical
  66374. */
  66375. constructor(isVertical?: boolean);
  66376. protected _arrangeChildren(): void;
  66377. }
  66378. }
  66379. declare module BABYLON {
  66380. /**
  66381. * Mode that determines the coordinate system to use.
  66382. */
  66383. export enum GLTFLoaderCoordinateSystemMode {
  66384. /**
  66385. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  66386. */
  66387. AUTO = 0,
  66388. /**
  66389. * Sets the useRightHandedSystem flag on the scene.
  66390. */
  66391. FORCE_RIGHT_HANDED = 1
  66392. }
  66393. /**
  66394. * Mode that determines what animations will start.
  66395. */
  66396. export enum GLTFLoaderAnimationStartMode {
  66397. /**
  66398. * No animation will start.
  66399. */
  66400. NONE = 0,
  66401. /**
  66402. * The first animation will start.
  66403. */
  66404. FIRST = 1,
  66405. /**
  66406. * All animations will start.
  66407. */
  66408. ALL = 2
  66409. }
  66410. /**
  66411. * Interface that contains the data for the glTF asset.
  66412. */
  66413. export interface IGLTFLoaderData {
  66414. /**
  66415. * Object that represents the glTF JSON.
  66416. */
  66417. json: Object;
  66418. /**
  66419. * The BIN chunk of a binary glTF.
  66420. */
  66421. bin: Nullable<ArrayBufferView>;
  66422. }
  66423. /**
  66424. * Interface for extending the loader.
  66425. */
  66426. export interface IGLTFLoaderExtension {
  66427. /**
  66428. * The name of this extension.
  66429. */
  66430. readonly name: string;
  66431. /**
  66432. * Defines whether this extension is enabled.
  66433. */
  66434. enabled: boolean;
  66435. }
  66436. /**
  66437. * Loader state.
  66438. */
  66439. export enum GLTFLoaderState {
  66440. /**
  66441. * The asset is loading.
  66442. */
  66443. LOADING = 0,
  66444. /**
  66445. * The asset is ready for rendering.
  66446. */
  66447. READY = 1,
  66448. /**
  66449. * The asset is completely loaded.
  66450. */
  66451. COMPLETE = 2
  66452. }
  66453. /** @hidden */
  66454. export interface IGLTFLoader extends IDisposable {
  66455. readonly state: Nullable<GLTFLoaderState>;
  66456. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  66457. meshes: AbstractMesh[];
  66458. particleSystems: IParticleSystem[];
  66459. skeletons: Skeleton[];
  66460. animationGroups: AnimationGroup[];
  66461. }>;
  66462. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  66463. }
  66464. /**
  66465. * File loader for loading glTF files into a scene.
  66466. */
  66467. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  66468. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  66469. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  66470. /**
  66471. * Raised when the asset has been parsed
  66472. */
  66473. onParsedObservable: Observable<IGLTFLoaderData>;
  66474. private _onParsedObserver;
  66475. /**
  66476. * Raised when the asset has been parsed
  66477. */
  66478. onParsed: (loaderData: IGLTFLoaderData) => void;
  66479. /**
  66480. * 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.
  66481. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  66482. * Defaults to true.
  66483. * @hidden
  66484. */
  66485. static IncrementalLoading: boolean;
  66486. /**
  66487. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  66488. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  66489. * @hidden
  66490. */
  66491. static HomogeneousCoordinates: boolean;
  66492. /**
  66493. * The coordinate system mode. Defaults to AUTO.
  66494. */
  66495. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  66496. /**
  66497. * The animation start mode. Defaults to FIRST.
  66498. */
  66499. animationStartMode: GLTFLoaderAnimationStartMode;
  66500. /**
  66501. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  66502. */
  66503. compileMaterials: boolean;
  66504. /**
  66505. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  66506. */
  66507. useClipPlane: boolean;
  66508. /**
  66509. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  66510. */
  66511. compileShadowGenerators: boolean;
  66512. /**
  66513. * Defines if the Alpha blended materials are only applied as coverage.
  66514. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  66515. * If true, no extra effects are applied to transparent pixels.
  66516. */
  66517. transparencyAsCoverage: boolean;
  66518. /**
  66519. * Function called before loading a url referenced by the asset.
  66520. */
  66521. preprocessUrlAsync: (url: string) => Promise<string>;
  66522. /**
  66523. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  66524. */
  66525. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  66526. private _onMeshLoadedObserver;
  66527. /**
  66528. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  66529. */
  66530. onMeshLoaded: (mesh: AbstractMesh) => void;
  66531. /**
  66532. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  66533. */
  66534. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  66535. private _onTextureLoadedObserver;
  66536. /**
  66537. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  66538. */
  66539. onTextureLoaded: (texture: BaseTexture) => void;
  66540. /**
  66541. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  66542. */
  66543. readonly onMaterialLoadedObservable: Observable<Material>;
  66544. private _onMaterialLoadedObserver;
  66545. /**
  66546. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  66547. */
  66548. onMaterialLoaded: (material: Material) => void;
  66549. /**
  66550. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  66551. */
  66552. readonly onCameraLoadedObservable: Observable<Camera>;
  66553. private _onCameraLoadedObserver;
  66554. /**
  66555. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  66556. */
  66557. onCameraLoaded: (camera: Camera) => void;
  66558. /**
  66559. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  66560. * For assets with LODs, raised when all of the LODs are complete.
  66561. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  66562. */
  66563. readonly onCompleteObservable: Observable<void>;
  66564. private _onCompleteObserver;
  66565. /**
  66566. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  66567. * For assets with LODs, raised when all of the LODs are complete.
  66568. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  66569. */
  66570. onComplete: () => void;
  66571. /**
  66572. * Observable raised when an error occurs.
  66573. */
  66574. readonly onErrorObservable: Observable<any>;
  66575. private _onErrorObserver;
  66576. /**
  66577. * Callback raised when an error occurs.
  66578. */
  66579. onError: (reason: any) => void;
  66580. /**
  66581. * Observable raised after the loader is disposed.
  66582. */
  66583. readonly onDisposeObservable: Observable<void>;
  66584. private _onDisposeObserver;
  66585. /**
  66586. * Callback raised after the loader is disposed.
  66587. */
  66588. onDispose: () => void;
  66589. /**
  66590. * Observable raised after a loader extension is created.
  66591. * Set additional options for a loader extension in this event.
  66592. */
  66593. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  66594. private _onExtensionLoadedObserver;
  66595. /**
  66596. * Callback raised after a loader extension is created.
  66597. */
  66598. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  66599. /**
  66600. * Defines if the loader logging is enabled.
  66601. */
  66602. loggingEnabled: boolean;
  66603. /**
  66604. * Defines if the loader should capture performance counters.
  66605. */
  66606. capturePerformanceCounters: boolean;
  66607. /**
  66608. * Defines if the loader should validate the asset.
  66609. */
  66610. validate: boolean;
  66611. /**
  66612. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  66613. */
  66614. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  66615. private _onValidatedObserver;
  66616. /**
  66617. * Callback raised after a loader extension is created.
  66618. */
  66619. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  66620. private _loader;
  66621. /**
  66622. * Name of the loader ("gltf")
  66623. */
  66624. name: string;
  66625. /**
  66626. * Supported file extensions of the loader (.gltf, .glb)
  66627. */
  66628. extensions: ISceneLoaderPluginExtensions;
  66629. /**
  66630. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  66631. */
  66632. dispose(): void;
  66633. /** @hidden */ private _clear(): void;
  66634. /**
  66635. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  66636. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66637. * @param scene the scene the meshes should be added to
  66638. * @param data the glTF data to load
  66639. * @param rootUrl root url to load from
  66640. * @param onProgress event that fires when loading progress has occured
  66641. * @param fileName Defines the name of the file to load
  66642. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66643. */
  66644. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66645. meshes: AbstractMesh[];
  66646. particleSystems: IParticleSystem[];
  66647. skeletons: Skeleton[];
  66648. animationGroups: AnimationGroup[];
  66649. }>;
  66650. /**
  66651. * Imports all objects from the loaded glTF data and adds them to the scene
  66652. * @param scene the scene the objects should be added to
  66653. * @param data the glTF data to load
  66654. * @param rootUrl root url to load from
  66655. * @param onProgress event that fires when loading progress has occured
  66656. * @param fileName Defines the name of the file to load
  66657. * @returns a promise which completes when objects have been loaded to the scene
  66658. */
  66659. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66660. /**
  66661. * Load into an asset container.
  66662. * @param scene The scene to load into
  66663. * @param data The data to import
  66664. * @param rootUrl The root url for scene and resources
  66665. * @param onProgress The callback when the load progresses
  66666. * @param fileName Defines the name of the file to load
  66667. * @returns The loaded asset container
  66668. */
  66669. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  66670. /**
  66671. * If the data string can be loaded directly.
  66672. * @param data string contianing the file data
  66673. * @returns if the data can be loaded directly
  66674. */
  66675. canDirectLoad(data: string): boolean;
  66676. /**
  66677. * Rewrites a url by combining a root url and response url.
  66678. */
  66679. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  66680. /**
  66681. * Instantiates a glTF file loader plugin.
  66682. * @returns the created plugin
  66683. */
  66684. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  66685. /**
  66686. * The loader state or null if the loader is not active.
  66687. */
  66688. readonly loaderState: Nullable<GLTFLoaderState>;
  66689. /**
  66690. * Returns a promise that resolves when the asset is completely loaded.
  66691. * @returns a promise that resolves when the asset is completely loaded.
  66692. */
  66693. whenCompleteAsync(): Promise<void>;
  66694. private _parseAsync;
  66695. private _validateAsync;
  66696. private _getLoader;
  66697. private _unpackBinary;
  66698. private _unpackBinaryV1;
  66699. private _unpackBinaryV2;
  66700. private static _parseVersion;
  66701. private static _compareVersion;
  66702. private static _decodeBufferToText;
  66703. private static readonly _logSpaces;
  66704. private _logIndentLevel;
  66705. private _loggingEnabled;
  66706. /** @hidden */ private _log: (message: string) => void;
  66707. /** @hidden */ private _logOpen(message: string): void;
  66708. /** @hidden */ private _logClose(): void;
  66709. private _logEnabled;
  66710. private _logDisabled;
  66711. private _capturePerformanceCounters;
  66712. /** @hidden */ private _startPerformanceCounter: (counterName: string) => void;
  66713. /** @hidden */ private _endPerformanceCounter: (counterName: string) => void;
  66714. private _startPerformanceCounterEnabled;
  66715. private _startPerformanceCounterDisabled;
  66716. private _endPerformanceCounterEnabled;
  66717. private _endPerformanceCounterDisabled;
  66718. }
  66719. }
  66720. declare module BABYLON.GLTF1 {
  66721. /**
  66722. * Enums
  66723. * @hidden
  66724. */
  66725. export enum EComponentType {
  66726. BYTE = 5120,
  66727. UNSIGNED_BYTE = 5121,
  66728. SHORT = 5122,
  66729. UNSIGNED_SHORT = 5123,
  66730. FLOAT = 5126
  66731. }
  66732. /** @hidden */
  66733. export enum EShaderType {
  66734. FRAGMENT = 35632,
  66735. VERTEX = 35633
  66736. }
  66737. /** @hidden */
  66738. export enum EParameterType {
  66739. BYTE = 5120,
  66740. UNSIGNED_BYTE = 5121,
  66741. SHORT = 5122,
  66742. UNSIGNED_SHORT = 5123,
  66743. INT = 5124,
  66744. UNSIGNED_INT = 5125,
  66745. FLOAT = 5126,
  66746. FLOAT_VEC2 = 35664,
  66747. FLOAT_VEC3 = 35665,
  66748. FLOAT_VEC4 = 35666,
  66749. INT_VEC2 = 35667,
  66750. INT_VEC3 = 35668,
  66751. INT_VEC4 = 35669,
  66752. BOOL = 35670,
  66753. BOOL_VEC2 = 35671,
  66754. BOOL_VEC3 = 35672,
  66755. BOOL_VEC4 = 35673,
  66756. FLOAT_MAT2 = 35674,
  66757. FLOAT_MAT3 = 35675,
  66758. FLOAT_MAT4 = 35676,
  66759. SAMPLER_2D = 35678
  66760. }
  66761. /** @hidden */
  66762. export enum ETextureWrapMode {
  66763. CLAMP_TO_EDGE = 33071,
  66764. MIRRORED_REPEAT = 33648,
  66765. REPEAT = 10497
  66766. }
  66767. /** @hidden */
  66768. export enum ETextureFilterType {
  66769. NEAREST = 9728,
  66770. LINEAR = 9728,
  66771. NEAREST_MIPMAP_NEAREST = 9984,
  66772. LINEAR_MIPMAP_NEAREST = 9985,
  66773. NEAREST_MIPMAP_LINEAR = 9986,
  66774. LINEAR_MIPMAP_LINEAR = 9987
  66775. }
  66776. /** @hidden */
  66777. export enum ETextureFormat {
  66778. ALPHA = 6406,
  66779. RGB = 6407,
  66780. RGBA = 6408,
  66781. LUMINANCE = 6409,
  66782. LUMINANCE_ALPHA = 6410
  66783. }
  66784. /** @hidden */
  66785. export enum ECullingType {
  66786. FRONT = 1028,
  66787. BACK = 1029,
  66788. FRONT_AND_BACK = 1032
  66789. }
  66790. /** @hidden */
  66791. export enum EBlendingFunction {
  66792. ZERO = 0,
  66793. ONE = 1,
  66794. SRC_COLOR = 768,
  66795. ONE_MINUS_SRC_COLOR = 769,
  66796. DST_COLOR = 774,
  66797. ONE_MINUS_DST_COLOR = 775,
  66798. SRC_ALPHA = 770,
  66799. ONE_MINUS_SRC_ALPHA = 771,
  66800. DST_ALPHA = 772,
  66801. ONE_MINUS_DST_ALPHA = 773,
  66802. CONSTANT_COLOR = 32769,
  66803. ONE_MINUS_CONSTANT_COLOR = 32770,
  66804. CONSTANT_ALPHA = 32771,
  66805. ONE_MINUS_CONSTANT_ALPHA = 32772,
  66806. SRC_ALPHA_SATURATE = 776
  66807. }
  66808. /** @hidden */
  66809. export interface IGLTFProperty {
  66810. extensions?: {
  66811. [key: string]: any;
  66812. };
  66813. extras?: Object;
  66814. }
  66815. /** @hidden */
  66816. export interface IGLTFChildRootProperty extends IGLTFProperty {
  66817. name?: string;
  66818. }
  66819. /** @hidden */
  66820. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  66821. bufferView: string;
  66822. byteOffset: number;
  66823. byteStride: number;
  66824. count: number;
  66825. type: string;
  66826. componentType: EComponentType;
  66827. max?: number[];
  66828. min?: number[];
  66829. name?: string;
  66830. }
  66831. /** @hidden */
  66832. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  66833. buffer: string;
  66834. byteOffset: number;
  66835. byteLength: number;
  66836. byteStride: number;
  66837. target?: number;
  66838. }
  66839. /** @hidden */
  66840. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  66841. uri: string;
  66842. byteLength?: number;
  66843. type?: string;
  66844. }
  66845. /** @hidden */
  66846. export interface IGLTFShader extends IGLTFChildRootProperty {
  66847. uri: string;
  66848. type: EShaderType;
  66849. }
  66850. /** @hidden */
  66851. export interface IGLTFProgram extends IGLTFChildRootProperty {
  66852. attributes: string[];
  66853. fragmentShader: string;
  66854. vertexShader: string;
  66855. }
  66856. /** @hidden */
  66857. export interface IGLTFTechniqueParameter {
  66858. type: number;
  66859. count?: number;
  66860. semantic?: string;
  66861. node?: string;
  66862. value?: number | boolean | string | Array<any>;
  66863. source?: string;
  66864. babylonValue?: any;
  66865. }
  66866. /** @hidden */
  66867. export interface IGLTFTechniqueCommonProfile {
  66868. lightingModel: string;
  66869. texcoordBindings: Object;
  66870. parameters?: Array<any>;
  66871. }
  66872. /** @hidden */
  66873. export interface IGLTFTechniqueStatesFunctions {
  66874. blendColor?: number[];
  66875. blendEquationSeparate?: number[];
  66876. blendFuncSeparate?: number[];
  66877. colorMask: boolean[];
  66878. cullFace: number[];
  66879. }
  66880. /** @hidden */
  66881. export interface IGLTFTechniqueStates {
  66882. enable: number[];
  66883. functions: IGLTFTechniqueStatesFunctions;
  66884. }
  66885. /** @hidden */
  66886. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  66887. parameters: {
  66888. [key: string]: IGLTFTechniqueParameter;
  66889. };
  66890. program: string;
  66891. attributes: {
  66892. [key: string]: string;
  66893. };
  66894. uniforms: {
  66895. [key: string]: string;
  66896. };
  66897. states: IGLTFTechniqueStates;
  66898. }
  66899. /** @hidden */
  66900. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  66901. technique?: string;
  66902. values: string[];
  66903. }
  66904. /** @hidden */
  66905. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  66906. attributes: {
  66907. [key: string]: string;
  66908. };
  66909. indices: string;
  66910. material: string;
  66911. mode?: number;
  66912. }
  66913. /** @hidden */
  66914. export interface IGLTFMesh extends IGLTFChildRootProperty {
  66915. primitives: IGLTFMeshPrimitive[];
  66916. }
  66917. /** @hidden */
  66918. export interface IGLTFImage extends IGLTFChildRootProperty {
  66919. uri: string;
  66920. }
  66921. /** @hidden */
  66922. export interface IGLTFSampler extends IGLTFChildRootProperty {
  66923. magFilter?: number;
  66924. minFilter?: number;
  66925. wrapS?: number;
  66926. wrapT?: number;
  66927. }
  66928. /** @hidden */
  66929. export interface IGLTFTexture extends IGLTFChildRootProperty {
  66930. sampler: string;
  66931. source: string;
  66932. format?: ETextureFormat;
  66933. internalFormat?: ETextureFormat;
  66934. target?: number;
  66935. type?: number;
  66936. babylonTexture?: Texture;
  66937. }
  66938. /** @hidden */
  66939. export interface IGLTFAmbienLight {
  66940. color?: number[];
  66941. }
  66942. /** @hidden */
  66943. export interface IGLTFDirectionalLight {
  66944. color?: number[];
  66945. }
  66946. /** @hidden */
  66947. export interface IGLTFPointLight {
  66948. color?: number[];
  66949. constantAttenuation?: number;
  66950. linearAttenuation?: number;
  66951. quadraticAttenuation?: number;
  66952. }
  66953. /** @hidden */
  66954. export interface IGLTFSpotLight {
  66955. color?: number[];
  66956. constantAttenuation?: number;
  66957. fallOfAngle?: number;
  66958. fallOffExponent?: number;
  66959. linearAttenuation?: number;
  66960. quadraticAttenuation?: number;
  66961. }
  66962. /** @hidden */
  66963. export interface IGLTFLight extends IGLTFChildRootProperty {
  66964. type: string;
  66965. }
  66966. /** @hidden */
  66967. export interface IGLTFCameraOrthographic {
  66968. xmag: number;
  66969. ymag: number;
  66970. zfar: number;
  66971. znear: number;
  66972. }
  66973. /** @hidden */
  66974. export interface IGLTFCameraPerspective {
  66975. aspectRatio: number;
  66976. yfov: number;
  66977. zfar: number;
  66978. znear: number;
  66979. }
  66980. /** @hidden */
  66981. export interface IGLTFCamera extends IGLTFChildRootProperty {
  66982. type: string;
  66983. }
  66984. /** @hidden */
  66985. export interface IGLTFAnimationChannelTarget {
  66986. id: string;
  66987. path: string;
  66988. }
  66989. /** @hidden */
  66990. export interface IGLTFAnimationChannel {
  66991. sampler: string;
  66992. target: IGLTFAnimationChannelTarget;
  66993. }
  66994. /** @hidden */
  66995. export interface IGLTFAnimationSampler {
  66996. input: string;
  66997. output: string;
  66998. interpolation?: string;
  66999. }
  67000. /** @hidden */
  67001. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  67002. channels?: IGLTFAnimationChannel[];
  67003. parameters?: {
  67004. [key: string]: string;
  67005. };
  67006. samplers?: {
  67007. [key: string]: IGLTFAnimationSampler;
  67008. };
  67009. }
  67010. /** @hidden */
  67011. export interface IGLTFNodeInstanceSkin {
  67012. skeletons: string[];
  67013. skin: string;
  67014. meshes: string[];
  67015. }
  67016. /** @hidden */
  67017. export interface IGLTFSkins extends IGLTFChildRootProperty {
  67018. bindShapeMatrix: number[];
  67019. inverseBindMatrices: string;
  67020. jointNames: string[];
  67021. babylonSkeleton?: Skeleton;
  67022. }
  67023. /** @hidden */
  67024. export interface IGLTFNode extends IGLTFChildRootProperty {
  67025. camera?: string;
  67026. children: string[];
  67027. skin?: string;
  67028. jointName?: string;
  67029. light?: string;
  67030. matrix: number[];
  67031. mesh?: string;
  67032. meshes?: string[];
  67033. rotation?: number[];
  67034. scale?: number[];
  67035. translation?: number[];
  67036. babylonNode?: Node;
  67037. }
  67038. /** @hidden */
  67039. export interface IGLTFScene extends IGLTFChildRootProperty {
  67040. nodes: string[];
  67041. }
  67042. /** @hidden */
  67043. export interface IGLTFRuntime {
  67044. extensions: {
  67045. [key: string]: any;
  67046. };
  67047. accessors: {
  67048. [key: string]: IGLTFAccessor;
  67049. };
  67050. buffers: {
  67051. [key: string]: IGLTFBuffer;
  67052. };
  67053. bufferViews: {
  67054. [key: string]: IGLTFBufferView;
  67055. };
  67056. meshes: {
  67057. [key: string]: IGLTFMesh;
  67058. };
  67059. lights: {
  67060. [key: string]: IGLTFLight;
  67061. };
  67062. cameras: {
  67063. [key: string]: IGLTFCamera;
  67064. };
  67065. nodes: {
  67066. [key: string]: IGLTFNode;
  67067. };
  67068. images: {
  67069. [key: string]: IGLTFImage;
  67070. };
  67071. textures: {
  67072. [key: string]: IGLTFTexture;
  67073. };
  67074. shaders: {
  67075. [key: string]: IGLTFShader;
  67076. };
  67077. programs: {
  67078. [key: string]: IGLTFProgram;
  67079. };
  67080. samplers: {
  67081. [key: string]: IGLTFSampler;
  67082. };
  67083. techniques: {
  67084. [key: string]: IGLTFTechnique;
  67085. };
  67086. materials: {
  67087. [key: string]: IGLTFMaterial;
  67088. };
  67089. animations: {
  67090. [key: string]: IGLTFAnimation;
  67091. };
  67092. skins: {
  67093. [key: string]: IGLTFSkins;
  67094. };
  67095. currentScene?: Object;
  67096. scenes: {
  67097. [key: string]: IGLTFScene;
  67098. };
  67099. extensionsUsed: string[];
  67100. extensionsRequired?: string[];
  67101. buffersCount: number;
  67102. shaderscount: number;
  67103. scene: Scene;
  67104. rootUrl: string;
  67105. loadedBufferCount: number;
  67106. loadedBufferViews: {
  67107. [name: string]: ArrayBufferView;
  67108. };
  67109. loadedShaderCount: number;
  67110. importOnlyMeshes: boolean;
  67111. importMeshesNames?: string[];
  67112. dummyNodes: Node[];
  67113. }
  67114. /** @hidden */
  67115. export interface INodeToRoot {
  67116. bone: Bone;
  67117. node: IGLTFNode;
  67118. id: string;
  67119. }
  67120. /** @hidden */
  67121. export interface IJointNode {
  67122. node: IGLTFNode;
  67123. id: string;
  67124. }
  67125. }
  67126. declare module BABYLON.GLTF1 {
  67127. /**
  67128. * Utils functions for GLTF
  67129. * @hidden
  67130. */
  67131. export class GLTFUtils {
  67132. /**
  67133. * Sets the given "parameter" matrix
  67134. * @param scene: the Scene object
  67135. * @param source: the source node where to pick the matrix
  67136. * @param parameter: the GLTF technique parameter
  67137. * @param uniformName: the name of the shader's uniform
  67138. * @param shaderMaterial: the shader material
  67139. */
  67140. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  67141. /**
  67142. * Sets the given "parameter" matrix
  67143. * @param shaderMaterial: the shader material
  67144. * @param uniform: the name of the shader's uniform
  67145. * @param value: the value of the uniform
  67146. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  67147. */
  67148. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  67149. /**
  67150. * Returns the wrap mode of the texture
  67151. * @param mode: the mode value
  67152. */
  67153. static GetWrapMode(mode: number): number;
  67154. /**
  67155. * Returns the byte stride giving an accessor
  67156. * @param accessor: the GLTF accessor objet
  67157. */
  67158. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  67159. /**
  67160. * Returns the texture filter mode giving a mode value
  67161. * @param mode: the filter mode value
  67162. */
  67163. static GetTextureFilterMode(mode: number): ETextureFilterType;
  67164. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  67165. /**
  67166. * Returns a buffer from its accessor
  67167. * @param gltfRuntime: the GLTF runtime
  67168. * @param accessor: the GLTF accessor
  67169. */
  67170. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  67171. /**
  67172. * Decodes a buffer view into a string
  67173. * @param view: the buffer view
  67174. */
  67175. static DecodeBufferToText(view: ArrayBufferView): string;
  67176. /**
  67177. * Returns the default material of gltf. Related to
  67178. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  67179. * @param scene: the Babylon.js scene
  67180. */
  67181. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  67182. private static _DefaultMaterial;
  67183. }
  67184. }
  67185. declare module BABYLON.GLTF1 {
  67186. /**
  67187. * Implementation of the base glTF spec
  67188. * @hidden
  67189. */
  67190. export class GLTFLoaderBase {
  67191. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  67192. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67193. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  67194. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67195. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  67196. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67197. }
  67198. /**
  67199. * glTF V1 Loader
  67200. * @hidden
  67201. */
  67202. export class GLTFLoader implements IGLTFLoader {
  67203. static Extensions: {
  67204. [name: string]: GLTFLoaderExtension;
  67205. };
  67206. static RegisterExtension(extension: GLTFLoaderExtension): void;
  67207. state: Nullable<GLTFLoaderState>;
  67208. dispose(): void;
  67209. private _importMeshAsync;
  67210. /**
  67211. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  67212. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67213. * @param scene the scene the meshes should be added to
  67214. * @param data gltf data containing information of the meshes in a loaded file
  67215. * @param rootUrl root url to load from
  67216. * @param onProgress event that fires when loading progress has occured
  67217. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67218. */
  67219. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  67220. meshes: AbstractMesh[];
  67221. particleSystems: IParticleSystem[];
  67222. skeletons: Skeleton[];
  67223. animationGroups: AnimationGroup[];
  67224. }>;
  67225. private _loadAsync;
  67226. /**
  67227. * Imports all objects from a loaded gltf file and adds them to the scene
  67228. * @param scene the scene the objects should be added to
  67229. * @param data gltf data containing information of the meshes in a loaded file
  67230. * @param rootUrl root url to load from
  67231. * @param onProgress event that fires when loading progress has occured
  67232. * @returns a promise which completes when objects have been loaded to the scene
  67233. */
  67234. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  67235. private _loadShadersAsync;
  67236. private _loadBuffersAsync;
  67237. private _createNodes;
  67238. }
  67239. /** @hidden */
  67240. export abstract class GLTFLoaderExtension {
  67241. private _name;
  67242. constructor(name: string);
  67243. readonly name: string;
  67244. /**
  67245. * Defines an override for loading the runtime
  67246. * Return true to stop further extensions from loading the runtime
  67247. */
  67248. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  67249. /**
  67250. * Defines an onverride for creating gltf runtime
  67251. * Return true to stop further extensions from creating the runtime
  67252. */
  67253. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  67254. /**
  67255. * Defines an override for loading buffers
  67256. * Return true to stop further extensions from loading this buffer
  67257. */
  67258. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  67259. /**
  67260. * Defines an override for loading texture buffers
  67261. * Return true to stop further extensions from loading this texture data
  67262. */
  67263. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67264. /**
  67265. * Defines an override for creating textures
  67266. * Return true to stop further extensions from loading this texture
  67267. */
  67268. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  67269. /**
  67270. * Defines an override for loading shader strings
  67271. * Return true to stop further extensions from loading this shader data
  67272. */
  67273. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67274. /**
  67275. * Defines an override for loading materials
  67276. * Return true to stop further extensions from loading this material
  67277. */
  67278. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67279. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  67280. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  67281. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67282. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67283. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  67284. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67285. private static LoadTextureBufferAsync;
  67286. private static CreateTextureAsync;
  67287. private static ApplyExtensions;
  67288. }
  67289. }
  67290. declare module BABYLON.GLTF1 {
  67291. /** @hidden */
  67292. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  67293. private _bin;
  67294. constructor();
  67295. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  67296. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67297. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67298. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67299. }
  67300. }
  67301. declare module BABYLON.GLTF1 {
  67302. /** @hidden */
  67303. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  67304. constructor();
  67305. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  67306. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67307. private _loadTexture;
  67308. }
  67309. }
  67310. declare module BABYLON.GLTF2.Loader {
  67311. /**
  67312. * Loader interface with an index field.
  67313. */
  67314. export interface IArrayItem {
  67315. /**
  67316. * The index of this item in the array.
  67317. */
  67318. index: number;
  67319. }
  67320. /**
  67321. * Loader interface with additional members.
  67322. */
  67323. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  67324. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  67325. /** @hidden */ private _babylonVertexBuffer?: Promise<VertexBuffer>;
  67326. }
  67327. /**
  67328. * Loader interface with additional members.
  67329. */
  67330. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  67331. }
  67332. /** @hidden */
  67333. export interface _IAnimationSamplerData {
  67334. input: Float32Array;
  67335. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  67336. output: Float32Array;
  67337. }
  67338. /**
  67339. * Loader interface with additional members.
  67340. */
  67341. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  67342. /** @hidden */ private _data?: Promise<_IAnimationSamplerData>;
  67343. }
  67344. /**
  67345. * Loader interface with additional members.
  67346. */
  67347. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  67348. channels: IAnimationChannel[];
  67349. samplers: IAnimationSampler[];
  67350. /** @hidden */ private _babylonAnimationGroup?: AnimationGroup;
  67351. }
  67352. /**
  67353. * Loader interface with additional members.
  67354. */
  67355. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  67356. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  67357. }
  67358. /**
  67359. * Loader interface with additional members.
  67360. */
  67361. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  67362. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  67363. /** @hidden */ private _babylonBuffer?: Promise<Buffer>;
  67364. }
  67365. /**
  67366. * Loader interface with additional members.
  67367. */
  67368. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  67369. }
  67370. /**
  67371. * Loader interface with additional members.
  67372. */
  67373. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  67374. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  67375. }
  67376. /**
  67377. * Loader interface with additional members.
  67378. */
  67379. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  67380. }
  67381. /**
  67382. * Loader interface with additional members.
  67383. */
  67384. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  67385. }
  67386. /**
  67387. * Loader interface with additional members.
  67388. */
  67389. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  67390. baseColorTexture?: ITextureInfo;
  67391. metallicRoughnessTexture?: ITextureInfo;
  67392. }
  67393. /**
  67394. * Loader interface with additional members.
  67395. */
  67396. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  67397. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  67398. normalTexture?: IMaterialNormalTextureInfo;
  67399. occlusionTexture?: IMaterialOcclusionTextureInfo;
  67400. emissiveTexture?: ITextureInfo;
  67401. /** @hidden */ private _data?: {
  67402. [babylonDrawMode: number]: {
  67403. babylonMaterial: Material;
  67404. babylonMeshes: AbstractMesh[];
  67405. promise: Promise<void>;
  67406. };
  67407. };
  67408. }
  67409. /**
  67410. * Loader interface with additional members.
  67411. */
  67412. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  67413. primitives: IMeshPrimitive[];
  67414. }
  67415. /**
  67416. * Loader interface with additional members.
  67417. */
  67418. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  67419. /** @hidden */ private _instanceData?: {
  67420. babylonSourceMesh: Mesh;
  67421. promise: Promise<any>;
  67422. };
  67423. }
  67424. /**
  67425. * Loader interface with additional members.
  67426. */
  67427. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  67428. /**
  67429. * The parent glTF node.
  67430. */
  67431. parent?: INode;
  67432. /** @hidden */ private _babylonTransformNode?: TransformNode;
  67433. /** @hidden */ private _primitiveBabylonMeshes?: AbstractMesh[];
  67434. /** @hidden */ private _babylonBones?: Bone[];
  67435. /** @hidden */ private _numMorphTargets?: number;
  67436. }
  67437. /** @hidden */
  67438. export interface _ISamplerData {
  67439. noMipMaps: boolean;
  67440. samplingMode: number;
  67441. wrapU: number;
  67442. wrapV: number;
  67443. }
  67444. /**
  67445. * Loader interface with additional members.
  67446. */
  67447. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  67448. /** @hidden */ private _data?: _ISamplerData;
  67449. }
  67450. /**
  67451. * Loader interface with additional members.
  67452. */
  67453. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  67454. }
  67455. /**
  67456. * Loader interface with additional members.
  67457. */
  67458. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  67459. /** @hidden */ private _data?: {
  67460. babylonSkeleton: Skeleton;
  67461. promise: Promise<void>;
  67462. };
  67463. }
  67464. /**
  67465. * Loader interface with additional members.
  67466. */
  67467. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  67468. }
  67469. /**
  67470. * Loader interface with additional members.
  67471. */
  67472. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  67473. }
  67474. /**
  67475. * Loader interface with additional members.
  67476. */
  67477. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  67478. accessors?: IAccessor[];
  67479. animations?: IAnimation[];
  67480. buffers?: IBuffer[];
  67481. bufferViews?: IBufferView[];
  67482. cameras?: ICamera[];
  67483. images?: IImage[];
  67484. materials?: IMaterial[];
  67485. meshes?: IMesh[];
  67486. nodes?: INode[];
  67487. samplers?: ISampler[];
  67488. scenes?: IScene[];
  67489. skins?: ISkin[];
  67490. textures?: ITexture[];
  67491. }
  67492. }
  67493. declare module BABYLON.GLTF2 {
  67494. /**
  67495. * Interface for a glTF loader extension.
  67496. */
  67497. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  67498. /**
  67499. * Called after the loader state changes to LOADING.
  67500. */
  67501. onLoading?(): void;
  67502. /**
  67503. * Called after the loader state changes to READY.
  67504. */
  67505. onReady?(): void;
  67506. /**
  67507. * Define this method to modify the default behavior when loading scenes.
  67508. * @param context The context when loading the asset
  67509. * @param scene The glTF scene property
  67510. * @returns A promise that resolves when the load is complete or null if not handled
  67511. */
  67512. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  67513. /**
  67514. * Define this method to modify the default behavior when loading nodes.
  67515. * @param context The context when loading the asset
  67516. * @param node The glTF node property
  67517. * @param assign A function called synchronously after parsing the glTF properties
  67518. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  67519. */
  67520. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67521. /**
  67522. * Define this method to modify the default behavior when loading cameras.
  67523. * @param context The context when loading the asset
  67524. * @param camera The glTF camera property
  67525. * @param assign A function called synchronously after parsing the glTF properties
  67526. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  67527. */
  67528. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  67529. /**
  67530. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  67531. * @param context The context when loading the asset
  67532. * @param primitive The glTF mesh primitive property
  67533. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  67534. */ private _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  67535. /**
  67536. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  67537. * @param context The context when loading the asset
  67538. * @param name The mesh name when loading the asset
  67539. * @param node The glTF node when loading the asset
  67540. * @param mesh The glTF mesh when loading the asset
  67541. * @param primitive The glTF mesh primitive property
  67542. * @param assign A function called synchronously after parsing the glTF properties
  67543. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  67544. */ private _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  67545. /**
  67546. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  67547. * @param context The context when loading the asset
  67548. * @param material The glTF material property
  67549. * @param assign A function called synchronously after parsing the glTF properties
  67550. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  67551. */ private _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  67552. /**
  67553. * Define this method to modify the default behavior when creating materials.
  67554. * @param context The context when loading the asset
  67555. * @param material The glTF material property
  67556. * @param babylonDrawMode The draw mode for the Babylon material
  67557. * @returns The Babylon material or null if not handled
  67558. */
  67559. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  67560. /**
  67561. * Define this method to modify the default behavior when loading material properties.
  67562. * @param context The context when loading the asset
  67563. * @param material The glTF material property
  67564. * @param babylonMaterial The Babylon material
  67565. * @returns A promise that resolves when the load is complete or null if not handled
  67566. */
  67567. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67568. /**
  67569. * Define this method to modify the default behavior when loading texture infos.
  67570. * @param context The context when loading the asset
  67571. * @param textureInfo The glTF texture info property
  67572. * @param assign A function called synchronously after parsing the glTF properties
  67573. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  67574. */
  67575. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  67576. /**
  67577. * Define this method to modify the default behavior when loading animations.
  67578. * @param context The context when loading the asset
  67579. * @param animation The glTF animation property
  67580. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  67581. */
  67582. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  67583. /**
  67584. * @hidden Define this method to modify the default behavior when loading skins.
  67585. * @param context The context when loading the asset
  67586. * @param node The glTF node property
  67587. * @param skin The glTF skin property
  67588. * @returns A promise that resolves when the load is complete or null if not handled
  67589. */ private _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  67590. /**
  67591. * @hidden Define this method to modify the default behavior when loading uris.
  67592. * @param context The context when loading the asset
  67593. * @param property The glTF property associated with the uri
  67594. * @param uri The uri to load
  67595. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  67596. */ private _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  67597. }
  67598. }
  67599. declare module BABYLON.GLTF2 {
  67600. /**
  67601. * Helper class for working with arrays when loading the glTF asset
  67602. */
  67603. export class ArrayItem {
  67604. /**
  67605. * Gets an item from the given array.
  67606. * @param context The context when loading the asset
  67607. * @param array The array to get the item from
  67608. * @param index The index to the array
  67609. * @returns The array item
  67610. */
  67611. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  67612. /**
  67613. * Assign an `index` field to each item of the given array.
  67614. * @param array The array of items
  67615. */
  67616. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  67617. }
  67618. /**
  67619. * The glTF 2.0 loader
  67620. */
  67621. export class GLTFLoader implements IGLTFLoader {
  67622. /** @hidden */ private _completePromises: Promise<any>[];
  67623. private _disposed;
  67624. private _parent;
  67625. private _state;
  67626. private _extensions;
  67627. private _rootUrl;
  67628. private _fileName;
  67629. private _uniqueRootUrl;
  67630. private _gltf;
  67631. private _babylonScene;
  67632. private _rootBabylonMesh;
  67633. private _defaultBabylonMaterialData;
  67634. private _progressCallback?;
  67635. private _requests;
  67636. private static readonly _DefaultSampler;
  67637. private static _ExtensionNames;
  67638. private static _ExtensionFactories;
  67639. /**
  67640. * Registers a loader extension.
  67641. * @param name The name of the loader extension.
  67642. * @param factory The factory function that creates the loader extension.
  67643. */
  67644. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  67645. /**
  67646. * Unregisters a loader extension.
  67647. * @param name The name of the loader extenion.
  67648. * @returns A boolean indicating whether the extension has been unregistered
  67649. */
  67650. static UnregisterExtension(name: string): boolean;
  67651. /**
  67652. * Gets the loader state.
  67653. */
  67654. readonly state: Nullable<GLTFLoaderState>;
  67655. /**
  67656. * The glTF object parsed from the JSON.
  67657. */
  67658. readonly gltf: IGLTF;
  67659. /**
  67660. * The Babylon scene when loading the asset.
  67661. */
  67662. readonly babylonScene: Scene;
  67663. /**
  67664. * The root Babylon mesh when loading the asset.
  67665. */
  67666. readonly rootBabylonMesh: Mesh;
  67667. /** @hidden */
  67668. constructor(parent: GLTFFileLoader);
  67669. /** @hidden */
  67670. dispose(): void;
  67671. /** @hidden */
  67672. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67673. meshes: AbstractMesh[];
  67674. particleSystems: IParticleSystem[];
  67675. skeletons: Skeleton[];
  67676. animationGroups: AnimationGroup[];
  67677. }>;
  67678. /** @hidden */
  67679. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67680. private _loadAsync;
  67681. private _loadData;
  67682. private _setupData;
  67683. private _loadExtensions;
  67684. private _checkExtensions;
  67685. private _setState;
  67686. private _createRootNode;
  67687. /**
  67688. * Loads a glTF scene.
  67689. * @param context The context when loading the asset
  67690. * @param scene The glTF scene property
  67691. * @returns A promise that resolves when the load is complete
  67692. */
  67693. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  67694. private _forEachPrimitive;
  67695. private _getMeshes;
  67696. private _getSkeletons;
  67697. private _getAnimationGroups;
  67698. private _startAnimations;
  67699. /**
  67700. * Loads a glTF node.
  67701. * @param context The context when loading the asset
  67702. * @param node The glTF node property
  67703. * @param assign A function called synchronously after parsing the glTF properties
  67704. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  67705. */
  67706. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  67707. private _loadMeshAsync;
  67708. /**
  67709. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  67710. * @param context The context when loading the asset
  67711. * @param name The mesh name when loading the asset
  67712. * @param node The glTF node when loading the asset
  67713. * @param mesh The glTF mesh when loading the asset
  67714. * @param primitive The glTF mesh primitive property
  67715. * @param assign A function called synchronously after parsing the glTF properties
  67716. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  67717. */ private _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  67718. private _loadVertexDataAsync;
  67719. private _createMorphTargets;
  67720. private _loadMorphTargetsAsync;
  67721. private _loadMorphTargetVertexDataAsync;
  67722. private static _LoadTransform;
  67723. private _loadSkinAsync;
  67724. private _loadBones;
  67725. private _loadBone;
  67726. private _loadSkinInverseBindMatricesDataAsync;
  67727. private _updateBoneMatrices;
  67728. private _getNodeMatrix;
  67729. /**
  67730. * Loads a glTF camera.
  67731. * @param context The context when loading the asset
  67732. * @param camera The glTF camera property
  67733. * @param assign A function called synchronously after parsing the glTF properties
  67734. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  67735. */
  67736. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  67737. private _loadAnimationsAsync;
  67738. /**
  67739. * Loads a glTF animation.
  67740. * @param context The context when loading the asset
  67741. * @param animation The glTF animation property
  67742. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  67743. */
  67744. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  67745. /**
  67746. * @hidden Loads a glTF animation channel.
  67747. * @param context The context when loading the asset
  67748. * @param animationContext The context of the animation when loading the asset
  67749. * @param animation The glTF animation property
  67750. * @param channel The glTF animation channel property
  67751. * @param babylonAnimationGroup The babylon animation group property
  67752. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  67753. * @returns A void promise when the channel load is complete
  67754. */ private _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  67755. private _loadAnimationSamplerAsync;
  67756. private _loadBufferAsync;
  67757. /**
  67758. * Loads a glTF buffer view.
  67759. * @param context The context when loading the asset
  67760. * @param bufferView The glTF buffer view property
  67761. * @returns A promise that resolves with the loaded data when the load is complete
  67762. */
  67763. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  67764. private _loadAccessorAsync;
  67765. private _loadFloatAccessorAsync;
  67766. private _loadIndicesAccessorAsync;
  67767. private _loadVertexBufferViewAsync;
  67768. private _loadVertexAccessorAsync;
  67769. private _loadMaterialMetallicRoughnessPropertiesAsync;
  67770. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  67771. private _createDefaultMaterial;
  67772. /**
  67773. * Creates a Babylon material from a glTF material.
  67774. * @param context The context when loading the asset
  67775. * @param material The glTF material property
  67776. * @param babylonDrawMode The draw mode for the Babylon material
  67777. * @returns The Babylon material
  67778. */
  67779. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  67780. /**
  67781. * Loads properties from a glTF material into a Babylon material.
  67782. * @param context The context when loading the asset
  67783. * @param material The glTF material property
  67784. * @param babylonMaterial The Babylon material
  67785. * @returns A promise that resolves when the load is complete
  67786. */
  67787. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67788. /**
  67789. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  67790. * @param context The context when loading the asset
  67791. * @param material The glTF material property
  67792. * @param babylonMaterial The Babylon material
  67793. * @returns A promise that resolves when the load is complete
  67794. */
  67795. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67796. /**
  67797. * Loads the alpha properties from a glTF material into a Babylon material.
  67798. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  67799. * @param context The context when loading the asset
  67800. * @param material The glTF material property
  67801. * @param babylonMaterial The Babylon material
  67802. */
  67803. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  67804. /**
  67805. * Loads a glTF texture info.
  67806. * @param context The context when loading the asset
  67807. * @param textureInfo The glTF texture info property
  67808. * @param assign A function called synchronously after parsing the glTF properties
  67809. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  67810. */
  67811. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  67812. private _loadTextureAsync;
  67813. private _loadSampler;
  67814. /**
  67815. * Loads a glTF image.
  67816. * @param context The context when loading the asset
  67817. * @param image The glTF image property
  67818. * @returns A promise that resolves with the loaded data when the load is complete
  67819. */
  67820. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  67821. /**
  67822. * Loads a glTF uri.
  67823. * @param context The context when loading the asset
  67824. * @param property The glTF property associated with the uri
  67825. * @param uri The base64 or relative uri
  67826. * @returns A promise that resolves with the loaded data when the load is complete
  67827. */
  67828. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  67829. private _onProgress;
  67830. /**
  67831. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  67832. * @param babylonObject the Babylon object with metadata
  67833. * @param pointer the JSON pointer
  67834. */
  67835. static AddPointerMetadata(babylonObject: {
  67836. metadata: any;
  67837. }, pointer: string): void;
  67838. private static _GetTextureWrapMode;
  67839. private static _GetTextureSamplingMode;
  67840. private static _GetTypedArrayConstructor;
  67841. private static _GetTypedArray;
  67842. private static _GetNumComponents;
  67843. private static _ValidateUri;
  67844. private static _GetDrawMode;
  67845. private _compileMaterialsAsync;
  67846. private _compileShadowGeneratorsAsync;
  67847. private _forEachExtensions;
  67848. private _applyExtensions;
  67849. private _extensionsOnLoading;
  67850. private _extensionsOnReady;
  67851. private _extensionsLoadSceneAsync;
  67852. private _extensionsLoadNodeAsync;
  67853. private _extensionsLoadCameraAsync;
  67854. private _extensionsLoadVertexDataAsync;
  67855. private _extensionsLoadMeshPrimitiveAsync;
  67856. private _extensionsLoadMaterialAsync;
  67857. private _extensionsCreateMaterial;
  67858. private _extensionsLoadMaterialPropertiesAsync;
  67859. private _extensionsLoadTextureInfoAsync;
  67860. private _extensionsLoadAnimationAsync;
  67861. private _extensionsLoadSkinAsync;
  67862. private _extensionsLoadUriAsync;
  67863. /**
  67864. * Helper method called by a loader extension to load an glTF extension.
  67865. * @param context The context when loading the asset
  67866. * @param property The glTF property to load the extension from
  67867. * @param extensionName The name of the extension to load
  67868. * @param actionAsync The action to run
  67869. * @returns The promise returned by actionAsync or null if the extension does not exist
  67870. */
  67871. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  67872. /**
  67873. * Helper method called by a loader extension to load a glTF extra.
  67874. * @param context The context when loading the asset
  67875. * @param property The glTF property to load the extra from
  67876. * @param extensionName The name of the extension to load
  67877. * @param actionAsync The action to run
  67878. * @returns The promise returned by actionAsync or null if the extra does not exist
  67879. */
  67880. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  67881. /**
  67882. * Increments the indentation level and logs a message.
  67883. * @param message The message to log
  67884. */
  67885. logOpen(message: string): void;
  67886. /**
  67887. * Decrements the indentation level.
  67888. */
  67889. logClose(): void;
  67890. /**
  67891. * Logs a message
  67892. * @param message The message to log
  67893. */
  67894. log(message: string): void;
  67895. /**
  67896. * Starts a performance counter.
  67897. * @param counterName The name of the performance counter
  67898. */
  67899. startPerformanceCounter(counterName: string): void;
  67900. /**
  67901. * Ends a performance counter.
  67902. * @param counterName The name of the performance counter
  67903. */
  67904. endPerformanceCounter(counterName: string): void;
  67905. }
  67906. }
  67907. declare module BABYLON.GLTF2.Loader.Extensions {
  67908. /**
  67909. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  67910. */
  67911. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  67912. /** The name of this extension. */
  67913. readonly name: string;
  67914. /** Defines whether this extension is enabled. */
  67915. enabled: boolean;
  67916. private _loader;
  67917. private _lights?;
  67918. /** @hidden */
  67919. constructor(loader: GLTFLoader);
  67920. /** @hidden */
  67921. dispose(): void;
  67922. /** @hidden */
  67923. onLoading(): void;
  67924. /** @hidden */
  67925. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67926. private _loadLightAsync;
  67927. }
  67928. }
  67929. declare module BABYLON.GLTF2.Loader.Extensions {
  67930. /**
  67931. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  67932. */
  67933. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  67934. /** The name of this extension. */
  67935. readonly name: string;
  67936. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  67937. dracoCompression?: DracoCompression;
  67938. /** Defines whether this extension is enabled. */
  67939. enabled: boolean;
  67940. private _loader;
  67941. /** @hidden */
  67942. constructor(loader: GLTFLoader);
  67943. /** @hidden */
  67944. dispose(): void;
  67945. /** @hidden */ private _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  67946. }
  67947. }
  67948. declare module BABYLON.GLTF2.Loader.Extensions {
  67949. /**
  67950. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  67951. */
  67952. export class KHR_lights implements IGLTFLoaderExtension {
  67953. /** The name of this extension. */
  67954. readonly name: string;
  67955. /** Defines whether this extension is enabled. */
  67956. enabled: boolean;
  67957. private _loader;
  67958. private _lights?;
  67959. /** @hidden */
  67960. constructor(loader: GLTFLoader);
  67961. /** @hidden */
  67962. dispose(): void;
  67963. /** @hidden */
  67964. onLoading(): void;
  67965. /** @hidden */
  67966. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67967. }
  67968. }
  67969. declare module BABYLON.GLTF2.Loader.Extensions {
  67970. /**
  67971. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  67972. */
  67973. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  67974. /** The name of this extension. */
  67975. readonly name: string;
  67976. /** Defines whether this extension is enabled. */
  67977. enabled: boolean;
  67978. private _loader;
  67979. /** @hidden */
  67980. constructor(loader: GLTFLoader);
  67981. /** @hidden */
  67982. dispose(): void;
  67983. /** @hidden */
  67984. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67985. private _loadSpecularGlossinessPropertiesAsync;
  67986. }
  67987. }
  67988. declare module BABYLON.GLTF2.Loader.Extensions {
  67989. /**
  67990. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  67991. */
  67992. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  67993. /** The name of this extension. */
  67994. readonly name: string;
  67995. /** Defines whether this extension is enabled. */
  67996. enabled: boolean;
  67997. private _loader;
  67998. /** @hidden */
  67999. constructor(loader: GLTFLoader);
  68000. /** @hidden */
  68001. dispose(): void;
  68002. /** @hidden */
  68003. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68004. private _loadUnlitPropertiesAsync;
  68005. }
  68006. }
  68007. declare module BABYLON.GLTF2.Loader.Extensions {
  68008. /**
  68009. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  68010. */
  68011. export class KHR_texture_transform implements IGLTFLoaderExtension {
  68012. /** The name of this extension. */
  68013. readonly name: string;
  68014. /** Defines whether this extension is enabled. */
  68015. enabled: boolean;
  68016. private _loader;
  68017. /** @hidden */
  68018. constructor(loader: GLTFLoader);
  68019. /** @hidden */
  68020. dispose(): void;
  68021. /** @hidden */
  68022. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  68023. }
  68024. }
  68025. declare module BABYLON.GLTF2.Loader.Extensions {
  68026. /**
  68027. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  68028. */
  68029. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  68030. /** The name of this extension. */
  68031. readonly name: string;
  68032. /** Defines whether this extension is enabled. */
  68033. enabled: boolean;
  68034. private _loader;
  68035. private _clips;
  68036. private _emitters;
  68037. /** @hidden */
  68038. constructor(loader: GLTFLoader);
  68039. /** @hidden */
  68040. dispose(): void;
  68041. /** @hidden */
  68042. onLoading(): void;
  68043. /** @hidden */
  68044. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  68045. /** @hidden */
  68046. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68047. /** @hidden */
  68048. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  68049. private _loadClipAsync;
  68050. private _loadEmitterAsync;
  68051. private _getEventAction;
  68052. private _loadAnimationEventAsync;
  68053. }
  68054. }
  68055. declare module BABYLON.GLTF2.Loader.Extensions {
  68056. /**
  68057. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  68058. */
  68059. export class MSFT_lod implements IGLTFLoaderExtension {
  68060. /** The name of this extension. */
  68061. readonly name: string;
  68062. /** Defines whether this extension is enabled. */
  68063. enabled: boolean;
  68064. /**
  68065. * Maximum number of LODs to load, starting from the lowest LOD.
  68066. */
  68067. maxLODsToLoad: number;
  68068. /**
  68069. * Observable raised when all node LODs of one level are loaded.
  68070. * The event data is the index of the loaded LOD starting from zero.
  68071. * Dispose the loader to cancel the loading of the next level of LODs.
  68072. */
  68073. onNodeLODsLoadedObservable: Observable<number>;
  68074. /**
  68075. * Observable raised when all material LODs of one level are loaded.
  68076. * The event data is the index of the loaded LOD starting from zero.
  68077. * Dispose the loader to cancel the loading of the next level of LODs.
  68078. */
  68079. onMaterialLODsLoadedObservable: Observable<number>;
  68080. private _loader;
  68081. private _nodeIndexLOD;
  68082. private _nodeSignalLODs;
  68083. private _nodePromiseLODs;
  68084. private _materialIndexLOD;
  68085. private _materialSignalLODs;
  68086. private _materialPromiseLODs;
  68087. /** @hidden */
  68088. constructor(loader: GLTFLoader);
  68089. /** @hidden */
  68090. dispose(): void;
  68091. /** @hidden */
  68092. onReady(): void;
  68093. /** @hidden */
  68094. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68095. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  68096. /** @hidden */ private _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  68097. /**
  68098. * Gets an array of LOD properties from lowest to highest.
  68099. */
  68100. private _getLODs;
  68101. private _disposeUnusedMaterials;
  68102. }
  68103. }
  68104. declare module BABYLON.GLTF2.Loader.Extensions {
  68105. /** @hidden */
  68106. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  68107. readonly name: string;
  68108. enabled: boolean;
  68109. private _loader;
  68110. constructor(loader: GLTFLoader);
  68111. dispose(): void;
  68112. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68113. }
  68114. }
  68115. declare module BABYLON.GLTF2.Loader.Extensions {
  68116. /** @hidden */
  68117. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  68118. readonly name: string;
  68119. enabled: boolean;
  68120. private _loader;
  68121. constructor(loader: GLTFLoader);
  68122. dispose(): void;
  68123. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68124. }
  68125. }
  68126. declare module BABYLON.GLTF2.Loader.Extensions {
  68127. /**
  68128. * Store glTF extras (if present) in BJS objects' metadata
  68129. */
  68130. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  68131. /** The name of this extension. */
  68132. readonly name: string;
  68133. /** Defines whether this extension is enabled. */
  68134. enabled: boolean;
  68135. private _loader;
  68136. private _assignExtras;
  68137. /** @hidden */
  68138. constructor(loader: GLTFLoader);
  68139. /** @hidden */
  68140. dispose(): void;
  68141. /** @hidden */
  68142. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68143. /** @hidden */
  68144. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  68145. /** @hidden */
  68146. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  68147. }
  68148. }
  68149. declare module BABYLON {
  68150. /**
  68151. * Class reading and parsing the MTL file bundled with the obj file.
  68152. */
  68153. export class MTLFileLoader {
  68154. /**
  68155. * All material loaded from the mtl will be set here
  68156. */
  68157. materials: StandardMaterial[];
  68158. /**
  68159. * This function will read the mtl file and create each material described inside
  68160. * This function could be improve by adding :
  68161. * -some component missing (Ni, Tf...)
  68162. * -including the specific options available
  68163. *
  68164. * @param scene defines the scene the material will be created in
  68165. * @param data defines the mtl data to parse
  68166. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  68167. */
  68168. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  68169. /**
  68170. * Gets the texture for the material.
  68171. *
  68172. * If the material is imported from input file,
  68173. * We sanitize the url to ensure it takes the textre from aside the material.
  68174. *
  68175. * @param rootUrl The root url to load from
  68176. * @param value The value stored in the mtl
  68177. * @return The Texture
  68178. */
  68179. private static _getTexture;
  68180. }
  68181. /**
  68182. * Options for loading OBJ/MTL files
  68183. */
  68184. type MeshLoadOptions = {
  68185. /**
  68186. * Defines if UVs are optimized by default during load.
  68187. */
  68188. OptimizeWithUV: boolean;
  68189. /**
  68190. * Defines custom scaling of UV coordinates of loaded meshes.
  68191. */
  68192. UVScaling: Vector2;
  68193. /**
  68194. * Invert model on y-axis (does a model scaling inversion)
  68195. */
  68196. InvertY: boolean;
  68197. /**
  68198. * Invert Y-Axis of referenced textures on load
  68199. */
  68200. InvertTextureY: boolean;
  68201. /**
  68202. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68203. */
  68204. ImportVertexColors: boolean;
  68205. /**
  68206. * Compute the normals for the model, even if normals are present in the file.
  68207. */
  68208. ComputeNormals: boolean;
  68209. /**
  68210. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68211. */
  68212. SkipMaterials: boolean;
  68213. /**
  68214. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68215. */
  68216. MaterialLoadingFailsSilently: boolean;
  68217. };
  68218. /**
  68219. * OBJ file type loader.
  68220. * This is a babylon scene loader plugin.
  68221. */
  68222. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  68223. /**
  68224. * Defines if UVs are optimized by default during load.
  68225. */
  68226. static OPTIMIZE_WITH_UV: boolean;
  68227. /**
  68228. * Invert model on y-axis (does a model scaling inversion)
  68229. */
  68230. static INVERT_Y: boolean;
  68231. /**
  68232. * Invert Y-Axis of referenced textures on load
  68233. */
  68234. static INVERT_TEXTURE_Y: boolean;
  68235. /**
  68236. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68237. */
  68238. static IMPORT_VERTEX_COLORS: boolean;
  68239. /**
  68240. * Compute the normals for the model, even if normals are present in the file.
  68241. */
  68242. static COMPUTE_NORMALS: boolean;
  68243. /**
  68244. * Defines custom scaling of UV coordinates of loaded meshes.
  68245. */
  68246. static UV_SCALING: Vector2;
  68247. /**
  68248. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68249. */
  68250. static SKIP_MATERIALS: boolean;
  68251. /**
  68252. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68253. *
  68254. * Defaults to true for backwards compatibility.
  68255. */
  68256. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  68257. /**
  68258. * Defines the name of the plugin.
  68259. */
  68260. name: string;
  68261. /**
  68262. * Defines the extension the plugin is able to load.
  68263. */
  68264. extensions: string;
  68265. /** @hidden */
  68266. obj: RegExp;
  68267. /** @hidden */
  68268. group: RegExp;
  68269. /** @hidden */
  68270. mtllib: RegExp;
  68271. /** @hidden */
  68272. usemtl: RegExp;
  68273. /** @hidden */
  68274. smooth: RegExp;
  68275. /** @hidden */
  68276. vertexPattern: RegExp;
  68277. /** @hidden */
  68278. normalPattern: RegExp;
  68279. /** @hidden */
  68280. uvPattern: RegExp;
  68281. /** @hidden */
  68282. facePattern1: RegExp;
  68283. /** @hidden */
  68284. facePattern2: RegExp;
  68285. /** @hidden */
  68286. facePattern3: RegExp;
  68287. /** @hidden */
  68288. facePattern4: RegExp;
  68289. /** @hidden */
  68290. facePattern5: RegExp;
  68291. private _meshLoadOptions;
  68292. /**
  68293. * Creates loader for .OBJ files
  68294. *
  68295. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  68296. */
  68297. constructor(meshLoadOptions?: MeshLoadOptions);
  68298. private static readonly currentMeshLoadOptions;
  68299. /**
  68300. * Calls synchronously the MTL file attached to this obj.
  68301. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  68302. * Without this function materials are not displayed in the first frame (but displayed after).
  68303. * In consequence it is impossible to get material information in your HTML file
  68304. *
  68305. * @param url The URL of the MTL file
  68306. * @param rootUrl
  68307. * @param onSuccess Callback function to be called when the MTL file is loaded
  68308. * @private
  68309. */
  68310. private _loadMTL;
  68311. /**
  68312. * Instantiates a OBJ file loader plugin.
  68313. * @returns the created plugin
  68314. */
  68315. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  68316. /**
  68317. * If the data string can be loaded directly.
  68318. *
  68319. * @param data string containing the file data
  68320. * @returns if the data can be loaded directly
  68321. */
  68322. canDirectLoad(data: string): boolean;
  68323. /**
  68324. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  68325. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68326. * @param scene the scene the meshes should be added to
  68327. * @param data the OBJ data to load
  68328. * @param rootUrl root url to load from
  68329. * @param onProgress event that fires when loading progress has occured
  68330. * @param fileName Defines the name of the file to load
  68331. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68332. */
  68333. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68334. meshes: AbstractMesh[];
  68335. particleSystems: IParticleSystem[];
  68336. skeletons: Skeleton[];
  68337. animationGroups: AnimationGroup[];
  68338. }>;
  68339. /**
  68340. * Imports all objects from the loaded OBJ data and adds them to the scene
  68341. * @param scene the scene the objects should be added to
  68342. * @param data the OBJ data to load
  68343. * @param rootUrl root url to load from
  68344. * @param onProgress event that fires when loading progress has occured
  68345. * @param fileName Defines the name of the file to load
  68346. * @returns a promise which completes when objects have been loaded to the scene
  68347. */
  68348. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68349. /**
  68350. * Load into an asset container.
  68351. * @param scene The scene to load into
  68352. * @param data The data to import
  68353. * @param rootUrl The root url for scene and resources
  68354. * @param onProgress The callback when the load progresses
  68355. * @param fileName Defines the name of the file to load
  68356. * @returns The loaded asset container
  68357. */
  68358. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  68359. /**
  68360. * Read the OBJ file and create an Array of meshes.
  68361. * Each mesh contains all information given by the OBJ and the MTL file.
  68362. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  68363. *
  68364. * @param meshesNames
  68365. * @param scene Scene The scene where are displayed the data
  68366. * @param data String The content of the obj file
  68367. * @param rootUrl String The path to the folder
  68368. * @returns Array<AbstractMesh>
  68369. * @private
  68370. */
  68371. private _parseSolid;
  68372. }
  68373. }
  68374. declare module BABYLON {
  68375. /**
  68376. * STL file type loader.
  68377. * This is a babylon scene loader plugin.
  68378. */
  68379. export class STLFileLoader implements ISceneLoaderPlugin {
  68380. /** @hidden */
  68381. solidPattern: RegExp;
  68382. /** @hidden */
  68383. facetsPattern: RegExp;
  68384. /** @hidden */
  68385. normalPattern: RegExp;
  68386. /** @hidden */
  68387. vertexPattern: RegExp;
  68388. /**
  68389. * Defines the name of the plugin.
  68390. */
  68391. name: string;
  68392. /**
  68393. * Defines the extensions the stl loader is able to load.
  68394. * force data to come in as an ArrayBuffer
  68395. * we'll convert to string if it looks like it's an ASCII .stl
  68396. */
  68397. extensions: ISceneLoaderPluginExtensions;
  68398. /**
  68399. * Import meshes into a scene.
  68400. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  68401. * @param scene The scene to import into
  68402. * @param data The data to import
  68403. * @param rootUrl The root url for scene and resources
  68404. * @param meshes The meshes array to import into
  68405. * @param particleSystems The particle systems array to import into
  68406. * @param skeletons The skeletons array to import into
  68407. * @param onError The callback when import fails
  68408. * @returns True if successful or false otherwise
  68409. */
  68410. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  68411. /**
  68412. * Load into a scene.
  68413. * @param scene The scene to load into
  68414. * @param data The data to import
  68415. * @param rootUrl The root url for scene and resources
  68416. * @param onError The callback when import fails
  68417. * @returns true if successful or false otherwise
  68418. */
  68419. load(scene: Scene, data: any, rootUrl: string): boolean;
  68420. /**
  68421. * Load into an asset container.
  68422. * @param scene The scene to load into
  68423. * @param data The data to import
  68424. * @param rootUrl The root url for scene and resources
  68425. * @param onError The callback when import fails
  68426. * @returns The loaded asset container
  68427. */
  68428. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  68429. private _isBinary;
  68430. private _parseBinary;
  68431. private _parseASCII;
  68432. }
  68433. }
  68434. declare module BABYLON {
  68435. /**
  68436. * Class for generating OBJ data from a Babylon scene.
  68437. */
  68438. export class OBJExport {
  68439. /**
  68440. * Exports the geometry of a Mesh array in .OBJ file format (text)
  68441. * @param mesh defines the list of meshes to serialize
  68442. * @param materials defines if materials should be exported
  68443. * @param matlibname defines the name of the associated mtl file
  68444. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  68445. * @returns the OBJ content
  68446. */
  68447. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  68448. /**
  68449. * Exports the material(s) of a mesh in .MTL file format (text)
  68450. * @param mesh defines the mesh to extract the material from
  68451. * @returns the mtl content
  68452. */
  68453. static MTL(mesh: Mesh): string;
  68454. }
  68455. }
  68456. declare module BABYLON {
  68457. /** @hidden */
  68458. export var __IGLTFExporterExtension: number;
  68459. /**
  68460. * Interface for extending the exporter
  68461. * @hidden
  68462. */
  68463. export interface IGLTFExporterExtension {
  68464. /**
  68465. * The name of this extension
  68466. */
  68467. readonly name: string;
  68468. /**
  68469. * Defines whether this extension is enabled
  68470. */
  68471. enabled: boolean;
  68472. /**
  68473. * Defines whether this extension is required
  68474. */
  68475. required: boolean;
  68476. }
  68477. }
  68478. declare module BABYLON.GLTF2.Exporter {
  68479. /** @hidden */
  68480. export var __IGLTFExporterExtensionV2: number;
  68481. /**
  68482. * Interface for a glTF exporter extension
  68483. * @hidden
  68484. */
  68485. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  68486. /**
  68487. * Define this method to modify the default behavior before exporting a texture
  68488. * @param context The context when loading the asset
  68489. * @param babylonTexture The glTF texture info property
  68490. * @param mimeType The mime-type of the generated image
  68491. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  68492. */
  68493. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  68494. /**
  68495. * Define this method to modify the default behavior when exporting texture info
  68496. * @param context The context when loading the asset
  68497. * @param meshPrimitive glTF mesh primitive
  68498. * @param babylonSubMesh Babylon submesh
  68499. * @param binaryWriter glTF serializer binary writer instance
  68500. * @returns nullable IMeshPrimitive promise
  68501. */
  68502. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  68503. /**
  68504. * Define this method to modify the default behavior when exporting a node
  68505. * @param context The context when exporting the node
  68506. * @param node glTF node
  68507. * @param babylonNode BabylonJS node
  68508. * @returns nullable INode promise
  68509. */
  68510. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68511. /**
  68512. * Called after the exporter state changes to EXPORTING
  68513. */
  68514. onExporting?(): void;
  68515. }
  68516. }
  68517. declare module BABYLON.GLTF2.Exporter {
  68518. /**
  68519. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  68520. * @hidden
  68521. */
  68522. export class _GLTFMaterialExporter {
  68523. /**
  68524. * Represents the dielectric specular values for R, G and B
  68525. */
  68526. private static readonly _DielectricSpecular;
  68527. /**
  68528. * Allows the maximum specular power to be defined for material calculations
  68529. */
  68530. private static readonly _MaxSpecularPower;
  68531. /**
  68532. * Mapping to store textures
  68533. */
  68534. private _textureMap;
  68535. /**
  68536. * Numeric tolerance value
  68537. */
  68538. private static readonly _Epsilon;
  68539. /**
  68540. * Reference to the glTF Exporter
  68541. */
  68542. private _exporter;
  68543. constructor(exporter: _Exporter);
  68544. /**
  68545. * Specifies if two colors are approximately equal in value
  68546. * @param color1 first color to compare to
  68547. * @param color2 second color to compare to
  68548. * @param epsilon threshold value
  68549. */
  68550. private static FuzzyEquals;
  68551. /**
  68552. * Gets the materials from a Babylon scene and converts them to glTF materials
  68553. * @param scene babylonjs scene
  68554. * @param mimeType texture mime type
  68555. * @param images array of images
  68556. * @param textures array of textures
  68557. * @param materials array of materials
  68558. * @param imageData mapping of texture names to base64 textures
  68559. * @param hasTextureCoords specifies if texture coordinates are present on the material
  68560. */ private _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68561. /**
  68562. * Makes a copy of the glTF material without the texture parameters
  68563. * @param originalMaterial original glTF material
  68564. * @returns glTF material without texture parameters
  68565. */ private _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  68566. /**
  68567. * Specifies if the material has any texture parameters present
  68568. * @param material glTF Material
  68569. * @returns boolean specifying if texture parameters are present
  68570. */ private _hasTexturesPresent(material: IMaterial): boolean;
  68571. /**
  68572. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  68573. * @param babylonStandardMaterial
  68574. * @returns glTF Metallic Roughness Material representation
  68575. */ private _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  68576. /**
  68577. * Computes the metallic factor
  68578. * @param diffuse diffused value
  68579. * @param specular specular value
  68580. * @param oneMinusSpecularStrength one minus the specular strength
  68581. * @returns metallic value
  68582. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  68583. /**
  68584. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  68585. * @param glTFMaterial glTF material
  68586. * @param babylonMaterial Babylon material
  68587. */
  68588. private static _SetAlphaMode;
  68589. /**
  68590. * Converts a Babylon Standard Material to a glTF Material
  68591. * @param babylonStandardMaterial BJS Standard Material
  68592. * @param mimeType mime type to use for the textures
  68593. * @param images array of glTF image interfaces
  68594. * @param textures array of glTF texture interfaces
  68595. * @param materials array of glTF material interfaces
  68596. * @param imageData map of image file name to data
  68597. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68598. */ private _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68599. /**
  68600. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68601. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  68602. * @param mimeType mime type to use for the textures
  68603. * @param images array of glTF image interfaces
  68604. * @param textures array of glTF texture interfaces
  68605. * @param materials array of glTF material interfaces
  68606. * @param imageData map of image file name to data
  68607. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68608. */ private _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68609. /**
  68610. * Converts an image typed array buffer to a base64 image
  68611. * @param buffer typed array buffer
  68612. * @param width width of the image
  68613. * @param height height of the image
  68614. * @param mimeType mimetype of the image
  68615. * @returns base64 image string
  68616. */
  68617. private _createBase64FromCanvasAsync;
  68618. /**
  68619. * Generates a white texture based on the specified width and height
  68620. * @param width width of the texture in pixels
  68621. * @param height height of the texture in pixels
  68622. * @param scene babylonjs scene
  68623. * @returns white texture
  68624. */
  68625. private _createWhiteTexture;
  68626. /**
  68627. * 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
  68628. * @param texture1 first texture to resize
  68629. * @param texture2 second texture to resize
  68630. * @param scene babylonjs scene
  68631. * @returns resized textures or null
  68632. */
  68633. private _resizeTexturesToSameDimensions;
  68634. /**
  68635. * Converts an array of pixels to a Float32Array
  68636. * Throws an error if the pixel format is not supported
  68637. * @param pixels - array buffer containing pixel values
  68638. * @returns Float32 of pixels
  68639. */
  68640. private _convertPixelArrayToFloat32;
  68641. /**
  68642. * Convert Specular Glossiness Textures to Metallic Roughness
  68643. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  68644. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  68645. * @param diffuseTexture texture used to store diffuse information
  68646. * @param specularGlossinessTexture texture used to store specular and glossiness information
  68647. * @param factors specular glossiness material factors
  68648. * @param mimeType the mime type to use for the texture
  68649. * @returns pbr metallic roughness interface or null
  68650. */
  68651. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  68652. /**
  68653. * Converts specular glossiness material properties to metallic roughness
  68654. * @param specularGlossiness interface with specular glossiness material properties
  68655. * @returns interface with metallic roughness material properties
  68656. */
  68657. private _convertSpecularGlossinessToMetallicRoughness;
  68658. /**
  68659. * Calculates the surface reflectance, independent of lighting conditions
  68660. * @param color Color source to calculate brightness from
  68661. * @returns number representing the perceived brightness, or zero if color is undefined
  68662. */
  68663. private _getPerceivedBrightness;
  68664. /**
  68665. * Returns the maximum color component value
  68666. * @param color
  68667. * @returns maximum color component value, or zero if color is null or undefined
  68668. */
  68669. private _getMaxComponent;
  68670. /**
  68671. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  68672. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68673. * @param mimeType mime type to use for the textures
  68674. * @param images array of glTF image interfaces
  68675. * @param textures array of glTF texture interfaces
  68676. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68677. * @param imageData map of image file name to data
  68678. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68679. * @returns glTF PBR Metallic Roughness factors
  68680. */
  68681. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  68682. private _getGLTFTextureSampler;
  68683. private _getGLTFTextureWrapMode;
  68684. private _getGLTFTextureWrapModesSampler;
  68685. /**
  68686. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  68687. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68688. * @param mimeType mime type to use for the textures
  68689. * @param images array of glTF image interfaces
  68690. * @param textures array of glTF texture interfaces
  68691. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68692. * @param imageData map of image file name to data
  68693. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68694. * @returns glTF PBR Metallic Roughness factors
  68695. */
  68696. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  68697. /**
  68698. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68699. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68700. * @param mimeType mime type to use for the textures
  68701. * @param images array of glTF image interfaces
  68702. * @param textures array of glTF texture interfaces
  68703. * @param materials array of glTF material interfaces
  68704. * @param imageData map of image file name to data
  68705. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68706. */ private _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68707. private setMetallicRoughnessPbrMaterial;
  68708. private getPixelsFromTexture;
  68709. /**
  68710. * Extracts a texture from a Babylon texture into file data and glTF data
  68711. * @param babylonTexture Babylon texture to extract
  68712. * @param mimeType Mime Type of the babylonTexture
  68713. * @return glTF texture info, or null if the texture format is not supported
  68714. */ private _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; private _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  68715. /**
  68716. * Builds a texture from base64 string
  68717. * @param base64Texture base64 texture string
  68718. * @param baseTextureName Name to use for the texture
  68719. * @param mimeType image mime type for the texture
  68720. * @param images array of images
  68721. * @param textures array of textures
  68722. * @param imageData map of image data
  68723. * @returns glTF texture info, or null if the texture format is not supported
  68724. */
  68725. private _getTextureInfoFromBase64;
  68726. }
  68727. }
  68728. declare module BABYLON {
  68729. /**
  68730. * Class for holding and downloading glTF file data
  68731. */
  68732. export class GLTFData {
  68733. /**
  68734. * Object which contains the file name as the key and its data as the value
  68735. */
  68736. glTFFiles: {
  68737. [fileName: string]: string | Blob;
  68738. };
  68739. /**
  68740. * Initializes the glTF file object
  68741. */
  68742. constructor();
  68743. /**
  68744. * Downloads the glTF data as files based on their names and data
  68745. */
  68746. downloadFiles(): void;
  68747. }
  68748. }
  68749. declare module BABYLON {
  68750. /**
  68751. * Holds a collection of exporter options and parameters
  68752. */
  68753. export interface IExportOptions {
  68754. /**
  68755. * Function which indicates whether a babylon node should be exported or not
  68756. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  68757. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  68758. */
  68759. shouldExportNode?(node: Node): boolean;
  68760. /**
  68761. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  68762. * @param metadata source metadata to read from
  68763. * @returns the data to store to glTF node extras
  68764. */
  68765. metadataSelector?(metadata: any): any;
  68766. /**
  68767. * The sample rate to bake animation curves
  68768. */
  68769. animationSampleRate?: number;
  68770. /**
  68771. * Begin serialization without waiting for the scene to be ready
  68772. */
  68773. exportWithoutWaitingForScene?: boolean;
  68774. }
  68775. /**
  68776. * Class for generating glTF data from a Babylon scene.
  68777. */
  68778. export class GLTF2Export {
  68779. /**
  68780. * Exports the geometry of the scene to .gltf file format asynchronously
  68781. * @param scene Babylon scene with scene hierarchy information
  68782. * @param filePrefix File prefix to use when generating the glTF file
  68783. * @param options Exporter options
  68784. * @returns Returns an object with a .gltf file and associates texture names
  68785. * as keys and their data and paths as values
  68786. */
  68787. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68788. private static _PreExportAsync;
  68789. private static _PostExportAsync;
  68790. /**
  68791. * Exports the geometry of the scene to .glb file format asychronously
  68792. * @param scene Babylon scene with scene hierarchy information
  68793. * @param filePrefix File prefix to use when generating glb file
  68794. * @param options Exporter options
  68795. * @returns Returns an object with a .glb filename as key and data as value
  68796. */
  68797. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68798. }
  68799. }
  68800. declare module BABYLON.GLTF2.Exporter {
  68801. /**
  68802. * @hidden
  68803. */
  68804. export class _GLTFUtilities {
  68805. /**
  68806. * Creates a buffer view based on the supplied arguments
  68807. * @param bufferIndex index value of the specified buffer
  68808. * @param byteOffset byte offset value
  68809. * @param byteLength byte length of the bufferView
  68810. * @param byteStride byte distance between conequential elements
  68811. * @param name name of the buffer view
  68812. * @returns bufferView for glTF
  68813. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  68814. /**
  68815. * Creates an accessor based on the supplied arguments
  68816. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  68817. * @param name The name of the accessor
  68818. * @param type The type of the accessor
  68819. * @param componentType The datatype of components in the attribute
  68820. * @param count The number of attributes referenced by this accessor
  68821. * @param byteOffset The offset relative to the start of the bufferView in bytes
  68822. * @param min Minimum value of each component in this attribute
  68823. * @param max Maximum value of each component in this attribute
  68824. * @returns accessor for glTF
  68825. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  68826. /**
  68827. * Calculates the minimum and maximum values of an array of position floats
  68828. * @param positions Positions array of a mesh
  68829. * @param vertexStart Starting vertex offset to calculate min and max values
  68830. * @param vertexCount Number of vertices to check for min and max values
  68831. * @returns min number array and max number array
  68832. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  68833. min: number[];
  68834. max: number[];
  68835. };
  68836. /**
  68837. * Converts a new right-handed Vector3
  68838. * @param vector vector3 array
  68839. * @returns right-handed Vector3
  68840. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  68841. /**
  68842. * Converts a Vector3 to right-handed
  68843. * @param vector Vector3 to convert to right-handed
  68844. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  68845. /**
  68846. * Converts a three element number array to right-handed
  68847. * @param vector number array to convert to right-handed
  68848. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  68849. /**
  68850. * Converts a new right-handed Vector3
  68851. * @param vector vector3 array
  68852. * @returns right-handed Vector3
  68853. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  68854. /**
  68855. * Converts a Vector3 to right-handed
  68856. * @param vector Vector3 to convert to right-handed
  68857. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  68858. /**
  68859. * Converts a three element number array to right-handed
  68860. * @param vector number array to convert to right-handed
  68861. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  68862. /**
  68863. * Converts a Vector4 to right-handed
  68864. * @param vector Vector4 to convert to right-handed
  68865. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  68866. /**
  68867. * Converts a Vector4 to right-handed
  68868. * @param vector Vector4 to convert to right-handed
  68869. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  68870. /**
  68871. * Converts a Quaternion to right-handed
  68872. * @param quaternion Source quaternion to convert to right-handed
  68873. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  68874. /**
  68875. * Converts a Quaternion to right-handed
  68876. * @param quaternion Source quaternion to convert to right-handed
  68877. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  68878. }
  68879. }
  68880. declare module BABYLON.GLTF2.Exporter {
  68881. /**
  68882. * Converts Babylon Scene into glTF 2.0.
  68883. * @hidden
  68884. */
  68885. export class _Exporter {
  68886. /**
  68887. * Stores the glTF to export
  68888. */ private _glTF: IGLTF;
  68889. /**
  68890. * Stores all generated buffer views, which represents views into the main glTF buffer data
  68891. */ private _bufferViews: IBufferView[];
  68892. /**
  68893. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  68894. */ private _accessors: IAccessor[];
  68895. /**
  68896. * Stores all the generated nodes, which contains transform and/or mesh information per node
  68897. */
  68898. private _nodes;
  68899. /**
  68900. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  68901. */
  68902. private _scenes;
  68903. /**
  68904. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  68905. */
  68906. private _meshes;
  68907. /**
  68908. * Stores all the generated material information, which represents the appearance of each primitive
  68909. */ private _materials: IMaterial[]; private _materialMap: {
  68910. [materialID: number]: number;
  68911. };
  68912. /**
  68913. * Stores all the generated texture information, which is referenced by glTF materials
  68914. */ private _textures: ITexture[];
  68915. /**
  68916. * Stores all the generated image information, which is referenced by glTF textures
  68917. */ private _images: IImage[];
  68918. /**
  68919. * Stores all the texture samplers
  68920. */ private _samplers: ISampler[];
  68921. /**
  68922. * Stores all the generated animation samplers, which is referenced by glTF animations
  68923. */
  68924. /**
  68925. * Stores the animations for glTF models
  68926. */
  68927. private _animations;
  68928. /**
  68929. * Stores the total amount of bytes stored in the glTF buffer
  68930. */
  68931. private _totalByteLength;
  68932. /**
  68933. * Stores a reference to the Babylon scene containing the source geometry and material information
  68934. */ private _babylonScene: Scene;
  68935. /**
  68936. * Stores a map of the image data, where the key is the file name and the value
  68937. * is the image data
  68938. */ private _imageData: {
  68939. [fileName: string]: {
  68940. data: Uint8Array;
  68941. mimeType: ImageMimeType;
  68942. };
  68943. };
  68944. /**
  68945. * Stores a map of the unique id of a node to its index in the node array
  68946. */
  68947. private _nodeMap;
  68948. /**
  68949. * Specifies if the Babylon scene should be converted to right-handed on export
  68950. */ private _convertToRightHandedSystem: boolean;
  68951. /**
  68952. * Baked animation sample rate
  68953. */
  68954. private _animationSampleRate;
  68955. private _options;
  68956. private _localEngine; private _glTFMaterialExporter: _GLTFMaterialExporter;
  68957. private _extensions;
  68958. private static _ExtensionNames;
  68959. private static _ExtensionFactories;
  68960. 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>>;
  68961. private _forEachExtensions;
  68962. private _extensionsOnExporting;
  68963. /**
  68964. * Load glTF serializer extensions
  68965. */
  68966. private _loadExtensions;
  68967. /**
  68968. * Creates a glTF Exporter instance, which can accept optional exporter options
  68969. * @param babylonScene Babylon scene object
  68970. * @param options Options to modify the behavior of the exporter
  68971. */
  68972. constructor(babylonScene: Scene, options?: IExportOptions);
  68973. /**
  68974. * Registers a glTF exporter extension
  68975. * @param name Name of the extension to export
  68976. * @param factory The factory function that creates the exporter extension
  68977. */
  68978. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  68979. /**
  68980. * Un-registers an exporter extension
  68981. * @param name The name fo the exporter extension
  68982. * @returns A boolean indicating whether the extension has been un-registered
  68983. */
  68984. static UnregisterExtension(name: string): boolean;
  68985. /**
  68986. * Lazy load a local engine with premultiplied alpha set to false
  68987. */ private _getLocalEngine(): Engine;
  68988. private reorderIndicesBasedOnPrimitiveMode;
  68989. /**
  68990. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  68991. * clock-wise during export to glTF
  68992. * @param submesh BabylonJS submesh
  68993. * @param primitiveMode Primitive mode of the mesh
  68994. * @param sideOrientation the winding order of the submesh
  68995. * @param vertexBufferKind The type of vertex attribute
  68996. * @param meshAttributeArray The vertex attribute data
  68997. * @param byteOffset The offset to the binary data
  68998. * @param binaryWriter The binary data for the glTF file
  68999. */
  69000. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  69001. /**
  69002. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  69003. * clock-wise during export to glTF
  69004. * @param submesh BabylonJS submesh
  69005. * @param primitiveMode Primitive mode of the mesh
  69006. * @param sideOrientation the winding order of the submesh
  69007. * @param vertexBufferKind The type of vertex attribute
  69008. * @param meshAttributeArray The vertex attribute data
  69009. * @param byteOffset The offset to the binary data
  69010. * @param binaryWriter The binary data for the glTF file
  69011. */
  69012. private reorderTriangleFillMode;
  69013. /**
  69014. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  69015. * clock-wise during export to glTF
  69016. * @param submesh BabylonJS submesh
  69017. * @param primitiveMode Primitive mode of the mesh
  69018. * @param sideOrientation the winding order of the submesh
  69019. * @param vertexBufferKind The type of vertex attribute
  69020. * @param meshAttributeArray The vertex attribute data
  69021. * @param byteOffset The offset to the binary data
  69022. * @param binaryWriter The binary data for the glTF file
  69023. */
  69024. private reorderTriangleStripDrawMode;
  69025. /**
  69026. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  69027. * clock-wise during export to glTF
  69028. * @param submesh BabylonJS submesh
  69029. * @param primitiveMode Primitive mode of the mesh
  69030. * @param sideOrientation the winding order of the submesh
  69031. * @param vertexBufferKind The type of vertex attribute
  69032. * @param meshAttributeArray The vertex attribute data
  69033. * @param byteOffset The offset to the binary data
  69034. * @param binaryWriter The binary data for the glTF file
  69035. */
  69036. private reorderTriangleFanMode;
  69037. /**
  69038. * Writes the vertex attribute data to binary
  69039. * @param vertices The vertices to write to the binary writer
  69040. * @param byteOffset The offset into the binary writer to overwrite binary data
  69041. * @param vertexAttributeKind The vertex attribute type
  69042. * @param meshAttributeArray The vertex attribute data
  69043. * @param binaryWriter The writer containing the binary data
  69044. */
  69045. private writeVertexAttributeData;
  69046. /**
  69047. * Writes mesh attribute data to a data buffer
  69048. * Returns the bytelength of the data
  69049. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  69050. * @param meshAttributeArray Array containing the attribute data
  69051. * @param binaryWriter The buffer to write the binary data to
  69052. * @param indices Used to specify the order of the vertex data
  69053. */
  69054. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  69055. /**
  69056. * Generates glTF json data
  69057. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  69058. * @param glTFPrefix Text to use when prefixing a glTF file
  69059. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  69060. * @returns json data as string
  69061. */
  69062. private generateJSON;
  69063. /**
  69064. * Generates data for .gltf and .bin files based on the glTF prefix string
  69065. * @param glTFPrefix Text to use when prefixing a glTF file
  69066. * @returns GLTFData with glTF file data
  69067. */ private _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  69068. /**
  69069. * Creates a binary buffer for glTF
  69070. * @returns array buffer for binary data
  69071. */
  69072. private _generateBinaryAsync;
  69073. /**
  69074. * Pads the number to a multiple of 4
  69075. * @param num number to pad
  69076. * @returns padded number
  69077. */
  69078. private _getPadding;
  69079. /**
  69080. * Generates a glb file from the json and binary data
  69081. * Returns an object with the glb file name as the key and data as the value
  69082. * @param glTFPrefix
  69083. * @returns object with glb filename as key and data as value
  69084. */ private _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  69085. /**
  69086. * Sets the TRS for each node
  69087. * @param node glTF Node for storing the transformation data
  69088. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  69089. */
  69090. private setNodeTransformation;
  69091. private getVertexBufferFromMesh;
  69092. /**
  69093. * Creates a bufferview based on the vertices type for the Babylon mesh
  69094. * @param kind Indicates the type of vertices data
  69095. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  69096. * @param binaryWriter The buffer to write the bufferview data to
  69097. */
  69098. private createBufferViewKind;
  69099. /**
  69100. * The primitive mode of the Babylon mesh
  69101. * @param babylonMesh The BabylonJS mesh
  69102. */
  69103. private getMeshPrimitiveMode;
  69104. /**
  69105. * Sets the primitive mode of the glTF mesh primitive
  69106. * @param meshPrimitive glTF mesh primitive
  69107. * @param primitiveMode The primitive mode
  69108. */
  69109. private setPrimitiveMode;
  69110. /**
  69111. * Sets the vertex attribute accessor based of the glTF mesh primitive
  69112. * @param meshPrimitive glTF mesh primitive
  69113. * @param attributeKind vertex attribute
  69114. * @returns boolean specifying if uv coordinates are present
  69115. */
  69116. private setAttributeKind;
  69117. /**
  69118. * Sets data for the primitive attributes of each submesh
  69119. * @param mesh glTF Mesh object to store the primitive attribute information
  69120. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  69121. * @param binaryWriter Buffer to write the attribute data to
  69122. */
  69123. private setPrimitiveAttributesAsync;
  69124. /**
  69125. * Creates a glTF scene based on the array of meshes
  69126. * Returns the the total byte offset
  69127. * @param babylonScene Babylon scene to get the mesh data from
  69128. * @param binaryWriter Buffer to write binary data to
  69129. */
  69130. private createSceneAsync;
  69131. /**
  69132. * Creates a mapping of Node unique id to node index and handles animations
  69133. * @param babylonScene Babylon Scene
  69134. * @param nodes Babylon transform nodes
  69135. * @param binaryWriter Buffer to write binary data to
  69136. * @returns Node mapping of unique id to index
  69137. */
  69138. private createNodeMapAndAnimationsAsync;
  69139. /**
  69140. * Creates a glTF node from a Babylon mesh
  69141. * @param babylonMesh Source Babylon mesh
  69142. * @param binaryWriter Buffer for storing geometry data
  69143. * @returns glTF node
  69144. */
  69145. private createNodeAsync;
  69146. }
  69147. /**
  69148. * @hidden
  69149. *
  69150. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  69151. */
  69152. export class _BinaryWriter {
  69153. /**
  69154. * Array buffer which stores all binary data
  69155. */
  69156. private _arrayBuffer;
  69157. /**
  69158. * View of the array buffer
  69159. */
  69160. private _dataView;
  69161. /**
  69162. * byte offset of data in array buffer
  69163. */
  69164. private _byteOffset;
  69165. /**
  69166. * Initialize binary writer with an initial byte length
  69167. * @param byteLength Initial byte length of the array buffer
  69168. */
  69169. constructor(byteLength: number);
  69170. /**
  69171. * Resize the array buffer to the specified byte length
  69172. * @param byteLength
  69173. */
  69174. private resizeBuffer;
  69175. /**
  69176. * Get an array buffer with the length of the byte offset
  69177. * @returns ArrayBuffer resized to the byte offset
  69178. */
  69179. getArrayBuffer(): ArrayBuffer;
  69180. /**
  69181. * Get the byte offset of the array buffer
  69182. * @returns byte offset
  69183. */
  69184. getByteOffset(): number;
  69185. /**
  69186. * Stores an UInt8 in the array buffer
  69187. * @param entry
  69188. * @param byteOffset If defined, specifies where to set the value as an offset.
  69189. */
  69190. setUInt8(entry: number, byteOffset?: number): void;
  69191. /**
  69192. * Gets an UInt32 in the array buffer
  69193. * @param entry
  69194. * @param byteOffset If defined, specifies where to set the value as an offset.
  69195. */
  69196. getUInt32(byteOffset: number): number;
  69197. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69198. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69199. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69200. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69201. /**
  69202. * Stores a Float32 in the array buffer
  69203. * @param entry
  69204. */
  69205. setFloat32(entry: number, byteOffset?: number): void;
  69206. /**
  69207. * Stores an UInt32 in the array buffer
  69208. * @param entry
  69209. * @param byteOffset If defined, specifies where to set the value as an offset.
  69210. */
  69211. setUInt32(entry: number, byteOffset?: number): void;
  69212. }
  69213. }
  69214. declare module BABYLON.GLTF2.Exporter {
  69215. /**
  69216. * @hidden
  69217. * Interface to store animation data.
  69218. */
  69219. export interface _IAnimationData {
  69220. /**
  69221. * Keyframe data.
  69222. */
  69223. inputs: number[];
  69224. /**
  69225. * Value data.
  69226. */
  69227. outputs: number[][];
  69228. /**
  69229. * Animation interpolation data.
  69230. */
  69231. samplerInterpolation: AnimationSamplerInterpolation;
  69232. /**
  69233. * Minimum keyframe value.
  69234. */
  69235. inputsMin: number;
  69236. /**
  69237. * Maximum keyframe value.
  69238. */
  69239. inputsMax: number;
  69240. }
  69241. /**
  69242. * @hidden
  69243. */
  69244. export interface _IAnimationInfo {
  69245. /**
  69246. * The target channel for the animation
  69247. */
  69248. animationChannelTargetPath: AnimationChannelTargetPath;
  69249. /**
  69250. * The glTF accessor type for the data.
  69251. */
  69252. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  69253. /**
  69254. * Specifies if quaternions should be used.
  69255. */
  69256. useQuaternion: boolean;
  69257. }
  69258. /**
  69259. * @hidden
  69260. * Utility class for generating glTF animation data from BabylonJS.
  69261. */
  69262. export class _GLTFAnimation {
  69263. /**
  69264. * @ignore
  69265. *
  69266. * Creates glTF channel animation from BabylonJS animation.
  69267. * @param babylonTransformNode - BabylonJS mesh.
  69268. * @param animation - animation.
  69269. * @param animationChannelTargetPath - The target animation channel.
  69270. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  69271. * @param useQuaternion - Specifies if quaternions are used.
  69272. * @returns nullable IAnimationData
  69273. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  69274. private static _DeduceAnimationInfo;
  69275. /**
  69276. * @ignore
  69277. * Create node animations from the transform node animations
  69278. * @param babylonNode
  69279. * @param runtimeGLTFAnimation
  69280. * @param idleGLTFAnimations
  69281. * @param nodeMap
  69282. * @param nodes
  69283. * @param binaryWriter
  69284. * @param bufferViews
  69285. * @param accessors
  69286. * @param convertToRightHandedSystem
  69287. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  69288. [key: number]: number;
  69289. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  69290. /**
  69291. * @ignore
  69292. * Create node animations from the animation groups
  69293. * @param babylonScene
  69294. * @param glTFAnimations
  69295. * @param nodeMap
  69296. * @param nodes
  69297. * @param binaryWriter
  69298. * @param bufferViews
  69299. * @param accessors
  69300. * @param convertToRightHandedSystem
  69301. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  69302. [key: number]: number;
  69303. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  69304. private static AddAnimation;
  69305. /**
  69306. * Create a baked animation
  69307. * @param babylonTransformNode BabylonJS mesh
  69308. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  69309. * @param animationChannelTargetPath animation target channel
  69310. * @param minFrame minimum animation frame
  69311. * @param maxFrame maximum animation frame
  69312. * @param fps frames per second of the animation
  69313. * @param inputs input key frames of the animation
  69314. * @param outputs output key frame data of the animation
  69315. * @param convertToRightHandedSystem converts the values to right-handed
  69316. * @param useQuaternion specifies if quaternions should be used
  69317. */
  69318. private static _CreateBakedAnimation;
  69319. private static _ConvertFactorToVector3OrQuaternion;
  69320. private static _SetInterpolatedValue;
  69321. /**
  69322. * Creates linear animation from the animation key frames
  69323. * @param babylonTransformNode BabylonJS mesh
  69324. * @param animation BabylonJS animation
  69325. * @param animationChannelTargetPath The target animation channel
  69326. * @param frameDelta The difference between the last and first frame of the animation
  69327. * @param inputs Array to store the key frame times
  69328. * @param outputs Array to store the key frame data
  69329. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  69330. * @param useQuaternion Specifies if quaternions are used in the animation
  69331. */
  69332. private static _CreateLinearOrStepAnimation;
  69333. /**
  69334. * Creates cubic spline animation from the animation key frames
  69335. * @param babylonTransformNode BabylonJS mesh
  69336. * @param animation BabylonJS animation
  69337. * @param animationChannelTargetPath The target animation channel
  69338. * @param frameDelta The difference between the last and first frame of the animation
  69339. * @param inputs Array to store the key frame times
  69340. * @param outputs Array to store the key frame data
  69341. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  69342. * @param useQuaternion Specifies if quaternions are used in the animation
  69343. */
  69344. private static _CreateCubicSplineAnimation;
  69345. private static _GetBasePositionRotationOrScale;
  69346. /**
  69347. * Adds a key frame value
  69348. * @param keyFrame
  69349. * @param animation
  69350. * @param outputs
  69351. * @param animationChannelTargetPath
  69352. * @param basePositionRotationOrScale
  69353. * @param convertToRightHandedSystem
  69354. * @param useQuaternion
  69355. */
  69356. private static _AddKeyframeValue;
  69357. /**
  69358. * Determine the interpolation based on the key frames
  69359. * @param keyFrames
  69360. * @param animationChannelTargetPath
  69361. * @param useQuaternion
  69362. */
  69363. private static _DeduceInterpolation;
  69364. /**
  69365. * Adds an input tangent or output tangent to the output data
  69366. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  69367. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  69368. * @param outputs The animation data by keyframe
  69369. * @param animationChannelTargetPath The target animation channel
  69370. * @param interpolation The interpolation type
  69371. * @param keyFrame The key frame with the animation data
  69372. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  69373. * @param useQuaternion Specifies if quaternions are used
  69374. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  69375. */
  69376. private static AddSplineTangent;
  69377. /**
  69378. * Get the minimum and maximum key frames' frame values
  69379. * @param keyFrames animation key frames
  69380. * @returns the minimum and maximum key frame value
  69381. */
  69382. private static calculateMinMaxKeyFrames;
  69383. }
  69384. }
  69385. declare module BABYLON.GLTF2.Exporter {
  69386. /** @hidden */
  69387. export var textureTransformPixelShader: {
  69388. name: string;
  69389. shader: string;
  69390. };
  69391. }
  69392. declare module BABYLON.GLTF2.Exporter.Extensions {
  69393. /**
  69394. * @hidden
  69395. */
  69396. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  69397. /** Name of this extension */
  69398. readonly name: string;
  69399. /** Defines whether this extension is enabled */
  69400. enabled: boolean;
  69401. /** Defines whether this extension is required */
  69402. required: boolean;
  69403. /** Reference to the glTF exporter */
  69404. private _exporter;
  69405. constructor(exporter: _Exporter);
  69406. dispose(): void;
  69407. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  69408. /**
  69409. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  69410. * @param babylonTexture
  69411. * @param offset
  69412. * @param rotation
  69413. * @param scale
  69414. * @param scene
  69415. */
  69416. private _textureTransformTextureAsync;
  69417. }
  69418. }
  69419. declare module BABYLON.GLTF2.Exporter.Extensions {
  69420. /**
  69421. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  69422. */
  69423. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  69424. /** The name of this extension. */
  69425. readonly name: string;
  69426. /** Defines whether this extension is enabled. */
  69427. enabled: boolean;
  69428. /** Defines whether this extension is required */
  69429. required: boolean;
  69430. /** Reference to the glTF exporter */
  69431. private _exporter;
  69432. private _lights;
  69433. /** @hidden */
  69434. constructor(exporter: _Exporter);
  69435. /** @hidden */
  69436. dispose(): void;
  69437. /** @hidden */
  69438. onExporting(): void;
  69439. /**
  69440. * Define this method to modify the default behavior when exporting a node
  69441. * @param context The context when exporting the node
  69442. * @param node glTF node
  69443. * @param babylonNode BabylonJS node
  69444. * @returns nullable INode promise
  69445. */
  69446. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69447. }
  69448. }
  69449. declare module BABYLON {
  69450. /**
  69451. * Class for generating STL data from a Babylon scene.
  69452. */
  69453. export class STLExport {
  69454. /**
  69455. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  69456. * @param meshes list defines the mesh to serialize
  69457. * @param download triggers the automatic download of the file.
  69458. * @param fileName changes the downloads fileName.
  69459. * @param binary changes the STL to a binary type.
  69460. * @param isLittleEndian toggle for binary type exporter.
  69461. * @returns the STL as UTF8 string
  69462. */
  69463. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  69464. }
  69465. }
  69466. declare module "babylonjs-gltf2interface" {
  69467. export = BABYLON.GLTF2;
  69468. }
  69469. /**
  69470. * Module for glTF 2.0 Interface
  69471. */
  69472. declare module BABYLON.GLTF2 {
  69473. /**
  69474. * The datatype of the components in the attribute
  69475. */
  69476. const enum AccessorComponentType {
  69477. /**
  69478. * Byte
  69479. */
  69480. BYTE = 5120,
  69481. /**
  69482. * Unsigned Byte
  69483. */
  69484. UNSIGNED_BYTE = 5121,
  69485. /**
  69486. * Short
  69487. */
  69488. SHORT = 5122,
  69489. /**
  69490. * Unsigned Short
  69491. */
  69492. UNSIGNED_SHORT = 5123,
  69493. /**
  69494. * Unsigned Int
  69495. */
  69496. UNSIGNED_INT = 5125,
  69497. /**
  69498. * Float
  69499. */
  69500. FLOAT = 5126,
  69501. }
  69502. /**
  69503. * Specifies if the attirbute is a scalar, vector, or matrix
  69504. */
  69505. const enum AccessorType {
  69506. /**
  69507. * Scalar
  69508. */
  69509. SCALAR = "SCALAR",
  69510. /**
  69511. * Vector2
  69512. */
  69513. VEC2 = "VEC2",
  69514. /**
  69515. * Vector3
  69516. */
  69517. VEC3 = "VEC3",
  69518. /**
  69519. * Vector4
  69520. */
  69521. VEC4 = "VEC4",
  69522. /**
  69523. * Matrix2x2
  69524. */
  69525. MAT2 = "MAT2",
  69526. /**
  69527. * Matrix3x3
  69528. */
  69529. MAT3 = "MAT3",
  69530. /**
  69531. * Matrix4x4
  69532. */
  69533. MAT4 = "MAT4",
  69534. }
  69535. /**
  69536. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  69537. */
  69538. const enum AnimationChannelTargetPath {
  69539. /**
  69540. * Translation
  69541. */
  69542. TRANSLATION = "translation",
  69543. /**
  69544. * Rotation
  69545. */
  69546. ROTATION = "rotation",
  69547. /**
  69548. * Scale
  69549. */
  69550. SCALE = "scale",
  69551. /**
  69552. * Weights
  69553. */
  69554. WEIGHTS = "weights",
  69555. }
  69556. /**
  69557. * Interpolation algorithm
  69558. */
  69559. const enum AnimationSamplerInterpolation {
  69560. /**
  69561. * The animated values are linearly interpolated between keyframes
  69562. */
  69563. LINEAR = "LINEAR",
  69564. /**
  69565. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  69566. */
  69567. STEP = "STEP",
  69568. /**
  69569. * The animation's interpolation is computed using a cubic spline with specified tangents
  69570. */
  69571. CUBICSPLINE = "CUBICSPLINE",
  69572. }
  69573. /**
  69574. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  69575. */
  69576. const enum CameraType {
  69577. /**
  69578. * A perspective camera containing properties to create a perspective projection matrix
  69579. */
  69580. PERSPECTIVE = "perspective",
  69581. /**
  69582. * An orthographic camera containing properties to create an orthographic projection matrix
  69583. */
  69584. ORTHOGRAPHIC = "orthographic",
  69585. }
  69586. /**
  69587. * The mime-type of the image
  69588. */
  69589. const enum ImageMimeType {
  69590. /**
  69591. * JPEG Mime-type
  69592. */
  69593. JPEG = "image/jpeg",
  69594. /**
  69595. * PNG Mime-type
  69596. */
  69597. PNG = "image/png",
  69598. }
  69599. /**
  69600. * The alpha rendering mode of the material
  69601. */
  69602. const enum MaterialAlphaMode {
  69603. /**
  69604. * The alpha value is ignored and the rendered output is fully opaque
  69605. */
  69606. OPAQUE = "OPAQUE",
  69607. /**
  69608. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  69609. */
  69610. MASK = "MASK",
  69611. /**
  69612. * 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)
  69613. */
  69614. BLEND = "BLEND",
  69615. }
  69616. /**
  69617. * The type of the primitives to render
  69618. */
  69619. const enum MeshPrimitiveMode {
  69620. /**
  69621. * Points
  69622. */
  69623. POINTS = 0,
  69624. /**
  69625. * Lines
  69626. */
  69627. LINES = 1,
  69628. /**
  69629. * Line Loop
  69630. */
  69631. LINE_LOOP = 2,
  69632. /**
  69633. * Line Strip
  69634. */
  69635. LINE_STRIP = 3,
  69636. /**
  69637. * Triangles
  69638. */
  69639. TRIANGLES = 4,
  69640. /**
  69641. * Triangle Strip
  69642. */
  69643. TRIANGLE_STRIP = 5,
  69644. /**
  69645. * Triangle Fan
  69646. */
  69647. TRIANGLE_FAN = 6,
  69648. }
  69649. /**
  69650. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  69651. */
  69652. const enum TextureMagFilter {
  69653. /**
  69654. * Nearest
  69655. */
  69656. NEAREST = 9728,
  69657. /**
  69658. * Linear
  69659. */
  69660. LINEAR = 9729,
  69661. }
  69662. /**
  69663. * Minification filter. All valid values correspond to WebGL enums
  69664. */
  69665. const enum TextureMinFilter {
  69666. /**
  69667. * Nearest
  69668. */
  69669. NEAREST = 9728,
  69670. /**
  69671. * Linear
  69672. */
  69673. LINEAR = 9729,
  69674. /**
  69675. * Nearest Mip-Map Nearest
  69676. */
  69677. NEAREST_MIPMAP_NEAREST = 9984,
  69678. /**
  69679. * Linear Mipmap Nearest
  69680. */
  69681. LINEAR_MIPMAP_NEAREST = 9985,
  69682. /**
  69683. * Nearest Mipmap Linear
  69684. */
  69685. NEAREST_MIPMAP_LINEAR = 9986,
  69686. /**
  69687. * Linear Mipmap Linear
  69688. */
  69689. LINEAR_MIPMAP_LINEAR = 9987,
  69690. }
  69691. /**
  69692. * S (U) wrapping mode. All valid values correspond to WebGL enums
  69693. */
  69694. const enum TextureWrapMode {
  69695. /**
  69696. * Clamp to Edge
  69697. */
  69698. CLAMP_TO_EDGE = 33071,
  69699. /**
  69700. * Mirrored Repeat
  69701. */
  69702. MIRRORED_REPEAT = 33648,
  69703. /**
  69704. * Repeat
  69705. */
  69706. REPEAT = 10497,
  69707. }
  69708. /**
  69709. * glTF Property
  69710. */
  69711. interface IProperty {
  69712. /**
  69713. * Dictionary object with extension-specific objects
  69714. */
  69715. extensions?: {
  69716. [key: string]: any;
  69717. };
  69718. /**
  69719. * Application-Specific data
  69720. */
  69721. extras?: any;
  69722. }
  69723. /**
  69724. * glTF Child of Root Property
  69725. */
  69726. interface IChildRootProperty extends IProperty {
  69727. /**
  69728. * The user-defined name of this object
  69729. */
  69730. name?: string;
  69731. }
  69732. /**
  69733. * Indices of those attributes that deviate from their initialization value
  69734. */
  69735. interface IAccessorSparseIndices extends IProperty {
  69736. /**
  69737. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69738. */
  69739. bufferView: number;
  69740. /**
  69741. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69742. */
  69743. byteOffset?: number;
  69744. /**
  69745. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  69746. */
  69747. componentType: AccessorComponentType;
  69748. }
  69749. /**
  69750. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  69751. */
  69752. interface IAccessorSparseValues extends IProperty {
  69753. /**
  69754. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69755. */
  69756. bufferView: number;
  69757. /**
  69758. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69759. */
  69760. byteOffset?: number;
  69761. }
  69762. /**
  69763. * Sparse storage of attributes that deviate from their initialization value
  69764. */
  69765. interface IAccessorSparse extends IProperty {
  69766. /**
  69767. * The number of attributes encoded in this sparse accessor
  69768. */
  69769. count: number;
  69770. /**
  69771. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  69772. */
  69773. indices: IAccessorSparseIndices;
  69774. /**
  69775. * 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
  69776. */
  69777. values: IAccessorSparseValues;
  69778. }
  69779. /**
  69780. * 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
  69781. */
  69782. interface IAccessor extends IChildRootProperty {
  69783. /**
  69784. * The index of the bufferview
  69785. */
  69786. bufferView?: number;
  69787. /**
  69788. * The offset relative to the start of the bufferView in bytes
  69789. */
  69790. byteOffset?: number;
  69791. /**
  69792. * The datatype of components in the attribute
  69793. */
  69794. componentType: AccessorComponentType;
  69795. /**
  69796. * Specifies whether integer data values should be normalized
  69797. */
  69798. normalized?: boolean;
  69799. /**
  69800. * The number of attributes referenced by this accessor
  69801. */
  69802. count: number;
  69803. /**
  69804. * Specifies if the attribute is a scalar, vector, or matrix
  69805. */
  69806. type: AccessorType;
  69807. /**
  69808. * Maximum value of each component in this attribute
  69809. */
  69810. max?: number[];
  69811. /**
  69812. * Minimum value of each component in this attribute
  69813. */
  69814. min?: number[];
  69815. /**
  69816. * Sparse storage of attributes that deviate from their initialization value
  69817. */
  69818. sparse?: IAccessorSparse;
  69819. }
  69820. /**
  69821. * Targets an animation's sampler at a node's property
  69822. */
  69823. interface IAnimationChannel extends IProperty {
  69824. /**
  69825. * The index of a sampler in this animation used to compute the value for the target
  69826. */
  69827. sampler: number;
  69828. /**
  69829. * The index of the node and TRS property to target
  69830. */
  69831. target: IAnimationChannelTarget;
  69832. }
  69833. /**
  69834. * The index of the node and TRS property that an animation channel targets
  69835. */
  69836. interface IAnimationChannelTarget extends IProperty {
  69837. /**
  69838. * The index of the node to target
  69839. */
  69840. node: number;
  69841. /**
  69842. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  69843. */
  69844. path: AnimationChannelTargetPath;
  69845. }
  69846. /**
  69847. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  69848. */
  69849. interface IAnimationSampler extends IProperty {
  69850. /**
  69851. * The index of an accessor containing keyframe input values, e.g., time
  69852. */
  69853. input: number;
  69854. /**
  69855. * Interpolation algorithm
  69856. */
  69857. interpolation?: AnimationSamplerInterpolation;
  69858. /**
  69859. * The index of an accessor, containing keyframe output values
  69860. */
  69861. output: number;
  69862. }
  69863. /**
  69864. * A keyframe animation
  69865. */
  69866. interface IAnimation extends IChildRootProperty {
  69867. /**
  69868. * An array of channels, each of which targets an animation's sampler at a node's property
  69869. */
  69870. channels: IAnimationChannel[];
  69871. /**
  69872. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  69873. */
  69874. samplers: IAnimationSampler[];
  69875. }
  69876. /**
  69877. * Metadata about the glTF asset
  69878. */
  69879. interface IAsset extends IChildRootProperty {
  69880. /**
  69881. * A copyright message suitable for display to credit the content creator
  69882. */
  69883. copyright?: string;
  69884. /**
  69885. * Tool that generated this glTF model. Useful for debugging
  69886. */
  69887. generator?: string;
  69888. /**
  69889. * The glTF version that this asset targets
  69890. */
  69891. version: string;
  69892. /**
  69893. * The minimum glTF version that this asset targets
  69894. */
  69895. minVersion?: string;
  69896. }
  69897. /**
  69898. * A buffer points to binary geometry, animation, or skins
  69899. */
  69900. interface IBuffer extends IChildRootProperty {
  69901. /**
  69902. * 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
  69903. */
  69904. uri?: string;
  69905. /**
  69906. * The length of the buffer in bytes
  69907. */
  69908. byteLength: number;
  69909. }
  69910. /**
  69911. * A view into a buffer generally representing a subset of the buffer
  69912. */
  69913. interface IBufferView extends IChildRootProperty {
  69914. /**
  69915. * The index of the buffer
  69916. */
  69917. buffer: number;
  69918. /**
  69919. * The offset into the buffer in bytes
  69920. */
  69921. byteOffset?: number;
  69922. /**
  69923. * The lenth of the bufferView in bytes
  69924. */
  69925. byteLength: number;
  69926. /**
  69927. * The stride, in bytes
  69928. */
  69929. byteStride?: number;
  69930. }
  69931. /**
  69932. * An orthographic camera containing properties to create an orthographic projection matrix
  69933. */
  69934. interface ICameraOrthographic extends IProperty {
  69935. /**
  69936. * The floating-point horizontal magnification of the view. Must not be zero
  69937. */
  69938. xmag: number;
  69939. /**
  69940. * The floating-point vertical magnification of the view. Must not be zero
  69941. */
  69942. ymag: number;
  69943. /**
  69944. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  69945. */
  69946. zfar: number;
  69947. /**
  69948. * The floating-point distance to the near clipping plane
  69949. */
  69950. znear: number;
  69951. }
  69952. /**
  69953. * A perspective camera containing properties to create a perspective projection matrix
  69954. */
  69955. interface ICameraPerspective extends IProperty {
  69956. /**
  69957. * The floating-point aspect ratio of the field of view
  69958. */
  69959. aspectRatio?: number;
  69960. /**
  69961. * The floating-point vertical field of view in radians
  69962. */
  69963. yfov: number;
  69964. /**
  69965. * The floating-point distance to the far clipping plane
  69966. */
  69967. zfar?: number;
  69968. /**
  69969. * The floating-point distance to the near clipping plane
  69970. */
  69971. znear: number;
  69972. }
  69973. /**
  69974. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  69975. */
  69976. interface ICamera extends IChildRootProperty {
  69977. /**
  69978. * An orthographic camera containing properties to create an orthographic projection matrix
  69979. */
  69980. orthographic?: ICameraOrthographic;
  69981. /**
  69982. * A perspective camera containing properties to create a perspective projection matrix
  69983. */
  69984. perspective?: ICameraPerspective;
  69985. /**
  69986. * Specifies if the camera uses a perspective or orthographic projection
  69987. */
  69988. type: CameraType;
  69989. }
  69990. /**
  69991. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  69992. */
  69993. interface IImage extends IChildRootProperty {
  69994. /**
  69995. * 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
  69996. */
  69997. uri?: string;
  69998. /**
  69999. * The image's MIME type
  70000. */
  70001. mimeType?: ImageMimeType;
  70002. /**
  70003. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  70004. */
  70005. bufferView?: number;
  70006. }
  70007. /**
  70008. * Material Normal Texture Info
  70009. */
  70010. interface IMaterialNormalTextureInfo extends ITextureInfo {
  70011. /**
  70012. * The scalar multiplier applied to each normal vector of the normal texture
  70013. */
  70014. scale?: number;
  70015. }
  70016. /**
  70017. * Material Occlusion Texture Info
  70018. */
  70019. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  70020. /**
  70021. * A scalar multiplier controlling the amount of occlusion applied
  70022. */
  70023. strength?: number;
  70024. }
  70025. /**
  70026. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  70027. */
  70028. interface IMaterialPbrMetallicRoughness {
  70029. /**
  70030. * The material's base color factor
  70031. */
  70032. baseColorFactor?: number[];
  70033. /**
  70034. * The base color texture
  70035. */
  70036. baseColorTexture?: ITextureInfo;
  70037. /**
  70038. * The metalness of the material
  70039. */
  70040. metallicFactor?: number;
  70041. /**
  70042. * The roughness of the material
  70043. */
  70044. roughnessFactor?: number;
  70045. /**
  70046. * The metallic-roughness texture
  70047. */
  70048. metallicRoughnessTexture?: ITextureInfo;
  70049. }
  70050. /**
  70051. * The material appearance of a primitive
  70052. */
  70053. interface IMaterial extends IChildRootProperty {
  70054. /**
  70055. * 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
  70056. */
  70057. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  70058. /**
  70059. * The normal map texture
  70060. */
  70061. normalTexture?: IMaterialNormalTextureInfo;
  70062. /**
  70063. * The occlusion map texture
  70064. */
  70065. occlusionTexture?: IMaterialOcclusionTextureInfo;
  70066. /**
  70067. * The emissive map texture
  70068. */
  70069. emissiveTexture?: ITextureInfo;
  70070. /**
  70071. * 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
  70072. */
  70073. emissiveFactor?: number[];
  70074. /**
  70075. * The alpha rendering mode of the material
  70076. */
  70077. alphaMode?: MaterialAlphaMode;
  70078. /**
  70079. * The alpha cutoff value of the material
  70080. */
  70081. alphaCutoff?: number;
  70082. /**
  70083. * Specifies whether the material is double sided
  70084. */
  70085. doubleSided?: boolean;
  70086. }
  70087. /**
  70088. * Geometry to be rendered with the given material
  70089. */
  70090. interface IMeshPrimitive extends IProperty {
  70091. /**
  70092. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  70093. */
  70094. attributes: {
  70095. [name: string]: number;
  70096. };
  70097. /**
  70098. * The index of the accessor that contains the indices
  70099. */
  70100. indices?: number;
  70101. /**
  70102. * The index of the material to apply to this primitive when rendering
  70103. */
  70104. material?: number;
  70105. /**
  70106. * The type of primitives to render. All valid values correspond to WebGL enums
  70107. */
  70108. mode?: MeshPrimitiveMode;
  70109. /**
  70110. * 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
  70111. */
  70112. targets?: {
  70113. [name: string]: number;
  70114. }[];
  70115. }
  70116. /**
  70117. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  70118. */
  70119. interface IMesh extends IChildRootProperty {
  70120. /**
  70121. * An array of primitives, each defining geometry to be rendered with a material
  70122. */
  70123. primitives: IMeshPrimitive[];
  70124. /**
  70125. * Array of weights to be applied to the Morph Targets
  70126. */
  70127. weights?: number[];
  70128. }
  70129. /**
  70130. * A node in the node hierarchy
  70131. */
  70132. interface INode extends IChildRootProperty {
  70133. /**
  70134. * The index of the camera referenced by this node
  70135. */
  70136. camera?: number;
  70137. /**
  70138. * The indices of this node's children
  70139. */
  70140. children?: number[];
  70141. /**
  70142. * The index of the skin referenced by this node
  70143. */
  70144. skin?: number;
  70145. /**
  70146. * A floating-point 4x4 transformation matrix stored in column-major order
  70147. */
  70148. matrix?: number[];
  70149. /**
  70150. * The index of the mesh in this node
  70151. */
  70152. mesh?: number;
  70153. /**
  70154. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  70155. */
  70156. rotation?: number[];
  70157. /**
  70158. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  70159. */
  70160. scale?: number[];
  70161. /**
  70162. * The node's translation along the x, y, and z axes
  70163. */
  70164. translation?: number[];
  70165. /**
  70166. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  70167. */
  70168. weights?: number[];
  70169. }
  70170. /**
  70171. * Texture sampler properties for filtering and wrapping modes
  70172. */
  70173. interface ISampler extends IChildRootProperty {
  70174. /**
  70175. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70176. */
  70177. magFilter?: TextureMagFilter;
  70178. /**
  70179. * Minification filter. All valid values correspond to WebGL enums
  70180. */
  70181. minFilter?: TextureMinFilter;
  70182. /**
  70183. * S (U) wrapping mode. All valid values correspond to WebGL enums
  70184. */
  70185. wrapS?: TextureWrapMode;
  70186. /**
  70187. * T (V) wrapping mode. All valid values correspond to WebGL enums
  70188. */
  70189. wrapT?: TextureWrapMode;
  70190. }
  70191. /**
  70192. * The root nodes of a scene
  70193. */
  70194. interface IScene extends IChildRootProperty {
  70195. /**
  70196. * The indices of each root node
  70197. */
  70198. nodes: number[];
  70199. }
  70200. /**
  70201. * Joints and matrices defining a skin
  70202. */
  70203. interface ISkin extends IChildRootProperty {
  70204. /**
  70205. * 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
  70206. */
  70207. inverseBindMatrices?: number;
  70208. /**
  70209. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  70210. */
  70211. skeleton?: number;
  70212. /**
  70213. * 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)
  70214. */
  70215. joints: number[];
  70216. }
  70217. /**
  70218. * A texture and its sampler
  70219. */
  70220. interface ITexture extends IChildRootProperty {
  70221. /**
  70222. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  70223. */
  70224. sampler?: number;
  70225. /**
  70226. * The index of the image used by this texture
  70227. */
  70228. source: number;
  70229. }
  70230. /**
  70231. * Reference to a texture
  70232. */
  70233. interface ITextureInfo extends IProperty {
  70234. /**
  70235. * The index of the texture
  70236. */
  70237. index: number;
  70238. /**
  70239. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  70240. */
  70241. texCoord?: number;
  70242. }
  70243. /**
  70244. * The root object for a glTF asset
  70245. */
  70246. interface IGLTF extends IProperty {
  70247. /**
  70248. * An array of accessors. An accessor is a typed view into a bufferView
  70249. */
  70250. accessors?: IAccessor[];
  70251. /**
  70252. * An array of keyframe animations
  70253. */
  70254. animations?: IAnimation[];
  70255. /**
  70256. * Metadata about the glTF asset
  70257. */
  70258. asset: IAsset;
  70259. /**
  70260. * An array of buffers. A buffer points to binary geometry, animation, or skins
  70261. */
  70262. buffers?: IBuffer[];
  70263. /**
  70264. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  70265. */
  70266. bufferViews?: IBufferView[];
  70267. /**
  70268. * An array of cameras
  70269. */
  70270. cameras?: ICamera[];
  70271. /**
  70272. * Names of glTF extensions used somewhere in this asset
  70273. */
  70274. extensionsUsed?: string[];
  70275. /**
  70276. * Names of glTF extensions required to properly load this asset
  70277. */
  70278. extensionsRequired?: string[];
  70279. /**
  70280. * An array of images. An image defines data used to create a texture
  70281. */
  70282. images?: IImage[];
  70283. /**
  70284. * An array of materials. A material defines the appearance of a primitive
  70285. */
  70286. materials?: IMaterial[];
  70287. /**
  70288. * An array of meshes. A mesh is a set of primitives to be rendered
  70289. */
  70290. meshes?: IMesh[];
  70291. /**
  70292. * An array of nodes
  70293. */
  70294. nodes?: INode[];
  70295. /**
  70296. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  70297. */
  70298. samplers?: ISampler[];
  70299. /**
  70300. * The index of the default scene
  70301. */
  70302. scene?: number;
  70303. /**
  70304. * An array of scenes
  70305. */
  70306. scenes?: IScene[];
  70307. /**
  70308. * An array of skins. A skin is defined by joints and matrices
  70309. */
  70310. skins?: ISkin[];
  70311. /**
  70312. * An array of textures
  70313. */
  70314. textures?: ITexture[];
  70315. }
  70316. /**
  70317. * The glTF validation results
  70318. * @ignore
  70319. */
  70320. interface IGLTFValidationResults {
  70321. info: {
  70322. generator: string;
  70323. hasAnimations: boolean;
  70324. hasDefaultScene: boolean;
  70325. hasMaterials: boolean;
  70326. hasMorphTargets: boolean;
  70327. hasSkins: boolean;
  70328. hasTextures: boolean;
  70329. maxAttributesUsed: number;
  70330. primitivesCount: number
  70331. };
  70332. issues: {
  70333. messages: Array<string>;
  70334. numErrors: number;
  70335. numHints: number;
  70336. numInfos: number;
  70337. numWarnings: number;
  70338. truncated: boolean
  70339. };
  70340. mimeType: string;
  70341. uri: string;
  70342. validatedAt: string;
  70343. validatorVersion: string;
  70344. }
  70345. /**
  70346. * The glTF validation options
  70347. */
  70348. interface IGLTFValidationOptions {
  70349. /** Uri to use */
  70350. uri?: string;
  70351. /** Function used to load external resources */
  70352. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  70353. /** Boolean indicating that we need to validate accessor data */
  70354. validateAccessorData?: boolean;
  70355. /** max number of issues allowed */
  70356. maxIssues?: number;
  70357. /** Ignored issues */
  70358. ignoredIssues?: Array<string>;
  70359. /** Value to override severy settings */
  70360. severityOverrides?: Object;
  70361. }
  70362. /**
  70363. * The glTF validator object
  70364. * @ignore
  70365. */
  70366. interface IGLTFValidator {
  70367. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  70368. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  70369. }
  70370. }
  70371. declare module BABYLON {
  70372. /** @hidden */
  70373. export var cellPixelShader: {
  70374. name: string;
  70375. shader: string;
  70376. };
  70377. }
  70378. declare module BABYLON {
  70379. /** @hidden */
  70380. export var cellVertexShader: {
  70381. name: string;
  70382. shader: string;
  70383. };
  70384. }
  70385. declare module BABYLON {
  70386. export class CellMaterial extends BABYLON.PushMaterial {
  70387. private _diffuseTexture;
  70388. diffuseTexture: BABYLON.BaseTexture;
  70389. diffuseColor: BABYLON.Color3; private _computeHighLevel: boolean;
  70390. computeHighLevel: boolean;
  70391. private _disableLighting;
  70392. disableLighting: boolean;
  70393. private _maxSimultaneousLights;
  70394. maxSimultaneousLights: number;
  70395. private _renderId;
  70396. constructor(name: string, scene: BABYLON.Scene);
  70397. needAlphaBlending(): boolean;
  70398. needAlphaTesting(): boolean;
  70399. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70400. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70401. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70402. getAnimatables(): BABYLON.IAnimatable[];
  70403. getActiveTextures(): BABYLON.BaseTexture[];
  70404. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70405. dispose(forceDisposeEffect?: boolean): void;
  70406. getClassName(): string;
  70407. clone(name: string): CellMaterial;
  70408. serialize(): any;
  70409. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  70410. }
  70411. }
  70412. declare module BABYLON {
  70413. export class CustomShaderStructure {
  70414. FragmentStore: string;
  70415. VertexStore: string;
  70416. constructor();
  70417. }
  70418. export class ShaderSpecialParts {
  70419. constructor();
  70420. Fragment_Begin: string;
  70421. Fragment_Definitions: string;
  70422. Fragment_MainBegin: string;
  70423. Fragment_Custom_Diffuse: string;
  70424. Fragment_Before_Lights: string;
  70425. Fragment_Before_Fog: string;
  70426. Fragment_Custom_Alpha: string;
  70427. Fragment_Before_FragColor: string;
  70428. Vertex_Begin: string;
  70429. Vertex_Definitions: string;
  70430. Vertex_MainBegin: string;
  70431. Vertex_Before_PositionUpdated: string;
  70432. Vertex_Before_NormalUpdated: string;
  70433. Vertex_MainEnd: string;
  70434. }
  70435. export class CustomMaterial extends BABYLON.StandardMaterial {
  70436. static ShaderIndexer: number;
  70437. CustomParts: ShaderSpecialParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  70438. FragmentShader: string;
  70439. VertexShader: string;
  70440. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  70441. ReviewUniform(name: string, arr: string[]): string[];
  70442. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  70443. constructor(name: string, scene: BABYLON.Scene);
  70444. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  70445. Fragment_Begin(shaderPart: string): CustomMaterial;
  70446. Fragment_Definitions(shaderPart: string): CustomMaterial;
  70447. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  70448. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  70449. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  70450. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  70451. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  70452. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  70453. Vertex_Begin(shaderPart: string): CustomMaterial;
  70454. Vertex_Definitions(shaderPart: string): CustomMaterial;
  70455. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  70456. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  70457. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  70458. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  70459. }
  70460. }
  70461. declare module BABYLON {
  70462. export class ShaderAlebdoParts {
  70463. constructor();
  70464. Fragment_Begin: string;
  70465. Fragment_Definitions: string;
  70466. Fragment_MainBegin: string;
  70467. Fragment_Custom_Albedo: string;
  70468. Fragment_Before_Lights: string;
  70469. Fragment_Custom_MetallicRoughness: string;
  70470. Fragment_Custom_MicroSurface: string;
  70471. Fragment_Before_Fog: string;
  70472. Fragment_Custom_Alpha: string;
  70473. Fragment_Before_FragColor: string;
  70474. Vertex_Begin: string;
  70475. Vertex_Definitions: string;
  70476. Vertex_MainBegin: string;
  70477. Vertex_Before_PositionUpdated: string;
  70478. Vertex_Before_NormalUpdated: string;
  70479. Vertex_MainEnd: string;
  70480. }
  70481. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  70482. static ShaderIndexer: number;
  70483. CustomParts: ShaderAlebdoParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  70484. FragmentShader: string;
  70485. VertexShader: string;
  70486. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  70487. ReviewUniform(name: string, arr: string[]): string[];
  70488. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  70489. constructor(name: string, scene: BABYLON.Scene);
  70490. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  70491. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  70492. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  70493. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  70494. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  70495. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  70496. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  70497. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  70498. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  70499. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  70500. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  70501. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  70502. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  70503. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  70504. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  70505. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  70506. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  70507. }
  70508. }
  70509. declare module BABYLON {
  70510. /** @hidden */
  70511. export var firePixelShader: {
  70512. name: string;
  70513. shader: string;
  70514. };
  70515. }
  70516. declare module BABYLON {
  70517. /** @hidden */
  70518. export var fireVertexShader: {
  70519. name: string;
  70520. shader: string;
  70521. };
  70522. }
  70523. declare module BABYLON {
  70524. export class FireMaterial extends BABYLON.PushMaterial {
  70525. private _diffuseTexture;
  70526. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70527. private _distortionTexture;
  70528. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70529. private _opacityTexture;
  70530. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70531. diffuseColor: BABYLON.Color3;
  70532. speed: number;
  70533. private _scaledDiffuse;
  70534. private _renderId;
  70535. private _lastTime;
  70536. constructor(name: string, scene: BABYLON.Scene);
  70537. needAlphaBlending(): boolean;
  70538. needAlphaTesting(): boolean;
  70539. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70540. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70541. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70542. getAnimatables(): BABYLON.IAnimatable[];
  70543. getActiveTextures(): BABYLON.BaseTexture[];
  70544. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70545. getClassName(): string;
  70546. dispose(forceDisposeEffect?: boolean): void;
  70547. clone(name: string): FireMaterial;
  70548. serialize(): any;
  70549. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  70550. }
  70551. }
  70552. declare module BABYLON {
  70553. /** @hidden */
  70554. export var furPixelShader: {
  70555. name: string;
  70556. shader: string;
  70557. };
  70558. }
  70559. declare module BABYLON {
  70560. /** @hidden */
  70561. export var furVertexShader: {
  70562. name: string;
  70563. shader: string;
  70564. };
  70565. }
  70566. declare module BABYLON {
  70567. export class FurMaterial extends BABYLON.PushMaterial {
  70568. private _diffuseTexture;
  70569. diffuseTexture: BABYLON.BaseTexture;
  70570. private _heightTexture;
  70571. heightTexture: BABYLON.BaseTexture;
  70572. diffuseColor: BABYLON.Color3;
  70573. furLength: number;
  70574. furAngle: number;
  70575. furColor: BABYLON.Color3;
  70576. furOffset: number;
  70577. furSpacing: number;
  70578. furGravity: BABYLON.Vector3;
  70579. furSpeed: number;
  70580. furDensity: number;
  70581. furOcclusion: number;
  70582. furTexture: BABYLON.DynamicTexture;
  70583. private _disableLighting;
  70584. disableLighting: boolean;
  70585. private _maxSimultaneousLights;
  70586. maxSimultaneousLights: number;
  70587. highLevelFur: boolean; private _meshes: BABYLON.AbstractMesh[];
  70588. private _renderId;
  70589. private _furTime;
  70590. constructor(name: string, scene: BABYLON.Scene);
  70591. furTime: number;
  70592. needAlphaBlending(): boolean;
  70593. needAlphaTesting(): boolean;
  70594. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70595. updateFur(): void;
  70596. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70597. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70598. getAnimatables(): BABYLON.IAnimatable[];
  70599. getActiveTextures(): BABYLON.BaseTexture[];
  70600. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70601. dispose(forceDisposeEffect?: boolean): void;
  70602. clone(name: string): FurMaterial;
  70603. serialize(): any;
  70604. getClassName(): string;
  70605. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  70606. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  70607. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  70608. }
  70609. }
  70610. declare module BABYLON {
  70611. /** @hidden */
  70612. export var gradientPixelShader: {
  70613. name: string;
  70614. shader: string;
  70615. };
  70616. }
  70617. declare module BABYLON {
  70618. /** @hidden */
  70619. export var gradientVertexShader: {
  70620. name: string;
  70621. shader: string;
  70622. };
  70623. }
  70624. declare module BABYLON {
  70625. export class GradientMaterial extends BABYLON.PushMaterial {
  70626. private _maxSimultaneousLights;
  70627. maxSimultaneousLights: number;
  70628. topColor: BABYLON.Color3;
  70629. topColorAlpha: number;
  70630. bottomColor: BABYLON.Color3;
  70631. bottomColorAlpha: number;
  70632. offset: number;
  70633. scale: number;
  70634. smoothness: number;
  70635. private _disableLighting;
  70636. disableLighting: boolean;
  70637. private _renderId;
  70638. constructor(name: string, scene: BABYLON.Scene);
  70639. needAlphaBlending(): boolean;
  70640. needAlphaTesting(): boolean;
  70641. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70642. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70643. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70644. getAnimatables(): BABYLON.IAnimatable[];
  70645. dispose(forceDisposeEffect?: boolean): void;
  70646. clone(name: string): GradientMaterial;
  70647. serialize(): any;
  70648. getClassName(): string;
  70649. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  70650. }
  70651. }
  70652. declare module BABYLON {
  70653. /** @hidden */
  70654. export var gridPixelShader: {
  70655. name: string;
  70656. shader: string;
  70657. };
  70658. }
  70659. declare module BABYLON {
  70660. /** @hidden */
  70661. export var gridVertexShader: {
  70662. name: string;
  70663. shader: string;
  70664. };
  70665. }
  70666. declare module BABYLON {
  70667. /**
  70668. * The grid materials allows you to wrap any shape with a grid.
  70669. * Colors are customizable.
  70670. */
  70671. export class GridMaterial extends BABYLON.PushMaterial {
  70672. /**
  70673. * Main color of the grid (e.g. between lines)
  70674. */
  70675. mainColor: BABYLON.Color3;
  70676. /**
  70677. * Color of the grid lines.
  70678. */
  70679. lineColor: BABYLON.Color3;
  70680. /**
  70681. * The scale of the grid compared to unit.
  70682. */
  70683. gridRatio: number;
  70684. /**
  70685. * Allows setting an offset for the grid lines.
  70686. */
  70687. gridOffset: BABYLON.Vector3;
  70688. /**
  70689. * The frequency of thicker lines.
  70690. */
  70691. majorUnitFrequency: number;
  70692. /**
  70693. * The visibility of minor units in the grid.
  70694. */
  70695. minorUnitVisibility: number;
  70696. /**
  70697. * The grid opacity outside of the lines.
  70698. */
  70699. opacity: number;
  70700. /**
  70701. * Determine RBG output is premultiplied by alpha value.
  70702. */
  70703. preMultiplyAlpha: boolean;
  70704. private _opacityTexture;
  70705. opacityTexture: BABYLON.BaseTexture;
  70706. private _gridControl;
  70707. private _renderId;
  70708. /**
  70709. * constructor
  70710. * @param name The name given to the material in order to identify it afterwards.
  70711. * @param scene The scene the material is used in.
  70712. */
  70713. constructor(name: string, scene: BABYLON.Scene);
  70714. /**
  70715. * Returns wehter or not the grid requires alpha blending.
  70716. */
  70717. needAlphaBlending(): boolean;
  70718. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70719. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70720. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70721. /**
  70722. * Dispose the material and its associated resources.
  70723. * @param forceDisposeEffect will also dispose the used effect when true
  70724. */
  70725. dispose(forceDisposeEffect?: boolean): void;
  70726. clone(name: string): GridMaterial;
  70727. serialize(): any;
  70728. getClassName(): string;
  70729. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  70730. }
  70731. }
  70732. declare module BABYLON {
  70733. /** @hidden */
  70734. export var lavaPixelShader: {
  70735. name: string;
  70736. shader: string;
  70737. };
  70738. }
  70739. declare module BABYLON {
  70740. /** @hidden */
  70741. export var lavaVertexShader: {
  70742. name: string;
  70743. shader: string;
  70744. };
  70745. }
  70746. declare module BABYLON {
  70747. export class LavaMaterial extends BABYLON.PushMaterial {
  70748. private _diffuseTexture;
  70749. diffuseTexture: BABYLON.BaseTexture;
  70750. noiseTexture: BABYLON.BaseTexture;
  70751. fogColor: BABYLON.Color3;
  70752. speed: number;
  70753. movingSpeed: number;
  70754. lowFrequencySpeed: number;
  70755. fogDensity: number;
  70756. private _lastTime;
  70757. diffuseColor: BABYLON.Color3;
  70758. private _disableLighting;
  70759. disableLighting: boolean;
  70760. private _unlit;
  70761. unlit: boolean;
  70762. private _maxSimultaneousLights;
  70763. maxSimultaneousLights: number;
  70764. private _scaledDiffuse;
  70765. private _renderId;
  70766. constructor(name: string, scene: BABYLON.Scene);
  70767. needAlphaBlending(): boolean;
  70768. needAlphaTesting(): boolean;
  70769. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70770. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70771. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70772. getAnimatables(): BABYLON.IAnimatable[];
  70773. getActiveTextures(): BABYLON.BaseTexture[];
  70774. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70775. dispose(forceDisposeEffect?: boolean): void;
  70776. clone(name: string): LavaMaterial;
  70777. serialize(): any;
  70778. getClassName(): string;
  70779. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  70780. }
  70781. }
  70782. declare module BABYLON {
  70783. /** @hidden */
  70784. export var mixPixelShader: {
  70785. name: string;
  70786. shader: string;
  70787. };
  70788. }
  70789. declare module BABYLON {
  70790. /** @hidden */
  70791. export var mixVertexShader: {
  70792. name: string;
  70793. shader: string;
  70794. };
  70795. }
  70796. declare module BABYLON {
  70797. export class MixMaterial extends BABYLON.PushMaterial {
  70798. /**
  70799. * Mix textures
  70800. */
  70801. private _mixTexture1;
  70802. mixTexture1: BABYLON.BaseTexture;
  70803. private _mixTexture2;
  70804. mixTexture2: BABYLON.BaseTexture;
  70805. /**
  70806. * Diffuse textures
  70807. */
  70808. private _diffuseTexture1;
  70809. diffuseTexture1: BABYLON.Texture;
  70810. private _diffuseTexture2;
  70811. diffuseTexture2: BABYLON.Texture;
  70812. private _diffuseTexture3;
  70813. diffuseTexture3: BABYLON.Texture;
  70814. private _diffuseTexture4;
  70815. diffuseTexture4: BABYLON.Texture;
  70816. private _diffuseTexture5;
  70817. diffuseTexture5: BABYLON.Texture;
  70818. private _diffuseTexture6;
  70819. diffuseTexture6: BABYLON.Texture;
  70820. private _diffuseTexture7;
  70821. diffuseTexture7: BABYLON.Texture;
  70822. private _diffuseTexture8;
  70823. diffuseTexture8: BABYLON.Texture;
  70824. /**
  70825. * Uniforms
  70826. */
  70827. diffuseColor: BABYLON.Color3;
  70828. specularColor: BABYLON.Color3;
  70829. specularPower: number;
  70830. private _disableLighting;
  70831. disableLighting: boolean;
  70832. private _maxSimultaneousLights;
  70833. maxSimultaneousLights: number;
  70834. private _renderId;
  70835. constructor(name: string, scene: BABYLON.Scene);
  70836. needAlphaBlending(): boolean;
  70837. needAlphaTesting(): boolean;
  70838. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70839. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70840. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70841. getAnimatables(): BABYLON.IAnimatable[];
  70842. getActiveTextures(): BABYLON.BaseTexture[];
  70843. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70844. dispose(forceDisposeEffect?: boolean): void;
  70845. clone(name: string): MixMaterial;
  70846. serialize(): any;
  70847. getClassName(): string;
  70848. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  70849. }
  70850. }
  70851. declare module BABYLON {
  70852. /** @hidden */
  70853. export var normalPixelShader: {
  70854. name: string;
  70855. shader: string;
  70856. };
  70857. }
  70858. declare module BABYLON {
  70859. /** @hidden */
  70860. export var normalVertexShader: {
  70861. name: string;
  70862. shader: string;
  70863. };
  70864. }
  70865. declare module BABYLON {
  70866. export class NormalMaterial extends BABYLON.PushMaterial {
  70867. private _diffuseTexture;
  70868. diffuseTexture: BABYLON.BaseTexture;
  70869. diffuseColor: BABYLON.Color3;
  70870. private _disableLighting;
  70871. disableLighting: boolean;
  70872. private _maxSimultaneousLights;
  70873. maxSimultaneousLights: number;
  70874. private _renderId;
  70875. constructor(name: string, scene: BABYLON.Scene);
  70876. needAlphaBlending(): boolean;
  70877. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70878. needAlphaTesting(): boolean;
  70879. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70880. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70881. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70882. getAnimatables(): BABYLON.IAnimatable[];
  70883. getActiveTextures(): BABYLON.BaseTexture[];
  70884. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70885. dispose(forceDisposeEffect?: boolean): void;
  70886. clone(name: string): NormalMaterial;
  70887. serialize(): any;
  70888. getClassName(): string;
  70889. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  70890. }
  70891. }
  70892. declare module BABYLON {
  70893. /** @hidden */
  70894. export var shadowOnlyPixelShader: {
  70895. name: string;
  70896. shader: string;
  70897. };
  70898. }
  70899. declare module BABYLON {
  70900. /** @hidden */
  70901. export var shadowOnlyVertexShader: {
  70902. name: string;
  70903. shader: string;
  70904. };
  70905. }
  70906. declare module BABYLON {
  70907. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  70908. private _renderId;
  70909. private _activeLight;
  70910. constructor(name: string, scene: BABYLON.Scene);
  70911. shadowColor: BABYLON.Color3;
  70912. needAlphaBlending(): boolean;
  70913. needAlphaTesting(): boolean;
  70914. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70915. activeLight: BABYLON.IShadowLight;
  70916. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70917. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70918. clone(name: string): ShadowOnlyMaterial;
  70919. serialize(): any;
  70920. getClassName(): string;
  70921. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  70922. }
  70923. }
  70924. declare module BABYLON {
  70925. /** @hidden */
  70926. export var simplePixelShader: {
  70927. name: string;
  70928. shader: string;
  70929. };
  70930. }
  70931. declare module BABYLON {
  70932. /** @hidden */
  70933. export var simpleVertexShader: {
  70934. name: string;
  70935. shader: string;
  70936. };
  70937. }
  70938. declare module BABYLON {
  70939. export class SimpleMaterial extends BABYLON.PushMaterial {
  70940. private _diffuseTexture;
  70941. diffuseTexture: BABYLON.BaseTexture;
  70942. diffuseColor: BABYLON.Color3;
  70943. private _disableLighting;
  70944. disableLighting: boolean;
  70945. private _maxSimultaneousLights;
  70946. maxSimultaneousLights: number;
  70947. private _renderId;
  70948. constructor(name: string, scene: BABYLON.Scene);
  70949. needAlphaBlending(): boolean;
  70950. needAlphaTesting(): boolean;
  70951. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70952. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70953. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70954. getAnimatables(): BABYLON.IAnimatable[];
  70955. getActiveTextures(): BABYLON.BaseTexture[];
  70956. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70957. dispose(forceDisposeEffect?: boolean): void;
  70958. clone(name: string): SimpleMaterial;
  70959. serialize(): any;
  70960. getClassName(): string;
  70961. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  70962. }
  70963. }
  70964. declare module BABYLON {
  70965. /** @hidden */
  70966. export var skyPixelShader: {
  70967. name: string;
  70968. shader: string;
  70969. };
  70970. }
  70971. declare module BABYLON {
  70972. /** @hidden */
  70973. export var skyVertexShader: {
  70974. name: string;
  70975. shader: string;
  70976. };
  70977. }
  70978. declare module BABYLON {
  70979. /**
  70980. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  70981. * @see https://doc.babylonjs.com/extensions/sky
  70982. */
  70983. export class SkyMaterial extends BABYLON.PushMaterial {
  70984. /**
  70985. * Defines the overall luminance of sky in interval ]0, 1[.
  70986. */
  70987. luminance: number;
  70988. /**
  70989. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  70990. */
  70991. turbidity: number;
  70992. /**
  70993. * Defines the sky appearance (light intensity).
  70994. */
  70995. rayleigh: number;
  70996. /**
  70997. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  70998. */
  70999. mieCoefficient: number;
  71000. /**
  71001. * Defines the amount of haze particles following the Mie scattering theory.
  71002. */
  71003. mieDirectionalG: number;
  71004. /**
  71005. * Defines the distance of the sun according to the active scene camera.
  71006. */
  71007. distance: number;
  71008. /**
  71009. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  71010. * "inclined".
  71011. */
  71012. inclination: number;
  71013. /**
  71014. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  71015. * an object direction and a reference direction.
  71016. */
  71017. azimuth: number;
  71018. /**
  71019. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  71020. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  71021. */
  71022. sunPosition: BABYLON.Vector3;
  71023. /**
  71024. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  71025. * .sunPosition property.
  71026. */
  71027. useSunPosition: boolean;
  71028. /**
  71029. * Defines an offset vector used to get a horizon offset.
  71030. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  71031. */
  71032. cameraOffset: BABYLON.Vector3;
  71033. private _cameraPosition;
  71034. private _renderId;
  71035. /**
  71036. * Instantiates a new sky material.
  71037. * This material allows to create dynamic and texture free
  71038. * effects for skyboxes by taking care of the atmosphere state.
  71039. * @see https://doc.babylonjs.com/extensions/sky
  71040. * @param name Define the name of the material in the scene
  71041. * @param scene Define the scene the material belong to
  71042. */
  71043. constructor(name: string, scene: BABYLON.Scene);
  71044. /**
  71045. * Specifies if the material will require alpha blending
  71046. * @returns a boolean specifying if alpha blending is needed
  71047. */
  71048. needAlphaBlending(): boolean;
  71049. /**
  71050. * Specifies if this material should be rendered in alpha test mode
  71051. * @returns false as the sky material doesn't need alpha testing.
  71052. */
  71053. needAlphaTesting(): boolean;
  71054. /**
  71055. * Get the texture used for alpha test purpose.
  71056. * @returns null as the sky material has no texture.
  71057. */
  71058. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71059. /**
  71060. * Get if the submesh is ready to be used and all its information available.
  71061. * Child classes can use it to update shaders
  71062. * @param mesh defines the mesh to check
  71063. * @param subMesh defines which submesh to check
  71064. * @param useInstances specifies that instances should be used
  71065. * @returns a boolean indicating that the submesh is ready or not
  71066. */
  71067. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71068. /**
  71069. * Binds the submesh to this material by preparing the effect and shader to draw
  71070. * @param world defines the world transformation matrix
  71071. * @param mesh defines the mesh containing the submesh
  71072. * @param subMesh defines the submesh to bind the material to
  71073. */
  71074. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71075. /**
  71076. * Get the list of animatables in the material.
  71077. * @returns the list of animatables object used in the material
  71078. */
  71079. getAnimatables(): BABYLON.IAnimatable[];
  71080. /**
  71081. * Disposes the material
  71082. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  71083. */
  71084. dispose(forceDisposeEffect?: boolean): void;
  71085. /**
  71086. * Makes a duplicate of the material, and gives it a new name
  71087. * @param name defines the new name for the duplicated material
  71088. * @returns the cloned material
  71089. */
  71090. clone(name: string): SkyMaterial;
  71091. /**
  71092. * Serializes this material in a JSON representation
  71093. * @returns the serialized material object
  71094. */
  71095. serialize(): any;
  71096. /**
  71097. * Gets the current class name of the material e.g. "SkyMaterial"
  71098. * Mainly use in serialization.
  71099. * @returns the class name
  71100. */
  71101. getClassName(): string;
  71102. /**
  71103. * Creates a sky material from parsed material data
  71104. * @param source defines the JSON representation of the material
  71105. * @param scene defines the hosting scene
  71106. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71107. * @returns a new sky material
  71108. */
  71109. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  71110. }
  71111. }
  71112. declare module BABYLON {
  71113. /** @hidden */
  71114. export var terrainPixelShader: {
  71115. name: string;
  71116. shader: string;
  71117. };
  71118. }
  71119. declare module BABYLON {
  71120. /** @hidden */
  71121. export var terrainVertexShader: {
  71122. name: string;
  71123. shader: string;
  71124. };
  71125. }
  71126. declare module BABYLON {
  71127. export class TerrainMaterial extends BABYLON.PushMaterial {
  71128. private _mixTexture;
  71129. mixTexture: BABYLON.BaseTexture;
  71130. private _diffuseTexture1;
  71131. diffuseTexture1: BABYLON.Texture;
  71132. private _diffuseTexture2;
  71133. diffuseTexture2: BABYLON.Texture;
  71134. private _diffuseTexture3;
  71135. diffuseTexture3: BABYLON.Texture;
  71136. private _bumpTexture1;
  71137. bumpTexture1: BABYLON.Texture;
  71138. private _bumpTexture2;
  71139. bumpTexture2: BABYLON.Texture;
  71140. private _bumpTexture3;
  71141. bumpTexture3: BABYLON.Texture;
  71142. diffuseColor: BABYLON.Color3;
  71143. specularColor: BABYLON.Color3;
  71144. specularPower: number;
  71145. private _disableLighting;
  71146. disableLighting: boolean;
  71147. private _maxSimultaneousLights;
  71148. maxSimultaneousLights: number;
  71149. private _renderId;
  71150. constructor(name: string, scene: BABYLON.Scene);
  71151. needAlphaBlending(): boolean;
  71152. needAlphaTesting(): boolean;
  71153. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71154. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71155. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71156. getAnimatables(): BABYLON.IAnimatable[];
  71157. getActiveTextures(): BABYLON.BaseTexture[];
  71158. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71159. dispose(forceDisposeEffect?: boolean): void;
  71160. clone(name: string): TerrainMaterial;
  71161. serialize(): any;
  71162. getClassName(): string;
  71163. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  71164. }
  71165. }
  71166. declare module BABYLON {
  71167. /** @hidden */
  71168. export var triplanarPixelShader: {
  71169. name: string;
  71170. shader: string;
  71171. };
  71172. }
  71173. declare module BABYLON {
  71174. /** @hidden */
  71175. export var triplanarVertexShader: {
  71176. name: string;
  71177. shader: string;
  71178. };
  71179. }
  71180. declare module BABYLON {
  71181. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  71182. mixTexture: BABYLON.BaseTexture;
  71183. private _diffuseTextureX;
  71184. diffuseTextureX: BABYLON.BaseTexture;
  71185. private _diffuseTextureY;
  71186. diffuseTextureY: BABYLON.BaseTexture;
  71187. private _diffuseTextureZ;
  71188. diffuseTextureZ: BABYLON.BaseTexture;
  71189. private _normalTextureX;
  71190. normalTextureX: BABYLON.BaseTexture;
  71191. private _normalTextureY;
  71192. normalTextureY: BABYLON.BaseTexture;
  71193. private _normalTextureZ;
  71194. normalTextureZ: BABYLON.BaseTexture;
  71195. tileSize: number;
  71196. diffuseColor: BABYLON.Color3;
  71197. specularColor: BABYLON.Color3;
  71198. specularPower: number;
  71199. private _disableLighting;
  71200. disableLighting: boolean;
  71201. private _maxSimultaneousLights;
  71202. maxSimultaneousLights: number;
  71203. private _renderId;
  71204. constructor(name: string, scene: BABYLON.Scene);
  71205. needAlphaBlending(): boolean;
  71206. needAlphaTesting(): boolean;
  71207. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71208. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71209. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71210. getAnimatables(): BABYLON.IAnimatable[];
  71211. getActiveTextures(): BABYLON.BaseTexture[];
  71212. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71213. dispose(forceDisposeEffect?: boolean): void;
  71214. clone(name: string): TriPlanarMaterial;
  71215. serialize(): any;
  71216. getClassName(): string;
  71217. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  71218. }
  71219. }
  71220. declare module BABYLON {
  71221. /** @hidden */
  71222. export var waterPixelShader: {
  71223. name: string;
  71224. shader: string;
  71225. };
  71226. }
  71227. declare module BABYLON {
  71228. /** @hidden */
  71229. export var waterVertexShader: {
  71230. name: string;
  71231. shader: string;
  71232. };
  71233. }
  71234. declare module BABYLON {
  71235. export class WaterMaterial extends BABYLON.PushMaterial {
  71236. renderTargetSize: BABYLON.Vector2;
  71237. private _bumpTexture;
  71238. bumpTexture: BABYLON.BaseTexture;
  71239. diffuseColor: BABYLON.Color3;
  71240. specularColor: BABYLON.Color3;
  71241. specularPower: number;
  71242. private _disableLighting;
  71243. disableLighting: boolean;
  71244. private _maxSimultaneousLights;
  71245. maxSimultaneousLights: number;
  71246. /**
  71247. * @param {number}: Represents the wind force
  71248. */
  71249. windForce: number;
  71250. /**
  71251. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  71252. */
  71253. windDirection: BABYLON.Vector2;
  71254. /**
  71255. * @param {number}: Wave height, represents the height of the waves
  71256. */
  71257. waveHeight: number;
  71258. /**
  71259. * @param {number}: Bump height, represents the bump height related to the bump map
  71260. */
  71261. bumpHeight: number;
  71262. /**
  71263. * @param {boolean}: Add a smaller moving bump to less steady waves.
  71264. */
  71265. private _bumpSuperimpose;
  71266. bumpSuperimpose: boolean;
  71267. /**
  71268. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  71269. */
  71270. private _fresnelSeparate;
  71271. fresnelSeparate: boolean;
  71272. /**
  71273. * @param {boolean}: bump Waves modify the reflection.
  71274. */
  71275. private _bumpAffectsReflection;
  71276. bumpAffectsReflection: boolean;
  71277. /**
  71278. * @param {number}: The water color blended with the refraction (near)
  71279. */
  71280. waterColor: BABYLON.Color3;
  71281. /**
  71282. * @param {number}: The blend factor related to the water color
  71283. */
  71284. colorBlendFactor: number;
  71285. /**
  71286. * @param {number}: The water color blended with the reflection (far)
  71287. */
  71288. waterColor2: BABYLON.Color3;
  71289. /**
  71290. * @param {number}: The blend factor related to the water color (reflection, far)
  71291. */
  71292. colorBlendFactor2: number;
  71293. /**
  71294. * @param {number}: Represents the maximum length of a wave
  71295. */
  71296. waveLength: number;
  71297. /**
  71298. * @param {number}: Defines the waves speed
  71299. */
  71300. waveSpeed: number;
  71301. /**
  71302. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  71303. * will avoid calculating useless pixels in the pixel shader of the water material.
  71304. */
  71305. disableClipPlane: boolean;
  71306. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  71307. private _mesh;
  71308. private _refractionRTT;
  71309. private _reflectionRTT;
  71310. private _reflectionTransform;
  71311. private _lastTime;
  71312. private _lastDeltaTime;
  71313. private _renderId;
  71314. private _useLogarithmicDepth;
  71315. private _waitingRenderList;
  71316. private _imageProcessingConfiguration;
  71317. private _imageProcessingObserver;
  71318. /**
  71319. * Gets a boolean indicating that current material needs to register RTT
  71320. */
  71321. readonly hasRenderTargetTextures: boolean;
  71322. /**
  71323. * Constructor
  71324. */
  71325. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  71326. useLogarithmicDepth: boolean;
  71327. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  71328. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  71329. addToRenderList(node: any): void;
  71330. enableRenderTargets(enable: boolean): void;
  71331. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  71332. readonly renderTargetsEnabled: boolean;
  71333. needAlphaBlending(): boolean;
  71334. needAlphaTesting(): boolean;
  71335. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71336. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71337. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71338. private _createRenderTargets;
  71339. getAnimatables(): BABYLON.IAnimatable[];
  71340. getActiveTextures(): BABYLON.BaseTexture[];
  71341. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71342. dispose(forceDisposeEffect?: boolean): void;
  71343. clone(name: string): WaterMaterial;
  71344. serialize(): any;
  71345. getClassName(): string;
  71346. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  71347. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  71348. }
  71349. }
  71350. declare module BABYLON {
  71351. /** @hidden */
  71352. export var asciiartPixelShader: {
  71353. name: string;
  71354. shader: string;
  71355. };
  71356. }
  71357. declare module BABYLON {
  71358. /**
  71359. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  71360. *
  71361. * It basically takes care rendering the font front the given font size to a texture.
  71362. * This is used later on in the postprocess.
  71363. */
  71364. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  71365. private _font;
  71366. private _text;
  71367. private _charSize;
  71368. /**
  71369. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  71370. */
  71371. readonly charSize: number;
  71372. /**
  71373. * Create a new instance of the Ascii Art FontTexture class
  71374. * @param name the name of the texture
  71375. * @param font the font to use, use the W3C CSS notation
  71376. * @param text the caracter set to use in the rendering.
  71377. * @param scene the scene that owns the texture
  71378. */
  71379. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  71380. /**
  71381. * Gets the max char width of a font.
  71382. * @param font the font to use, use the W3C CSS notation
  71383. * @return the max char width
  71384. */
  71385. private getFontWidth;
  71386. /**
  71387. * Gets the max char height of a font.
  71388. * @param font the font to use, use the W3C CSS notation
  71389. * @return the max char height
  71390. */
  71391. private getFontHeight;
  71392. /**
  71393. * Clones the current AsciiArtTexture.
  71394. * @return the clone of the texture.
  71395. */
  71396. clone(): AsciiArtFontTexture;
  71397. /**
  71398. * Parses a json object representing the texture and returns an instance of it.
  71399. * @param source the source JSON representation
  71400. * @param scene the scene to create the texture for
  71401. * @return the parsed texture
  71402. */
  71403. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  71404. }
  71405. /**
  71406. * Option available in the Ascii Art Post Process.
  71407. */
  71408. export interface IAsciiArtPostProcessOptions {
  71409. /**
  71410. * The font to use following the w3c font definition.
  71411. */
  71412. font?: string;
  71413. /**
  71414. * The character set to use in the postprocess.
  71415. */
  71416. characterSet?: string;
  71417. /**
  71418. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  71419. * This number is defined between 0 and 1;
  71420. */
  71421. mixToTile?: number;
  71422. /**
  71423. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  71424. * This number is defined between 0 and 1;
  71425. */
  71426. mixToNormal?: number;
  71427. }
  71428. /**
  71429. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  71430. *
  71431. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71432. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  71433. */
  71434. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  71435. /**
  71436. * The font texture used to render the char in the post process.
  71437. */
  71438. private _asciiArtFontTexture;
  71439. /**
  71440. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  71441. * This number is defined between 0 and 1;
  71442. */
  71443. mixToTile: number;
  71444. /**
  71445. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  71446. * This number is defined between 0 and 1;
  71447. */
  71448. mixToNormal: number;
  71449. /**
  71450. * Instantiates a new Ascii Art Post Process.
  71451. * @param name the name to give to the postprocess
  71452. * @camera the camera to apply the post process to.
  71453. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  71454. */
  71455. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  71456. }
  71457. }
  71458. declare module BABYLON {
  71459. /** @hidden */
  71460. export var digitalrainPixelShader: {
  71461. name: string;
  71462. shader: string;
  71463. };
  71464. }
  71465. declare module BABYLON {
  71466. /**
  71467. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  71468. *
  71469. * It basically takes care rendering the font front the given font size to a texture.
  71470. * This is used later on in the postprocess.
  71471. */
  71472. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  71473. private _font;
  71474. private _text;
  71475. private _charSize;
  71476. /**
  71477. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  71478. */
  71479. readonly charSize: number;
  71480. /**
  71481. * Create a new instance of the Digital Rain FontTexture class
  71482. * @param name the name of the texture
  71483. * @param font the font to use, use the W3C CSS notation
  71484. * @param text the caracter set to use in the rendering.
  71485. * @param scene the scene that owns the texture
  71486. */
  71487. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  71488. /**
  71489. * Gets the max char width of a font.
  71490. * @param font the font to use, use the W3C CSS notation
  71491. * @return the max char width
  71492. */
  71493. private getFontWidth;
  71494. /**
  71495. * Gets the max char height of a font.
  71496. * @param font the font to use, use the W3C CSS notation
  71497. * @return the max char height
  71498. */
  71499. private getFontHeight;
  71500. /**
  71501. * Clones the current DigitalRainFontTexture.
  71502. * @return the clone of the texture.
  71503. */
  71504. clone(): DigitalRainFontTexture;
  71505. /**
  71506. * Parses a json object representing the texture and returns an instance of it.
  71507. * @param source the source JSON representation
  71508. * @param scene the scene to create the texture for
  71509. * @return the parsed texture
  71510. */
  71511. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  71512. }
  71513. /**
  71514. * Option available in the Digital Rain Post Process.
  71515. */
  71516. export interface IDigitalRainPostProcessOptions {
  71517. /**
  71518. * The font to use following the w3c font definition.
  71519. */
  71520. font?: string;
  71521. /**
  71522. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  71523. * This number is defined between 0 and 1;
  71524. */
  71525. mixToTile?: number;
  71526. /**
  71527. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  71528. * This number is defined between 0 and 1;
  71529. */
  71530. mixToNormal?: number;
  71531. }
  71532. /**
  71533. * DigitalRainPostProcess helps rendering everithing in digital rain.
  71534. *
  71535. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71536. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  71537. */
  71538. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  71539. /**
  71540. * The font texture used to render the char in the post process.
  71541. */
  71542. private _digitalRainFontTexture;
  71543. /**
  71544. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  71545. * This number is defined between 0 and 1;
  71546. */
  71547. mixToTile: number;
  71548. /**
  71549. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  71550. * This number is defined between 0 and 1;
  71551. */
  71552. mixToNormal: number;
  71553. /**
  71554. * Instantiates a new Digital Rain Post Process.
  71555. * @param name the name to give to the postprocess
  71556. * @camera the camera to apply the post process to.
  71557. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  71558. */
  71559. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  71560. }
  71561. }
  71562. declare module BABYLON {
  71563. /** @hidden */
  71564. export var oceanPostProcessPixelShader: {
  71565. name: string;
  71566. shader: string;
  71567. };
  71568. }
  71569. declare module BABYLON {
  71570. /**
  71571. * Option available in the Ocean Post Process.
  71572. */
  71573. export interface IOceanPostProcessOptions {
  71574. /**
  71575. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  71576. */
  71577. reflectionSize?: number | {
  71578. width: number;
  71579. height: number;
  71580. } | {
  71581. ratio: number;
  71582. };
  71583. /**
  71584. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  71585. */
  71586. refractionSize?: number | {
  71587. width: number;
  71588. height: number;
  71589. } | {
  71590. ratio: number;
  71591. };
  71592. }
  71593. /**
  71594. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  71595. *
  71596. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71597. * Example usage:
  71598. * var pp = new OceanPostProcess("myOcean", camera);
  71599. * pp.reflectionEnabled = true;
  71600. * pp.refractionEnabled = true;
  71601. */
  71602. export class OceanPostProcess extends BABYLON.PostProcess {
  71603. /**
  71604. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  71605. */
  71606. /**
  71607. * Sets weither or not the real-time reflection is enabled on the ocean.
  71608. * Is set to true, the reflection mirror texture will be used as reflection texture.
  71609. */
  71610. reflectionEnabled: boolean;
  71611. /**
  71612. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  71613. */
  71614. /**
  71615. * Sets weither or not the real-time refraction is enabled on the ocean.
  71616. * Is set to true, the refraction render target texture will be used as refraction texture.
  71617. */
  71618. refractionEnabled: boolean;
  71619. /**
  71620. * Gets wether or not the post-processes is supported by the running hardware.
  71621. * This requires draw buffer supports.
  71622. */
  71623. readonly isSupported: boolean;
  71624. /**
  71625. * This is the reflection mirror texture used to display reflections on the ocean.
  71626. * By default, render list is empty.
  71627. */
  71628. reflectionTexture: BABYLON.MirrorTexture;
  71629. /**
  71630. * This is the refraction render target texture used to display refraction on the ocean.
  71631. * By default, render list is empty.
  71632. */
  71633. refractionTexture: BABYLON.RenderTargetTexture;
  71634. private _time;
  71635. private _cameraRotation;
  71636. private _cameraViewMatrix;
  71637. private _reflectionEnabled;
  71638. private _refractionEnabled;
  71639. private _geometryRenderer;
  71640. /**
  71641. * Instantiates a new Ocean Post Process.
  71642. * @param name the name to give to the postprocess.
  71643. * @camera the camera to apply the post process to.
  71644. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  71645. */
  71646. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  71647. /**
  71648. * Returns the appropriate defines according to the current configuration.
  71649. */
  71650. private _getDefines;
  71651. /**
  71652. * Computes the current camera rotation as the shader requires a camera rotation.
  71653. */
  71654. private _computeCameraRotation;
  71655. }
  71656. }
  71657. declare module BABYLON {
  71658. /** @hidden */
  71659. export var brickProceduralTexturePixelShader: {
  71660. name: string;
  71661. shader: string;
  71662. };
  71663. }
  71664. declare module BABYLON {
  71665. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  71666. private _numberOfBricksHeight;
  71667. private _numberOfBricksWidth;
  71668. private _jointColor;
  71669. private _brickColor;
  71670. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71671. updateShaderUniforms(): void;
  71672. numberOfBricksHeight: number;
  71673. numberOfBricksWidth: number;
  71674. jointColor: BABYLON.Color3;
  71675. brickColor: BABYLON.Color3;
  71676. /**
  71677. * Serializes this brick procedural texture
  71678. * @returns a serialized brick procedural texture object
  71679. */
  71680. serialize(): any;
  71681. /**
  71682. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  71683. * @param parsedTexture defines parsed texture data
  71684. * @param scene defines the current scene
  71685. * @param rootUrl defines the root URL containing brick procedural texture information
  71686. * @returns a parsed Brick Procedural BABYLON.Texture
  71687. */
  71688. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  71689. }
  71690. }
  71691. declare module BABYLON {
  71692. /** @hidden */
  71693. export var cloudProceduralTexturePixelShader: {
  71694. name: string;
  71695. shader: string;
  71696. };
  71697. }
  71698. declare module BABYLON {
  71699. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  71700. private _skyColor;
  71701. private _cloudColor;
  71702. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71703. updateShaderUniforms(): void;
  71704. skyColor: BABYLON.Color4;
  71705. cloudColor: BABYLON.Color4;
  71706. /**
  71707. * Serializes this cloud procedural texture
  71708. * @returns a serialized cloud procedural texture object
  71709. */
  71710. serialize(): any;
  71711. /**
  71712. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  71713. * @param parsedTexture defines parsed texture data
  71714. * @param scene defines the current scene
  71715. * @param rootUrl defines the root URL containing cloud procedural texture information
  71716. * @returns a parsed Cloud Procedural BABYLON.Texture
  71717. */
  71718. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  71719. }
  71720. }
  71721. declare module BABYLON {
  71722. /** @hidden */
  71723. export var fireProceduralTexturePixelShader: {
  71724. name: string;
  71725. shader: string;
  71726. };
  71727. }
  71728. declare module BABYLON {
  71729. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  71730. private _time;
  71731. private _speed;
  71732. private _autoGenerateTime;
  71733. private _fireColors;
  71734. private _alphaThreshold;
  71735. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71736. updateShaderUniforms(): void;
  71737. render(useCameraPostProcess?: boolean): void;
  71738. static readonly PurpleFireColors: BABYLON.Color3[];
  71739. static readonly GreenFireColors: BABYLON.Color3[];
  71740. static readonly RedFireColors: BABYLON.Color3[];
  71741. static readonly BlueFireColors: BABYLON.Color3[];
  71742. autoGenerateTime: boolean;
  71743. fireColors: BABYLON.Color3[];
  71744. time: number;
  71745. speed: BABYLON.Vector2;
  71746. alphaThreshold: number;
  71747. /**
  71748. * Serializes this fire procedural texture
  71749. * @returns a serialized fire procedural texture object
  71750. */
  71751. serialize(): any;
  71752. /**
  71753. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  71754. * @param parsedTexture defines parsed texture data
  71755. * @param scene defines the current scene
  71756. * @param rootUrl defines the root URL containing fire procedural texture information
  71757. * @returns a parsed Fire Procedural BABYLON.Texture
  71758. */
  71759. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  71760. }
  71761. }
  71762. declare module BABYLON {
  71763. /** @hidden */
  71764. export var grassProceduralTexturePixelShader: {
  71765. name: string;
  71766. shader: string;
  71767. };
  71768. }
  71769. declare module BABYLON {
  71770. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  71771. private _grassColors;
  71772. private _groundColor;
  71773. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71774. updateShaderUniforms(): void;
  71775. grassColors: BABYLON.Color3[];
  71776. groundColor: BABYLON.Color3;
  71777. /**
  71778. * Serializes this grass procedural texture
  71779. * @returns a serialized grass procedural texture object
  71780. */
  71781. serialize(): any;
  71782. /**
  71783. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  71784. * @param parsedTexture defines parsed texture data
  71785. * @param scene defines the current scene
  71786. * @param rootUrl defines the root URL containing grass procedural texture information
  71787. * @returns a parsed Grass Procedural BABYLON.Texture
  71788. */
  71789. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  71790. }
  71791. }
  71792. declare module BABYLON {
  71793. /** @hidden */
  71794. export var marbleProceduralTexturePixelShader: {
  71795. name: string;
  71796. shader: string;
  71797. };
  71798. }
  71799. declare module BABYLON {
  71800. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  71801. private _numberOfTilesHeight;
  71802. private _numberOfTilesWidth;
  71803. private _amplitude;
  71804. private _jointColor;
  71805. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71806. updateShaderUniforms(): void;
  71807. numberOfTilesHeight: number;
  71808. amplitude: number;
  71809. numberOfTilesWidth: number;
  71810. jointColor: BABYLON.Color3;
  71811. /**
  71812. * Serializes this marble procedural texture
  71813. * @returns a serialized marble procedural texture object
  71814. */
  71815. serialize(): any;
  71816. /**
  71817. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  71818. * @param parsedTexture defines parsed texture data
  71819. * @param scene defines the current scene
  71820. * @param rootUrl defines the root URL containing marble procedural texture information
  71821. * @returns a parsed Marble Procedural BABYLON.Texture
  71822. */
  71823. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  71824. }
  71825. }
  71826. declare module BABYLON {
  71827. /** @hidden */
  71828. export var normalMapProceduralTexturePixelShader: {
  71829. name: string;
  71830. shader: string;
  71831. };
  71832. }
  71833. declare module BABYLON {
  71834. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  71835. private _baseTexture;
  71836. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71837. updateShaderUniforms(): void;
  71838. render(useCameraPostProcess?: boolean): void;
  71839. resize(size: any, generateMipMaps: any): void;
  71840. baseTexture: BABYLON.Texture;
  71841. /**
  71842. * Serializes this normal map procedural texture
  71843. * @returns a serialized normal map procedural texture object
  71844. */
  71845. serialize(): any;
  71846. /**
  71847. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  71848. * @param parsedTexture defines parsed texture data
  71849. * @param scene defines the current scene
  71850. * @param rootUrl defines the root URL containing normal map procedural texture information
  71851. * @returns a parsed Normal Map Procedural BABYLON.Texture
  71852. */
  71853. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  71854. }
  71855. }
  71856. declare module BABYLON {
  71857. /** @hidden */
  71858. export var perlinNoiseProceduralTexturePixelShader: {
  71859. name: string;
  71860. shader: string;
  71861. };
  71862. }
  71863. declare module BABYLON {
  71864. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  71865. time: number;
  71866. timeScale: number;
  71867. translationSpeed: number;
  71868. private _currentTranslation;
  71869. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71870. updateShaderUniforms(): void;
  71871. render(useCameraPostProcess?: boolean): void;
  71872. resize(size: any, generateMipMaps: any): void;
  71873. /**
  71874. * Serializes this perlin noise procedural texture
  71875. * @returns a serialized perlin noise procedural texture object
  71876. */
  71877. serialize(): any;
  71878. /**
  71879. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  71880. * @param parsedTexture defines parsed texture data
  71881. * @param scene defines the current scene
  71882. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  71883. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  71884. */
  71885. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  71886. }
  71887. }
  71888. declare module BABYLON {
  71889. /** @hidden */
  71890. export var roadProceduralTexturePixelShader: {
  71891. name: string;
  71892. shader: string;
  71893. };
  71894. }
  71895. declare module BABYLON {
  71896. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  71897. private _roadColor;
  71898. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71899. updateShaderUniforms(): void;
  71900. roadColor: BABYLON.Color3;
  71901. /**
  71902. * Serializes this road procedural texture
  71903. * @returns a serialized road procedural texture object
  71904. */
  71905. serialize(): any;
  71906. /**
  71907. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  71908. * @param parsedTexture defines parsed texture data
  71909. * @param scene defines the current scene
  71910. * @param rootUrl defines the root URL containing road procedural texture information
  71911. * @returns a parsed Road Procedural BABYLON.Texture
  71912. */
  71913. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  71914. }
  71915. }
  71916. declare module BABYLON {
  71917. /** @hidden */
  71918. export var starfieldProceduralTexturePixelShader: {
  71919. name: string;
  71920. shader: string;
  71921. };
  71922. }
  71923. declare module BABYLON {
  71924. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  71925. private _time;
  71926. private _alpha;
  71927. private _beta;
  71928. private _zoom;
  71929. private _formuparam;
  71930. private _stepsize;
  71931. private _tile;
  71932. private _brightness;
  71933. private _darkmatter;
  71934. private _distfading;
  71935. private _saturation;
  71936. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71937. updateShaderUniforms(): void;
  71938. time: number;
  71939. alpha: number;
  71940. beta: number;
  71941. formuparam: number;
  71942. stepsize: number;
  71943. zoom: number;
  71944. tile: number;
  71945. brightness: number;
  71946. darkmatter: number;
  71947. distfading: number;
  71948. saturation: number;
  71949. /**
  71950. * Serializes this starfield procedural texture
  71951. * @returns a serialized starfield procedural texture object
  71952. */
  71953. serialize(): any;
  71954. /**
  71955. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  71956. * @param parsedTexture defines parsed texture data
  71957. * @param scene defines the current scene
  71958. * @param rootUrl defines the root URL containing startfield procedural texture information
  71959. * @returns a parsed Starfield Procedural BABYLON.Texture
  71960. */
  71961. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  71962. }
  71963. }
  71964. declare module BABYLON {
  71965. /** @hidden */
  71966. export var woodProceduralTexturePixelShader: {
  71967. name: string;
  71968. shader: string;
  71969. };
  71970. }
  71971. declare module BABYLON {
  71972. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  71973. private _ampScale;
  71974. private _woodColor;
  71975. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71976. updateShaderUniforms(): void;
  71977. ampScale: number;
  71978. woodColor: BABYLON.Color3;
  71979. /**
  71980. * Serializes this wood procedural texture
  71981. * @returns a serialized wood procedural texture object
  71982. */
  71983. serialize(): any;
  71984. /**
  71985. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  71986. * @param parsedTexture defines parsed texture data
  71987. * @param scene defines the current scene
  71988. * @param rootUrl defines the root URL containing wood procedural texture information
  71989. * @returns a parsed Wood Procedural BABYLON.Texture
  71990. */
  71991. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  71992. }
  71993. }